commit 6238b96a6a306aa7f5451675434b6bd3b4cabfd8
parent 1160b14fe64eeed0b757f96249946c5904685c13
Author: Kris Maglione <jg@suckless.org>
Date: Sat, 3 Mar 2007 21:33:43 -0500
Fix titlebar flicker. Fix an infinate event loop bug. Fix strlcat conflict.
Diffstat:
5 files changed, 55 insertions(+), 35 deletions(-)
diff --git a/client.c b/client.c
@@ -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, Bool floating, Bool frame, BlitzAlign
}
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 @@ focus_client(Client *c) {
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 --git a/column.c b/column.c
@@ -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 --git a/event.c b/event.c
@@ -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 --git a/frame.c b/frame.c
@@ -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,9 +217,6 @@ focus_frame(Frame *f, Bool restack) {
old_in_a = a->sel;
a->sel = f;
- if(!a->floating
- && ((a->mode == Colstack) || (a->mode == Colmax)))
- arrange_column(a, False);
if(a != old_a)
focus_area(f->area);
@@ -228,6 +226,10 @@ focus_frame(Frame *f, Bool restack) {
focus_client(f->client);
+ if(!a->floating
+ && ((a->mode == Colstack) || (a->mode == Colmax)))
+ arrange_column(a, False);
+
if((f != old)
&& (f->area == old_a))
write_event("ClientFocus 0x%x\n", f->client->win);
@@ -244,6 +246,7 @@ frame_delta_h() {
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 --git a/wmii.h b/wmii.h
@@ -399,6 +399,7 @@ void grab_button(Window w, uint button, ulong mod);
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);