wmii

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

commit 7d7928689302f9d969ced4262df49ea70c632b35
parent 6d8c5fe0036e741e0f39c5f44a660fd89c8f8f50
Author: Kris Maglione <jg@suckless.org>
Date:   Fri, 23 Feb 2007 16:03:20 -0500

Focus windows when entering their titlebars, except when stacked.

Diffstat:
client.c | 1+
event.c | 27+++++++++++++--------------
frame.c | 16++++++++++++++++
geom.c | 4++--
wmii.h | 1+
5 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/client.c b/client.c @@ -51,6 +51,7 @@ create_client(Window w, XWindowAttributes *wa) { SubstructureRedirectMask | SubstructureNotifyMask | ExposureMask + | EnterWindowMask | PointerMotionMask | KeyPressMask | ButtonPressMask diff --git a/event.c b/event.c @@ -169,14 +169,20 @@ static void enternotify(XEvent *e) { XCrossingEvent *ev = &e->xcrossing; Client *c; + Frame *f; - if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) + if(ev->mode != NotifyNormal) return; if((c = client_of_win(ev->window))) { - if(c->sel->area->mode == Colmax) - c = c->sel->area->sel->client; - focus(c, False); - set_cursor(c, cursor[CurNormal]); + if(ev->detail != NotifyInferior) { + focus(c, False); + set_cursor(c, cursor[CurNormal]); + } + } + else if((f = frame_of_win(ev->window))) { + if(f->area->floating || !f->collapsed) + focus(f->client, False); + set_frame_cursor(f, ev->x, ev->y); } else if(ev->window == blz.root) { sel_screen = True; @@ -337,17 +343,10 @@ maprequest(XEvent *e) { static void motionnotify(XEvent *e) { XMotionEvent *ev = &e->xmotion; - Cursor cur; Frame *f; - if((f = frame_of_win(ev->window))) { - if(!ispointinrect(ev->x, ev->y, &f->titlebar) - &&!ev->subwindow) { - cur = cursor_of_quad(quadofcoord(&f->rect, ev->x_root, ev->y_root)); - set_cursor(f->client, cur); - }else - set_cursor(f->client, cursor[CurNormal]); - } + if((f = frame_of_win(ev->window))) + set_frame_cursor(f, ev->x, ev->y); } static void diff --git a/frame.c b/frame.c @@ -114,6 +114,22 @@ resize_frame(Frame *f, XRectangle *r) { } } +void +set_frame_cursor(Frame *f, int x, int y) { + XRectangle r; + Cursor cur; + + if(!ispointinrect(x, y, &f->titlebar) + &&!ispointinrect(x, y, &f->crect)) { + r = f->rect; + r.x = 0; + r.y = 0; + cur = cursor_of_quad(quadofcoord(&r, x, y)); + set_cursor(f->client, cur); + }else + set_cursor(f->client, cursor[CurNormal]); +} + Bool frame_to_top(Frame *f) { Frame **tf; diff --git a/geom.c b/geom.c @@ -5,8 +5,8 @@ Bool ispointinrect(int x, int y, XRectangle * r) { - return (x >= r->x) && (x <= r_east(r)) - && (y >= r->y) && (y <= r_south(r)); + return (x >= r->x) && (x < r_east(r)) + && (y >= r->y) && (y < r_south(r)); } BlitzAlign diff --git a/wmii.h b/wmii.h @@ -348,6 +348,7 @@ extern void remove_frame(Frame *f); extern void insert_frame(Frame *pos, Frame *f, Bool before); extern void resize_frame(Frame *f, XRectangle *r); extern Bool frame_to_top(Frame *f); +extern void set_frame_cursor(Frame *f, int x, int y); extern void swap_frames(Frame *fa, Frame *fb); extern int frame_delta_h(); extern void draw_frame(Frame *f);