X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fxcb.c;h=303d6af1cf2c9b583fff8653bd69fe230e00e457;hb=67ec2333ee659e4b8ce90e75b94a518a2dee81c0;hp=5dda5ccee1bc6d940842af8100fb04209923ff03;hpb=487ccb536a6746656c1635078c7ad44892703d71;p=i3%2Fi3 diff --git a/src/xcb.c b/src/xcb.c index 5dda5cce..303d6af1 100644 --- a/src/xcb.c +++ b/src/xcb.c @@ -4,7 +4,7 @@ * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009 Michael Stapelberg and contributors (see also: LICENSE) * * xcb.c: Helper functions for easier usage of XCB * @@ -154,6 +154,35 @@ void xcb_set_window_rect(xcb_connection_t *conn, xcb_window_t window, Rect r) { add_ignore_event(cookie.sequence, -1); } +/* + * Returns the first supported _NET_WM_WINDOW_TYPE atom. + * + */ +xcb_atom_t xcb_get_preferred_window_type(xcb_get_property_reply_t *reply) { + if (reply == NULL || xcb_get_property_value_length(reply) == 0) + return XCB_NONE; + + xcb_atom_t *atoms; + if ((atoms = xcb_get_property_value(reply)) == NULL) + return XCB_NONE; + + for (int i = 0; i < xcb_get_property_value_length(reply) / (reply->format / 8); i++) { + if (atoms[i] == A__NET_WM_WINDOW_TYPE_NORMAL || + atoms[i] == A__NET_WM_WINDOW_TYPE_DIALOG || + atoms[i] == A__NET_WM_WINDOW_TYPE_UTILITY || + atoms[i] == A__NET_WM_WINDOW_TYPE_TOOLBAR || + atoms[i] == A__NET_WM_WINDOW_TYPE_SPLASH || + atoms[i] == A__NET_WM_WINDOW_TYPE_MENU || + atoms[i] == A__NET_WM_WINDOW_TYPE_DROPDOWN_MENU || + atoms[i] == A__NET_WM_WINDOW_TYPE_POPUP_MENU || + atoms[i] == A__NET_WM_WINDOW_TYPE_TOOLTIP) { + return atoms[i]; + } + } + + return XCB_NONE; +} + /* * Returns true if the given reply contains the given atom. *