You are not logged in.

#1 2009-08-02 18:19:41

9nqksfhn
Member
Registered: 2009-07-22
Posts: 28

Cycle through windows using mouse wheel.

Hi,

I want to get a set up that allows me to cycle through open windows by holding down the right mouse button and rolling the scroll wheel in xfce. Does anyone have any advice on how I might do this?

Thanks.

Offline

#2 2009-08-02 21:52:55

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: Cycle through windows using mouse wheel.

try another window manager... maybe openbox. but i think usually mouse button events are caught by the applications (I think, but i am by no means an expert)

cheerio Phil

Offline

#3 2009-08-03 05:23:02

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: Cycle through windows using mouse wheel.

If you have some way of cycling through the apps using a command line app, it shouldn't be hard to get some code to capture right click + scroll and call the app (I have posted some code on the forum already that could help), but you're probably better off trying another window manager if you need this kind of thing.

Offline

#4 2009-08-03 09:24:08

9nqksfhn
Member
Registered: 2009-07-22
Posts: 28

Re: Cycle through windows using mouse wheel.

Using ALT + TAB I can cycle in one direction, and using ALT + SHIFT + TAB I can cycle in the other direction. I can use xdotool to send the keycommands, but I don't know how to capture right click + scroll.

Thanks.

Offline

#5 2009-08-03 11:32:40

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: Cycle through windows using mouse wheel.

Here's something I hacked up based on some other code I have, however I haven't tested it so I have no idea if it will work, also the right click will currently be passed on to the active window which could be annoying.

If you want to try it, change the system() lines to match the xdotool command line you need, save as main.c, compile with "gcc -o scrollswitch main.c -lX11", run the resulting scrollswitch executable and cross your fingers smile

#include <X11/Xlib.h>

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main()
{
    Display *dpy;
    XEvent ev;

    int right_down = 0;

    if (!(dpy = XOpenDisplay(NULL))) {
        fprintf(stderr, "Could not open display %s", getenv("DISPLAY"));
    }

    // Guessing that 3
    XGrabButton(dpy, 3, 0, DefaultRootWindow(dpy), True, ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
    XGrabButton(dpy, 4, 0, DefaultRootWindow(dpy), True, ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
    XGrabButton(dpy, 5, 0, DefaultRootWindow(dpy), True, ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);

    for (;;) {
        XNextEvent(dpy, &ev);

        if (ev.type == ButtonPress) {
            if (ev.xbutton.button == 3) { /* Right click */
                right_down = 1;
                /* Grab pointer so we receive ButtonRelease */
                XGrabPointer(dpy, DefaultRootWindow(dpy), True, PointerMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
                XAllowEvents(dpy, ReplayPointer, CurrentTime); /* Allow other apps to process this message */
            }

            if (right_down) {
                if (ev.xbutton.button == 4) { /* Scroll up? */
                    system("xdotool alt shift tab"); // Fix this
                }
                if (ev.xbutton.button == 5) { /* Scroll down? */
                    system("xdotool alt tab"); // Fix this
                }
            } else {
                XAllowEvents(dpy, ReplayPointer, CurrentTime); /* Allow other apps to process this message */
            }
        } else if (ev.type == ButtonRelease) {
            if (right_down) {
                XUngrabPointer(dpy, CurrentTime);
                right_down = 0;
            }
        }
    }

    XCloseDisplay(dpy);

    return 0;
}

Offline

#6 2009-08-03 13:21:29

9nqksfhn
Member
Registered: 2009-07-22
Posts: 28

Re: Cycle through windows using mouse wheel.

Hi, I tried it, it seemed to work but unfortunately it seems xfce ignores the window cycle key commands if any of the mouse buttons are being pressed at the same time. I will try to see if it can work in a different window manager.

Offline

#7 2009-08-03 13:53:31

9nqksfhn
Member
Registered: 2009-07-22
Posts: 28

Re: Cycle through windows using mouse wheel.

OK, I tried it with openbox, which does cycle when a mouse button is being pressed, and it still doesn't work, I guess to code just doesn't work.

Offline

#8 2009-08-03 14:50:51

9nqksfhn
Member
Registered: 2009-07-22
Posts: 28

Re: Cycle through windows using mouse wheel.

FYI you said the right click will be passed on to the active window, but this is not the case, in fact right click becomes disabled while the program is running.

Offline

#9 2009-08-03 17:00:52

9nqksfhn
Member
Registered: 2009-07-22
Posts: 28

Re: Cycle through windows using mouse wheel.

If this is not feasible then holding down superkey and rolling the scroll wheel would be almost as good.

Thanks.

Offline

#10 2009-08-03 23:03:39

alterecco
Member
Registered: 2009-07-13
Posts: 152

Re: Cycle through windows using mouse wheel.

9nqksfhn wrote:

If this is not feasible then holding down superkey and rolling the scroll wheel would be almost as good.

Have a look at evrouter (in AUR) for handling that. Should be fairly easy to set up

.]

Last edited by alterecco (2009-08-03 23:04:00)

Offline

#11 2009-08-04 18:11:57

9nqksfhn
Member
Registered: 2009-07-22
Posts: 28

Re: Cycle through windows using mouse wheel.

@alterecco Thanks a lot, that worked.

Offline

Board footer

Powered by FluxBB