diff --git a/awesome.c b/awesome.c index 67af703a6..1001097f8 100644 --- a/awesome.c +++ b/awesome.c @@ -126,7 +126,7 @@ setup(int screen) /* select for events */ wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask - | EnterWindowMask | LeaveWindowMask | StructureNotifyMask; + | EnterWindowMask | LeaveWindowMask | StructureNotifyMask | PointerMotionMask; wa.cursor = globalconf.cursor[CurNormal]; XChangeWindowAttributes(globalconf.display, @@ -322,6 +322,7 @@ main(int argc, char *argv[]) handler[DestroyNotify] = handle_event_destroynotify; handler[EnterNotify] = handle_event_enternotify; handler[LeaveNotify] = handle_event_leavenotify; + handler[MotionNotify] = handle_event_motionnotify; handler[Expose] = handle_event_expose; handler[KeyPress] = handle_event_keypress; handler[MappingNotify] = handle_event_mappingnotify; @@ -417,15 +418,6 @@ main(int argc, char *argv[]) if(handler[ev.type]) 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 */ XSync(dpy, False); } diff --git a/client.c b/client.c index 6f8963fe8..478d081c8 100644 --- a/client.c +++ b/client.c @@ -230,7 +230,6 @@ client_focus(Client *c, int screen, Bool raise) widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS); ewmh_update_net_active_window(phys_screen); - globalconf.drop_events |= EnterWindowMask; } /** Manage a new client @@ -768,7 +767,6 @@ uicb_client_swapprev(int screen __attribute__ ((unused)), { client_list_swap(&globalconf.clients, prev, globalconf.focus->client); 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); 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_push(&globalconf.clients, sel); globalconf.screens[screen].need_arrange = True; - globalconf.drop_events |= EnterWindowMask; } } diff --git a/event.c b/event.c index 877982a1b..c36eb26b8 100644 --- a/event.c +++ b/event.c @@ -207,7 +207,7 @@ handle_event_configurenotify(XEvent * e) } void -handle_event_destroynotify(XEvent * e) +handle_event_destroynotify(XEvent *e) { Client *c; XDestroyWindowEvent *ev = &e->xdestroywindow; @@ -216,16 +216,25 @@ handle_event_destroynotify(XEvent * e) client_unmanage(c); } +/** Handle event enternotify + * \param e XEvent + */ void -handle_event_enternotify(XEvent * e) +handle_event_enternotify(XEvent *e) { Client *c; XCrossingEvent *ev = &e->xcrossing; int screen; - if(ev->mode != NotifyNormal) + if(ev->mode != NotifyNormal + || (ev->x_root == globalconf.pointer_x + && ev->y_root == globalconf.pointer_y)) 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))) { 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++) if(ev->window == RootWindow(e->xany.display, 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 @@ -258,7 +277,7 @@ handle_event_expose(XEvent *e) } void -handle_event_keypress(XEvent * e) +handle_event_keypress(XEvent *e) { int screen, x, y, d; unsigned int m; diff --git a/event.h b/event.h index 8b2da492f..8d9e80be3 100644 --- a/event.h +++ b/event.h @@ -33,6 +33,7 @@ void handle_event_configurerequest(XEvent *); void handle_event_configurenotify(XEvent *); void handle_event_destroynotify(XEvent *); void handle_event_enternotify(XEvent *); +void handle_event_motionnotify(XEvent *); void handle_event_expose(XEvent *); void handle_event_keypress(XEvent *); void handle_event_leavenotify(XEvent *); diff --git a/structs.h b/structs.h index f08c85d5d..edbd75d97 100644 --- a/structs.h +++ b/structs.h @@ -331,8 +331,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; + /** Last XMotionEvent coords */ + int pointer_x, pointer_y; }; #endif