Merge branch 'master' of ssh://git.naquadah.org/var/cache/git/awesome

This commit is contained in:
Julien Danjou 2008-03-06 10:28:29 +01:00
commit 5efe8c6de4
4 changed files with 126 additions and 68 deletions

View File

@ -321,33 +321,33 @@ main(int argc, char *argv[])
} }
handler = p_new(event_handler *, LASTEvent); handler = p_new(event_handler *, LASTEvent);
handler[ButtonPress] = handle_event_buttonpress; handler[ButtonPress] = event_handle_buttonpress;
handler[ConfigureRequest] = handle_event_configurerequest; handler[ConfigureRequest] = event_handle_configurerequest;
handler[ConfigureNotify] = handle_event_configurenotify; handler[ConfigureNotify] = event_handle_configurenotify;
handler[DestroyNotify] = handle_event_destroynotify; handler[DestroyNotify] = event_handle_destroynotify;
handler[EnterNotify] = handle_event_enternotify; handler[EnterNotify] = event_handle_enternotify;
handler[LeaveNotify] = handle_event_leavenotify; handler[LeaveNotify] = event_handle_leavenotify;
handler[MotionNotify] = handle_event_motionnotify; handler[MotionNotify] = event_handle_motionnotify;
handler[Expose] = handle_event_expose; handler[Expose] = event_handle_expose;
handler[KeyPress] = handle_event_keypress; handler[KeyPress] = event_handle_keypress;
handler[MappingNotify] = handle_event_mappingnotify; handler[MappingNotify] = event_handle_mappingnotify;
handler[MapRequest] = handle_event_maprequest; handler[MapRequest] = event_handle_maprequest;
handler[PropertyNotify] = handle_event_propertynotify; handler[PropertyNotify] = event_handle_propertynotify;
handler[UnmapNotify] = handle_event_unmapnotify; handler[UnmapNotify] = event_handle_unmapnotify;
handler[ClientMessage] = handle_event_clientmessage; handler[ClientMessage] = event_handle_clientmessage;
/* check for shape extension */ /* check for shape extension */
if((globalconf.have_shape = XShapeQueryExtension(dpy, &shape_event, &e_dummy))) if((globalconf.have_shape = XShapeQueryExtension(dpy, &shape_event, &e_dummy)))
{ {
p_realloc(&handler, shape_event + 1); p_realloc(&handler, shape_event + 1);
handler[shape_event] = handle_event_shape; handler[shape_event] = event_handle_shape;
} }
/* check for randr extension */ /* check for randr extension */
if((globalconf.have_randr = XRRQueryExtension(dpy, &randr_event_base, &e_dummy))) if((globalconf.have_randr = XRRQueryExtension(dpy, &randr_event_base, &e_dummy)))
{ {
p_realloc(&handler, randr_event_base + RRScreenChangeNotify + 1); p_realloc(&handler, randr_event_base + RRScreenChangeNotify + 1);
handler[randr_event_base + RRScreenChangeNotify] = handle_event_randr_screen_change_notify; handler[randr_event_base + RRScreenChangeNotify] = event_handle_randr_screen_change_notify;
} }
XSync(dpy, False); XSync(dpy, False);

112
event.c
View File

@ -42,8 +42,15 @@
extern AwesomeConf globalconf; extern AwesomeConf globalconf;
/** Handle mouse button click
* \param screen screen number
* \param button button number
* \param state modkeys state
* \param buttons buttons list to check for
* \param arg optional arg passed to uicb, otherwise buttons' arg are used
*/
static void static void
handle_mouse_button_press(int screen, unsigned int button, unsigned int state, event_handle_mouse_button_press(int screen, unsigned int button, unsigned int state,
Button *buttons, char *arg) Button *buttons, char *arg)
{ {
Button *b; Button *b;
@ -59,8 +66,11 @@ handle_mouse_button_press(int screen, unsigned int button, unsigned int state,
} }
} }
/** Handle XButtonPressed events
* \param e XEvent
*/
void void
handle_event_buttonpress(XEvent *e) event_handle_buttonpress(XEvent *e)
{ {
int i, screen, x = 0, y = 0; int i, screen, x = 0, y = 0;
unsigned int udummy; unsigned int udummy;
@ -125,7 +135,7 @@ handle_event_buttonpress(XEvent *e)
window_grabbuttons(get_phys_screen(c->screen), c->win); window_grabbuttons(get_phys_screen(c->screen), c->win);
} }
else else
handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.client, NULL); event_handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.client, NULL);
} }
else else
for(screen = 0; screen < ScreenCount(e->xany.display); screen++) for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
@ -136,14 +146,17 @@ handle_event_buttonpress(XEvent *e)
&i, &udummy)) &i, &udummy))
{ {
screen = screen_get_bycoord(screen, x, y); screen = screen_get_bycoord(screen, x, y);
handle_mouse_button_press(screen, ev->button, ev->state, event_handle_mouse_button_press(screen, ev->button, ev->state,
globalconf.buttons.root, NULL); globalconf.buttons.root, NULL);
return; return;
} }
} }
/** Handle XConfigureRequest events
* \param e XEvent
*/
void void
handle_event_configurerequest(XEvent * e) event_handle_configurerequest(XEvent * e)
{ {
Client *c; Client *c;
XConfigureRequestEvent *ev = &e->xconfigurerequest; XConfigureRequestEvent *ev = &e->xconfigurerequest;
@ -192,8 +205,11 @@ handle_event_configurerequest(XEvent * e)
} }
} }
/** Handle XConfigure events
* \param e XEvent
*/
void void
handle_event_configurenotify(XEvent * e) event_handle_configurenotify(XEvent * e)
{ {
XConfigureEvent *ev = &e->xconfigure; XConfigureEvent *ev = &e->xconfigure;
int screen; int screen;
@ -206,8 +222,11 @@ handle_event_configurenotify(XEvent * e)
uicb_exec(0, globalconf.argv); uicb_exec(0, globalconf.argv);
} }
/** Handle XDestroyWindow events
* \param e XEvent
*/
void void
handle_event_destroynotify(XEvent *e) event_handle_destroynotify(XEvent *e)
{ {
Client *c; Client *c;
XDestroyWindowEvent *ev = &e->xdestroywindow; XDestroyWindowEvent *ev = &e->xdestroywindow;
@ -216,11 +235,11 @@ handle_event_destroynotify(XEvent *e)
client_unmanage(c); client_unmanage(c);
} }
/** Handle event enternotify /** Handle XCrossing events on enter
* \param e XEvent * \param e XEvent
*/ */
void void
handle_event_enternotify(XEvent *e) event_handle_enternotify(XEvent *e)
{ {
Client *c; Client *c;
XCrossingEvent *ev = &e->xcrossing; XCrossingEvent *ev = &e->xcrossing;
@ -250,8 +269,11 @@ handle_event_enternotify(XEvent *e)
} }
/** Handle XMotion events
* \param e XEvent
*/
void void
handle_event_motionnotify(XEvent *e) event_handle_motionnotify(XEvent *e)
{ {
XMotionEvent *ev = &e->xmotion; XMotionEvent *ev = &e->xmotion;
@ -259,8 +281,11 @@ handle_event_motionnotify(XEvent *e)
globalconf.pointer_y = ev->y_root; globalconf.pointer_y = ev->y_root;
} }
/** Handle XExpose events
* \param e XEvent
*/
void void
handle_event_expose(XEvent *e) event_handle_expose(XEvent *e)
{ {
XExposeEvent *ev = &e->xexpose; XExposeEvent *ev = &e->xexpose;
int screen; int screen;
@ -276,8 +301,11 @@ handle_event_expose(XEvent *e)
} }
} }
/** Handle XKey events
* \param e XEvent
*/
void void
handle_event_keypress(XEvent *e) event_handle_keypress(XEvent *e)
{ {
int screen, x, y, d; int screen, x, y, d;
unsigned int m; unsigned int m;
@ -306,8 +334,11 @@ handle_event_keypress(XEvent *e)
} }
} }
/** Handle XCrossing events on leave
* \param e XEvent
*/
void void
handle_event_leavenotify(XEvent * e) event_handle_leavenotify(XEvent * e)
{ {
XCrossingEvent *ev = &e->xcrossing; XCrossingEvent *ev = &e->xcrossing;
int screen; int screen;
@ -317,8 +348,11 @@ handle_event_leavenotify(XEvent * e)
client_focus(NULL, screen, True); client_focus(NULL, screen, True);
} }
/** Handle XMapping events
* \param e XEvent
*/
void void
handle_event_mappingnotify(XEvent *e) event_handle_mappingnotify(XEvent *e)
{ {
XMappingEvent *ev = &e->xmapping; XMappingEvent *ev = &e->xmapping;
int screen; int screen;
@ -329,8 +363,11 @@ handle_event_mappingnotify(XEvent *e)
grabkeys(get_phys_screen(screen)); grabkeys(get_phys_screen(screen));
} }
/** Handle XMapRequest events
* \param e XEvent
*/
void void
handle_event_maprequest(XEvent *e) event_handle_maprequest(XEvent *e)
{ {
static XWindowAttributes wa; static XWindowAttributes wa;
XMapRequestEvent *ev = &e->xmaprequest; XMapRequestEvent *ev = &e->xmaprequest;
@ -355,8 +392,11 @@ handle_event_maprequest(XEvent *e)
} }
} }
/** Handle XProperty events
* \param e XEvent
*/
void void
handle_event_propertynotify(XEvent * e) event_handle_propertynotify(XEvent * e)
{ {
Client *c; Client *c;
Window trans; Window trans;
@ -386,8 +426,11 @@ handle_event_propertynotify(XEvent * e)
} }
} }
/** Handle XUnmap events
* \param e XEvent
*/
void void
handle_event_unmapnotify(XEvent * e) event_handle_unmapnotify(XEvent * e)
{ {
Client *c; Client *c;
XUnmapEvent *ev = &e->xunmap; XUnmapEvent *ev = &e->xunmap;
@ -398,8 +441,11 @@ handle_event_unmapnotify(XEvent * e)
client_unmanage(c); client_unmanage(c);
} }
/** Handle XShape events
* \param e XEvent
*/
void void
handle_event_shape(XEvent * e) event_handle_shape(XEvent * e)
{ {
XShapeEvent *ev = (XShapeEvent *) e; XShapeEvent *ev = (XShapeEvent *) e;
Client *c = client_get_bywin(globalconf.clients, ev->window); Client *c = client_get_bywin(globalconf.clients, ev->window);
@ -408,34 +454,46 @@ handle_event_shape(XEvent * e)
window_setshape(get_phys_screen(c->screen), c->win); window_setshape(get_phys_screen(c->screen), c->win);
} }
/** Handle XRandR events
* \param e XEvent
*/
void void
handle_event_randr_screen_change_notify(XEvent *e) event_handle_randr_screen_change_notify(XEvent *e)
{ {
XRRUpdateConfiguration(e); XRRUpdateConfiguration(e);
uicb_exec(0, globalconf.argv); uicb_exec(0, globalconf.argv);
} }
/** Handle XClientMessage events
* \param e XEvent
*/
void void
handle_event_clientmessage(XEvent *e) event_handle_clientmessage(XEvent *e)
{ {
ewmh_process_client_message(&e->xclient); ewmh_process_client_message(&e->xclient);
} }
/** Grab keys on root window
* \param phys_screen physical screen id
*/
void void
grabkeys(int phys_screen) grabkeys(int phys_screen)
{ {
Key *k; Key *k;
KeyCode code;
XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen)); XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen));
for(k = globalconf.keys; k; k = k->next) for(k = globalconf.keys; k; k = k->next)
if(k->keycode)
{ {
if((code = k->keycode) == 0) XGrabKey(globalconf.display, k->keycode, k->mod,
continue; RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
XGrabKey(globalconf.display, code, k->mod, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); XGrabKey(globalconf.display, k->keycode, k->mod | LockMask,
XGrabKey(globalconf.display, code, k->mod | LockMask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
XGrabKey(globalconf.display, code, k->mod | globalconf.numlockmask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask,
XGrabKey(globalconf.display, code, k->mod | globalconf.numlockmask | LockMask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask | LockMask,
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
} }
} }
// 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

32
event.h
View File

@ -28,22 +28,22 @@
void grabkeys(int); void grabkeys(int);
void handle_event_buttonpress(XEvent *); void event_handle_buttonpress(XEvent *);
void handle_event_configurerequest(XEvent *); void event_handle_configurerequest(XEvent *);
void handle_event_configurenotify(XEvent *); void event_handle_configurenotify(XEvent *);
void handle_event_destroynotify(XEvent *); void event_handle_destroynotify(XEvent *);
void handle_event_enternotify(XEvent *); void event_handle_enternotify(XEvent *);
void handle_event_motionnotify(XEvent *); void event_handle_motionnotify(XEvent *);
void handle_event_expose(XEvent *); void event_handle_expose(XEvent *);
void handle_event_keypress(XEvent *); void event_handle_keypress(XEvent *);
void handle_event_leavenotify(XEvent *); void event_handle_leavenotify(XEvent *);
void handle_event_mappingnotify(XEvent *); void event_handle_mappingnotify(XEvent *);
void handle_event_maprequest(XEvent *); void event_handle_maprequest(XEvent *);
void handle_event_propertynotify(XEvent *); void event_handle_propertynotify(XEvent *);
void handle_event_unmapnotify(XEvent *); void event_handle_unmapnotify(XEvent *);
void handle_event_shape(XEvent *); void event_handle_shape(XEvent *);
void handle_event_randr_screen_change_notify(XEvent *); void event_handle_randr_screen_change_notify(XEvent *);
void handle_event_clientmessage(XEvent *); void event_handle_clientmessage(XEvent *);
#endif #endif
// 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

14
mouse.c
View File

@ -80,16 +80,16 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
XUngrabPointer(globalconf.display, CurrentTime); XUngrabPointer(globalconf.display, CurrentTime);
return; return;
case ConfigureRequest: case ConfigureRequest:
handle_event_configurerequest(&ev); event_handle_configurerequest(&ev);
break; break;
case Expose: case Expose:
handle_event_expose(&ev); event_handle_expose(&ev);
break; break;
case MapRequest: case MapRequest:
handle_event_maprequest(&ev); event_handle_maprequest(&ev);
break; break;
case EnterNotify: case EnterNotify:
handle_event_enternotify(&ev); event_handle_enternotify(&ev);
break; break;
case MotionNotify: case MotionNotify:
if(c->isfloating || layout->arrange == layout_floating) if(c->isfloating || layout->arrange == layout_floating)
@ -206,13 +206,13 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
XUngrabPointer(globalconf.display, CurrentTime); XUngrabPointer(globalconf.display, CurrentTime);
return; return;
case ConfigureRequest: case ConfigureRequest:
handle_event_configurerequest(&ev); event_handle_configurerequest(&ev);
break; break;
case Expose: case Expose:
handle_event_expose(&ev); event_handle_expose(&ev);
break; break;
case MapRequest: case MapRequest:
handle_event_maprequest(&ev); event_handle_maprequest(&ev);
break; break;
case MotionNotify: case MotionNotify:
if(layout->arrange == layout_floating || c->isfloating) if(layout->arrange == layout_floating || c->isfloating)