add a common infra to drop events

This commit is contained in:
Julien Danjou 2008-01-18 11:21:40 +01:00
parent 6fce5830ff
commit 83a0a4daf8
5 changed files with 13 additions and 11 deletions

View File

@ -394,6 +394,16 @@ main(int argc, char *argv[])
XNextEvent(dpy, &ev); XNextEvent(dpy, &ev);
if(handler[ev.type]) if(handler[ev.type])
handler[ev.type](&ev); /* call handler */ 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 */ /* need to resync */
XSync(dpy, False); XSync(dpy, False);
} }

View File

@ -217,6 +217,7 @@ focus(Client *c, Bool selscreen, int screen)
RevertToPointerRoot, CurrentTime); RevertToPointerRoot, CurrentTime);
ewmh_update_net_active_window(phys_screen); ewmh_update_net_active_window(phys_screen);
globalconf.drop_events |= EnterWindowMask;
} }
/** Manage a new client /** Manage a new client

View File

@ -275,7 +275,6 @@ handle_event_keypress(XEvent * e)
XKeyEvent *ev = &e->xkey; XKeyEvent *ev = &e->xkey;
Window dummy; Window dummy;
Key *k; Key *k;
XEvent event;
keysym = XKeycodeToKeysym(e->xany.display, (KeyCode) ev->keycode, 0); keysym = XKeycodeToKeysym(e->xany.display, (KeyCode) ev->keycode, 0);
@ -299,7 +298,6 @@ handle_event_keypress(XEvent * e)
k->func(screen, k->arg); k->func(screen, k->arg);
break; break;
} }
while(XCheckMaskEvent(globalconf.display, EnterWindowMask, &event));
} }
void void
@ -333,7 +331,6 @@ handle_event_maprequest(XEvent *e)
int screen, x, y, d; int screen, x, y, d;
unsigned int m; unsigned int m;
Window dummy; Window dummy;
XEvent event;
if(!XGetWindowAttributes(e->xany.display, ev->window, &wa)) if(!XGetWindowAttributes(e->xany.display, ev->window, &wa))
return; return;
@ -346,8 +343,6 @@ handle_event_maprequest(XEvent *e)
&dummy, &dummy, &x, &y, &d, &d, &m)) &dummy, &dummy, &x, &y, &d, &d, &m))
screen = get_screen_bycoord(x, y); screen = get_screen_bycoord(x, y);
client_manage(ev->window, &wa, screen); 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; Client *c;
XUnmapEvent *ev = &e->xunmap; XUnmapEvent *ev = &e->xunmap;
XEvent event;
if((c = get_client_bywin(globalconf.clients, ev->window)) if((c = get_client_bywin(globalconf.clients, ev->window))
&& ev->event == RootWindow(e->xany.display, get_phys_screen(c->screen)) && ev->event == RootWindow(e->xany.display, get_phys_screen(c->screen))
&& ev->send_event && window_getstate(c->win) == NormalState) && ev->send_event && window_getstate(c->win) == NormalState)
client_unmanage(c); client_unmanage(c);
/* do this to keep focused client */
while(XCheckMaskEvent(globalconf.display, EnterWindowMask, &event));
} }
void void

View File

@ -329,7 +329,6 @@ uicb_client_movetoscreen(int screen __attribute__ ((unused)), char *arg)
{ {
int new_screen, prev_screen; int new_screen, prev_screen;
Client *sel = globalconf.focus->client; Client *sel = globalconf.focus->client;
XEvent event;
if(!sel || !XineramaIsActive(globalconf.display)) if(!sel || !XineramaIsActive(globalconf.display))
return; return;
@ -348,7 +347,5 @@ uicb_client_movetoscreen(int screen __attribute__ ((unused)), char *arg)
move_client_to_screen(sel, new_screen, True); move_client_to_screen(sel, new_screen, True);
move_mouse_pointer_to_screen(new_screen); move_mouse_pointer_to_screen(new_screen);
focus(sel, True, sel->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 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -324,6 +324,8 @@ struct AwesomeConf
tag_client_node_t *tclink; tag_client_node_t *tclink;
/** Command line passed to awesome */ /** Command line passed to awesome */
char *argv; char *argv;
/** EventMask to drop before each XEvent treatement */
long drop_events;
}; };
#endif #endif