From 281e1fb5ab1de616a6b58ed14635992de6fe3b0d Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Fri, 30 Jun 2006 14:10:03 +0200 Subject: [PATCH] added focus{in,out} notification (this is necessary to get a clue while we can grab the keyboard for the tagbar) --- cmd/wm/client.c | 3 ++- cmd/wm/event.c | 22 ++++++++++++++++++++++ liblitz/blitz.h | 2 ++ liblitz/input.c | 10 ++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/cmd/wm/client.c b/cmd/wm/client.c index cf3f3f22..6440ccc7 100644 --- a/cmd/wm/client.c +++ b/cmd/wm/client.c @@ -116,7 +116,8 @@ create_client(Window w, XWindowAttributes *wa) fwa.background_pixmap = ParentRelative; fwa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | ExposureMask - | ButtonPressMask | PointerMotionMask | ButtonReleaseMask; + | ButtonPressMask | PointerMotionMask | FocusChangeMask + | ButtonReleaseMask | KeyPressMask; c->framewin = XCreateWindow(blz.display, blz.root, c->rect.x, c->rect.y, c->rect.width + 2 * def.border, diff --git a/cmd/wm/event.c b/cmd/wm/event.c index 746e7503..4d5dc4cd 100644 --- a/cmd/wm/event.c +++ b/cmd/wm/event.c @@ -16,6 +16,8 @@ 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_focusin(XEvent *e); +static void handle_focusout(XEvent *e); static void handle_leavenotify(XEvent *e); static void handle_expose(XEvent *e); static void handle_keypress(XEvent *e); @@ -31,6 +33,8 @@ void (*handler[LASTEvent]) (XEvent *) = { [ConfigureRequest]= handle_configurerequest, [DestroyNotify] = handle_destroynotify, [EnterNotify] = handle_enternotify, + [FocusIn] = handle_focusin, + [FocusOut] = handle_focusout, [LeaveNotify] = handle_leavenotify, [Expose] = handle_expose, [KeyPress] = handle_keypress, @@ -84,6 +88,24 @@ handle_buttonrelease(XEvent *e) } } +static void +handle_focusin(XEvent *e) +{ + Frame *f; + XFocusChangeEvent *ev = &e->xfocus; + if((f = frame_of_win(ev->window))) + blitz_focusin_input(&f->tagbar); +} + +static void +handle_focusout(XEvent *e) +{ + Frame *f; + XFocusChangeEvent *ev = &e->xfocus; + if((f = frame_of_win(ev->window))) + blitz_focusout_input(&f->tagbar); +} + static void handle_motionnotify(XEvent *e) { diff --git a/liblitz/blitz.h b/liblitz/blitz.h index 12aa50a8..0128438d 100644 --- a/liblitz/blitz.h +++ b/liblitz/blitz.h @@ -100,3 +100,5 @@ Bool blitz_bpress_input(BlitzInput *i, int x, int y); Bool blitz_brelease_input(BlitzInput *i, int x, int y); Bool blitz_bmotion_input(BlitzInput *i, int x, int y); Bool blitz_ispointinrect(int x, int y, XRectangle * r); +void blitz_focusin_input(BlitzInput *i); +void blitz_focusout_input(BlitzInput *i); diff --git a/liblitz/input.c b/liblitz/input.c index 45da9c54..2fc34793 100644 --- a/liblitz/input.c +++ b/liblitz/input.c @@ -143,6 +143,16 @@ charof(BlitzInput *i, int x, int y) return xcharof(i, x, i->text, strlen(i->text)); } +void +blitz_focusin_input(BlitzInput *i) +{ +} + +void +blitz_focusout_input(BlitzInput *i) +{ +} + Bool blitz_bpress_input(BlitzInput *i, int x, int y) {