[event] Cosmetic and manage enhancement

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-04-09 18:27:25 +02:00
parent da0b04d667
commit 8f069ceb9b
1 changed files with 35 additions and 28 deletions

59
event.c
View File

@ -52,7 +52,8 @@ extern AwesomeConf globalconf;
* \param arg optional arg passed to uicb, otherwise buttons' arg are used * \param arg optional arg passed to uicb, otherwise buttons' arg are used
*/ */
static void static void
event_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;
@ -79,8 +80,11 @@ event_handle_buttonpress(void *data __attribute__ ((unused)),
Client *c; Client *c;
Widget *widget; Widget *widget;
Statusbar *statusbar; Statusbar *statusbar;
xcb_query_pointer_cookie_t qc;
xcb_query_pointer_reply_t *qr; xcb_query_pointer_reply_t *qr;
qc = xcb_query_pointer(connection, ev->event);
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++) for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next) for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
if(statusbar->sw->window == ev->event || statusbar->sw->window == ev->child) if(statusbar->sw->window == ev->event || statusbar->sw->window == ev->child)
@ -113,7 +117,8 @@ event_handle_buttonpress(void *data __attribute__ ((unused)),
if(statusbar->sw->geometry.height - ev->event_y >= widget->area.x if(statusbar->sw->geometry.height - ev->event_y >= widget->area.x
&& statusbar->sw->geometry.height - ev->event_y && statusbar->sw->geometry.height - ev->event_y
< widget->area.x + widget->area.width < widget->area.x + widget->area.width
&& ev->event_x >= widget->area.y && ev->event_x < widget->area.y + widget->area.height) && ev->event_x >= widget->area.y
&& ev->event_x < widget->area.y + widget->area.height)
{ {
widget->button_press(widget, ev); widget->button_press(widget, ev);
return 0; return 0;
@ -126,6 +131,7 @@ event_handle_buttonpress(void *data __attribute__ ((unused)),
return 0; return 0;
} }
/* Check for titlebar first */
for(c = globalconf.clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
if(c->titlebar.sw && c->titlebar.sw->window == ev->event) if(c->titlebar.sw && c->titlebar.sw->window == ev->event)
{ {
@ -155,9 +161,7 @@ event_handle_buttonpress(void *data __attribute__ ((unused)),
else else
for(screen = 0; screen < xcb_setup_roots_length(xcb_get_setup(connection)); screen++) for(screen = 0; screen < xcb_setup_roots_length(xcb_get_setup(connection)); screen++)
if(xcb_aux_get_screen(connection, screen)->root == ev->event if(xcb_aux_get_screen(connection, screen)->root == ev->event
&& (qr = xcb_query_pointer_reply(connection, && (qr = xcb_query_pointer_reply(connection, qc, NULL)))
xcb_query_pointer(connection, ev->event),
NULL)) != NULL)
{ {
screen = screen_get_bycoord(globalconf.screens_info, screen, qr->root_x, qr->root_y); screen = screen_get_bycoord(globalconf.screens_info, screen, qr->root_x, qr->root_y);
event_handle_mouse_button_press(screen, ev->detail, ev->state, event_handle_mouse_button_press(screen, ev->detail, ev->state,
@ -443,46 +447,48 @@ int
event_handle_maprequest(void *data __attribute__ ((unused)), event_handle_maprequest(void *data __attribute__ ((unused)),
xcb_connection_t *connection, xcb_map_request_event_t *ev) xcb_connection_t *connection, xcb_map_request_event_t *ev)
{ {
xcb_get_window_attributes_reply_t *wa;
int screen_nbr = 0; int screen_nbr = 0;
xcb_query_pointer_reply_t *qpr = NULL; xcb_get_window_attributes_cookie_t wa_c;
xcb_get_geometry_reply_t *wgeom; xcb_get_window_attributes_reply_t *wa_r;
xcb_query_pointer_cookie_t qp_c;
xcb_query_pointer_reply_t *qp_r = NULL;
xcb_get_geometry_cookie_t geom_c;
xcb_get_geometry_reply_t *geom_r;
xcb_screen_iterator_t iter; xcb_screen_iterator_t iter;
if((wa = xcb_get_window_attributes_reply(connection, wa_c = xcb_get_window_attributes(connection, ev->window);
xcb_get_window_attributes(connection, ev->window), geom_c = xcb_get_geometry(connection, ev->window);
NULL)) == NULL) qp_c = xcb_query_pointer(connection, xcb_aux_get_screen(globalconf.connection, screen_nbr)->root);
if(!(wa_r = xcb_get_window_attributes_reply(connection, wa_c, NULL)))
return -1; return -1;
if(wa->override_redirect)
if(wa_r->override_redirect)
{ {
p_delete(&wa); p_delete(&wa_r);
return 0; return 0;
} }
p_delete(&wa); p_delete(&wa_r);
if(!client_get_bywin(globalconf.clients, ev->window)) if(!client_get_bywin(globalconf.clients, ev->window))
{ {
if((wgeom = xcb_get_geometry_reply(connection, if(!(geom_r = xcb_get_geometry_reply(connection, geom_c, NULL)))
xcb_get_geometry(connection, ev->window), NULL)) == NULL)
return -1; return -1;
if(globalconf.screens_info->xinerama_is_active if(globalconf.screens_info->xinerama_is_active
&& (qpr = xcb_query_pointer_reply(connection, && (qp_r = xcb_query_pointer_reply(connection, qp_c, NULL)))
xcb_query_pointer(connection,
xcb_aux_get_screen(globalconf.connection, screen_nbr)->root),
NULL)) != NULL)
{ {
screen_nbr = screen_get_bycoord(globalconf.screens_info, screen_nbr, screen_nbr = screen_get_bycoord(globalconf.screens_info, screen_nbr,
qpr->root_x, qpr->root_y); qp_r->root_x, qp_r->root_y);
p_delete(&qpr); p_delete(&qp_r);
} }
else else
for(iter = xcb_setup_roots_iterator(xcb_get_setup(connection)), screen_nbr = 0; for(iter = xcb_setup_roots_iterator(xcb_get_setup(connection)), screen_nbr = 0;
iter.rem && iter.data->root != wgeom->root; xcb_screen_next (&iter), ++screen_nbr); iter.rem && iter.data->root != geom_r->root; xcb_screen_next (&iter), ++screen_nbr);
client_manage(ev->window, wgeom, screen_nbr); client_manage(ev->window, geom_r, screen_nbr);
p_delete(&wgeom); p_delete(&geom_r);
} }
return 0; return 0;
@ -515,7 +521,8 @@ event_handle_propertynotify(void *data __attribute__ ((unused)),
else if (ev->atom == WM_HINTS) else if (ev->atom == WM_HINTS)
client_updatewmhints(c); client_updatewmhints(c);
if(ev->atom == WM_NAME || ev->atom == xutil_intern_atom(globalconf.connection, "_NET_WM_NAME")) if(ev->atom == WM_NAME
|| ev->atom == xutil_intern_atom(globalconf.connection, "_NET_WM_NAME"))
client_updatetitle(c); client_updatetitle(c);
} }