replace drop_events arch by x,y pointer coordinates saving

This commit is contained in:
Julien Danjou 2008-03-04 10:14:13 +01:00
parent 317929baea
commit de8dcbb724
5 changed files with 28 additions and 20 deletions

View File

@ -126,7 +126,7 @@ setup(int screen)
/* select for events */ /* select for events */
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask; | EnterWindowMask | LeaveWindowMask | StructureNotifyMask | PointerMotionMask;
wa.cursor = globalconf.cursor[CurNormal]; wa.cursor = globalconf.cursor[CurNormal];
XChangeWindowAttributes(globalconf.display, XChangeWindowAttributes(globalconf.display,
@ -322,6 +322,7 @@ main(int argc, char *argv[])
handler[DestroyNotify] = handle_event_destroynotify; handler[DestroyNotify] = handle_event_destroynotify;
handler[EnterNotify] = handle_event_enternotify; handler[EnterNotify] = handle_event_enternotify;
handler[LeaveNotify] = handle_event_leavenotify; handler[LeaveNotify] = handle_event_leavenotify;
handler[MotionNotify] = handle_event_motionnotify;
handler[Expose] = handle_event_expose; handler[Expose] = handle_event_expose;
handler[KeyPress] = handle_event_keypress; handler[KeyPress] = handle_event_keypress;
handler[MappingNotify] = handle_event_mappingnotify; handler[MappingNotify] = handle_event_mappingnotify;
@ -417,15 +418,6 @@ main(int argc, char *argv[])
if(handler[ev.type]) if(handler[ev.type])
handler[ev.type](&ev); handler[ev.type](&ev);
/* 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

@ -230,7 +230,6 @@ client_focus(Client *c, int screen, Bool raise)
widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS);
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
@ -768,7 +767,6 @@ uicb_client_swapprev(int screen __attribute__ ((unused)),
{ {
client_list_swap(&globalconf.clients, prev, globalconf.focus->client); client_list_swap(&globalconf.clients, prev, globalconf.focus->client);
globalconf.screens[prev->screen].need_arrange = True; globalconf.screens[prev->screen].need_arrange = True;
globalconf.drop_events |= EnterWindowMask;
} }
} }
@ -787,7 +785,6 @@ uicb_client_swapnext(int screen __attribute__ ((unused)),
{ {
client_list_swap(&globalconf.clients, globalconf.focus->client, next); client_list_swap(&globalconf.clients, globalconf.focus->client, next);
globalconf.screens[next->screen].need_arrange = True; globalconf.screens[next->screen].need_arrange = True;
globalconf.drop_events |= EnterWindowMask;
} }
} }
@ -1000,7 +997,6 @@ uicb_client_zoom(int screen, char *arg __attribute__ ((unused)))
client_list_detach(&globalconf.clients, sel); client_list_detach(&globalconf.clients, sel);
client_list_push(&globalconf.clients, sel); client_list_push(&globalconf.clients, sel);
globalconf.screens[screen].need_arrange = True; globalconf.screens[screen].need_arrange = True;
globalconf.drop_events |= EnterWindowMask;
} }
} }

27
event.c
View File

@ -207,7 +207,7 @@ handle_event_configurenotify(XEvent * e)
} }
void void
handle_event_destroynotify(XEvent * e) handle_event_destroynotify(XEvent *e)
{ {
Client *c; Client *c;
XDestroyWindowEvent *ev = &e->xdestroywindow; XDestroyWindowEvent *ev = &e->xdestroywindow;
@ -216,16 +216,25 @@ handle_event_destroynotify(XEvent * e)
client_unmanage(c); client_unmanage(c);
} }
/** Handle event enternotify
* \param e XEvent
*/
void void
handle_event_enternotify(XEvent * e) handle_event_enternotify(XEvent *e)
{ {
Client *c; Client *c;
XCrossingEvent *ev = &e->xcrossing; XCrossingEvent *ev = &e->xcrossing;
int screen; int screen;
if(ev->mode != NotifyNormal) if(ev->mode != NotifyNormal
|| (ev->x_root == globalconf.pointer_x
&& ev->y_root == globalconf.pointer_y))
return; return;
/* the idea behing saving pointer_x and pointer_y is Bob Marley powered */
globalconf.pointer_x = ev->x_root;
globalconf.pointer_y = ev->y_root;
if((c = client_get_bywin(globalconf.clients, ev->window))) if((c = client_get_bywin(globalconf.clients, ev->window)))
{ {
window_grabbuttons(get_phys_screen(c->screen), c->win); window_grabbuttons(get_phys_screen(c->screen), c->win);
@ -238,6 +247,16 @@ handle_event_enternotify(XEvent * e)
for(screen = 0; screen < ScreenCount(e->xany.display); screen++) for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
if(ev->window == RootWindow(e->xany.display, screen)) if(ev->window == RootWindow(e->xany.display, screen))
window_root_grabbuttons(screen); window_root_grabbuttons(screen);
}
void
handle_event_motionnotify(XEvent *e)
{
XMotionEvent *ev = &e->xmotion;
globalconf.pointer_x = ev->x_root;
globalconf.pointer_y = ev->y_root;
} }
void void
@ -258,7 +277,7 @@ handle_event_expose(XEvent *e)
} }
void void
handle_event_keypress(XEvent * e) handle_event_keypress(XEvent *e)
{ {
int screen, x, y, d; int screen, x, y, d;
unsigned int m; unsigned int m;

View File

@ -33,6 +33,7 @@ void handle_event_configurerequest(XEvent *);
void handle_event_configurenotify(XEvent *); void handle_event_configurenotify(XEvent *);
void handle_event_destroynotify(XEvent *); void handle_event_destroynotify(XEvent *);
void handle_event_enternotify(XEvent *); void handle_event_enternotify(XEvent *);
void handle_event_motionnotify(XEvent *);
void handle_event_expose(XEvent *); void handle_event_expose(XEvent *);
void handle_event_keypress(XEvent *); void handle_event_keypress(XEvent *);
void handle_event_leavenotify(XEvent *); void handle_event_leavenotify(XEvent *);

View File

@ -331,8 +331,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 */ /** Last XMotionEvent coords */
long drop_events; int pointer_x, pointer_y;
}; };
#endif #endif