[hackers] [wmii] Focus windows when entering their titlebars, except when stacked.

From: Kris Maglione <jg_AT_suckless.org>
Date: Fri Feb 23 22:04:24 2007

changeset: 1945:d84460b42254
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Fri Feb 23 16:03:20 2007 -0500
summary: Focus windows when entering their titlebars, except when stacked.

diff -r 5b981e3b39a1 -r d84460b42254 client.c
--- a/client.c Fri Feb 23 15:11:39 2007 -0500
+++ b/client.c Fri Feb 23 16:03:20 2007 -0500
@@ -51,6 +51,7 @@ create_client(Window w, XWindowAttribute
                   SubstructureRedirectMask
                 | SubstructureNotifyMask
                 | ExposureMask
+ | EnterWindowMask
                 | PointerMotionMask
                 | KeyPressMask
                 | ButtonPressMask
diff -r 5b981e3b39a1 -r d84460b42254 event.c
--- a/event.c Fri Feb 23 15:11:39 2007 -0500
+++ b/event.c Fri Feb 23 16:03:20 2007 -0500
@@ -169,14 +169,20 @@ enternotify(XEvent *e) {
 enternotify(XEvent *e) {
         XCrossingEvent *ev = &e->xcrossing;
         Client *c;
-
- if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
+ Frame *f;
+
+ 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 @@ static void
 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 -r 5b981e3b39a1 -r d84460b42254 frame.c
--- a/frame.c Fri Feb 23 15:11:39 2007 -0500
+++ b/frame.c Fri Feb 23 16:03:20 2007 -0500
@@ -112,6 +112,22 @@ resize_frame(Frame *f, XRectangle *r) {
                 }else
                         check_frame_constraints(&f->rect);
         }
+}
+
+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
diff -r 5b981e3b39a1 -r d84460b42254 geom.c
--- a/geom.c Fri Feb 23 15:11:39 2007 -0500
+++ b/geom.c Fri Feb 23 16:03:20 2007 -0500
@@ -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 -r 5b981e3b39a1 -r d84460b42254 wmii.h
--- a/wmii.h Fri Feb 23 15:11:39 2007 -0500
+++ b/wmii.h Fri Feb 23 16:03:20 2007 -0500
@@ -348,6 +348,7 @@ extern void insert_frame(Frame *pos, Fra
 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);
Received on Fri Feb 23 2007 - 22:04:24 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:51 UTC