You are not logged in.
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
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
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
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
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
#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
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
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
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
If this is not feasible then holding down superkey and rolling the scroll wheel would be almost as good.
Thanks.
Offline
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
@alterecco Thanks a lot, that worked.
Offline