Focus windows when entering their titlebars, except when stacked.

This commit is contained in:
Kris Maglione 2007-02-23 16:03:20 -05:00
parent 6d8c5fe003
commit 7d79286893
5 changed files with 33 additions and 16 deletions

View File

@ -51,6 +51,7 @@ create_client(Window w, XWindowAttributes *wa) {
SubstructureRedirectMask
| SubstructureNotifyMask
| ExposureMask
| EnterWindowMask
| PointerMotionMask
| KeyPressMask
| ButtonPressMask

27
event.c
View File

@ -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

16
frame.c
View File

@ -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;

4
geom.c
View File

@ -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

1
wmii.h
View File

@ -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);