[hackers] [wmii] Fixed Denis' focus bug

From: Kris Maglione <jg_AT_suckless.org>
Date: Tue Feb 13 19:23:11 2007

changeset: 1867:da344f848ae8
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Tue Feb 13 13:19:01 2007 -0500
summary: Fixed Denis' focus bug

diff -r 2978806df14e -r da344f848ae8 area.c
--- a/area.c Tue Feb 13 12:04:42 2007 -0500
+++ b/area.c Tue Feb 13 13:19:01 2007 -0500
@@ -175,8 +175,7 @@ detach_from_area(Area *a, Frame *f) {
         if(a->sel == f) {
                 if(!pr)
                         pr = a->frame;
- if((a->view == screen->sel) &&
- (a->view->sel == a) && (pr))
+ if((a->view->sel == a) && (pr))
                         focus_frame(pr, False);
                 else
                         a->sel = pr;
@@ -320,10 +319,6 @@ focus_area(Area *a) {
         f = a->sel;
         old_a = v->sel;
 
- /* XXX: Replace this with an assert later */
- if(a == old_a)
- return;
-
         v->sel = a;
 
         if(f)
@@ -340,9 +335,9 @@ focus_area(Area *a) {
 
         if(f) {
                 draw_frame(f);
- XSetInputFocus(blz.dpy, f->client->win, RevertToParent, CurrentTime);
+ focus_client(f->client);
         }else
- XSetInputFocus(blz.dpy, screen->barwin, RevertToPointerRoot, CurrentTime);
+ focus_client(nil);
 
         if(old_a && old_a->sel)
                 draw_frame(old_a->sel);
diff -r 2978806df14e -r da344f848ae8 client.c
--- a/client.c Tue Feb 13 12:04:42 2007 -0500
+++ b/client.c Tue Feb 13 13:19:01 2007 -0500
@@ -545,6 +545,17 @@ match_sizehints(Client *c, XRectangle *r
 }
 
 void
+focus_client(Client *c) {
+ if(screen->focus != c) {
+ if(c)
+ XSetInputFocus(blz.dpy, c->win, RevertToParent, CurrentTime);
+ else
+ XSetInputFocus(blz.dpy, screen->barwin, RevertToParent, CurrentTime);
+ screen->focus = c;
+ }
+}
+
+void
 resize_client(Client *c, XRectangle *r) {
         Frame *f;
         Bool floating;
diff -r 2978806df14e -r da344f848ae8 frame.c
--- a/frame.c Tue Feb 13 12:04:42 2007 -0500
+++ b/frame.c Tue Feb 13 13:19:01 2007 -0500
@@ -181,7 +181,7 @@ focus_frame(Frame *f, Bool restack) {
                 return;
 
         if(a == old_a) {
- XSetInputFocus(blz.dpy, f->client->win, RevertToParent, CurrentTime);
+ focus_client(f->client);
                 draw_frame(f);
         }
         else if(old_in_a)
diff -r 2978806df14e -r da344f848ae8 wmii.h
--- a/wmii.h Tue Feb 13 12:04:42 2007 -0500
+++ b/wmii.h Tue Feb 13 13:19:01 2007 -0500
@@ -222,6 +222,7 @@ struct WMScreen {
         Bar *lbar;
         Bar *rbar;
         View *sel;
+ Client *focus;
         Window barwin;
 
         XRectangle rect;
@@ -296,6 +297,7 @@ extern void reparent_client(Client *c, W
 extern void reparent_client(Client *c, Window w, int x, int y);
 extern void manage_client(Client *c);
 extern void focus(Client *c, Bool restack);
+extern void focus_client(Client *c);
 extern void resize_client(Client *c, XRectangle *r);
 extern void match_sizehints(Client *c, XRectangle *r, Bool floating, BlitzAlign sticky);
 extern char *send_client(Frame *f, char *arg, Bool swap);
Received on Tue Feb 13 2007 - 19:23:11 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:17 UTC