2 * event.c - event handlers
4 * Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include <xcb/randr.h>
24 #include <xcb/xcb_atom.h>
25 #include <xcb/xcb_icccm.h>
26 #include <xcb/xcb_event.h>
36 #include "keybinding.h"
37 #include "keygrabber.h"
41 #include "layouts/floating.h"
42 #include "common/atoms.h"
44 extern awesome_t globalconf
;
46 /** Handle mouse button events.
47 * \param c The client on which the event happened or NULL.
48 * \param type Event type, press or release.
49 * \param button Button number.
50 * \param state Modkeys state.
51 * \param buttons Buttons array to check for.
54 event_handle_mouse_button(client_t
*c
,
58 button_array_t
*buttons
)
60 for(int i
= 0; i
< buttons
->len
; i
++)
61 if(button
== buttons
->tab
[i
]->button
62 && XUTIL_MASK_CLEAN(state
) == buttons
->tab
[i
]->mod
)
65 case XCB_BUTTON_PRESS
:
66 if(buttons
->tab
[i
]->press
!= LUA_REFNIL
)
70 luaA_client_userdata_new(globalconf
.L
, c
);
71 luaA_dofunction(globalconf
.L
, buttons
->tab
[i
]->press
, 1, 0);
74 luaA_dofunction(globalconf
.L
, buttons
->tab
[i
]->press
, 0, 0);
77 case XCB_BUTTON_RELEASE
:
78 if(buttons
->tab
[i
]->release
!= LUA_REFNIL
)
82 luaA_client_userdata_new(globalconf
.L
, c
);
83 luaA_dofunction(globalconf
.L
, buttons
->tab
[i
]->release
, 1, 0);
86 luaA_dofunction(globalconf
.L
, buttons
->tab
[i
]->release
, 0, 0);
92 /** Get a widget node from a wibox by coords.
93 * \param Container position.
94 * \param widgets The widget list.
95 * \param width The container width.
96 * \param height The container height.
97 * \param x X coordinate of the widget.
98 * \param y Y coordinate of the widget.
102 widget_getbycoords(position_t position
, widget_node_array_t
*widgets
,
103 int width
, int height
, int16_t *x
, int16_t *y
)
107 /* Need to transform coordinates like it was top/bottom */
124 for(int i
= 0; i
< widgets
->len
; i
++)
126 widget_node_t
*w
= &widgets
->tab
[i
];
127 if(w
->widget
->isvisible
&&
128 *x
>= w
->geometry
.x
&& *x
< w
->geometry
.x
+ w
->geometry
.width
129 && *y
>= w
->geometry
.y
&& *y
< w
->geometry
.y
+ w
->geometry
.height
)
136 /** The button press event handler.
137 * \param data The type of mouse event.
138 * \param connection The connection to the X server.
139 * \param ev The event.
142 event_handle_button(void *data
, xcb_connection_t
*connection
, xcb_button_press_event_t
*ev
)
145 const int nb_screen
= xcb_setup_roots_length(xcb_get_setup(connection
));
151 * button status (8 bits) + modifiers status (8 bits)
152 * we don't care for button status that we get, especially on release, so
156 if((wibox
= wibox_getbywin(ev
->event
))
157 || (wibox
= wibox_getbywin(ev
->child
)))
159 /* If the wibox is child, then x,y are
160 * relative to root window */
161 if(wibox
->sw
.window
== ev
->child
)
163 ev
->event_x
-= wibox
->sw
.geometry
.x
;
164 ev
->event_y
-= wibox
->sw
.geometry
.y
;
166 if((w
= widget_getbycoords(wibox
->position
, &wibox
->widgets
,
167 wibox
->sw
.geometry
.width
,
168 wibox
->sw
.geometry
.height
,
169 &ev
->event_x
, &ev
->event_y
)))
171 button_array_t
*b
= &w
->buttons
;
173 for(int i
= 0; i
< b
->len
; i
++)
174 if(ev
->detail
== b
->tab
[i
]->button
175 && XUTIL_MASK_CLEAN(ev
->state
) == b
->tab
[i
]->mod
)
176 switch(ev
->response_type
)
178 case XCB_BUTTON_PRESS
:
179 if(b
->tab
[i
]->press
!= LUA_REFNIL
)
181 luaA_wibox_userdata_new(globalconf
.L
, wibox
);
182 luaA_dofunction(globalconf
.L
, b
->tab
[i
]->press
, 1, 0);
185 case XCB_BUTTON_RELEASE
:
186 if(b
->tab
[i
]->release
!= LUA_REFNIL
)
188 luaA_wibox_userdata_new(globalconf
.L
, wibox
);
189 luaA_dofunction(globalconf
.L
, b
->tab
[i
]->release
, 1, 0);
194 /* return even if no widget match */
198 if((c
= client_getbywin(ev
->event
)))
200 event_handle_mouse_button(c
, ev
->response_type
, ev
->detail
, ev
->state
, &c
->buttons
);
201 xcb_allow_events(globalconf
.connection
,
202 XCB_ALLOW_REPLAY_POINTER
,
206 for(screen
= 0; screen
< nb_screen
; screen
++)
207 if(xutil_screen_get(connection
, screen
)->root
== ev
->event
)
209 event_handle_mouse_button(NULL
, ev
->response_type
, ev
->detail
, ev
->state
, &globalconf
.buttons
);
216 /** The configure event handler.
217 * \param data currently unused.
218 * \param connection The connection to the X server.
219 * \param ev The event.
222 event_handle_configurerequest(void *data
__attribute__ ((unused
)),
223 xcb_connection_t
*connection
, xcb_configure_request_event_t
*ev
)
228 if((c
= client_getbywin(ev
->window
)))
230 geometry
= c
->geometry
;
232 if(ev
->value_mask
& XCB_CONFIG_WINDOW_X
)
234 if(ev
->value_mask
& XCB_CONFIG_WINDOW_Y
)
236 if(ev
->value_mask
& XCB_CONFIG_WINDOW_WIDTH
)
237 geometry
.width
= ev
->width
;
238 if(ev
->value_mask
& XCB_CONFIG_WINDOW_HEIGHT
)
239 geometry
.height
= ev
->height
;
241 if(geometry
.x
!= c
->geometry
.x
|| geometry
.y
!= c
->geometry
.y
242 || geometry
.width
!= c
->geometry
.width
|| geometry
.height
!= c
->geometry
.height
)
244 if(client_isfloating(c
) || layout_get_current(c
->screen
) == layout_floating
)
246 client_resize(c
, geometry
, false);
247 if(client_hasstrut(c
))
248 /* All the wiboxes (may) need to be repositioned */
249 for(int screen
= 0; screen
< globalconf
.nscreen
; screen
++)
250 for(int i
= 0; i
< globalconf
.screens
[screen
].wiboxes
.len
; i
++)
252 wibox_t
*s
= globalconf
.screens
[screen
].wiboxes
.tab
[i
];
253 wibox_position_update(s
);
258 client_need_arrange(c
);
259 /* If we do not resize the client, at least tell it that it
260 * has its new configuration. That fixes at least
262 window_configure(c
->win
, c
->geometry
, c
->border
);
266 window_configure(c
->win
, geometry
, c
->border
);
270 uint16_t config_win_mask
= 0;
271 uint32_t config_win_vals
[7];
272 unsigned short i
= 0;
274 if(ev
->value_mask
& XCB_CONFIG_WINDOW_X
)
276 config_win_mask
|= XCB_CONFIG_WINDOW_X
;
277 config_win_vals
[i
++] = ev
->x
;
279 if(ev
->value_mask
& XCB_CONFIG_WINDOW_Y
)
281 config_win_mask
|= XCB_CONFIG_WINDOW_Y
;
282 config_win_vals
[i
++] = ev
->y
;
284 if(ev
->value_mask
& XCB_CONFIG_WINDOW_WIDTH
)
286 config_win_mask
|= XCB_CONFIG_WINDOW_WIDTH
;
287 config_win_vals
[i
++] = ev
->width
;
289 if(ev
->value_mask
& XCB_CONFIG_WINDOW_HEIGHT
)
291 config_win_mask
|= XCB_CONFIG_WINDOW_HEIGHT
;
292 config_win_vals
[i
++] = ev
->height
;
294 if(ev
->value_mask
& XCB_CONFIG_WINDOW_BORDER_WIDTH
)
296 config_win_mask
|= XCB_CONFIG_WINDOW_BORDER_WIDTH
;
297 config_win_vals
[i
++] = ev
->border_width
;
299 if(ev
->value_mask
& XCB_CONFIG_WINDOW_SIBLING
)
301 config_win_mask
|= XCB_CONFIG_WINDOW_SIBLING
;
302 config_win_vals
[i
++] = ev
->sibling
;
304 if(ev
->value_mask
& XCB_CONFIG_WINDOW_STACK_MODE
)
306 config_win_mask
|= XCB_CONFIG_WINDOW_STACK_MODE
;
307 config_win_vals
[i
++] = ev
->stack_mode
;
310 xcb_configure_window(connection
, ev
->window
, config_win_mask
, config_win_vals
);
316 /** The configure notify event handler.
317 * \param data currently unused.
318 * \param connection The connection to the X server.
319 * \param ev The event.
322 event_handle_configurenotify(void *data
__attribute__ ((unused
)),
323 xcb_connection_t
*connection
, xcb_configure_notify_event_t
*ev
)
326 const xcb_screen_t
*screen
;
328 for(screen_nbr
= 0; screen_nbr
< xcb_setup_roots_length(xcb_get_setup (connection
)); screen_nbr
++)
329 if((screen
= xutil_screen_get(connection
, screen_nbr
)) != NULL
330 && ev
->window
== screen
->root
331 && (ev
->width
!= screen
->width_in_pixels
332 || ev
->height
!= screen
->height_in_pixels
))
333 /* it's not that we panic, but restart */
339 /** The destroy notify event handler.
340 * \param data currently unused.
341 * \param connection The connection to the X server.
342 * \param ev The event.
345 event_handle_destroynotify(void *data
__attribute__ ((unused
)),
346 xcb_connection_t
*connection
__attribute__ ((unused
)),
347 xcb_destroy_notify_event_t
*ev
)
350 xembed_window_t
*emwin
;
352 if((c
= client_getbywin(ev
->window
)))
354 else if((emwin
= xembed_getbywin(globalconf
.embedded
, ev
->event
)))
356 xembed_window_list_detach(&globalconf
.embedded
, emwin
);
357 for(int i
= 0; i
< globalconf
.nscreen
; i
++)
358 widget_invalidate_bytype(i
, widget_systray
);
364 /** Handle a motion notify over widgets.
365 * \param object The object.
366 * \param mouse_over The pointer to the registered mouse over widget.
367 * \param widget The new widget the mouse is over.
370 event_handle_widget_motionnotify(void *object
,
371 widget_t
**mouse_over
,
374 if(widget
!= *mouse_over
)
378 if((*mouse_over
)->mouse_leave
!= LUA_REFNIL
)
380 /* call mouse leave function on old widget */
381 luaA_wibox_userdata_new(globalconf
.L
, object
);
382 luaA_dofunction(globalconf
.L
, (*mouse_over
)->mouse_leave
, 1, 0);
387 /* call mouse enter function on new widget and register it */
388 *mouse_over
= widget
;
389 if(widget
->mouse_enter
!= LUA_REFNIL
)
391 luaA_wibox_userdata_new(globalconf
.L
, object
);
392 luaA_dofunction(globalconf
.L
, widget
->mouse_enter
, 1, 0);
398 /** The motion notify event handler.
399 * \param data currently unused.
400 * \param connection The connection to the X server.
401 * \param ev The event.
404 event_handle_motionnotify(void *data
__attribute__ ((unused
)),
405 xcb_connection_t
*connection
,
406 xcb_motion_notify_event_t
*ev
)
408 wibox_t
*wibox
= wibox_getbywin(ev
->event
);
412 && (w
= widget_getbycoords(wibox
->position
, &wibox
->widgets
,
413 wibox
->sw
.geometry
.width
,
414 wibox
->sw
.geometry
.height
,
415 &ev
->event_x
, &ev
->event_y
)))
417 globalconf
.pointer_x
= ev
->root_x
;
418 globalconf
.pointer_y
= ev
->root_y
;
419 event_handle_widget_motionnotify(wibox
, &wibox
->mouse_over
, w
);
425 /** The leave notify event handler.
426 * \param data currently unused.
427 * \param connection The connection to the X server.
428 * \param ev The event.
431 event_handle_leavenotify(void *data
__attribute__ ((unused
)),
432 xcb_connection_t
*connection
,
433 xcb_leave_notify_event_t
*ev
)
435 wibox_t
*wibox
= wibox_getbywin(ev
->event
);
437 if(wibox
&& wibox
->mouse_over
)
439 if(wibox
->mouse_over
->mouse_leave
!= LUA_REFNIL
)
441 /* call mouse leave function on widget the mouse was over */
442 luaA_wibox_userdata_new(globalconf
.L
, wibox
);
443 luaA_dofunction(globalconf
.L
, wibox
->mouse_over
->mouse_leave
, 1, 0);
445 wibox
->mouse_over
= NULL
;
451 /** The enter notify event handler.
452 * \param data currently unused.
453 * \param connection The connection to the X server.
454 * \param ev The event.
457 event_handle_enternotify(void *data
__attribute__ ((unused
)),
458 xcb_connection_t
*connection
,
459 xcb_enter_notify_event_t
*ev
)
462 xembed_window_t
*emwin
;
466 if(ev
->mode
!= XCB_NOTIFY_MODE_NORMAL
467 || (ev
->root_x
== globalconf
.pointer_x
468 && ev
->root_y
== globalconf
.pointer_y
))
472 if((wibox
= wibox_getbywin(ev
->event
))
473 && (w
= widget_getbycoords(wibox
->position
, &wibox
->widgets
,
474 wibox
->sw
.geometry
.width
,
475 wibox
->sw
.geometry
.height
,
476 &ev
->event_x
, &ev
->event_y
)))
478 globalconf
.pointer_x
= ev
->root_x
;
479 globalconf
.pointer_y
= ev
->root_y
;
480 event_handle_widget_motionnotify(wibox
, &wibox
->mouse_over
, w
);
482 else if((c
= client_getbytitlebarwin(ev
->event
))
483 || (c
= client_getbywin(ev
->event
)))
485 window_buttons_grab(c
->win
, ev
->root
, &c
->buttons
);
486 /* The idea behind saving pointer_x and pointer_y is Bob Marley powered.
487 * this will allow us top drop some EnterNotify events and thus not giving
488 * focus to windows appering under the cursor without a cursor move */
489 globalconf
.pointer_x
= ev
->root_x
;
490 globalconf
.pointer_y
= ev
->root_y
;
492 if(globalconf
.hooks
.mouse_enter
!= LUA_REFNIL
)
494 luaA_client_userdata_new(globalconf
.L
, c
);
495 luaA_dofunction(globalconf
.L
, globalconf
.hooks
.mouse_enter
, 1, 0);
498 else if((emwin
= xembed_getbywin(globalconf
.embedded
, ev
->event
)))
499 xcb_ungrab_button(globalconf
.connection
, XCB_BUTTON_INDEX_ANY
,
500 xutil_screen_get(connection
, emwin
->phys_screen
)->root
,
501 XCB_BUTTON_MASK_ANY
);
502 else if(ev
->event
== ev
->root
)
503 window_root_buttons_grab(ev
->root
);
508 /** The expose event handler.
509 * \param data currently unused.
510 * \param connection The connection to the X server.
511 * \param ev The event.
514 event_handle_expose(void *data
__attribute__ ((unused
)),
515 xcb_connection_t
*connection
__attribute__ ((unused
)),
516 xcb_expose_event_t
*ev
)
518 wibox_t
*wibox
= wibox_getbywin(ev
->window
);
521 simplewindow_refresh_pixmap_partial(&wibox
->sw
,
523 ev
->width
, ev
->height
);
528 /** The key press event handler.
529 * \param data currently unused.
530 * \param connection The connection to the X server.
531 * \param ev The event.
534 event_handle_keypress(void *data
__attribute__ ((unused
)),
535 xcb_connection_t
*connection
__attribute__ ((unused
)),
536 xcb_key_press_event_t
*ev
)
538 if(globalconf
.keygrabber
!= LUA_REFNIL
)
540 lua_rawgeti(globalconf
.L
, LUA_REGISTRYINDEX
, globalconf
.keygrabber
);
541 if(keygrabber_handlekpress(globalconf
.L
, ev
))
543 if(lua_pcall(globalconf
.L
, 2, 1, 0))
545 warn("error running function: %s", lua_tostring(globalconf
.L
, -1));
546 luaA_keygrabber_stop(globalconf
.L
);
548 else if(!lua_isboolean(globalconf
.L
, -1) || !lua_toboolean(globalconf
.L
, -1))
549 luaA_keygrabber_stop(globalconf
.L
);
551 lua_pop(globalconf
.L
, 1); /* pop returned value or function if not called */
555 keybinding_t
*k
= keybinding_find(ev
);
556 if (k
&& k
->fct
!= LUA_REFNIL
)
557 luaA_dofunction(globalconf
.L
, k
->fct
, 0, 0);
563 /** The map request event handler.
564 * \param data currently unused.
565 * \param connection The connection to the X server.
566 * \param ev The event.
569 event_handle_maprequest(void *data
__attribute__ ((unused
)),
570 xcb_connection_t
*connection
, xcb_map_request_event_t
*ev
)
572 int phys_screen
, screen
= 0, ret
= 0;
574 xcb_get_window_attributes_cookie_t wa_c
;
575 xcb_get_window_attributes_reply_t
*wa_r
;
576 xcb_query_pointer_cookie_t qp_c
= { 0 };
577 xcb_query_pointer_reply_t
*qp_r
= NULL
;
578 xcb_get_geometry_cookie_t geom_c
;
579 xcb_get_geometry_reply_t
*geom_r
;
581 wa_c
= xcb_get_window_attributes_unchecked(connection
, ev
->window
);
583 if(!(wa_r
= xcb_get_window_attributes_reply(connection
, wa_c
, NULL
)))
586 if(wa_r
->override_redirect
)
589 if(xembed_getbywin(globalconf
.embedded
, ev
->window
))
591 xcb_map_window(connection
, ev
->window
);
592 xembed_window_activate(connection
, ev
->window
);
594 else if((c
= client_getbywin(ev
->window
)))
596 /* Check that it may be visible, but not asked to be hidden */
597 if(client_maybevisible(c
, c
->screen
) && !c
->ishidden
)
599 client_setminimized(c
, false);
600 /* it will be raised, so just update ourself */
606 geom_c
= xcb_get_geometry_unchecked(connection
, ev
->window
);
608 if(globalconf
.xinerama_is_active
)
609 qp_c
= xcb_query_pointer_unchecked(connection
,
610 xutil_screen_get(globalconf
.connection
,
611 globalconf
.default_screen
)->root
);
613 if(!(geom_r
= xcb_get_geometry_reply(connection
, geom_c
, NULL
)))
615 if(globalconf
.xinerama_is_active
)
616 qp_r
= xcb_query_pointer_reply(connection
, qp_c
, NULL
);
622 phys_screen
= xutil_root2screen(connection
, geom_r
->root
);
624 if(globalconf
.xinerama_is_active
625 && (qp_r
= xcb_query_pointer_reply(connection
, qp_c
, NULL
)))
626 screen
= screen_getbycoord(screen
, qp_r
->root_x
, qp_r
->root_y
);
628 screen
= phys_screen
;
630 client_manage(ev
->window
, geom_r
, phys_screen
, screen
);
640 /** The unmap notify event handler.
641 * \param data currently unused.
642 * \param connection The connection to the X server.
643 * \param ev The event.
646 event_handle_unmapnotify(void *data
__attribute__ ((unused
)),
647 xcb_connection_t
*connection
, xcb_unmap_notify_event_t
*ev
)
652 if((c
= client_getbywin(ev
->window
)))
654 if(ev
->event
== xutil_screen_get(connection
, c
->phys_screen
)->root
655 && XCB_EVENT_SENT(ev
)
656 && window_state_get_reply(window_state_get_unchecked(c
->win
)) == XCB_WM_STATE_NORMAL
)
659 else if((em
= xembed_getbywin(globalconf
.embedded
, ev
->window
)))
661 xembed_window_list_detach(&globalconf
.embedded
, em
);
662 for(int i
= 0; i
< globalconf
.nscreen
; i
++)
663 widget_invalidate_bytype(i
, widget_systray
);
669 /** The randr screen change notify event handler.
670 * \param data currently unused.
671 * \param connection The connection to the X server.
672 * \param ev The event.
675 event_handle_randr_screen_change_notify(void *data
__attribute__ ((unused
)),
676 xcb_connection_t
*connection
__attribute__ ((unused
)),
677 xcb_randr_screen_change_notify_event_t
*ev
)
679 if(!globalconf
.have_randr
)
682 /* Code of XRRUpdateConfiguration Xlib function ported to XCB
683 * (only the code relevant to RRScreenChangeNotify) as the latter
684 * doesn't provide this kind of function */
685 if(ev
->rotation
& (XCB_RANDR_ROTATION_ROTATE_90
| XCB_RANDR_ROTATION_ROTATE_270
))
686 xcb_randr_set_screen_size(connection
, ev
->root
, ev
->height
, ev
->width
,
687 ev
->mheight
, ev
->mwidth
);
689 xcb_randr_set_screen_size(connection
, ev
->root
, ev
->width
, ev
->height
,
690 ev
->mwidth
, ev
->mheight
);
692 /* XRRUpdateConfiguration also executes the following instruction
693 * but it's not useful because SubpixelOrder is not used at all at
696 * XRenderSetSubpixelOrder(dpy, snum, scevent->subpixel_order);
704 /** The client message event handler.
705 * \param data currently unused.
706 * \param connection The connection to the X server.
707 * \param ev The event.
710 event_handle_clientmessage(void *data
__attribute__ ((unused
)),
711 xcb_connection_t
*connection
,
712 xcb_client_message_event_t
*ev
)
716 if(ev
->type
== WM_CHANGE_STATE
)
718 if((c
= client_getbywin(ev
->window
))
720 && ev
->data
.data32
[0] == XCB_WM_STATE_ICONIC
)
721 client_setminimized(c
, true);
723 else if(ev
->type
== _XEMBED
)
724 return xembed_process_client_message(ev
);
725 else if(ev
->type
== _NET_SYSTEM_TRAY_OPCODE
)
726 return systray_process_client_message(ev
);
727 return ewmh_process_client_message(ev
);
730 /** The keymap change notify event handler.
731 * \param data Unused data.
732 * \param connection The connection to the X server.
733 * \param ev The event.
734 * \return Status code, 0 if everything's fine.
737 event_handle_mappingnotify(void *data
,
738 xcb_connection_t
*connection
,
739 xcb_mapping_notify_event_t
*ev
)
741 xcb_get_modifier_mapping_cookie_t xmapping_cookie
;
743 if(ev
->request
== XCB_MAPPING_MODIFIER
744 || ev
->request
== XCB_MAPPING_KEYBOARD
)
746 int nscreen
= xcb_setup_roots_length(xcb_get_setup(connection
));
749 /* Send the request to get the NumLock, ShiftLock and CapsLock masks */
750 xmapping_cookie
= xcb_get_modifier_mapping_unchecked(globalconf
.connection
);
752 /* Free and then allocate the key symbols */
753 xcb_key_symbols_free(globalconf
.keysyms
);
754 globalconf
.keysyms
= xcb_key_symbols_alloc(globalconf
.connection
);
756 /* Process the reply of previously sent mapping request */
757 xutil_lock_mask_get(globalconf
.connection
, xmapping_cookie
,
758 globalconf
.keysyms
, &globalconf
.numlockmask
,
759 &globalconf
.shiftlockmask
, &globalconf
.capslockmask
);
763 xcb_screen_t
*s
= xutil_screen_get(globalconf
.connection
, phys_screen
);
764 /* yes XCB_BUTTON_MASK_ANY is also for grab_key even if it's look
766 xcb_ungrab_key(connection
, XCB_GRAB_ANY
, s
->root
, XCB_BUTTON_MASK_ANY
);
768 } while(phys_screen
< nscreen
);
770 /* regrab everything */
771 keybinding_array_t
*arr
= &globalconf
.keys
.by_sym
;
772 for(int i
= 0; i
< arr
->len
; i
++)
773 window_root_grabkey(arr
->tab
[i
]);
775 arr
= &globalconf
.keys
.by_code
;
776 for(int i
= 0; i
< arr
->len
; i
++)
777 window_root_grabkey(arr
->tab
[i
]);
784 event_handle_reparentnotify(void *data
,
785 xcb_connection_t
*connection
,
786 xcb_reparent_notify_event_t
*ev
)
790 if((c
= client_getbywin(ev
->window
)))
796 void a_xcb_set_event_handlers(void)
798 const xcb_query_extension_reply_t
*randr_query
;
800 xcb_event_set_button_press_handler(&globalconf
.evenths
, event_handle_button
, NULL
);
801 xcb_event_set_button_release_handler(&globalconf
.evenths
, event_handle_button
, NULL
);
802 xcb_event_set_configure_request_handler(&globalconf
.evenths
, event_handle_configurerequest
, NULL
);
803 xcb_event_set_configure_notify_handler(&globalconf
.evenths
, event_handle_configurenotify
, NULL
);
804 xcb_event_set_destroy_notify_handler(&globalconf
.evenths
, event_handle_destroynotify
, NULL
);
805 xcb_event_set_enter_notify_handler(&globalconf
.evenths
, event_handle_enternotify
, NULL
);
806 xcb_event_set_leave_notify_handler(&globalconf
.evenths
, event_handle_leavenotify
, NULL
);
807 xcb_event_set_motion_notify_handler(&globalconf
.evenths
, event_handle_motionnotify
, NULL
);
808 xcb_event_set_expose_handler(&globalconf
.evenths
, event_handle_expose
, NULL
);
809 xcb_event_set_key_press_handler(&globalconf
.evenths
, event_handle_keypress
, NULL
);
810 xcb_event_set_map_request_handler(&globalconf
.evenths
, event_handle_maprequest
, NULL
);
811 xcb_event_set_unmap_notify_handler(&globalconf
.evenths
, event_handle_unmapnotify
, NULL
);
812 xcb_event_set_client_message_handler(&globalconf
.evenths
, event_handle_clientmessage
, NULL
);
813 xcb_event_set_mapping_notify_handler(&globalconf
.evenths
, event_handle_mappingnotify
, NULL
);
814 xcb_event_set_reparent_notify_handler(&globalconf
.evenths
, event_handle_reparentnotify
, NULL
);
816 /* check for randr extension */
817 randr_query
= xcb_get_extension_data(globalconf
.connection
, &xcb_randr_id
);
818 if((globalconf
.have_randr
= randr_query
->present
))
819 xcb_event_set_handler(&globalconf
.evenths
,
820 randr_query
->first_event
+ XCB_RANDR_SCREEN_CHANGE_NOTIFY
,
821 (xcb_generic_event_handler_t
) event_handle_randr_screen_change_notify
,
826 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80