2 * ewmh.c - EWMH support functions
4 * Copyright © 2007-2009 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 <sys/types.h>
26 #include <xcb/xcb_atom.h>
29 #include "objects/tag.h"
31 #include "objects/client.h"
33 #include "common/atoms.h"
34 #include "common/buffer.h"
35 #include "common/xutil.h"
37 #define _NET_WM_STATE_REMOVE 0
38 #define _NET_WM_STATE_ADD 1
39 #define _NET_WM_STATE_TOGGLE 2
41 /** Update client EWMH hints.
42 * \param c The client.
45 ewmh_client_update_hints(lua_State
*L
)
47 client_t
*c
= luaA_checkudata(L
, 1, &client_class
);
48 xcb_atom_t state
[10]; /* number of defined state atoms */
52 state
[i
++] = _NET_WM_STATE_MODAL
;
54 state
[i
++] = _NET_WM_STATE_FULLSCREEN
;
55 if(c
->maximized_vertical
)
56 state
[i
++] = _NET_WM_STATE_MAXIMIZED_VERT
;
57 if(c
->maximized_horizontal
)
58 state
[i
++] = _NET_WM_STATE_MAXIMIZED_HORZ
;
60 state
[i
++] = _NET_WM_STATE_STICKY
;
62 state
[i
++] = _NET_WM_STATE_SKIP_TASKBAR
;
64 state
[i
++] = _NET_WM_STATE_ABOVE
;
66 state
[i
++] = _NET_WM_STATE_BELOW
;
68 state
[i
++] = _NET_WM_STATE_HIDDEN
;
70 state
[i
++] = _NET_WM_STATE_DEMANDS_ATTENTION
;
72 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
73 c
->window
, _NET_WM_STATE
, XCB_ATOM_ATOM
, 32, i
, state
);
79 ewmh_update_net_active_window(lua_State
*L
)
83 if(globalconf
.focus
.client
)
84 win
= globalconf
.focus
.client
->window
;
88 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
89 globalconf
.screen
->root
,
90 _NET_ACTIVE_WINDOW
, XCB_ATOM_WINDOW
, 32, 1, &win
);
96 ewmh_update_net_client_list(lua_State
*L
)
98 xcb_window_t
*wins
= p_alloca(xcb_window_t
, globalconf
.clients
.len
);
101 foreach(client
, globalconf
.clients
)
102 wins
[n
++] = (*client
)->window
;
104 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
105 globalconf
.screen
->root
,
106 _NET_CLIENT_LIST
, XCB_ATOM_WINDOW
, 32, n
, wins
);
115 xcb_screen_t
*xscreen
= globalconf
.screen
;
119 _NET_SUPPORTING_WM_CHECK
,
122 _NET_CLIENT_LIST_STACKING
,
123 _NET_NUMBER_OF_DESKTOPS
,
124 _NET_CURRENT_DESKTOP
,
129 _NET_WM_STRUT_PARTIAL
,
131 _NET_WM_VISIBLE_ICON_NAME
,
134 _NET_WM_WINDOW_TYPE_DESKTOP
,
135 _NET_WM_WINDOW_TYPE_DOCK
,
136 _NET_WM_WINDOW_TYPE_TOOLBAR
,
137 _NET_WM_WINDOW_TYPE_MENU
,
138 _NET_WM_WINDOW_TYPE_UTILITY
,
139 _NET_WM_WINDOW_TYPE_SPLASH
,
140 _NET_WM_WINDOW_TYPE_DIALOG
,
141 _NET_WM_WINDOW_TYPE_DROPDOWN_MENU
,
142 _NET_WM_WINDOW_TYPE_POPUP_MENU
,
143 _NET_WM_WINDOW_TYPE_TOOLTIP
,
144 _NET_WM_WINDOW_TYPE_NOTIFICATION
,
145 _NET_WM_WINDOW_TYPE_COMBO
,
146 _NET_WM_WINDOW_TYPE_DND
,
147 _NET_WM_WINDOW_TYPE_NORMAL
,
151 _NET_WM_STATE_STICKY
,
152 _NET_WM_STATE_SKIP_TASKBAR
,
153 _NET_WM_STATE_FULLSCREEN
,
154 _NET_WM_STATE_MAXIMIZED_HORZ
,
155 _NET_WM_STATE_MAXIMIZED_VERT
,
159 _NET_WM_STATE_HIDDEN
,
160 _NET_WM_STATE_DEMANDS_ATTENTION
164 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
165 xscreen
->root
, _NET_SUPPORTED
, XCB_ATOM_ATOM
, 32,
166 countof(atom
), atom
);
168 /* create our own window */
169 father
= xcb_generate_id(globalconf
.connection
);
170 xcb_create_window(globalconf
.connection
, xscreen
->root_depth
,
171 father
, xscreen
->root
, -1, -1, 1, 1, 0,
172 XCB_COPY_FROM_PARENT
, xscreen
->root_visual
, 0, NULL
);
174 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
175 xscreen
->root
, _NET_SUPPORTING_WM_CHECK
, XCB_ATOM_WINDOW
, 32,
178 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
179 father
, _NET_SUPPORTING_WM_CHECK
, XCB_ATOM_WINDOW
, 32,
182 /* set the window manager name */
183 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
184 father
, _NET_WM_NAME
, UTF8_STRING
, 8, 7, "awesome");
186 /* set the window manager PID */
188 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
189 father
, _NET_WM_PID
, XCB_ATOM_CARDINAL
, 32, 1, &i
);
192 luaA_class_connect_signal(globalconf
.L
, &client_class
, "focus", ewmh_update_net_active_window
);
193 luaA_class_connect_signal(globalconf
.L
, &client_class
, "unfocus", ewmh_update_net_active_window
);
194 luaA_class_connect_signal(globalconf
.L
, &client_class
, "manage", ewmh_update_net_client_list
);
195 luaA_class_connect_signal(globalconf
.L
, &client_class
, "unmanage", ewmh_update_net_client_list
);
196 luaA_class_connect_signal(globalconf
.L
, &client_class
, "property::modal" , ewmh_client_update_hints
);
197 luaA_class_connect_signal(globalconf
.L
, &client_class
, "property::fullscreen" , ewmh_client_update_hints
);
198 luaA_class_connect_signal(globalconf
.L
, &client_class
, "property::maximized_horizontal" , ewmh_client_update_hints
);
199 luaA_class_connect_signal(globalconf
.L
, &client_class
, "property::maximized_vertical" , ewmh_client_update_hints
);
200 luaA_class_connect_signal(globalconf
.L
, &client_class
, "property::sticky" , ewmh_client_update_hints
);
201 luaA_class_connect_signal(globalconf
.L
, &client_class
, "property::skip_taskbar" , ewmh_client_update_hints
);
202 luaA_class_connect_signal(globalconf
.L
, &client_class
, "property::above" , ewmh_client_update_hints
);
203 luaA_class_connect_signal(globalconf
.L
, &client_class
, "property::below" , ewmh_client_update_hints
);
204 luaA_class_connect_signal(globalconf
.L
, &client_class
, "property::minimized" , ewmh_client_update_hints
);
205 luaA_class_connect_signal(globalconf
.L
, &client_class
, "property::urgent" , ewmh_client_update_hints
);
208 /** Set the client list in stacking order, bottom to top.
211 ewmh_update_net_client_list_stacking(void)
214 xcb_window_t
*wins
= p_alloca(xcb_window_t
, globalconf
.stack
.len
);
216 foreach(client
, globalconf
.stack
)
217 wins
[n
++] = (*client
)->window
;
219 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
220 globalconf
.screen
->root
,
221 _NET_CLIENT_LIST_STACKING
, XCB_ATOM_WINDOW
, 32, n
, wins
);
225 ewmh_update_net_numbers_of_desktop(void)
227 uint32_t count
= globalconf
.tags
.len
;
229 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
230 globalconf
.screen
->root
,
231 _NET_NUMBER_OF_DESKTOPS
, XCB_ATOM_CARDINAL
, 32, 1, &count
);
235 ewmh_update_net_current_desktop(void)
237 uint32_t idx
= tags_get_first_selected_index();
239 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
240 globalconf
.screen
->root
,
241 _NET_CURRENT_DESKTOP
, XCB_ATOM_CARDINAL
, 32, 1, &idx
);
245 ewmh_update_net_desktop_names(void)
249 buffer_inita(&buf
, BUFSIZ
);
251 foreach(tag
, globalconf
.tags
)
253 buffer_adds(&buf
, tag_get_name(*tag
));
254 buffer_addc(&buf
, '\0');
257 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
258 globalconf
.screen
->root
,
259 _NET_DESKTOP_NAMES
, UTF8_STRING
, 8, buf
.len
, buf
.s
);
264 ewmh_process_state_atom(client_t
*c
, xcb_atom_t state
, int set
)
266 luaA_object_push(globalconf
.L
, c
);
268 if(state
== _NET_WM_STATE_STICKY
)
270 if(set
== _NET_WM_STATE_REMOVE
)
271 client_set_sticky(globalconf
.L
, -1, false);
272 else if(set
== _NET_WM_STATE_ADD
)
273 client_set_sticky(globalconf
.L
, -1, true);
274 else if(set
== _NET_WM_STATE_TOGGLE
)
275 client_set_sticky(globalconf
.L
, -1, !c
->sticky
);
277 else if(state
== _NET_WM_STATE_SKIP_TASKBAR
)
279 if(set
== _NET_WM_STATE_REMOVE
)
280 client_set_skip_taskbar(globalconf
.L
, -1, false);
281 else if(set
== _NET_WM_STATE_ADD
)
282 client_set_skip_taskbar(globalconf
.L
, -1, true);
283 else if(set
== _NET_WM_STATE_TOGGLE
)
284 client_set_skip_taskbar(globalconf
.L
, -1, !c
->skip_taskbar
);
286 else if(state
== _NET_WM_STATE_FULLSCREEN
)
288 if(set
== _NET_WM_STATE_REMOVE
)
289 client_set_fullscreen(globalconf
.L
, -1, false);
290 else if(set
== _NET_WM_STATE_ADD
)
291 client_set_fullscreen(globalconf
.L
, -1, true);
292 else if(set
== _NET_WM_STATE_TOGGLE
)
293 client_set_fullscreen(globalconf
.L
, -1, !c
->fullscreen
);
295 else if(state
== _NET_WM_STATE_MAXIMIZED_HORZ
)
297 if(set
== _NET_WM_STATE_REMOVE
)
298 client_set_maximized_horizontal(globalconf
.L
, -1, false);
299 else if(set
== _NET_WM_STATE_ADD
)
300 client_set_maximized_horizontal(globalconf
.L
, -1, true);
301 else if(set
== _NET_WM_STATE_TOGGLE
)
302 client_set_maximized_horizontal(globalconf
.L
, -1, !c
->maximized_horizontal
);
304 else if(state
== _NET_WM_STATE_MAXIMIZED_VERT
)
306 if(set
== _NET_WM_STATE_REMOVE
)
307 client_set_maximized_vertical(globalconf
.L
, -1, false);
308 else if(set
== _NET_WM_STATE_ADD
)
309 client_set_maximized_vertical(globalconf
.L
, -1, true);
310 else if(set
== _NET_WM_STATE_TOGGLE
)
311 client_set_maximized_vertical(globalconf
.L
, -1, !c
->maximized_vertical
);
313 else if(state
== _NET_WM_STATE_ABOVE
)
315 if(set
== _NET_WM_STATE_REMOVE
)
316 client_set_above(globalconf
.L
, -1, false);
317 else if(set
== _NET_WM_STATE_ADD
)
318 client_set_above(globalconf
.L
, -1, true);
319 else if(set
== _NET_WM_STATE_TOGGLE
)
320 client_set_above(globalconf
.L
, -1, !c
->above
);
322 else if(state
== _NET_WM_STATE_BELOW
)
324 if(set
== _NET_WM_STATE_REMOVE
)
325 client_set_below(globalconf
.L
, -1, false);
326 else if(set
== _NET_WM_STATE_ADD
)
327 client_set_below(globalconf
.L
, -1, true);
328 else if(set
== _NET_WM_STATE_TOGGLE
)
329 client_set_below(globalconf
.L
, -1, !c
->below
);
331 else if(state
== _NET_WM_STATE_MODAL
)
333 if(set
== _NET_WM_STATE_REMOVE
)
334 client_set_modal(globalconf
.L
, -1, false);
335 else if(set
== _NET_WM_STATE_ADD
)
336 client_set_modal(globalconf
.L
, -1, true);
337 else if(set
== _NET_WM_STATE_TOGGLE
)
338 client_set_modal(globalconf
.L
, -1, !c
->modal
);
340 else if(state
== _NET_WM_STATE_HIDDEN
)
342 if(set
== _NET_WM_STATE_REMOVE
)
343 client_set_minimized(globalconf
.L
, -1, false);
344 else if(set
== _NET_WM_STATE_ADD
)
345 client_set_minimized(globalconf
.L
, -1, true);
346 else if(set
== _NET_WM_STATE_TOGGLE
)
347 client_set_minimized(globalconf
.L
, -1, !c
->minimized
);
349 else if(state
== _NET_WM_STATE_DEMANDS_ATTENTION
)
351 if(set
== _NET_WM_STATE_REMOVE
)
352 client_set_urgent(globalconf
.L
, -1, false);
353 else if(set
== _NET_WM_STATE_ADD
)
354 client_set_urgent(globalconf
.L
, -1, true);
355 else if(set
== _NET_WM_STATE_TOGGLE
)
356 client_set_urgent(globalconf
.L
, -1, !c
->urgent
);
359 lua_pop(globalconf
.L
, 1);
363 ewmh_process_client_message(xcb_client_message_event_t
*ev
)
367 if(ev
->type
== _NET_CURRENT_DESKTOP
)
368 tag_view_only_byindex(ev
->data
.data32
[0]);
369 else if(ev
->type
== _NET_CLOSE_WINDOW
)
371 if((c
= client_getbywin(ev
->window
)))
374 else if(ev
->type
== _NET_WM_DESKTOP
)
376 if((c
= client_getbywin(ev
->window
)))
378 if(ev
->data
.data32
[0] == 0xffffffff)
381 for(int i
= 0; i
< globalconf
.tags
.len
; i
++)
382 if((int)ev
->data
.data32
[0] == i
)
384 luaA_object_push(globalconf
.L
, globalconf
.tags
.tab
[i
]);
388 untag_client(c
, globalconf
.tags
.tab
[i
]);
391 else if(ev
->type
== _NET_WM_STATE
)
393 if((c
= client_getbywin(ev
->window
)))
395 ewmh_process_state_atom(c
, (xcb_atom_t
) ev
->data
.data32
[1], ev
->data
.data32
[0]);
396 if(ev
->data
.data32
[2])
397 ewmh_process_state_atom(c
, (xcb_atom_t
) ev
->data
.data32
[2],
401 else if(ev
->type
== _NET_ACTIVE_WINDOW
)
403 if((c
= client_getbywin(ev
->window
))) {
412 /** Update the client active desktop.
413 * This is "wrong" since it can be on several tags, but EWMH has a strict view
414 * of desktop system so just take the first tag.
415 * \param c The client.
418 ewmh_client_update_desktop(client_t
*c
)
422 for(i
= 0; i
< globalconf
.tags
.len
; i
++)
423 if(is_client_tagged(c
, globalconf
.tags
.tab
[i
]))
425 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
426 c
->window
, _NET_WM_DESKTOP
, XCB_ATOM_CARDINAL
, 32, 1, &i
);
429 /* It doesn't have any tags, remove the property */
430 xcb_delete_property(globalconf
.connection
, c
->window
, _NET_WM_DESKTOP
);
433 /** Update the client struts.
434 * \param window The window to update the struts for.
435 * \param strut The strut type to update the window with.
438 ewmh_update_strut(xcb_window_t window
, strut_t
*strut
)
442 const uint32_t state
[] =
450 strut
->right_start_y
,
454 strut
->bottom_start_x
,
458 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
459 window
, _NET_WM_STRUT_PARTIAL
, XCB_ATOM_CARDINAL
, 32, countof(state
), state
);
463 /** Update the window type.
464 * \param window The window to update.
465 * \param type The new type to set.
468 ewmh_update_window_type(xcb_window_t window
, uint32_t type
)
470 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
471 window
, _NET_WM_WINDOW_TYPE
, XCB_ATOM_ATOM
, 32, 1, &type
);
475 ewmh_client_check_hints(client_t
*c
)
480 xcb_get_property_cookie_t c0
, c1
, c2
;
481 xcb_get_property_reply_t
*reply
;
483 /* Send the GetProperty requests which will be processed later */
484 c0
= xcb_get_property_unchecked(globalconf
.connection
, false, c
->window
,
485 _NET_WM_DESKTOP
, XCB_GET_PROPERTY_TYPE_ANY
, 0, 1);
487 c1
= xcb_get_property_unchecked(globalconf
.connection
, false, c
->window
,
488 _NET_WM_STATE
, XCB_ATOM_ATOM
, 0, UINT32_MAX
);
490 c2
= xcb_get_property_unchecked(globalconf
.connection
, false, c
->window
,
491 _NET_WM_WINDOW_TYPE
, XCB_ATOM_ATOM
, 0, UINT32_MAX
);
493 reply
= xcb_get_property_reply(globalconf
.connection
, c0
, NULL
);
494 if(reply
&& reply
->value_len
&& (data
= xcb_get_property_value(reply
)))
496 desktop
= *(uint32_t *) data
;
499 else if (desktop
>= 0 && desktop
< globalconf
.tags
.len
)
500 for(int i
= 0; i
< globalconf
.tags
.len
; i
++)
503 luaA_object_push(globalconf
.L
, globalconf
.tags
.tab
[i
]);
507 untag_client(c
, globalconf
.tags
.tab
[i
]);
509 /* Value out of bounds, just give it the first tag */
510 if (globalconf
.tags
.len
> 0)
512 luaA_object_push(globalconf
.L
, globalconf
.tags
.tab
[0]);
519 reply
= xcb_get_property_reply(globalconf
.connection
, c1
, NULL
);
520 if(reply
&& (data
= xcb_get_property_value(reply
)))
522 state
= (xcb_atom_t
*) data
;
523 for(int i
= 0; i
< xcb_get_property_value_length(reply
) / ssizeof(xcb_atom_t
); i
++)
524 ewmh_process_state_atom(c
, state
[i
], _NET_WM_STATE_ADD
);
529 reply
= xcb_get_property_reply(globalconf
.connection
, c2
, NULL
);
530 if(reply
&& (data
= xcb_get_property_value(reply
)))
532 state
= (xcb_atom_t
*) data
;
533 for(int i
= 0; i
< xcb_get_property_value_length(reply
) / ssizeof(xcb_atom_t
); i
++)
534 if(state
[i
] == _NET_WM_WINDOW_TYPE_DESKTOP
)
535 c
->type
= MAX(c
->type
, WINDOW_TYPE_DESKTOP
);
536 else if(state
[i
] == _NET_WM_WINDOW_TYPE_DIALOG
)
537 c
->type
= MAX(c
->type
, WINDOW_TYPE_DIALOG
);
538 else if(state
[i
] == _NET_WM_WINDOW_TYPE_SPLASH
)
539 c
->type
= MAX(c
->type
, WINDOW_TYPE_SPLASH
);
540 else if(state
[i
] == _NET_WM_WINDOW_TYPE_DOCK
)
541 c
->type
= MAX(c
->type
, WINDOW_TYPE_DOCK
);
542 else if(state
[i
] == _NET_WM_WINDOW_TYPE_MENU
)
543 c
->type
= MAX(c
->type
, WINDOW_TYPE_MENU
);
544 else if(state
[i
] == _NET_WM_WINDOW_TYPE_TOOLBAR
)
545 c
->type
= MAX(c
->type
, WINDOW_TYPE_TOOLBAR
);
546 else if(state
[i
] == _NET_WM_WINDOW_TYPE_UTILITY
)
547 c
->type
= MAX(c
->type
, WINDOW_TYPE_UTILITY
);
553 /** Process the WM strut of a client.
554 * \param c The client.
555 * \param strut_r (Optional) An existing reply.
558 ewmh_process_client_strut(client_t
*c
)
561 xcb_get_property_reply_t
*strut_r
;
563 xcb_get_property_cookie_t strut_q
= xcb_get_property_unchecked(globalconf
.connection
, false, c
->window
,
564 _NET_WM_STRUT_PARTIAL
, XCB_ATOM_CARDINAL
, 0, 12);
565 strut_r
= xcb_get_property_reply(globalconf
.connection
, strut_q
, NULL
);
568 && strut_r
->value_len
569 && (data
= xcb_get_property_value(strut_r
)))
571 uint32_t *strut
= data
;
573 if(c
->strut
.left
!= strut
[0]
574 || c
->strut
.right
!= strut
[1]
575 || c
->strut
.top
!= strut
[2]
576 || c
->strut
.bottom
!= strut
[3]
577 || c
->strut
.left_start_y
!= strut
[4]
578 || c
->strut
.left_end_y
!= strut
[5]
579 || c
->strut
.right_start_y
!= strut
[6]
580 || c
->strut
.right_end_y
!= strut
[7]
581 || c
->strut
.top_start_x
!= strut
[8]
582 || c
->strut
.top_end_x
!= strut
[9]
583 || c
->strut
.bottom_start_x
!= strut
[10]
584 || c
->strut
.bottom_end_x
!= strut
[11])
586 c
->strut
.left
= strut
[0];
587 c
->strut
.right
= strut
[1];
588 c
->strut
.top
= strut
[2];
589 c
->strut
.bottom
= strut
[3];
590 c
->strut
.left_start_y
= strut
[4];
591 c
->strut
.left_end_y
= strut
[5];
592 c
->strut
.right_start_y
= strut
[6];
593 c
->strut
.right_end_y
= strut
[7];
594 c
->strut
.top_start_x
= strut
[8];
595 c
->strut
.top_end_x
= strut
[9];
596 c
->strut
.bottom_start_x
= strut
[10];
597 c
->strut
.bottom_end_x
= strut
[11];
599 luaA_object_push(globalconf
.L
, c
);
600 luaA_object_emit_signal(globalconf
.L
, -1, "property::struts", 0);
601 lua_pop(globalconf
.L
, 1);
608 /** Send request to get NET_WM_ICON (EWMH)
609 * \param w The window.
610 * \return The cookie associated with the request.
612 xcb_get_property_cookie_t
613 ewmh_window_icon_get_unchecked(xcb_window_t w
)
615 return xcb_get_property_unchecked(globalconf
.connection
, false, w
,
616 _NET_WM_ICON
, XCB_ATOM_CARDINAL
, 0, UINT32_MAX
);
619 static cairo_surface_t
*
620 ewmh_window_icon_from_reply(xcb_get_property_reply_t
*r
)
625 if(!r
|| r
->type
!= XCB_ATOM_CARDINAL
|| r
->format
!= 32 || r
->length
< 2)
628 data
= (uint32_t *) xcb_get_property_value(r
);
632 /* Check that the property is as long as it should be, handling integer
633 * overflow. <uint32_t> times <another uint32_t casted to uint64_t> always
634 * fits into an uint64_t and thus this multiplication cannot overflow.
636 len
= data
[0] * (uint64_t) data
[1];
637 if (!data
[0] || !data
[1] || len
> r
->length
- 2)
640 return draw_surface_from_data(data
[0], data
[1], data
+ 2);
644 * \param cookie The cookie.
645 * \return The number of elements on stack.
648 ewmh_window_icon_get_reply(xcb_get_property_cookie_t cookie
)
650 xcb_get_property_reply_t
*r
= xcb_get_property_reply(globalconf
.connection
, cookie
, NULL
);
651 cairo_surface_t
*surface
= ewmh_window_icon_from_reply(r
);
656 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80