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

View file

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

View file

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

View file

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

View file

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