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

View File

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

21
event.c
View File

@ -216,6 +216,9 @@ handle_event_destroynotify(XEvent * e)
client_unmanage(c);
}
/** Handle event enternotify
* \param e XEvent
*/
void
handle_event_enternotify(XEvent *e)
{
@ -223,9 +226,15 @@ handle_event_enternotify(XEvent * e)
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

View File

@ -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 *);

View File

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