Paul,
Please try the attached patch. I think it solves the problem you
describe, as well as another one that I describe at [1].
[1] http://yo.dan.free.fr/wmaker.phtml.en#switchp_auto_focus
I wrote it a while ago, it took me some time to figure out how it works
exactly :), but here is the outline. Right before unmapping the switch
panel, make WM ignore all focus events (this flag already exists, btw).
Restore normal behaviour afterwards. I used XEvent's in order to do
have the right timing.
Also, in cycling.c, eat "spurious" EnterNotify events to prevent
another case of wrong window focusing that I describe in [1].
Works for me (c) (fixes the intended bug, doesn't seem to introduce
ill behaviour, at least for my usage).
HTH,
-- Daniel
PS: Nicolas: Cool, thanks for the patch! :)
Paul Harris a écrit :
> Hi,
>
> could someone also please write a patch that removes the
> mouse-interactivity from the alt-tab menu?
>
> I use wmaker with "Input Focus Mode" set to auto (give focus to
> window under the mouse). When I alt tab, but the mouse just happens
> to be in the middle of the screen, the following happens:
> 1 - alt-tab menu appears, mouse is on top of menu.
> 2 - i alt-tab to the window i want, and release the alt key
> 3 - target window gets focus
> 4 - an instant later, focus reverts to the window under the mouse.
>
> step 4 does not happen when the mouse has been moved slightly down so
> that it does not end up over the alt-tab menu...
>
> thanks,
> Paul
>
> 2009/8/18 Nicolas Bonifas <[email protected]>
>
> > Hello,
> >
> > Here is a patch to handle the escape key in Windows-style cycling
> > (pressing the escape key gives focus back to the window which had
> > it before alt+tab was pressed, and quits the cycling panel).
> >
> > Regards,
> > Nicolas
> >
>
diff -Naur -x 88_switchp_auto_focus.diff wmaker-0.92.0-8-a/src/cycling.c wmaker-0.92.0-8-b/src/cycling.c
--- wmaker-0.92.0-8-a/src/cycling.c 2008-10-24 23:29:06.000000000 +0200
+++ wmaker-0.92.0-8-b/src/cycling.c 2008-10-25 00:02:45.000000000 +0200
@@ -131,7 +131,7 @@
int i;
WMMaskEvent(dpy, KeyPressMask|KeyReleaseMask|ExposureMask
- |PointerMotionMask|ButtonReleaseMask, &ev);
+ |PointerMotionMask|ButtonReleaseMask|EnterWindowMask, &ev);
/* ignore CapsLock */
modifiers = ev.xkey.state & ValidModMask;
@@ -207,7 +207,8 @@
}
}
break;
-
+ case EnterNotify: /* "eat" unwanted EnterNotify's */
+ break;
case LeaveNotify:
case MotionNotify:
case ButtonRelease:
diff -Naur -x 88_switchp_auto_focus.diff wmaker-0.92.0-8-a/src/event.c wmaker-0.92.0-8-b/src/event.c
--- wmaker-0.92.0-8-a/src/event.c 2008-10-25 00:02:39.000000000 +0200
+++ wmaker-0.92.0-8-b/src/event.c 2008-10-25 00:02:45.000000000 +0200
@@ -89,6 +89,7 @@
extern Atom _XA_WINDOWMAKER_WM_FUNCTION;
extern Atom _XA_WINDOWMAKER_COMMAND;
+extern Atom _XA_WM_IGNORE_FOCUS_EVENTS;
#ifdef SHAPE
extern Bool wShapeSupported;
@@ -982,6 +983,11 @@
wFrameWindowChangeState(wwin->frame, WS_FOCUSED);
break;
}
+ } else if (event->xclient.message_type == _XA_WM_IGNORE_FOCUS_EVENTS) {
+ WScreen *scr = wScreenSearchForRootWindow(event->xclient.window);
+ if (!scr)
+ return;
+ scr->flags.ignore_focus_events = event->xclient.data.l[0] ? 1 : 0;
#ifdef NETWM_HINTS
} else if (wNETWMProcessClientMessage(&event->xclient)) {
/* do nothing */
diff -Naur -x 88_switchp_auto_focus.diff wmaker-0.92.0-8-a/src/main.c wmaker-0.92.0-8-b/src/main.c
--- wmaker-0.92.0-8-a/src/main.c 2008-10-24 23:29:06.000000000 +0200
+++ wmaker-0.92.0-8-b/src/main.c 2008-10-25 00:02:45.000000000 +0200
@@ -114,6 +114,7 @@
Atom _XA_WINDOWMAKER_ICON_SIZE;
Atom _XA_WINDOWMAKER_ICON_TILE;
+Atom _XA_WM_IGNORE_FOCUS_EVENTS;
/* cursors */
Cursor wCursor[WCUR_LAST];
diff -Naur -x 88_switchp_auto_focus.diff wmaker-0.92.0-8-a/src/startup.c wmaker-0.92.0-8-b/src/startup.c
--- wmaker-0.92.0-8-a/src/startup.c 2008-10-24 23:29:06.000000000 +0200
+++ wmaker-0.92.0-8-b/src/startup.c 2008-10-25 00:02:45.000000000 +0200
@@ -134,6 +134,8 @@
extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW;
extern Atom _XA_GNUSTEP_TITLEBAR_STATE;
+extern Atom _XA_WM_IGNORE_FOCUS_EVENTS;
+
/* cursors */
extern Cursor wCursor[WCUR_LAST];
@@ -583,7 +585,9 @@
GNUSTEP_WM_ATTR_NAME,
GNUSTEP_WM_MINIATURIZE_WINDOW,
- GNUSTEP_TITLEBAR_STATE
+ GNUSTEP_TITLEBAR_STATE,
+
+ "WM_IGNORE_FOCUS_EVENTS",
};
@@ -661,6 +665,8 @@
_XA_GNUSTEP_WM_MINIATURIZE_WINDOW = atom[18];
_XA_GNUSTEP_TITLEBAR_STATE = atom[19];
+ _XA_WM_IGNORE_FOCUS_EVENTS = atom[20];
+
#ifdef XDND
wXDNDInitializeAtoms();
#endif
diff -Naur -x 88_switchp_auto_focus.diff wmaker-0.92.0-8-a/src/switchpanel.c wmaker-0.92.0-8-b/src/switchpanel.c
--- wmaker-0.92.0-8-a/src/switchpanel.c 2008-10-24 23:29:06.000000000 +0200
+++ wmaker-0.92.0-8-b/src/switchpanel.c 2008-10-25 00:02:45.000000000 +0200
@@ -574,13 +574,28 @@
}
+extern Atom _XA_WM_IGNORE_FOCUS_EVENTS;
+#include "window.h"
+
void wSwitchPanelDestroy(WSwitchPanel *panel)
{
int i;
RImage *image;
- if (panel->win)
- WMUnmapWidget(panel->win);
+ if (panel->win) {
+ Window info_win = panel->scr->info_window;
+ XEvent ev;
+ ev.xclient.type = ClientMessage;
+ ev.xclient.message_type = _XA_WM_IGNORE_FOCUS_EVENTS;
+ ev.xclient.format = 32;
+ ev.xclient.data.l[0] = True;
+ XSendEvent(dpy, info_win, True, EnterWindowMask, &ev);
+
+ WMUnmapWidget(panel->win);
+
+ ev.xclient.data.l[0] = False;
+ XSendEvent(dpy, info_win, True, EnterWindowMask, &ev);
+ }
if (panel->images) {
WM_ITERATE_ARRAY(panel->images, image, i) {