aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2012-03-09 21:28:33 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2012-03-10 14:33:31 +0200
commit7dc8e6e9f3f3cfc00ed966325c983a896401f6b1 (patch)
tree176bdc3422a4952d6ce08d145ee371a79aa424b5
parent737180c09f604e6731baca62b3e8c8733a2c29af (diff)
rework update_current()
-rw-r--r--monsterwm.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/monsterwm.c b/monsterwm.c
index f5d7cef..552b85b 100644
--- a/monsterwm.c
+++ b/monsterwm.c
@@ -827,29 +827,32 @@ void unmapnotify(XEvent *e) {
* - the window is fullscreen
* - the mode is MONOCLE and the window is not floating or transient */
void update_current(client *c) {
- if ((prevfocus = current)) XSetWindowBorder(dis, prevfocus->win, win_unfocus);
- if (!(current = c)) { XDeleteProperty(dis, root, netatoms[NET_ACTIVE]); return; }
+ if (!c) {
+ XDeleteProperty(dis, root, netatoms[NET_ACTIVE]);
+ current = prevfocus = NULL;
+ return;
+ } else if (c == prevfocus) { current = prevfocus; prevfocus = prev_client(current);
+ } else if (c != current) { prevfocus = current; current = c; }
XWindowChanges wc;
- if (current->isfloating || current->istransient) {
- XSetWindowBorderWidth(dis, current->win, BORDER_WIDTH);
- XRaiseWindow(dis, current->win);
- } else for (wc.sibling = current->win, c=head; c; c=c->next) {
+ for (wc.sibling = current->win, c=head; c; c=c->next) {
+ XSetWindowBorder(dis, c->win, c == current ? win_focus:win_unfocus);
XSetWindowBorderWidth(dis, c->win, (!head->next || c->isfullscrn ||
- (mode==MONOCLE && !ISFFT(c))) ? 0:BORDER_WIDTH);
+ (mode==MONOCLE && !ISFFT(c))) ? 0:BORDER_WIDTH);
+ if (current->isfloating || current->istransient) continue;
wc.stack_mode = (c->isfloating || c->istransient) ? Above:Below;
XConfigureWindow(dis, c->win, CWSibling|CWStackMode, &wc);
if (CLICK_TO_FOCUS) XGrabButton(dis, Button1, None, c->win, True,
ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None);
}
- tile();
- XSetWindowBorder(dis, current->win, win_focus);
+ if (current->isfloating || current->istransient) XRaiseWindow(dis, current->win);
XSetInputFocus(dis, current->win, RevertToPointerRoot, CurrentTime);
XChangeProperty(dis, root, netatoms[NET_ACTIVE], XA_WINDOW, 32,
PropModeReplace, (unsigned char *)&current->win, 1);
if (CLICK_TO_FOCUS) XUngrabButton(dis, Button1, None, current->win);
+ tile();
XSync(dis, False);
}