[hackers] [dwm] fixed focus steeling bug done by clients like opera

From: Anselm R. Garbe <garbeam_AT_gmail.com>
Date: Sat Nov 17 19:59:51 2007

changeset: 1067:d6d3085307d8
tag: tip
user: Anselm R. Garbe <garbeam_AT_gmail.com>
date: Sat Nov 17 19:59:13 2007 +0100
summary: fixed focus steeling bug done by clients like opera

diff -r 9f49779c6562 -r d6d3085307d8 dwm.c
--- a/dwm.c Sat Nov 17 18:59:51 2007 +0100
+++ b/dwm.c Sat Nov 17 19:59:13 2007 +0100
@@ -137,6 +137,7 @@ void expose(XEvent *e);
 void expose(XEvent *e);
 void floating(void); /* default floating layout */
 void focus(Client *c);
+void focusin(XEvent *e);
 void focusnext(const char *arg);
 void focusprev(const char *arg);
 Client *getclient(Window w);
@@ -206,9 +207,10 @@ void (*handler[LASTEvent]) (XEvent *) =
         [ConfigureNotify] = configurenotify,
         [DestroyNotify] = destroynotify,
         [EnterNotify] = enternotify,
+ [Expose] = expose,
+ [FocusIn] = focusin,
+ [KeyPress] = keypress,
         [LeaveNotify] = leavenotify,
- [Expose] = expose,
- [KeyPress] = keypress,
         [MappingNotify] = mappingnotify,
         [MapRequest] = maprequest,
         [PropertyNotify] = propertynotify,
@@ -710,6 +712,14 @@ focus(Client *c) {
 }
 
 void
+focusin(XEvent *e) { /* there are some broken focus acquiring clients */
+ XFocusChangeEvent *ev = &e->xfocus;
+
+ if(sel && ev->window != sel->win)
+ XSetInputFocus(dpy, sel->win, RevertToPointerRoot, CurrentTime);
+}
+
+void
 focusnext(const char *arg) {
         Client *c;
 
@@ -1026,8 +1036,7 @@ manage(Window w, XWindowAttributes *wa)
         XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
         configure(c); /* propagates border_width, if size doesn't change */
         updatesizehints(c);
- XSelectInput(dpy, w,
- StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
+ XSelectInput(dpy, w, EnterWindowMask | FocusChangeMask | PropertyChangeMask | StructureNotifyMask);
         grabbuttons(c, False);
         updatetitle(c);
         if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
Received on Sat Nov 17 2007 - 19:59:51 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:58:49 UTC