diff options
| author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2011-12-22 14:42:04 +0200 |
|---|---|---|
| committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2011-12-22 17:50:05 +0200 |
| commit | 94f223be22ce6b0f982f768a8eedb5fbc901d9d9 (patch) | |
| tree | 62e8e4664eab2775acdb3400245ccb7f8f71d80a | |
| parent | 01d6b26fd36f6b29c90edc63d706e705ff923879 (diff) | |
rework update_current() function
| -rw-r--r-- | monsterwm.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/monsterwm.c b/monsterwm.c index 34583cf..bd6d2f4 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -334,8 +334,7 @@ void maprequest(XEvent *e) { if(XGetTransientForHint(dis, ev->window, &trans) && trans) { add_window(ev->window); XMapWindow(dis, ev->window); - XSetInputFocus(dis, ev->window, RevertToParent, CurrentTime); - XRaiseWindow(dis, ev->window); + update_current(); return; } @@ -634,26 +633,21 @@ void togglepanel() { } void update_current(void) { - client *c; - - for(c=head; c; c=c->next) { - if(!head->next || mode == MONOCLE) - XSetWindowBorderWidth(dis, c->win, 0); - else - XSetWindowBorderWidth(dis, c->win, BORDER_WIDTH); + if(!head) return; + int border_width = (!head->next || mode == MONOCLE) ? 0 : BORDER_WIDTH; - if(current == c) { /* highlight current window */ - XSetWindowBorder(dis, c->win, win_focus); - XSetInputFocus(dis, c->win, RevertToParent, CurrentTime); - XRaiseWindow(dis, c->win); - if(CLICK_TO_FOCUS) XUngrabButton(dis, AnyButton, AnyModifier, c->win); - } else { - XSetWindowBorder(dis, c->win, win_unfocus); - if(CLICK_TO_FOCUS) XGrabButton(dis, AnyButton, AnyModifier, c->win, True, - ButtonPressMask|ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); - } + for(client *c=head; c; c=c->next) { + XSetWindowBorderWidth(dis, c->win, border_width); + XSetWindowBorder(dis, c->win, win_unfocus); + if(CLICK_TO_FOCUS) XGrabButton(dis, AnyButton, AnyModifier, c->win, True, + ButtonPressMask|ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); + } + if(current) { + XSetWindowBorder(dis, current->win, win_focus); + XSetInputFocus(dis, current->win, RevertToParent, CurrentTime); + XRaiseWindow(dis, current->win); + if(CLICK_TO_FOCUS) XUngrabButton(dis, AnyButton, AnyModifier, current->win); } - free(c); XSync(dis, False); } |
