From 83a0a4daf8c7a62d4929f78f4f0da260bc7578e5 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 18 Jan 2008 11:21:40 +0100 Subject: [PATCH] add a common infra to drop events --- awesome.c | 10 ++++++++++ client.c | 1 + event.c | 8 -------- screen.c | 3 --- structs.h | 2 ++ 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/awesome.c b/awesome.c index 2121b7a8..08eb9cdf 100644 --- a/awesome.c +++ b/awesome.c @@ -394,6 +394,16 @@ main(int argc, char *argv[]) XNextEvent(dpy, &ev); if(handler[ev.type]) handler[ev.type](&ev); /* call handler */ + + /* drop events requested to */ + if(globalconf.drop_events) + { + /* need to resync */ + XSync(dpy, False); + while(XCheckMaskEvent(dpy, globalconf.drop_events, &ev)); + globalconf.drop_events = NoEventMask; + } + /* need to resync */ XSync(dpy, False); } diff --git a/client.c b/client.c index b550bd50..3cce8888 100644 --- a/client.c +++ b/client.c @@ -217,6 +217,7 @@ focus(Client *c, Bool selscreen, int screen) RevertToPointerRoot, CurrentTime); ewmh_update_net_active_window(phys_screen); + globalconf.drop_events |= EnterWindowMask; } /** Manage a new client diff --git a/event.c b/event.c index ade35c46..81cd70b9 100644 --- a/event.c +++ b/event.c @@ -275,7 +275,6 @@ handle_event_keypress(XEvent * e) XKeyEvent *ev = &e->xkey; Window dummy; Key *k; - XEvent event; keysym = XKeycodeToKeysym(e->xany.display, (KeyCode) ev->keycode, 0); @@ -299,7 +298,6 @@ handle_event_keypress(XEvent * e) k->func(screen, k->arg); break; } - while(XCheckMaskEvent(globalconf.display, EnterWindowMask, &event)); } void @@ -333,7 +331,6 @@ handle_event_maprequest(XEvent *e) int screen, x, y, d; unsigned int m; Window dummy; - XEvent event; if(!XGetWindowAttributes(e->xany.display, ev->window, &wa)) return; @@ -346,8 +343,6 @@ handle_event_maprequest(XEvent *e) &dummy, &dummy, &x, &y, &d, &d, &m)) screen = get_screen_bycoord(x, y); client_manage(ev->window, &wa, screen); - /* do this to keep focused client */ - while(XCheckMaskEvent(globalconf.display, EnterWindowMask, &event)); } } @@ -387,14 +382,11 @@ handle_event_unmapnotify(XEvent * e) { Client *c; XUnmapEvent *ev = &e->xunmap; - XEvent event; if((c = get_client_bywin(globalconf.clients, ev->window)) && ev->event == RootWindow(e->xany.display, get_phys_screen(c->screen)) && ev->send_event && window_getstate(c->win) == NormalState) client_unmanage(c); - /* do this to keep focused client */ - while(XCheckMaskEvent(globalconf.display, EnterWindowMask, &event)); } void diff --git a/screen.c b/screen.c index fac25a8a..aa514a96 100644 --- a/screen.c +++ b/screen.c @@ -329,7 +329,6 @@ uicb_client_movetoscreen(int screen __attribute__ ((unused)), char *arg) { int new_screen, prev_screen; Client *sel = globalconf.focus->client; - XEvent event; if(!sel || !XineramaIsActive(globalconf.display)) return; @@ -348,7 +347,5 @@ uicb_client_movetoscreen(int screen __attribute__ ((unused)), char *arg) move_client_to_screen(sel, new_screen, True); move_mouse_pointer_to_screen(new_screen); focus(sel, True, sel->screen); - /* drop EnterWindow event to keep focus */ - XCheckMaskEvent(globalconf.display, EnterWindowMask, &event); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/structs.h b/structs.h index ecef9d8e..bd0a8044 100644 --- a/structs.h +++ b/structs.h @@ -324,6 +324,8 @@ struct AwesomeConf tag_client_node_t *tclink; /** Command line passed to awesome */ char *argv; + /** EventMask to drop before each XEvent treatement */ + long drop_events; }; #endif