naughty: add opacity option
[awesome.git] / ewmh.c
blob892a5e26d8e208d1a143a5f666a3cefb10ee3900
1 /*
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>
23 #include <unistd.h>
25 #include <xcb/xcb.h>
26 #include <xcb/xcb_atom.h>
28 #include "ewmh.h"
29 #include "tag.h"
30 #include "screen.h"
31 #include "client.h"
32 #include "widget.h"
33 #include "cnode.h"
34 #include "wibox.h"
35 #include "common/atoms.h"
36 #include "common/buffer.h"
38 #define _NET_WM_STATE_REMOVE 0
39 #define _NET_WM_STATE_ADD 1
40 #define _NET_WM_STATE_TOGGLE 2
42 /** Update the desktop geometry.
43 * \param phys_screen The physical screen id.
45 static void
46 ewmh_update_desktop_geometry(int phys_screen)
48 area_t geom = screen_area_get(phys_screen,
49 NULL,
50 NULL,
51 false);
52 uint32_t sizes[] = { geom.width, geom.height };
54 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
55 xutil_screen_get(globalconf.connection, phys_screen)->root,
56 _NET_DESKTOP_GEOMETRY, CARDINAL, 32, countof(sizes), sizes);
59 void
60 ewmh_init(int phys_screen)
62 xcb_window_t father;
63 xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen);
64 xcb_atom_t atom[] =
66 _NET_SUPPORTED,
67 _NET_SUPPORTING_WM_CHECK,
68 _NET_CLIENT_LIST,
69 _NET_CLIENT_LIST_STACKING,
70 _NET_NUMBER_OF_DESKTOPS,
71 _NET_CURRENT_DESKTOP,
72 _NET_DESKTOP_NAMES,
73 _NET_ACTIVE_WINDOW,
74 _NET_WORKAREA,
75 _NET_DESKTOP_GEOMETRY,
76 _NET_CLOSE_WINDOW,
77 _NET_WM_NAME,
78 _NET_WM_STRUT_PARTIAL,
79 _NET_WM_ICON_NAME,
80 _NET_WM_VISIBLE_ICON_NAME,
81 _NET_WM_DESKTOP,
82 _NET_WM_WINDOW_TYPE,
83 _NET_WM_WINDOW_TYPE_DESKTOP,
84 _NET_WM_WINDOW_TYPE_DOCK,
85 _NET_WM_WINDOW_TYPE_TOOLBAR,
86 _NET_WM_WINDOW_TYPE_MENU,
87 _NET_WM_WINDOW_TYPE_UTILITY,
88 _NET_WM_WINDOW_TYPE_SPLASH,
89 _NET_WM_WINDOW_TYPE_DIALOG,
90 _NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
91 _NET_WM_WINDOW_TYPE_POPUP_MENU,
92 _NET_WM_WINDOW_TYPE_TOOLTIP,
93 _NET_WM_WINDOW_TYPE_NOTIFICATION,
94 _NET_WM_WINDOW_TYPE_COMBO,
95 _NET_WM_WINDOW_TYPE_DND,
96 _NET_WM_WINDOW_TYPE_NORMAL,
97 _NET_WM_ICON,
98 _NET_WM_PID,
99 _NET_WM_STATE,
100 _NET_WM_STATE_STICKY,
101 _NET_WM_STATE_SKIP_TASKBAR,
102 _NET_WM_STATE_FULLSCREEN,
103 _NET_WM_STATE_MAXIMIZED_HORZ,
104 _NET_WM_STATE_MAXIMIZED_VERT,
105 _NET_WM_STATE_ABOVE,
106 _NET_WM_STATE_BELOW,
107 _NET_WM_STATE_MODAL,
108 _NET_WM_STATE_HIDDEN,
109 _NET_WM_STATE_DEMANDS_ATTENTION
111 int i;
113 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
114 xscreen->root, _NET_SUPPORTED, ATOM, 32,
115 countof(atom), atom);
117 /* create our own window */
118 father = xcb_generate_id(globalconf.connection);
119 xcb_create_window(globalconf.connection, xscreen->root_depth,
120 father, xscreen->root, -1, -1, 1, 1, 0,
121 XCB_COPY_FROM_PARENT, xscreen->root_visual, 0, NULL);
123 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
124 xscreen->root, _NET_SUPPORTING_WM_CHECK, WINDOW, 32,
125 1, &father);
127 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
128 father, _NET_SUPPORTING_WM_CHECK, WINDOW, 32,
129 1, &father);
131 /* set the window manager name */
132 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
133 father, _NET_WM_NAME, UTF8_STRING, 8, 7, "awesome");
135 /* set the window manager PID */
136 i = getpid();
137 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
138 father, _NET_WM_PID, CARDINAL, 32, 1, &i);
140 ewmh_update_desktop_geometry(phys_screen);
143 void
144 ewmh_update_net_client_list(int phys_screen)
146 xcb_window_t *wins;
147 client_t *c;
148 int n = 0;
150 for(c = globalconf.clients; c; c = c->next)
151 n++;
153 wins = p_alloca(xcb_window_t, n);
155 for(n = 0, c = globalconf.clients; c; c = c->next, n++)
156 if(c->phys_screen == phys_screen)
157 wins[n] = c->win;
159 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
160 xutil_screen_get(globalconf.connection, phys_screen)->root,
161 _NET_CLIENT_LIST, WINDOW, 32, n, wins);
164 /** Set the client list in stacking order, bottom to top.
165 * \param phys_screen The physical screen id.
167 void
168 ewmh_update_net_client_list_stacking(int phys_screen)
170 xcb_window_t *wins;
171 client_node_t *c;
172 int n = 0;
174 for(c = globalconf.stack; c; c = c->next)
175 n++;
177 wins = p_alloca(xcb_window_t, n);
179 for(n = 0, c = *client_node_list_last(&globalconf.stack); c; c = c->prev, n++)
180 if(c->client->phys_screen == phys_screen)
181 wins[n] = c->client->win;
183 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
184 xutil_screen_get(globalconf.connection, phys_screen)->root,
185 _NET_CLIENT_LIST_STACKING, WINDOW, 32, n, wins);
188 void
189 ewmh_update_net_numbers_of_desktop(int phys_screen)
191 uint32_t count = globalconf.screens[phys_screen].tags.len;
193 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
194 xutil_screen_get(globalconf.connection, phys_screen)->root,
195 _NET_NUMBER_OF_DESKTOPS, CARDINAL, 32, 1, &count);
198 void
199 ewmh_update_net_current_desktop(int phys_screen)
201 tag_array_t *tags = &globalconf.screens[phys_screen].tags;
202 uint32_t count = 0;
203 tag_t **curtags = tags_get_current(phys_screen);
205 while(count < (uint32_t) tags->len && tags->tab[count] != curtags[0])
206 count++;
208 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
209 xutil_screen_get(globalconf.connection, phys_screen)->root,
210 _NET_CURRENT_DESKTOP, CARDINAL, 32, 1, &count);
212 p_delete(&curtags);
215 void
216 ewmh_update_net_desktop_names(int phys_screen)
218 tag_array_t *tags = &globalconf.screens[phys_screen].tags;
219 buffer_t buf;
221 buffer_inita(&buf, BUFSIZ);
223 for(int i = 0; i < tags->len; i++)
225 buffer_adds(&buf, tags->tab[i]->name);
226 buffer_addc(&buf, '\0');
229 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
230 xutil_screen_get(globalconf.connection, phys_screen)->root,
231 _NET_DESKTOP_NAMES, UTF8_STRING, 8, buf.len, buf.s);
232 buffer_wipe(&buf);
235 /** Update the work area space for each physical screen and each desktop.
236 * \param phys_screen The physical screen id.
238 void
239 ewmh_update_workarea(int phys_screen)
241 tag_array_t *tags = &globalconf.screens[phys_screen].tags;
242 uint32_t *area = p_alloca(uint32_t, tags->len * 4);
243 area_t geom = screen_area_get(phys_screen,
244 &globalconf.screens[phys_screen].wiboxes,
245 &globalconf.screens[phys_screen].padding,
246 true);
249 for(int i = 0; i < tags->len; i++)
251 area[4 * i + 0] = geom.x;
252 area[4 * i + 1] = geom.y;
253 area[4 * i + 2] = geom.width;
254 area[4 * i + 3] = geom.height;
257 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
258 xutil_screen_get(globalconf.connection, phys_screen)->root,
259 _NET_WORKAREA, CARDINAL, 32, tags->len * 4, area);
262 void
263 ewmh_update_net_active_window(int phys_screen)
265 xcb_window_t win;
267 if(globalconf.screen_focus->client_focus
268 && globalconf.screen_focus->client_focus->phys_screen == phys_screen)
269 win = globalconf.screen_focus->client_focus->win;
270 else
271 win = XCB_NONE;
273 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
274 xutil_screen_get(globalconf.connection, phys_screen)->root,
275 _NET_ACTIVE_WINDOW, WINDOW, 32, 1, &win);
278 static void
279 ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
281 if(state == _NET_WM_STATE_STICKY)
283 if(set == _NET_WM_STATE_REMOVE)
284 client_setsticky(c, false);
285 else if(set == _NET_WM_STATE_ADD)
286 client_setsticky(c, true);
287 else if(set == _NET_WM_STATE_TOGGLE)
288 client_setsticky(c, !c->issticky);
290 else if(state == _NET_WM_STATE_SKIP_TASKBAR)
292 if(set == _NET_WM_STATE_REMOVE)
294 c->skiptb = false;
295 ewmh_client_update_hints(c);
297 else if(set == _NET_WM_STATE_ADD)
299 c->skiptb = true;
300 ewmh_client_update_hints(c);
302 else if(set == _NET_WM_STATE_TOGGLE)
304 c->skiptb = !c->skiptb;
305 ewmh_client_update_hints(c);
308 else if(state == _NET_WM_STATE_FULLSCREEN)
310 if(set == _NET_WM_STATE_REMOVE)
311 client_setfullscreen(c, false);
312 else if(set == _NET_WM_STATE_ADD)
313 client_setfullscreen(c, true);
314 else if(set == _NET_WM_STATE_TOGGLE)
315 client_setfullscreen(c, !c->isfullscreen);
317 else if(state == _NET_WM_STATE_MAXIMIZED_HORZ)
319 if(set == _NET_WM_STATE_REMOVE)
320 client_setmaxhoriz(c, false);
321 else if(set == _NET_WM_STATE_ADD)
322 client_setmaxhoriz(c, true);
323 else if(set == _NET_WM_STATE_TOGGLE)
324 client_setmaxhoriz(c, !c->ismaxhoriz);
326 else if(state == _NET_WM_STATE_MAXIMIZED_VERT)
328 if(set == _NET_WM_STATE_REMOVE)
329 client_setmaxvert(c, false);
330 else if(set == _NET_WM_STATE_ADD)
331 client_setmaxvert(c, true);
332 else if(set == _NET_WM_STATE_TOGGLE)
333 client_setmaxvert(c, !c->ismaxvert);
335 else if(state == _NET_WM_STATE_ABOVE)
337 if(set == _NET_WM_STATE_REMOVE)
338 client_setabove(c, false);
339 else if(set == _NET_WM_STATE_ADD)
340 client_setabove(c, true);
341 else if(set == _NET_WM_STATE_TOGGLE)
342 client_setabove(c, !c->isabove);
344 else if(state == _NET_WM_STATE_BELOW)
346 if(set == _NET_WM_STATE_REMOVE)
347 client_setbelow(c, false);
348 else if(set == _NET_WM_STATE_ADD)
349 client_setbelow(c, true);
350 else if(set == _NET_WM_STATE_TOGGLE)
351 client_setbelow(c, !c->isbelow);
353 else if(state == _NET_WM_STATE_MODAL)
355 if(set == _NET_WM_STATE_REMOVE)
356 client_setmodal(c, false);
357 else if(set == _NET_WM_STATE_ADD)
358 client_setmodal(c, true);
359 else if(set == _NET_WM_STATE_TOGGLE)
360 client_setmodal(c, !c->ismodal);
362 else if(state == _NET_WM_STATE_HIDDEN)
364 if(set == _NET_WM_STATE_REMOVE)
365 client_setminimized(c, false);
366 else if(set == _NET_WM_STATE_ADD)
367 client_setminimized(c, true);
368 else if(set == _NET_WM_STATE_TOGGLE)
369 client_setminimized(c, !c->isminimized);
371 else if(state == _NET_WM_STATE_DEMANDS_ATTENTION)
373 if(set == _NET_WM_STATE_REMOVE)
374 client_seturgent(c, false);
375 else if(set == _NET_WM_STATE_ADD)
376 client_seturgent(c, true);
377 else if(set == _NET_WM_STATE_TOGGLE)
378 client_seturgent(c, !c->isurgent);
383 ewmh_process_client_message(xcb_client_message_event_t *ev)
385 client_t *c;
386 int screen;
388 if(ev->type == _NET_CURRENT_DESKTOP)
389 for(screen = 0;
390 screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
391 screen++)
393 if(ev->window == xutil_screen_get(globalconf.connection, screen)->root)
394 tag_view_only_byindex(screen, ev->data.data32[0]);
396 else if(ev->type == _NET_CLOSE_WINDOW)
398 if((c = client_getbywin(ev->window)))
399 client_kill(c);
401 else if(ev->type == _NET_WM_DESKTOP)
403 if((c = client_getbywin(ev->window)))
405 tag_array_t *tags = &globalconf.screens[c->screen].tags;
407 if(ev->data.data32[0] == 0xffffffff)
408 c->issticky = true;
409 else
410 for(int i = 0; i < tags->len; i++)
411 if((int)ev->data.data32[0] == i)
412 tag_client(c, tags->tab[i]);
413 else
414 untag_client(c, tags->tab[i]);
417 else if(ev->type == _NET_WM_STATE)
419 if((c = client_getbywin(ev->window)))
421 ewmh_process_state_atom(c, (xcb_atom_t) ev->data.data32[1], ev->data.data32[0]);
422 if(ev->data.data32[2])
423 ewmh_process_state_atom(c, (xcb_atom_t) ev->data.data32[2],
424 ev->data.data32[0]);
427 else if(ev->type == _NET_ACTIVE_WINDOW)
429 if((c = client_getbywin(ev->window)))
430 client_focus(c);
433 return 0;
436 /** Update client EWMH hints.
437 * \param c The client.
439 void
440 ewmh_client_update_hints(client_t *c)
442 xcb_atom_t state[10]; /* number of defined state atoms */
443 int i = 0;
445 if(c->ismodal)
446 state[i++] = _NET_WM_STATE_MODAL;
447 if(c->isfullscreen)
448 state[i++] = _NET_WM_STATE_FULLSCREEN;
449 if(c->ismaxvert)
450 state[i++] = _NET_WM_STATE_MAXIMIZED_VERT;
451 if(c->ismaxhoriz)
452 state[i++] = _NET_WM_STATE_MAXIMIZED_HORZ;
453 if(c->issticky)
454 state[i++] = _NET_WM_STATE_STICKY;
455 if(c->skiptb)
456 state[i++] = _NET_WM_STATE_SKIP_TASKBAR;
457 if(c->isabove)
458 state[i++] = _NET_WM_STATE_ABOVE;
459 if(c->isbelow)
460 state[i++] = _NET_WM_STATE_BELOW;
461 if(c->isminimized)
462 state[i++] = _NET_WM_STATE_HIDDEN;
463 if(c->isurgent)
464 state[i++] = _NET_WM_STATE_DEMANDS_ATTENTION;
466 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
467 c->win, _NET_WM_STATE, ATOM, 32, i, state);
470 /** Update the client active desktop.
471 * This is "wrong" since it can be on several tags, but EWMH has a strict view
472 * of desktop system so just take the first tag.
473 * \param c The client.
475 void
476 ewmh_client_update_desktop(client_t *c)
478 int i;
479 tag_array_t *tags = &globalconf.screens[c->screen].tags;
481 for(i = 0; i < tags->len; i++)
482 if(is_client_tagged(c, tags->tab[i]))
484 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
485 c->win, _NET_WM_DESKTOP, CARDINAL, 32, 1, &i);
486 return;
490 /** Update the client struts.
491 * \param c The client.
493 void
494 ewmh_update_client_strut(client_t *c)
496 uint32_t state[] =
498 c->strut.left,
499 c->strut.right,
500 c->strut.top,
501 c->strut.bottom,
502 c->strut.left_start_y,
503 c->strut.left_end_y,
504 c->strut.right_start_y,
505 c->strut.right_end_y,
506 c->strut.top_start_x,
507 c->strut.top_end_x,
508 c->strut.bottom_start_x,
509 c->strut.bottom_end_x
512 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
513 c->win, _NET_WM_STRUT_PARTIAL, CARDINAL, 32, countof(state), state);
516 void
517 ewmh_client_check_hints(client_t *c)
519 xcb_atom_t *state;
520 void *data = NULL;
521 int desktop;
522 xcb_get_property_cookie_t c0, c1, c2;
523 xcb_get_property_reply_t *reply;
525 /* Send the GetProperty requests which will be processed later */
526 c0 = xcb_get_property_unchecked(globalconf.connection, false, c->win,
527 _NET_WM_DESKTOP, XCB_GET_PROPERTY_TYPE_ANY, 0, 1);
529 c1 = xcb_get_property_unchecked(globalconf.connection, false, c->win,
530 _NET_WM_STATE, ATOM, 0, UINT32_MAX);
532 c2 = xcb_get_property_unchecked(globalconf.connection, false, c->win,
533 _NET_WM_WINDOW_TYPE, ATOM, 0, UINT32_MAX);
535 reply = xcb_get_property_reply(globalconf.connection, c0, NULL);
536 if(reply && reply->value_len && (data = xcb_get_property_value(reply)))
538 tag_array_t *tags = &globalconf.screens[c->screen].tags;
540 desktop = *(uint32_t *) data;
541 if(desktop == -1)
542 c->issticky = true;
543 else
544 for(int i = 0; i < tags->len; i++)
545 if(desktop == i)
546 tag_client(c, tags->tab[i]);
547 else
548 untag_client(c, tags->tab[i]);
551 p_delete(&reply);
553 reply = xcb_get_property_reply(globalconf.connection, c1, NULL);
554 if(reply && (data = xcb_get_property_value(reply)))
556 state = (xcb_atom_t *) data;
557 for(int i = 0; i < xcb_get_property_value_length(reply); i++)
558 ewmh_process_state_atom(c, state[i], _NET_WM_STATE_ADD);
561 p_delete(&reply);
563 reply = xcb_get_property_reply(globalconf.connection, c2, NULL);
564 if(reply && (data = xcb_get_property_value(reply)))
566 state = (xcb_atom_t *) data;
567 for(int i = 0; i < xcb_get_property_value_length(reply); i++)
568 if(state[i] == _NET_WM_WINDOW_TYPE_DESKTOP)
569 c->type = MAX(c->type, WINDOW_TYPE_DESKTOP);
570 else if(state[i] == _NET_WM_WINDOW_TYPE_DIALOG)
571 c->type = MAX(c->type, WINDOW_TYPE_DIALOG);
572 else if(state[i] == _NET_WM_WINDOW_TYPE_SPLASH)
573 c->type = MAX(c->type, WINDOW_TYPE_SPLASH);
574 else if(state[i] == _NET_WM_WINDOW_TYPE_DOCK)
575 c->type = MAX(c->type, WINDOW_TYPE_DOCK);
576 else if(state[i] == _NET_WM_WINDOW_TYPE_MENU)
577 c->type = MAX(c->type, WINDOW_TYPE_MENU);
578 else if(state[i] == _NET_WM_WINDOW_TYPE_TOOLBAR)
579 c->type = MAX(c->type, WINDOW_TYPE_TOOLBAR);
580 else if(state[i] == _NET_WM_WINDOW_TYPE_UTILITY)
581 c->type = MAX(c->type, WINDOW_TYPE_UTILITY);
583 if(c->type != WINDOW_TYPE_NORMAL
584 && c->type != WINDOW_TYPE_DESKTOP
585 && !c->transient_for)
586 client_setabove(c, true);
589 p_delete(&reply);
592 /** Process the WM strut of a client.
593 * \param c The client.
595 void
596 ewmh_process_client_strut(client_t *c, xcb_get_property_reply_t *strut_r)
598 void *data;
599 xcb_get_property_reply_t *mstrut_r = NULL;
601 if(!strut_r)
603 xcb_get_property_cookie_t strut_q = xcb_get_property_unchecked(globalconf.connection, false, c->win,
604 _NET_WM_STRUT_PARTIAL, CARDINAL, 0, 12);
605 strut_r = mstrut_r = xcb_get_property_reply(globalconf.connection, strut_q, NULL);
608 if(strut_r
609 && strut_r->value_len
610 && (data = xcb_get_property_value(strut_r)))
612 uint32_t *strut = data;
614 if(c->strut.left != strut[0]
615 || c->strut.right != strut[1]
616 || c->strut.top != strut[2]
617 || c->strut.bottom != strut[3]
618 || c->strut.left_start_y != strut[4]
619 || c->strut.left_end_y != strut[5]
620 || c->strut.right_start_y != strut[6]
621 || c->strut.right_end_y != strut[7]
622 || c->strut.top_start_x != strut[8]
623 || c->strut.top_end_x != strut[9]
624 || c->strut.bottom_start_x != strut[10]
625 || c->strut.bottom_end_x != strut[11])
627 c->strut.left = strut[0];
628 c->strut.right = strut[1];
629 c->strut.top = strut[2];
630 c->strut.bottom = strut[3];
631 c->strut.left_start_y = strut[4];
632 c->strut.left_end_y = strut[5];
633 c->strut.right_start_y = strut[6];
634 c->strut.right_end_y = strut[7];
635 c->strut.top_start_x = strut[8];
636 c->strut.top_end_x = strut[9];
637 c->strut.bottom_start_x = strut[10];
638 c->strut.bottom_end_x = strut[11];
640 client_need_arrange(c);
641 /* All the wiboxes (may) need to be repositioned. */
642 wibox_update_positions();
644 hooks_property(c, "struts");
648 p_delete(&mstrut_r);
651 /** Send request to get NET_WM_ICON (EWMH)
652 * \param w The window.
653 * \return The cookie associated with the request.
655 xcb_get_property_cookie_t
656 ewmh_window_icon_get_unchecked(xcb_window_t w)
658 return xcb_get_property_unchecked(globalconf.connection, false, w,
659 _NET_WM_ICON, CARDINAL, 0, UINT32_MAX);
662 image_t *
663 ewmh_window_icon_from_reply(xcb_get_property_reply_t *r)
665 uint32_t *data;
667 if(!r || r->type != CARDINAL || r->format != 32 || r->length < 2 ||
668 !(data = (uint32_t *) xcb_get_property_value(r)))
669 return NULL;
671 if(data[0] && data[1])
672 return image_new_from_argb32(data[0], data[1], data + 2);
674 return NULL;
677 /** Get NET_WM_ICON.
678 * \param cookie The cookie.
679 * \return A draw_image_t structure which must be deleted after usage.
681 image_t *
682 ewmh_window_icon_get_reply(xcb_get_property_cookie_t cookie)
684 xcb_get_property_reply_t *r = xcb_get_property_reply(globalconf.connection, cookie, NULL);
685 image_t *icon = ewmh_window_icon_from_reply(r);
686 p_delete(&r);
687 return icon;
690 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80