widget: store supported align and use to render flex widgets
[awesome.git] / event.c
bloba16a4ba90f969a56e995b4766d8563cd895a7dba
1 /*
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.
22 #include <xcb/xcb.h>
23 #include <xcb/randr.h>
24 #include <xcb/xcb_atom.h>
25 #include <xcb/xcb_icccm.h>
26 #include <xcb/xcb_event.h>
28 #include "awesome.h"
29 #include "event.h"
30 #include "tag.h"
31 #include "window.h"
32 #include "ewmh.h"
33 #include "client.h"
34 #include "widget.h"
35 #include "titlebar.h"
36 #include "keybinding.h"
37 #include "keygrabber.h"
38 #include "luaa.h"
39 #include "systray.h"
40 #include "screen.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.
53 static void
54 event_handle_mouse_button(client_t *c,
55 uint8_t type,
56 xcb_button_t button,
57 uint16_t state,
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)
64 if(c)
66 luaA_client_userdata_new(globalconf.L, c);
67 luaA_dofunction(globalconf.L,
68 type == XCB_BUTTON_PRESS ?
69 buttons->tab[i]->press : buttons->tab[i]->release,
70 1, 0);
72 else
73 luaA_dofunction(globalconf.L,
74 type == XCB_BUTTON_PRESS ?
75 buttons->tab[i]->press : buttons->tab[i]->release,
76 0, 0);
80 /** Get a widget node from a wibox by coords.
81 * \param Container position.
82 * \param widgets The widget list.
83 * \param width The container width.
84 * \param height The container height.
85 * \param x X coordinate of the widget.
86 * \param y Y coordinate of the widget.
87 * \return A widget node.
89 static widget_node_t *
90 widget_getbycoords(position_t position, widget_node_array_t *widgets, int width, int height, int16_t *x, int16_t *y)
92 int tmp;
94 /* Need to transform coordinates like it was top/bottom */
95 switch(position)
97 case Right:
98 tmp = *y;
99 *y = width - *x;
100 *x = tmp;
101 break;
102 case Left:
103 tmp = *y;
104 *y = *x;
105 *x = height - tmp;
106 break;
107 default:
108 break;
111 for(int i = 0; i < widgets->len; i++)
113 widget_node_t *w = &widgets->tab[i];
114 if(w->widget->isvisible &&
115 *x >= w->geometry.x && *x < w->geometry.x + w->geometry.width
116 && *y >= w->geometry.y && *y < w->geometry.y + w->geometry.height)
117 return w;
120 return NULL;
123 /** The button press event handler.
124 * \param data The type of mouse event.
125 * \param connection The connection to the X server.
126 * \param ev The event.
128 static int
129 event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_event_t *ev)
131 int screen;
132 const int nb_screen = xcb_setup_roots_length(xcb_get_setup(connection));
133 client_t *c;
134 widget_node_t *w;
135 wibox_t *wibox;
137 /* ev->state is
138 * button status (8 bits) + modifiers status (8 bits)
139 * we don't care for button status that we get, especially on release, so
140 * drop them */
141 ev->state &= 0x00ff;
143 if((wibox = wibox_getbywin(ev->event))
144 || (wibox = wibox_getbywin(ev->child)))
146 /* If the wibox is child, then x,y are
147 * relative to root window */
148 if(wibox->sw.window == ev->child)
150 ev->event_x -= wibox->sw.geometry.x;
151 ev->event_y -= wibox->sw.geometry.y;
153 if((w = widget_getbycoords(wibox->position, &wibox->widgets,
154 wibox->sw.geometry.width,
155 wibox->sw.geometry.height,
156 &ev->event_x, &ev->event_y)))
157 w->widget->button(w, ev, wibox->screen, wibox);
158 /* return even if no widget match */
159 return 0;
162 if((c = client_getbywin(ev->event)))
164 event_handle_mouse_button(c, ev->response_type, ev->detail, ev->state, &c->buttons);
165 xcb_allow_events(globalconf.connection,
166 XCB_ALLOW_REPLAY_POINTER,
167 XCB_CURRENT_TIME);
169 else
170 for(screen = 0; screen < nb_screen; screen++)
171 if(xutil_screen_get(connection, screen)->root == ev->event)
173 event_handle_mouse_button(NULL, ev->response_type, ev->detail, ev->state, &globalconf.buttons);
174 return 0;
177 return 0;
180 /** The configure event handler.
181 * \param data currently unused.
182 * \param connection The connection to the X server.
183 * \param ev The event.
185 static int
186 event_handle_configurerequest(void *data __attribute__ ((unused)),
187 xcb_connection_t *connection, xcb_configure_request_event_t *ev)
189 client_t *c;
190 area_t geometry;
192 if((c = client_getbywin(ev->window)))
194 geometry = c->geometry;
196 if(ev->value_mask & XCB_CONFIG_WINDOW_X)
197 geometry.x = ev->x;
198 if(ev->value_mask & XCB_CONFIG_WINDOW_Y)
199 geometry.y = ev->y;
200 if(ev->value_mask & XCB_CONFIG_WINDOW_WIDTH)
201 geometry.width = ev->width;
202 if(ev->value_mask & XCB_CONFIG_WINDOW_HEIGHT)
203 geometry.height = ev->height;
205 if(geometry.x != c->geometry.x || geometry.y != c->geometry.y
206 || geometry.width != c->geometry.width || geometry.height != c->geometry.height)
208 if(client_isfloating(c) || layout_get_current(c->screen) == layout_floating)
210 client_resize(c, geometry, false);
211 if(client_hasstrut(c))
212 /* All the wiboxes (may) need to be repositioned */
213 for(int screen = 0; screen < globalconf.nscreen; screen++)
214 for(int i = 0; i < globalconf.screens[screen].wiboxes.len; i++)
216 wibox_t *s = globalconf.screens[screen].wiboxes.tab[i];
217 wibox_position_update(s);
220 else
222 client_need_arrange(c);
223 /* If we do not resize the client, at least tell it that it
224 * has its new configuration. That fixes at least
225 * gnome-terminal */
226 window_configure(c->win, c->geometry, c->border);
229 else
230 window_configure(c->win, geometry, c->border);
232 else
234 uint16_t config_win_mask = 0;
235 uint32_t config_win_vals[7];
236 unsigned short i = 0;
238 if(ev->value_mask & XCB_CONFIG_WINDOW_X)
240 config_win_mask |= XCB_CONFIG_WINDOW_X;
241 config_win_vals[i++] = ev->x;
243 if(ev->value_mask & XCB_CONFIG_WINDOW_Y)
245 config_win_mask |= XCB_CONFIG_WINDOW_Y;
246 config_win_vals[i++] = ev->y;
248 if(ev->value_mask & XCB_CONFIG_WINDOW_WIDTH)
250 config_win_mask |= XCB_CONFIG_WINDOW_WIDTH;
251 config_win_vals[i++] = ev->width;
253 if(ev->value_mask & XCB_CONFIG_WINDOW_HEIGHT)
255 config_win_mask |= XCB_CONFIG_WINDOW_HEIGHT;
256 config_win_vals[i++] = ev->height;
258 if(ev->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH)
260 config_win_mask |= XCB_CONFIG_WINDOW_BORDER_WIDTH;
261 config_win_vals[i++] = ev->border_width;
263 if(ev->value_mask & XCB_CONFIG_WINDOW_SIBLING)
265 config_win_mask |= XCB_CONFIG_WINDOW_SIBLING;
266 config_win_vals[i++] = ev->sibling;
268 if(ev->value_mask & XCB_CONFIG_WINDOW_STACK_MODE)
270 config_win_mask |= XCB_CONFIG_WINDOW_STACK_MODE;
271 config_win_vals[i++] = ev->stack_mode;
274 xcb_configure_window(connection, ev->window, config_win_mask, config_win_vals);
277 return 0;
280 /** The configure notify event handler.
281 * \param data currently unused.
282 * \param connection The connection to the X server.
283 * \param ev The event.
285 static int
286 event_handle_configurenotify(void *data __attribute__ ((unused)),
287 xcb_connection_t *connection, xcb_configure_notify_event_t *ev)
289 int screen_nbr;
290 const xcb_screen_t *screen;
292 for(screen_nbr = 0; screen_nbr < xcb_setup_roots_length(xcb_get_setup (connection)); screen_nbr++)
293 if((screen = xutil_screen_get(connection, screen_nbr)) != NULL
294 && ev->window == screen->root
295 && (ev->width != screen->width_in_pixels
296 || ev->height != screen->height_in_pixels))
297 /* it's not that we panic, but restart */
298 awesome_restart();
300 return 0;
303 /** The destroy notify event handler.
304 * \param data currently unused.
305 * \param connection The connection to the X server.
306 * \param ev The event.
308 static int
309 event_handle_destroynotify(void *data __attribute__ ((unused)),
310 xcb_connection_t *connection __attribute__ ((unused)),
311 xcb_destroy_notify_event_t *ev)
313 client_t *c;
314 xembed_window_t *emwin;
315 int i;
317 if((c = client_getbywin(ev->window)))
318 client_unmanage(c);
319 else if((emwin = xembed_getbywin(globalconf.embedded, ev->event)))
321 xembed_window_list_detach(&globalconf.embedded, emwin);
322 for(i = 0; i < globalconf.nscreen; i++)
323 widget_invalidate_cache(i, WIDGET_CACHE_EMBEDDED);
326 return 0;
329 /** Handle a motion notify over widgets.
330 * \param object The object.
331 * \param mouse_over The pointer to the registered mouse over widget.
332 * \param w The new widget the mouse is over.
334 static void
335 event_handle_widget_motionnotify(void *object,
336 widget_t **mouse_over,
337 widget_node_t *w)
339 if(w->widget != *mouse_over)
341 if(*mouse_over)
343 /* call mouse leave function on old widget */
344 luaA_wibox_userdata_new(globalconf.L, object);
345 luaA_dofunction(globalconf.L, (*mouse_over)->mouse_leave, 1, 0);
347 if(w)
349 /* call mouse enter function on new widget and register it */
350 *mouse_over = w->widget;
351 luaA_wibox_userdata_new(globalconf.L, object);
352 luaA_dofunction(globalconf.L, w->widget->mouse_enter, 1, 0);
357 /** The motion notify event handler.
358 * \param data currently unused.
359 * \param connection The connection to the X server.
360 * \param ev The event.
362 static int
363 event_handle_motionnotify(void *data __attribute__ ((unused)),
364 xcb_connection_t *connection,
365 xcb_motion_notify_event_t *ev)
367 wibox_t *wibox = wibox_getbywin(ev->event);
368 widget_node_t *w;
370 if(wibox
371 && (w = widget_getbycoords(wibox->position, &wibox->widgets,
372 wibox->sw.geometry.width,
373 wibox->sw.geometry.height,
374 &ev->event_x, &ev->event_y)))
375 event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w);
377 return 0;
380 /** The leave notify event handler.
381 * \param data currently unused.
382 * \param connection The connection to the X server.
383 * \param ev The event.
385 static int
386 event_handle_leavenotify(void *data __attribute__ ((unused)),
387 xcb_connection_t *connection,
388 xcb_leave_notify_event_t *ev)
390 wibox_t *wibox = wibox_getbywin(ev->event);
392 if(wibox && wibox->mouse_over)
394 /* call mouse leave function on widget the mouse was over */
395 luaA_wibox_userdata_new(globalconf.L, wibox);
396 luaA_dofunction(globalconf.L, wibox->mouse_over->mouse_leave, 1, 0);
397 wibox->mouse_over = NULL;
400 return 0;
403 /** The enter notify event handler.
404 * \param data currently unused.
405 * \param connection The connection to the X server.
406 * \param ev The event.
408 static int
409 event_handle_enternotify(void *data __attribute__ ((unused)),
410 xcb_connection_t *connection,
411 xcb_enter_notify_event_t *ev)
413 client_t *c;
414 xembed_window_t *emwin;
415 wibox_t *wibox;
416 widget_node_t *w;
418 if(ev->mode != XCB_NOTIFY_MODE_NORMAL
419 || (ev->root_x == globalconf.pointer_x
420 && ev->root_y == globalconf.pointer_y))
421 return 0;
424 if((wibox = wibox_getbywin(ev->event))
425 && (w = widget_getbycoords(wibox->position, &wibox->widgets,
426 wibox->sw.geometry.width,
427 wibox->sw.geometry.height,
428 &ev->event_x, &ev->event_y)))
429 event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w);
430 else if((c = client_getbytitlebarwin(ev->event))
431 || (c = client_getbywin(ev->event)))
433 window_buttons_grab(c->win, ev->root, &c->buttons);
434 /* The idea behind saving pointer_x and pointer_y is Bob Marley powered.
435 * this will allow us top drop some EnterNotify events and thus not giving
436 * focus to windows appering under the cursor without a cursor move */
437 globalconf.pointer_x = ev->root_x;
438 globalconf.pointer_y = ev->root_y;
440 luaA_client_userdata_new(globalconf.L, c);
441 luaA_dofunction(globalconf.L, globalconf.hooks.mouse_enter, 1, 0);
443 else if((emwin = xembed_getbywin(globalconf.embedded, ev->event)))
444 xcb_ungrab_button(globalconf.connection, XCB_BUTTON_INDEX_ANY,
445 xutil_screen_get(connection, emwin->phys_screen)->root,
446 XCB_BUTTON_MASK_ANY);
447 else if(ev->event == ev->root)
448 window_root_buttons_grab(ev->root);
450 return 0;
453 /** The expose event handler.
454 * \param data currently unused.
455 * \param connection The connection to the X server.
456 * \param ev The event.
458 static int
459 event_handle_expose(void *data __attribute__ ((unused)),
460 xcb_connection_t *connection __attribute__ ((unused)),
461 xcb_expose_event_t *ev)
463 wibox_t *wibox = wibox_getbywin(ev->window);
465 if(wibox)
466 simplewindow_refresh_pixmap_partial(&wibox->sw,
467 ev->x, ev->y,
468 ev->width, ev->height);
470 return 0;
473 /** The key press event handler.
474 * \param data currently unused.
475 * \param connection The connection to the X server.
476 * \param ev The event.
478 static int
479 event_handle_keypress(void *data __attribute__ ((unused)),
480 xcb_connection_t *connection __attribute__ ((unused)),
481 xcb_key_press_event_t *ev)
483 if(globalconf.keygrabber != LUA_REFNIL)
485 lua_rawgeti(globalconf.L, LUA_REGISTRYINDEX, globalconf.keygrabber);
486 if(keygrabber_handlekpress(globalconf.L, ev))
488 if(lua_pcall(globalconf.L, 2, 1, 0))
490 warn("error running function: %s", lua_tostring(globalconf.L, -1));
491 keygrabber_ungrab();
493 else if(!lua_isboolean(globalconf.L, -1) || !lua_toboolean(globalconf.L, -1))
494 keygrabber_ungrab();
496 lua_pop(globalconf.L, 1); /* pop returned value or function if not called */
498 else
500 keybinding_t *k = keybinding_find(ev);
501 if (k && k->fct != LUA_REFNIL)
502 luaA_dofunction(globalconf.L, k->fct, 0, 0);
505 return 0;
508 /** The map request event handler.
509 * \param data currently unused.
510 * \param connection The connection to the X server.
511 * \param ev The event.
513 static int
514 event_handle_maprequest(void *data __attribute__ ((unused)),
515 xcb_connection_t *connection, xcb_map_request_event_t *ev)
517 int phys_screen, screen = 0, ret = 0;
518 client_t *c;
519 xcb_get_window_attributes_cookie_t wa_c;
520 xcb_get_window_attributes_reply_t *wa_r;
521 xcb_query_pointer_cookie_t qp_c = { 0 };
522 xcb_query_pointer_reply_t *qp_r = NULL;
523 xcb_get_geometry_cookie_t geom_c;
524 xcb_get_geometry_reply_t *geom_r;
526 wa_c = xcb_get_window_attributes_unchecked(connection, ev->window);
528 if(!(wa_r = xcb_get_window_attributes_reply(connection, wa_c, NULL)))
529 return -1;
531 if(wa_r->override_redirect)
532 goto bailout;
534 if(xembed_getbywin(globalconf.embedded, ev->window))
536 xcb_map_window(connection, ev->window);
537 xembed_window_activate(connection, ev->window);
539 else if((c = client_getbywin(ev->window)))
541 /* Check that it may be visible, but not asked to be hidden */
542 if(client_maybevisible(c, c->screen) && !c->ishidden)
544 client_setminimized(c, false);
545 /* it will be raised, so just update ourself */
546 client_raise(c);
549 else
551 geom_c = xcb_get_geometry_unchecked(connection, ev->window);
553 if(globalconf.xinerama_is_active)
554 qp_c = xcb_query_pointer_unchecked(connection,
555 xutil_screen_get(globalconf.connection,
556 globalconf.default_screen)->root);
558 if(!(geom_r = xcb_get_geometry_reply(connection, geom_c, NULL)))
560 if(globalconf.xinerama_is_active)
561 qp_r = xcb_query_pointer_reply(connection, qp_c, NULL);
562 ret = -1;
563 goto bailout;
567 phys_screen = xutil_root2screen(connection, geom_r->root);
569 if(globalconf.xinerama_is_active
570 && (qp_r = xcb_query_pointer_reply(connection, qp_c, NULL)))
571 screen = screen_getbycoord(screen, qp_r->root_x, qp_r->root_y);
572 else
573 screen = phys_screen;
575 client_manage(ev->window, geom_r, phys_screen, screen);
576 p_delete(&geom_r);
579 bailout:
580 p_delete(&qp_r);
581 p_delete(&wa_r);
582 return ret;
585 /** The unmap notify event handler.
586 * \param data currently unused.
587 * \param connection The connection to the X server.
588 * \param ev The event.
590 static int
591 event_handle_unmapnotify(void *data __attribute__ ((unused)),
592 xcb_connection_t *connection, xcb_unmap_notify_event_t *ev)
594 client_t *c;
595 xembed_window_t *em;
596 int i;
598 if((c = client_getbywin(ev->window)))
600 if(ev->event == xutil_screen_get(connection, c->phys_screen)->root
601 && XCB_EVENT_SENT(ev)
602 && window_state_get_reply(window_state_get_unchecked(c->win)) == XCB_WM_STATE_NORMAL)
603 client_unmanage(c);
605 else if((em = xembed_getbywin(globalconf.embedded, ev->window)))
607 xembed_window_list_detach(&globalconf.embedded, em);
608 for(i = 0; i < globalconf.nscreen; i++)
609 widget_invalidate_cache(i, WIDGET_CACHE_EMBEDDED);
612 return 0;
615 /** The randr screen change notify event handler.
616 * \param data currently unused.
617 * \param connection The connection to the X server.
618 * \param ev The event.
620 static int
621 event_handle_randr_screen_change_notify(void *data __attribute__ ((unused)),
622 xcb_connection_t *connection __attribute__ ((unused)),
623 xcb_randr_screen_change_notify_event_t *ev)
625 if(!globalconf.have_randr)
626 return -1;
628 /* Code of XRRUpdateConfiguration Xlib function ported to XCB
629 * (only the code relevant to RRScreenChangeNotify) as the latter
630 * doesn't provide this kind of function */
631 if(ev->rotation & (XCB_RANDR_ROTATION_ROTATE_90 | XCB_RANDR_ROTATION_ROTATE_270))
632 xcb_randr_set_screen_size(connection, ev->root, ev->height, ev->width,
633 ev->mheight, ev->mwidth);
634 else
635 xcb_randr_set_screen_size(connection, ev->root, ev->width, ev->height,
636 ev->mwidth, ev->mheight);
638 /* XRRUpdateConfiguration also executes the following instruction
639 * but it's not useful because SubpixelOrder is not used at all at
640 * the moment
642 * XRenderSetSubpixelOrder(dpy, snum, scevent->subpixel_order);
645 awesome_restart();
647 return 0;
650 /** The client message event handler.
651 * \param data currently unused.
652 * \param connection The connection to the X server.
653 * \param ev The event.
655 static int
656 event_handle_clientmessage(void *data __attribute__ ((unused)),
657 xcb_connection_t *connection,
658 xcb_client_message_event_t *ev)
660 client_t *c;
662 if(ev->type == WM_CHANGE_STATE)
664 if((c = client_getbywin(ev->window))
665 && ev->format == 32
666 && ev->data.data32[0] == XCB_WM_STATE_ICONIC)
667 client_setminimized(c, true);
669 else if(ev->type == _XEMBED)
670 return xembed_process_client_message(ev);
671 else if(ev->type == _NET_SYSTEM_TRAY_OPCODE)
672 return systray_process_client_message(ev);
673 return ewmh_process_client_message(ev);
676 /** The keymap change notify event handler.
677 * \param data Unused data.
678 * \param connection The connection to the X server.
679 * \param ev The event.
680 * \return Status code, 0 if everything's fine.
682 static int
683 event_handle_mappingnotify(void *data,
684 xcb_connection_t *connection,
685 xcb_mapping_notify_event_t *ev)
687 xcb_get_modifier_mapping_cookie_t xmapping_cookie;
689 if(ev->request == XCB_MAPPING_MODIFIER
690 || ev->request == XCB_MAPPING_KEYBOARD)
692 /* Send the request to get the NumLock, ShiftLock and CapsLock masks */
693 xmapping_cookie = xcb_get_modifier_mapping_unchecked(globalconf.connection);
695 /* Free and then allocate the key symbols */
696 xcb_key_symbols_free(globalconf.keysyms);
697 globalconf.keysyms = xcb_key_symbols_alloc(globalconf.connection);
699 /* Process the reply of previously sent mapping request */
700 xutil_lock_mask_get(globalconf.connection, xmapping_cookie,
701 globalconf.keysyms, &globalconf.numlockmask,
702 &globalconf.shiftlockmask, &globalconf.capslockmask);
705 return 0;
708 static int
709 event_handle_reparentnotify(void *data,
710 xcb_connection_t *connection,
711 xcb_reparent_notify_event_t *ev)
713 client_t *c;
715 if((c = client_getbywin(ev->window)))
716 client_unmanage(c);
718 return 0;
721 void a_xcb_set_event_handlers(void)
723 const xcb_query_extension_reply_t *randr_query;
725 xcb_event_set_button_press_handler(&globalconf.evenths, event_handle_button, NULL);
726 xcb_event_set_button_release_handler(&globalconf.evenths, event_handle_button, NULL);
727 xcb_event_set_configure_request_handler(&globalconf.evenths, event_handle_configurerequest, NULL);
728 xcb_event_set_configure_notify_handler(&globalconf.evenths, event_handle_configurenotify, NULL);
729 xcb_event_set_destroy_notify_handler(&globalconf.evenths, event_handle_destroynotify, NULL);
730 xcb_event_set_enter_notify_handler(&globalconf.evenths, event_handle_enternotify, NULL);
731 xcb_event_set_leave_notify_handler(&globalconf.evenths, event_handle_leavenotify, NULL);
732 xcb_event_set_motion_notify_handler(&globalconf.evenths, event_handle_motionnotify, NULL);
733 xcb_event_set_expose_handler(&globalconf.evenths, event_handle_expose, NULL);
734 xcb_event_set_key_press_handler(&globalconf.evenths, event_handle_keypress, NULL);
735 xcb_event_set_map_request_handler(&globalconf.evenths, event_handle_maprequest, NULL);
736 xcb_event_set_unmap_notify_handler(&globalconf.evenths, event_handle_unmapnotify, NULL);
737 xcb_event_set_client_message_handler(&globalconf.evenths, event_handle_clientmessage, NULL);
738 xcb_event_set_mapping_notify_handler(&globalconf.evenths, event_handle_mappingnotify, NULL);
739 xcb_event_set_reparent_notify_handler(&globalconf.evenths, event_handle_reparentnotify, NULL);
741 /* check for randr extension */
742 randr_query = xcb_get_extension_data(globalconf.connection, &xcb_randr_id);
743 if((globalconf.have_randr = randr_query->present))
744 xcb_event_set_handler(&globalconf.evenths,
745 randr_query->first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY,
746 (xcb_generic_event_handler_t) event_handle_randr_screen_change_notify,
747 NULL);
751 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80