wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 0104091f56b7c934c90265677635588d806f2e43
parent b5b00caa66a47bd61c29c52a93b64e03dfc84162
Author: Kris Maglione <bsdaemon@wmii.de>
Date:   Fri, 16 Jun 2006 02:52:13 -0400

Reapplied multihead patch that I backed out. No merge, unfortunately.


Diffstat:
cmd/wm/client.c | 19+++++++++++++------
cmd/wm/event.c | 23++++++++++++++++++-----
cmd/wm/wm.c | 7++++++-
cmd/wm/wm.h | 1+
4 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -128,12 +128,19 @@ update_client_grab(Client *c, Bool is_sel) void focus_client(Client *c, Bool restack) { - Client *old = sel_client(); - Frame *f = c->sel; - Client *old_in_area = sel_client_of_area(f->area); - View *v = f->area->view; + Client *old; + Frame *f; + Client *old_in_area; + View *v; static char buf[256]; + if(!sel_screen) + return; + + old = sel_client(); + f = c->sel; + old_in_area = sel_client_of_area(f->area); + v = f->area->view; v->sel = f->area; f->area->sel = f; c->floating = (f->area == v->area); @@ -286,7 +293,7 @@ draw_client(Client *c) d.font = blitzfont; d.gc = c->gc; - if(c == sel_client()) + if(sel_screen && (c == sel_client())) d.color = def.sel; else d.color = def.norm; @@ -323,7 +330,7 @@ draw_client(Client *c) blitz_drawborder(&d); d.rect.x = 0; - if(c == sel_client()) + if(sel_screen && (c == sel_client())) d.color = def.sel; else d.color = def.norm; diff --git a/cmd/wm/event.c b/cmd/wm/event.c @@ -16,6 +16,7 @@ static void handle_buttonrelease(XEvent * e); static void handle_configurerequest(XEvent * e); static void handle_destroynotify(XEvent * e); static void handle_enternotify(XEvent * e); +static void handle_leavenotify(XEvent * e); static void handle_expose(XEvent * e); static void handle_keypress(XEvent * e); static void handle_keymapnotify(XEvent * e); @@ -35,6 +36,7 @@ init_x_event_handler() handler[ConfigureRequest] = handle_configurerequest; handler[DestroyNotify] = handle_destroynotify; handler[EnterNotify] = handle_enternotify; + handler[LeaveNotify] = handle_leavenotify; handler[Expose] = handle_expose; handler[KeyPress] = handle_keypress; handler[KeymapNotify] = handle_keymapnotify; @@ -204,16 +206,27 @@ handle_enternotify(XEvent *e) return; if((c = client_of_win(ev->window))) { - Client *old = selected_client(); Frame *f = c->sel; Area *a = f->area; if(a->mode == Colmax) c = a->sel->client; - if(c != old) - focus(c, False); + focus(c, False); + } + else if(ev->window == root) { + sel_screen = True; + draw_clients(); + } +} + +static void +handle_leavenotify(XEvent *e) +{ + XCrossingEvent *ev = &e->xcrossing; + + if((ev->window == root) && !ev->same_screen) { + sel_screen = True; + draw_clients(); } - else if(ev->window == root) - XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); } static void diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -141,6 +141,9 @@ init_cursors() static void init_screen() { + Window w; + int ret; + unsigned mask; XGCValues gcv; gcv.subwindow_mode = IncludeInferiors; @@ -155,6 +158,8 @@ init_screen() rect.width = DisplayWidth(dpy, screen); rect.height = DisplayHeight(dpy, screen); def.snap = rect.height / 63; + + sel_screen = XQueryPointer(dpy, root, &w, &w, &ret, &ret, &ret, &ret, &mask); } /* @@ -315,7 +320,7 @@ main(int argc, char *argv[]) init_lock_keys(); init_screen(); - wa.event_mask = SubstructureRedirectMask; + wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask; wa.cursor = cursor[CurNormal]; XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -237,6 +237,7 @@ Atom net_atom[NetLast]; Cursor cursor[CurLast]; unsigned int valid_mask; unsigned int num_lock_mask; +Bool sel_screen; void (*handler[LASTEvent]) (XEvent *);