[hackers] [wmii] Fix titlebar flicker. Fix an infinate event loop bug. Fix strlcat conflict.

From: Kris Maglione <jg_AT_suckless.org>
Date: Sun Mar 04 03:34:25 2007

changeset: 1997:278171da62ae
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Mar 03 21:33:43 2007 -0500
summary: Fix titlebar flicker. Fix an infinate event loop bug. Fix strlcat conflict.

diff -r 8596f0046460 -r 278171da62ae client.c
--- a/client.c Sat Mar 03 17:56:46 2007 -0500
+++ b/client.c Sat Mar 03 21:33:43 2007 -0500
@@ -242,23 +242,6 @@ update_client_grab(Client *c) {
         }
 }
 
-/* convenience function */
-void
-focus(Client *c, Bool restack) {
- View *v;
- Frame *f;
-
- f = c->sel;
- if(!f)
- return;
-
- v = f->area->view;
- arrange_column(f->area, False);
- if(v != screen->sel)
- focus_view(screen, v);
- focus_frame(c->sel, restack);
-}
-
 void
 set_client_state(Client * c, int state) {
         long data[] = { state, None };
@@ -596,6 +579,21 @@ apply_sizehints(Client *c, XRectangle *r
 }
 
 void
+focus(Client *c, Bool restack) {
+ View *v;
+ Frame *f;
+
+ f = c->sel;
+ if(!f)
+ return;
+
+ v = f->area->view;
+ if(v != screen->sel)
+ focus_view(screen, v);
+ focus_frame(c->sel, restack);
+}
+
+void
 focus_client(Client *c) {
         XEvent ev;
 
@@ -620,15 +618,12 @@ void
 void
 resize_client(Client *c, XRectangle *r) {
         Frame *f;
+ XEvent ev;
 
         f = c->sel;
         resize_frame(f, r);
 
- if(f->area->view == screen->sel)
- XMoveResizeWindow(blz.dpy, c->framewin,
- f->rect.x, f->rect.y,
- f->rect.width, f->rect.height);
- else {
+ if(f->area->view != screen->sel) {
                 unmap_client(c, IconicState);
                 unmap_frame(c);
                 return;
@@ -642,6 +637,9 @@ resize_client(Client *c, XRectangle *r)
                 unmap_frame(c);
                 unmap_client(c, IconicState);
         }else if(f->collapsed) {
+ XMoveResizeWindow(blz.dpy, c->framewin,
+ f->rect.x, f->rect.y,
+ f->rect.width, f->rect.height);
                 map_frame(c);
                 unmap_client(c, IconicState);
         }else {
@@ -649,9 +647,16 @@ resize_client(Client *c, XRectangle *r)
                                 f->crect.x, f->crect.y,
                                 f->crect.width, f->crect.height);
                 map_client(c);
+ XMoveResizeWindow(blz.dpy, c->framewin,
+ f->rect.x, f->rect.y,
+ f->rect.width, f->rect.height);
                 map_frame(c);
                 configure_client(c);
         }
+
+ while(XCheckMaskEvent(blz.dpy, FocusChangeMask|ExposureMask, &ev))
+ if(handler[ev.xany.type])
+ handler[ev.xany.type](&ev);
 }
 
 void
diff -r 8596f0046460 -r 278171da62ae column.c
--- a/column.c Sat Mar 03 17:56:46 2007 -0500
+++ b/column.c Sat Mar 03 21:33:43 2007 -0500
@@ -180,11 +180,13 @@ arrange_column(Area *a, Bool dirty) {
         scale_column(a);
 resize:
         if(a->view == screen->sel) {
+ restack_view(a->view);
+ resize_client(a->sel->client, &a->sel->rect);
                 for(f=a->frame; f; f=f->anext)
- if(!f->collapsed)
+ if(!f->collapsed && f != a->sel)
                                 resize_client(f->client, &f->rect);
                 for(f=a->frame; f; f=f->anext)
- if(f->collapsed)
+ if(f->collapsed && f != a->sel)
                                 resize_client(f->client, &f->rect);
         }
 }
diff -r 8596f0046460 -r 278171da62ae event.c
--- a/event.c Sat Mar 03 17:56:46 2007 -0500
+++ b/event.c Sat Mar 03 21:33:43 2007 -0500
@@ -175,7 +175,7 @@ enternotify(XEvent *e) {
                 return;
 
         if((c = client_of_win(ev->window))) {
- if(ev->detail != NotifyInferior) {
+ if(ev->detail != NotifyInferior && screen->focus != c) {
                         if(verbose)
                                 fprintf(stderr, "enter_notify(c) => %s\n", c->name);
                         focus(c, False);
@@ -183,7 +183,7 @@ enternotify(XEvent *e) {
                 }else if(verbose)
                                 fprintf(stderr, "enter_notify(c[NotifyInferior]) => %s\n", c->name);
         }
- else if((f = frame_of_win(ev->window))) {
+ else if((f = frame_of_win(ev->window)) && screen->focus != c) {
                 if(verbose)
                         fprintf(stderr, "enter_notify(f) => %s\n", f->client->name);
                 if(f->area->floating || !f->collapsed)
@@ -235,7 +235,8 @@ focusin(XEvent *e) {
            ||(ev->detail == NotifyInferior)
            ||(ev->detail == NotifyAncestor)))
                 return;
- if(ev->mode == NotifyWhileGrabbed)
+ if((ev->mode == NotifyWhileGrabbed)
+ &&(screen->hasgrab != &c_magic))
                 return;
 
         c = client_of_win(ev->window);
@@ -258,6 +259,7 @@ focusin(XEvent *e) {
         }else if(ev->mode == NotifyGrab) {
                 if(ev->window == blz.root) {
                         if(XCheckMaskEvent(blz.dpy, KeyPressMask, &me)) {
+ screen->hasgrab = &c_magic;
                                 handler[me.xany.type](&me);
                                 return;
                         }
@@ -285,7 +287,8 @@ focusout(XEvent *e) {
 
         c = client_of_win(ev->window);
         if(c) {
- if(ev->mode == NotifyWhileGrabbed) {
+ if((ev->mode == NotifyWhileGrabbed)
+ &&(screen->hasgrab != &c_magic)) {
                         if((screen->focus)
                         &&(screen->hasgrab != screen->focus))
                                 screen->hasgrab = screen->focus;
diff -r 8596f0046460 -r 278171da62ae frame.c
--- a/frame.c Sat Mar 03 17:56:46 2007 -0500
+++ b/frame.c Sat Mar 03 21:33:43 2007 -0500
@@ -96,10 +96,9 @@ resize_frame(Frame *f, XRectangle *r) {
 
         frame2client(&f->crect);
 
- if(f->crect.height < labelh(&def.font)) {
- f->rect.height = frame_delta_h();
+ if(f->crect.height < labelh(&def.font))
                 f->collapsed = True;
- }else
+ else
                 f->collapsed = False;
 
         if(f->crect.width < labelh(&def.font)) {
@@ -107,8 +106,10 @@ resize_frame(Frame *f, XRectangle *r) {
                 f->collapsed = True;
         }
 
- if(f->collapsed)
+ if(f->collapsed) {
+ f->rect.height = labelh(&def.font);
                 f->crect = f->rect;
+ }
         f->crect.y = labelh(&def.font);
         f->crect.x = (f->rect.width - f->crect.width) / 2;
         
@@ -216,18 +217,19 @@ focus_frame(Frame *f, Bool restack) {
         old_in_a = a->sel;
 
         a->sel = f;
+
+ if(a != old_a)
+ focus_area(f->area);
+
+ if(v != screen->sel)
+ return;
+
+ focus_client(f->client);
+
         if(!a->floating
         && ((a->mode == Colstack) || (a->mode == Colmax)))
                 arrange_column(a, False);
 
- if(a != old_a)
- focus_area(f->area);
-
- if(v != screen->sel)
- return;
-
- focus_client(f->client);
-
         if((f != old)
         && (f->area == old_a))
                         write_event("ClientFocus 0x%x\n", f->client->win);
@@ -244,6 +246,7 @@ void
 void
 draw_frame(Frame *f) {
         BlitzBrush br = { 0 };
+ Frame *tf;
 
         br.blitz = &blz;
         br.font = &def.font;
@@ -253,6 +256,12 @@ draw_frame(Frame *f) {
                 br.color = def.focuscolor;
         else
                 br.color = def.normcolor;
+ if(!f->area->floating && f->area->mode == Colmax)
+ for(tf = f->area->frame; tf; tf=tf->anext)
+ if(tf->client == screen->focus) {
+ br.color = def.focuscolor;
+ break;
+ }
 
         br.rect = f->rect;
         br.rect.x = 0;
diff -r 8596f0046460 -r 278171da62ae wmii.h
--- a/wmii.h Sat Mar 03 17:56:46 2007 -0500
+++ b/wmii.h Sat Mar 03 21:33:43 2007 -0500
@@ -399,6 +399,7 @@ void update_rules(Rule **rule, const cha
 void update_rules(Rule **rule, const char *data);
 void trim(char *str, const char *chars);
 
+#define strlcat wmii_strlcat
 /* util.c */
 uint tokenize(char *res[], uint reslen, char *str, char delim);
 char *estrdup(const char *str);
Received on Sun Mar 04 2007 - 03:34:25 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:09 UTC