From c1b503af1a207214b8f8866d3a7b7895860b6d35 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 6 Mar 2008 09:05:15 +0100 Subject: [PATCH 1/3] Comment event.c functions --- event.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/event.c b/event.c index c36eb26b..c189a321 100644 --- a/event.c +++ b/event.c @@ -42,6 +42,13 @@ 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 handle_mouse_button_press(int screen, unsigned int button, unsigned int state, Button *buttons, char *arg) @@ -59,6 +66,9 @@ handle_mouse_button_press(int screen, unsigned int button, unsigned int state, } } +/** Handle XButtonPressed events + * \param e XEvent + */ void handle_event_buttonpress(XEvent *e) { @@ -142,6 +152,9 @@ handle_event_buttonpress(XEvent *e) } } +/** Handle XConfigureRequest events + * \param e XEvent + */ void handle_event_configurerequest(XEvent * e) { @@ -192,6 +205,9 @@ handle_event_configurerequest(XEvent * e) } } +/** Handle XConfigure events + * \param e XEvent + */ void handle_event_configurenotify(XEvent * e) { @@ -206,6 +222,9 @@ handle_event_configurenotify(XEvent * e) uicb_exec(0, globalconf.argv); } +/** Handle XDestroyWindow events + * \param e XEvent + */ void handle_event_destroynotify(XEvent *e) { @@ -216,7 +235,7 @@ handle_event_destroynotify(XEvent *e) client_unmanage(c); } -/** Handle event enternotify +/** Handle XCrossing events on enter * \param e XEvent */ void @@ -250,6 +269,9 @@ handle_event_enternotify(XEvent *e) } +/** Handle XMotion events + * \param e XEvent + */ void handle_event_motionnotify(XEvent *e) { @@ -259,6 +281,9 @@ handle_event_motionnotify(XEvent *e) globalconf.pointer_y = ev->y_root; } +/** Handle XExpose events + * \param e XEvent + */ void handle_event_expose(XEvent *e) { @@ -276,6 +301,9 @@ handle_event_expose(XEvent *e) } } +/** Handle XKey events + * \param e XEvent + */ void handle_event_keypress(XEvent *e) { @@ -306,6 +334,9 @@ handle_event_keypress(XEvent *e) } } +/** Handle XCrossing events on leave + * \param e XEvent + */ void handle_event_leavenotify(XEvent * e) { @@ -317,6 +348,9 @@ handle_event_leavenotify(XEvent * e) client_focus(NULL, screen, True); } +/** Handle XMapping events + * \param e XEvent + */ void handle_event_mappingnotify(XEvent *e) { @@ -329,6 +363,9 @@ handle_event_mappingnotify(XEvent *e) grabkeys(get_phys_screen(screen)); } +/** Handle XMapRequest events + * \param e XEvent + */ void handle_event_maprequest(XEvent *e) { @@ -355,6 +392,9 @@ handle_event_maprequest(XEvent *e) } } +/** Handle XProperty events + * \param e XEvent + */ void handle_event_propertynotify(XEvent * e) { @@ -386,6 +426,9 @@ handle_event_propertynotify(XEvent * e) } } +/** Handle XUnmap events + * \param e XEvent + */ void handle_event_unmapnotify(XEvent * e) { @@ -398,6 +441,9 @@ handle_event_unmapnotify(XEvent * e) client_unmanage(c); } +/** Handle XShape events + * \param e XEvent + */ void handle_event_shape(XEvent * e) { @@ -408,6 +454,9 @@ handle_event_shape(XEvent * e) window_setshape(get_phys_screen(c->screen), c->win); } +/** Handle XRandR events + * \param e XEvent + */ void handle_event_randr_screen_change_notify(XEvent *e) { @@ -415,12 +464,18 @@ handle_event_randr_screen_change_notify(XEvent *e) uicb_exec(0, globalconf.argv); } +/** Handle XClientMessage events + * \param e XEvent + */ void handle_event_clientmessage(XEvent *e) { ewmh_process_client_message(&e->xclient); } +/** Grab keys on root window + * \param phys_screen physical screen id + */ void grabkeys(int phys_screen) { From edb865a07026a2ca18a74fb2f60e025a2f47a71d Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 6 Mar 2008 09:07:33 +0100 Subject: [PATCH 2/3] Simplify grabkeys() function --- event.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/event.c b/event.c index c189a321..aa5be9b2 100644 --- a/event.c +++ b/event.c @@ -480,17 +480,20 @@ void grabkeys(int phys_screen) { Key *k; - KeyCode code; XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen)); + for(k = globalconf.keys; k; k = k->next) - { - if((code = k->keycode) == 0) - continue; - XGrabKey(globalconf.display, code, k->mod, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); - XGrabKey(globalconf.display, code, k->mod | LockMask, 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, code, k->mod | globalconf.numlockmask | LockMask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); - } + if(k->keycode) + { + XGrabKey(globalconf.display, k->keycode, k->mod, + RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); + XGrabKey(globalconf.display, k->keycode, k->mod | LockMask, + RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); + XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask, + 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 From dd9a1b99c458cc5a367fcf57a72920510327bd3c Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 6 Mar 2008 09:09:59 +0100 Subject: [PATCH 3/3] Rename events functions from handle_event... to event_handle --- awesome.c | 32 ++++++++++++++++---------------- event.c | 38 +++++++++++++++++++------------------- event.h | 32 ++++++++++++++++---------------- mouse.c | 14 +++++++------- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/awesome.c b/awesome.c index dedb5a6c..8ab5984c 100644 --- a/awesome.c +++ b/awesome.c @@ -321,33 +321,33 @@ main(int argc, char *argv[]) } handler = p_new(event_handler *, LASTEvent); - handler[ButtonPress] = handle_event_buttonpress; - handler[ConfigureRequest] = handle_event_configurerequest; - handler[ConfigureNotify] = handle_event_configurenotify; - 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; - handler[MapRequest] = handle_event_maprequest; - handler[PropertyNotify] = handle_event_propertynotify; - handler[UnmapNotify] = handle_event_unmapnotify; - handler[ClientMessage] = handle_event_clientmessage; + handler[ButtonPress] = event_handle_buttonpress; + handler[ConfigureRequest] = event_handle_configurerequest; + handler[ConfigureNotify] = event_handle_configurenotify; + handler[DestroyNotify] = event_handle_destroynotify; + handler[EnterNotify] = event_handle_enternotify; + handler[LeaveNotify] = event_handle_leavenotify; + handler[MotionNotify] = event_handle_motionnotify; + handler[Expose] = event_handle_expose; + handler[KeyPress] = event_handle_keypress; + handler[MappingNotify] = event_handle_mappingnotify; + handler[MapRequest] = event_handle_maprequest; + handler[PropertyNotify] = event_handle_propertynotify; + handler[UnmapNotify] = event_handle_unmapnotify; + handler[ClientMessage] = event_handle_clientmessage; /* check for shape extension */ if((globalconf.have_shape = XShapeQueryExtension(dpy, &shape_event, &e_dummy))) { p_realloc(&handler, shape_event + 1); - handler[shape_event] = handle_event_shape; + handler[shape_event] = event_handle_shape; } /* check for randr extension */ if((globalconf.have_randr = XRRQueryExtension(dpy, &randr_event_base, &e_dummy))) { 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); diff --git a/event.c b/event.c index aa5be9b2..fb5b1437 100644 --- a/event.c +++ b/event.c @@ -50,7 +50,7 @@ extern AwesomeConf globalconf; * \param arg optional arg passed to uicb, otherwise buttons' arg are used */ 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 *b; @@ -70,7 +70,7 @@ handle_mouse_button_press(int screen, unsigned int button, unsigned int state, * \param e XEvent */ void -handle_event_buttonpress(XEvent *e) +event_handle_buttonpress(XEvent *e) { int i, screen, x = 0, y = 0; unsigned int udummy; @@ -135,7 +135,7 @@ handle_event_buttonpress(XEvent *e) window_grabbuttons(get_phys_screen(c->screen), c->win); } 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 for(screen = 0; screen < ScreenCount(e->xany.display); screen++) @@ -146,7 +146,7 @@ handle_event_buttonpress(XEvent *e) &i, &udummy)) { 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); return; } @@ -156,7 +156,7 @@ handle_event_buttonpress(XEvent *e) * \param e XEvent */ void -handle_event_configurerequest(XEvent * e) +event_handle_configurerequest(XEvent * e) { Client *c; XConfigureRequestEvent *ev = &e->xconfigurerequest; @@ -209,7 +209,7 @@ handle_event_configurerequest(XEvent * e) * \param e XEvent */ void -handle_event_configurenotify(XEvent * e) +event_handle_configurenotify(XEvent * e) { XConfigureEvent *ev = &e->xconfigure; int screen; @@ -226,7 +226,7 @@ handle_event_configurenotify(XEvent * e) * \param e XEvent */ void -handle_event_destroynotify(XEvent *e) +event_handle_destroynotify(XEvent *e) { Client *c; XDestroyWindowEvent *ev = &e->xdestroywindow; @@ -239,7 +239,7 @@ handle_event_destroynotify(XEvent *e) * \param e XEvent */ void -handle_event_enternotify(XEvent *e) +event_handle_enternotify(XEvent *e) { Client *c; XCrossingEvent *ev = &e->xcrossing; @@ -273,7 +273,7 @@ handle_event_enternotify(XEvent *e) * \param e XEvent */ void -handle_event_motionnotify(XEvent *e) +event_handle_motionnotify(XEvent *e) { XMotionEvent *ev = &e->xmotion; @@ -285,7 +285,7 @@ handle_event_motionnotify(XEvent *e) * \param e XEvent */ void -handle_event_expose(XEvent *e) +event_handle_expose(XEvent *e) { XExposeEvent *ev = &e->xexpose; int screen; @@ -305,7 +305,7 @@ handle_event_expose(XEvent *e) * \param e XEvent */ void -handle_event_keypress(XEvent *e) +event_handle_keypress(XEvent *e) { int screen, x, y, d; unsigned int m; @@ -338,7 +338,7 @@ handle_event_keypress(XEvent *e) * \param e XEvent */ void -handle_event_leavenotify(XEvent * e) +event_handle_leavenotify(XEvent * e) { XCrossingEvent *ev = &e->xcrossing; int screen; @@ -352,7 +352,7 @@ handle_event_leavenotify(XEvent * e) * \param e XEvent */ void -handle_event_mappingnotify(XEvent *e) +event_handle_mappingnotify(XEvent *e) { XMappingEvent *ev = &e->xmapping; int screen; @@ -367,7 +367,7 @@ handle_event_mappingnotify(XEvent *e) * \param e XEvent */ void -handle_event_maprequest(XEvent *e) +event_handle_maprequest(XEvent *e) { static XWindowAttributes wa; XMapRequestEvent *ev = &e->xmaprequest; @@ -396,7 +396,7 @@ handle_event_maprequest(XEvent *e) * \param e XEvent */ void -handle_event_propertynotify(XEvent * e) +event_handle_propertynotify(XEvent * e) { Client *c; Window trans; @@ -430,7 +430,7 @@ handle_event_propertynotify(XEvent * e) * \param e XEvent */ void -handle_event_unmapnotify(XEvent * e) +event_handle_unmapnotify(XEvent * e) { Client *c; XUnmapEvent *ev = &e->xunmap; @@ -445,7 +445,7 @@ handle_event_unmapnotify(XEvent * e) * \param e XEvent */ void -handle_event_shape(XEvent * e) +event_handle_shape(XEvent * e) { XShapeEvent *ev = (XShapeEvent *) e; Client *c = client_get_bywin(globalconf.clients, ev->window); @@ -458,7 +458,7 @@ handle_event_shape(XEvent * e) * \param e XEvent */ void -handle_event_randr_screen_change_notify(XEvent *e) +event_handle_randr_screen_change_notify(XEvent *e) { XRRUpdateConfiguration(e); uicb_exec(0, globalconf.argv); @@ -468,7 +468,7 @@ handle_event_randr_screen_change_notify(XEvent *e) * \param e XEvent */ void -handle_event_clientmessage(XEvent *e) +event_handle_clientmessage(XEvent *e) { ewmh_process_client_message(&e->xclient); } diff --git a/event.h b/event.h index 8d9e80be..8ef38207 100644 --- a/event.h +++ b/event.h @@ -28,22 +28,22 @@ void grabkeys(int); -void handle_event_buttonpress(XEvent *); -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 *); -void handle_event_mappingnotify(XEvent *); -void handle_event_maprequest(XEvent *); -void handle_event_propertynotify(XEvent *); -void handle_event_unmapnotify(XEvent *); -void handle_event_shape(XEvent *); -void handle_event_randr_screen_change_notify(XEvent *); -void handle_event_clientmessage(XEvent *); +void event_handle_buttonpress(XEvent *); +void event_handle_configurerequest(XEvent *); +void event_handle_configurenotify(XEvent *); +void event_handle_destroynotify(XEvent *); +void event_handle_enternotify(XEvent *); +void event_handle_motionnotify(XEvent *); +void event_handle_expose(XEvent *); +void event_handle_keypress(XEvent *); +void event_handle_leavenotify(XEvent *); +void event_handle_mappingnotify(XEvent *); +void event_handle_maprequest(XEvent *); +void event_handle_propertynotify(XEvent *); +void event_handle_unmapnotify(XEvent *); +void event_handle_shape(XEvent *); +void event_handle_randr_screen_change_notify(XEvent *); +void event_handle_clientmessage(XEvent *); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/mouse.c b/mouse.c index dcd59417..d5a63587 100644 --- a/mouse.c +++ b/mouse.c @@ -80,16 +80,16 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) XUngrabPointer(globalconf.display, CurrentTime); return; case ConfigureRequest: - handle_event_configurerequest(&ev); + event_handle_configurerequest(&ev); break; case Expose: - handle_event_expose(&ev); + event_handle_expose(&ev); break; case MapRequest: - handle_event_maprequest(&ev); + event_handle_maprequest(&ev); break; case EnterNotify: - handle_event_enternotify(&ev); + event_handle_enternotify(&ev); break; case MotionNotify: if(c->isfloating || layout->arrange == layout_floating) @@ -206,13 +206,13 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused))) XUngrabPointer(globalconf.display, CurrentTime); return; case ConfigureRequest: - handle_event_configurerequest(&ev); + event_handle_configurerequest(&ev); break; case Expose: - handle_event_expose(&ev); + event_handle_expose(&ev); break; case MapRequest: - handle_event_maprequest(&ev); + event_handle_maprequest(&ev); break; case MotionNotify: if(layout->arrange == layout_floating || c->isfloating)