[dwm] cycling through views using mouse wheel

From: Daniel Schmitz <daniel.schmitz_AT_gmx.info>
Date: Wed, 30 Aug 2006 23:58:31 +0200

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Today I checked out the latest version of dwm. Customizing an
application by changing the code sounded a kind of keen to me, but when
I browsed through the code I was amazed by its simplicity and
readability. I was able do adjust it without knowing anything about Xlib. so
thank you, good job!

btw.
I have added code to cycle through the views using the mouse wheel

to dwm.h i've appended:

extern void nextview(Arg *arg);

to view.c:

void
nextview(Arg *arg)
{
        unsigned int i;
        signed int curview;

        for(i = 0; i < ntags; i++)
        {
                if (seltag[i] == True)
                {
                        seltag[i] = False;
                        curview = i;
                        break;
                }
        }

        curview += arg->i;
        if(curview<0)
                curview = ntags-1;
        else if(curview>=ntags)
                curview = 0;
        seltag[curview] = True;
        reorder();
        arrange(NULL);
}

finally to catch mouse-button4/5-events I changed the
buttonpress-function in event.c:

static void
buttonpress(XEvent *e)
{
        int x;
        Arg a;
        Client *c;
        XButtonPressedEvent *ev = &e->xbutton;

        if(barwin == ev->window) {
                x = 0;
                for(a.i = 0; a.i < ntags; a.i++) {
                        x += textw(tags[a.i]);
                        if(ev->x < x) {
                                if(ev->button == Button1)
                                        view(&a);
                                if(ev->button == Button4)
                                {
                                        a.i = -1;
                                        nextview(&a);
                                }
                                if(ev->button == Button5)
                                {
                                        a.i = +1;
                                        nextview(&a);
                                }
....

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE9goHcs3lCmR3J20RAlieAJ9w3QVfwj+PBMXbHbsIGM+9zpYvOQCgyQLN
G2F1U870ef/rAhQdT1Z1cxY=
=71Rs
-----END PGP SIGNATURE-----
Received on Wed Aug 30 2006 - 23:59:04 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:30:45 UTC