diff --git a/client.c b/client.c index 0440472c..ed4b6b3c 100644 --- a/client.c +++ b/client.c @@ -38,6 +38,7 @@ #include "systray.h" #include "layouts/floating.h" #include "common/markup.h" +#include "common/atoms.h" extern awesome_t globalconf; extern const name_func_link_t FloatingPlacementList[]; @@ -69,12 +70,7 @@ client_loadprops(client_t * c, screen_t *screen) tag_array_t *tags = &screen->tags; char *prop = NULL; - if(!xutil_gettextprop(globalconf.connection, c->win, &globalconf.atoms, - xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, - xutil_intern_atom(globalconf.connection, - &globalconf.atoms, - "_AWESOME_PROPERTIES")), - &prop)) + if(!xutil_gettextprop(globalconf.connection, c->win, _AWESOME_PROPERTIES, &prop)) return false; if(a_strlen(prop) != tags->len + 2) @@ -104,19 +100,13 @@ static bool window_isprotodel(xcb_window_t win) { uint32_t i, n; - xcb_atom_t wm_delete_win_atom; xcb_atom_t *protocols; bool ret = false; if(xcb_get_wm_protocols(globalconf.connection, win, &n, &protocols)) { - wm_delete_win_atom = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, - xutil_intern_atom(globalconf.connection, - &globalconf.atoms, - "WM_DELETE_WINDOW")); - for(i = 0; !ret && i < n; i++) - if(protocols[i] == wm_delete_win_atom) + if(protocols[i] == WM_DELETE_WINDOW) ret = true; p_delete(&protocols); } @@ -161,14 +151,9 @@ void client_updatetitle(client_t *c) { char *name; - xutil_intern_atom_request_t net_wm_name_q; - xcb_atom_t net_wm_name; - net_wm_name_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "_NET_WM_NAME"); - net_wm_name = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, net_wm_name_q); - - if(!xutil_gettextprop(globalconf.connection, c->win, &globalconf.atoms, net_wm_name, &name)) - if(!xutil_gettextprop(globalconf.connection, c->win, &globalconf.atoms, WM_NAME, &name)) + if(!xutil_gettextprop(globalconf.connection, c->win, _NET_WM_NAME, &name)) + if(!xutil_gettextprop(globalconf.connection, c->win, WM_NAME, &name)) return; p_delete(&c->name); @@ -643,20 +628,15 @@ client_saveprops(client_t *c) { tag_array_t *tags = &globalconf.screens[c->screen].tags; unsigned char *prop = p_alloca(unsigned char, tags->len + 3); - xutil_intern_atom_request_t atom_q; int i; - atom_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "_AWESOME_PROPERTIES"); - for(i = 0; i < tags->len; i++) prop[i] = is_client_tagged(c, tags->tab[i]) ? '1' : '0'; prop[i++] = c->isfloating ? '1' : '0'; prop[i++] = '0' + c->layer; - xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, c->win, - xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, atom_q), - STRING, 8, i, prop); + xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, c->win, _AWESOME_PROPERTIES, STRING, 8, i, prop); } /** Unban a client. @@ -678,10 +658,6 @@ void client_unmanage(client_t *c) { tag_array_t *tags = &globalconf.screens[c->screen].tags; - xutil_intern_atom_request_t awesome_properties_q; - xcb_atom_t awesome_properties; - - awesome_properties_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "_AWESOME_PROPERTIES"); /* call hook */ luaA_client_userdata_new(globalconf.L, c); @@ -719,8 +695,7 @@ client_unmanage(client_t *c) ewmh_update_net_client_list(c->phys_screen); /* delete properties */ - awesome_properties = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, awesome_properties_q); - xcb_delete_property(globalconf.connection, c->win, awesome_properties); + xcb_delete_property(globalconf.connection, c->win, _AWESOME_PROPERTIES); p_delete(&c); } @@ -860,13 +835,9 @@ void client_kill(client_t *c) { xcb_client_message_event_t ev; - xutil_intern_atom_request_t wm_protocols_q, wm_delete_window_q; if(window_isprotodel(c->win)) { - wm_protocols_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "WM_PROTOCOLS"); - wm_delete_window_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "WM_DELETE_WINDOW"); - /* Initialize all of event's fields first */ p_clear(&ev, 1); @@ -874,8 +845,8 @@ client_kill(client_t *c) ev.window = c->win; ev.format = 32; ev.data.data32[1] = XCB_CURRENT_TIME; - ev.type = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, wm_protocols_q); - ev.data.data32[0] = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, wm_delete_window_q); + ev.type = WM_PROTOCOLS; + ev.data.data32[0] = WM_DELETE_WINDOW; xcb_send_event(globalconf.connection, false, c->win, XCB_EVENT_MASK_NO_EVENT, (char *) &ev); diff --git a/common/atoms.c b/common/atoms.c index bcada856..8dcfbc70 100644 --- a/common/atoms.c +++ b/common/atoms.c @@ -22,39 +22,51 @@ #include "common/atoms.h" #include "common/util.h" -xcb_atom_t NET_SUPPORTED; -xcb_atom_t NET_CLIENT_LIST; -xcb_atom_t NET_CLIENT_LIST_STACKING; -xcb_atom_t NET_NUMBER_OF_DESKTOPS; -xcb_atom_t NET_CURRENT_DESKTOP; -xcb_atom_t NET_DESKTOP_NAMES; -xcb_atom_t NET_ACTIVE_WINDOW; -xcb_atom_t NET_WORKAREA; -xcb_atom_t NET_SUPPORTING_WM_CHECK; -xcb_atom_t NET_CLOSE_WINDOW; -xcb_atom_t NET_WM_NAME; -xcb_atom_t NET_WM_VISIBLE_NAME; -xcb_atom_t NET_WM_DESKTOP; -xcb_atom_t NET_WM_ICON_NAME; -xcb_atom_t NET_WM_VISIBLE_ICON_NAME; -xcb_atom_t NET_WM_WINDOW_TYPE; -xcb_atom_t NET_WM_WINDOW_TYPE_NORMAL; -xcb_atom_t NET_WM_WINDOW_TYPE_DESKTOP; -xcb_atom_t NET_WM_WINDOW_TYPE_DOCK; -xcb_atom_t NET_WM_WINDOW_TYPE_SPLASH; -xcb_atom_t NET_WM_WINDOW_TYPE_DIALOG; -xcb_atom_t NET_WM_ICON; -xcb_atom_t NET_WM_PID; -xcb_atom_t NET_WM_STATE; -xcb_atom_t NET_WM_STATE_STICKY; -xcb_atom_t NET_WM_STATE_SKIP_TASKBAR; -xcb_atom_t NET_WM_STATE_FULLSCREEN; -xcb_atom_t NET_WM_STATE_ABOVE; -xcb_atom_t NET_WM_STATE_BELOW; -xcb_atom_t NET_WM_STATE_MODAL; -xcb_atom_t NET_WM_STATE_HIDDEN; -xcb_atom_t NET_WM_STATE_DEMANDS_ATTENTION; +xcb_atom_t _NET_SUPPORTED; +xcb_atom_t _NET_CLIENT_LIST; +xcb_atom_t _NET_CLIENT_LIST_STACKING; +xcb_atom_t _NET_NUMBER_OF_DESKTOPS; +xcb_atom_t _NET_CURRENT_DESKTOP; +xcb_atom_t _NET_DESKTOP_NAMES; +xcb_atom_t _NET_ACTIVE_WINDOW; +xcb_atom_t _NET_WORKAREA; +xcb_atom_t _NET_SUPPORTING_WM_CHECK; +xcb_atom_t _NET_CLOSE_WINDOW; +xcb_atom_t _NET_WM_NAME; +xcb_atom_t _NET_WM_VISIBLE_NAME; +xcb_atom_t _NET_WM_DESKTOP; +xcb_atom_t _NET_WM_ICON_NAME; +xcb_atom_t _NET_WM_VISIBLE_ICON_NAME; +xcb_atom_t _NET_WM_WINDOW_TYPE; +xcb_atom_t _NET_WM_WINDOW_TYPE_NORMAL; +xcb_atom_t _NET_WM_WINDOW_TYPE_DESKTOP; +xcb_atom_t _NET_WM_WINDOW_TYPE_DOCK; +xcb_atom_t _NET_WM_WINDOW_TYPE_SPLASH; +xcb_atom_t _NET_WM_WINDOW_TYPE_DIALOG; +xcb_atom_t _NET_WM_ICON; +xcb_atom_t _NET_WM_PID; +xcb_atom_t _NET_WM_STATE; +xcb_atom_t _NET_WM_STATE_STICKY; +xcb_atom_t _NET_WM_STATE_SKIP_TASKBAR; +xcb_atom_t _NET_WM_STATE_FULLSCREEN; +xcb_atom_t _NET_WM_STATE_ABOVE; +xcb_atom_t _NET_WM_STATE_BELOW; +xcb_atom_t _NET_WM_STATE_MODAL; +xcb_atom_t _NET_WM_STATE_HIDDEN; +xcb_atom_t _NET_WM_STATE_DEMANDS_ATTENTION; xcb_atom_t UTF8_STRING; +xcb_atom_t _AWESOME_PROPERTIES; +xcb_atom_t WM_PROTOCOLS; +xcb_atom_t WM_DELETE_WINDOW; +xcb_atom_t _XEMBED; +xcb_atom_t _XEMBED_INFO; +xcb_atom_t _NET_SYSTEM_TRAY_OPCODE; +xcb_atom_t _KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR; +xcb_atom_t MANAGER; +xcb_atom_t _XROOTPMAP_ID; +xcb_atom_t WM_STATE; +xcb_atom_t _NET_WM_WINDOW_OPACITY; +xcb_atom_t _NET_SYSTEM_TRAY_ORIENTATION; typedef struct { @@ -64,39 +76,51 @@ typedef struct static atom_item_t ATOM_LIST[] = { - { "_NET_SUPPORTED", &NET_SUPPORTED }, - { "_NET_CLIENT_LIST", &NET_CLIENT_LIST }, - { "_NET_CLIENT_LIST_STACKING", &NET_CLIENT_LIST_STACKING }, - { "_NET_NUMBER_OF_DESKTOPS", &NET_NUMBER_OF_DESKTOPS }, - { "_NET_CURRENT_DESKTOP", &NET_CURRENT_DESKTOP }, - { "_NET_DESKTOP_NAMES", &NET_DESKTOP_NAMES }, - { "_NET_ACTIVE_WINDOW", &NET_ACTIVE_WINDOW }, - { "_NET_WORKAREA", &NET_WORKAREA }, - { "_NET_SUPPORTING_WM_CHECK", &NET_SUPPORTING_WM_CHECK }, - { "_NET_CLOSE_WINDOW", &NET_CLOSE_WINDOW }, - { "_NET_WM_NAME", &NET_WM_NAME }, - { "_NET_WM_VISIBLE_NAME", &NET_WM_VISIBLE_NAME }, - { "_NET_WM_DESKTOP", &NET_WM_DESKTOP }, - { "_NET_WM_ICON_NAME", &NET_WM_ICON_NAME }, - { "_NET_WM_VISIBLE_ICON_NAME", &NET_WM_VISIBLE_ICON_NAME }, - { "_NET_WM_WINDOW_TYPE", &NET_WM_WINDOW_TYPE }, - { "_NET_WM_WINDOW_TYPE_NORMAL", &NET_WM_WINDOW_TYPE_NORMAL }, - { "_NET_WM_WINDOW_TYPE_DESKTOP", &NET_WM_WINDOW_TYPE_DESKTOP }, - { "_NET_WM_WINDOW_TYPE_DOCK", &NET_WM_WINDOW_TYPE_DOCK }, - { "_NET_WM_WINDOW_TYPE_SPLASH", &NET_WM_WINDOW_TYPE_SPLASH }, - { "_NET_WM_WINDOW_TYPE_DIALOG", &NET_WM_WINDOW_TYPE_DIALOG }, - { "_NET_WM_ICON", &NET_WM_ICON }, - { "_NET_WM_PID", &NET_WM_PID }, - { "_NET_WM_STATE", &NET_WM_STATE }, - { "_NET_WM_STATE_STICKY", &NET_WM_STATE_STICKY }, - { "_NET_WM_STATE_SKIP_TASKBAR", &NET_WM_STATE_SKIP_TASKBAR }, - { "_NET_WM_STATE_FULLSCREEN", &NET_WM_STATE_FULLSCREEN }, - { "_NET_WM_STATE_ABOVE", &NET_WM_STATE_ABOVE }, - { "_NET_WM_STATE_BELOW", &NET_WM_STATE_BELOW }, - { "_NET_WM_STATE_MODAL", &NET_WM_STATE_MODAL }, - { "_NET_WM_STATE_HIDDEN", &NET_WM_STATE_HIDDEN }, - { "_NET_WM_STATE_DEMANDS_ATTENTION", &NET_WM_STATE_DEMANDS_ATTENTION }, + { "_NET_SUPPORTED", &_NET_SUPPORTED }, + { "_NET_CLIENT_LIST", &_NET_CLIENT_LIST }, + { "_NET_CLIENT_LIST_STACKING", &_NET_CLIENT_LIST_STACKING }, + { "_NET_NUMBER_OF_DESKTOPS", &_NET_NUMBER_OF_DESKTOPS }, + { "_NET_CURRENT_DESKTOP", &_NET_CURRENT_DESKTOP }, + { "_NET_DESKTOP_NAMES", &_NET_DESKTOP_NAMES }, + { "_NET_ACTIVE_WINDOW", &_NET_ACTIVE_WINDOW }, + { "_NET_WORKAREA", &_NET_WORKAREA }, + { "_NET_SUPPORTING_WM_CHECK", &_NET_SUPPORTING_WM_CHECK }, + { "_NET_CLOSE_WINDOW", &_NET_CLOSE_WINDOW }, + { "_NET_WM_NAME", &_NET_WM_NAME }, + { "_NET_WM_VISIBLE_NAME", &_NET_WM_VISIBLE_NAME }, + { "_NET_WM_DESKTOP", &_NET_WM_DESKTOP }, + { "_NET_WM_ICON_NAME", &_NET_WM_ICON_NAME }, + { "_NET_WM_VISIBLE_ICON_NAME", &_NET_WM_VISIBLE_ICON_NAME }, + { "_NET_WM_WINDOW_TYPE", &_NET_WM_WINDOW_TYPE }, + { "_NET_WM_WINDOW_TYPE_NORMAL", &_NET_WM_WINDOW_TYPE_NORMAL }, + { "_NET_WM_WINDOW_TYPE_DESKTOP", &_NET_WM_WINDOW_TYPE_DESKTOP }, + { "_NET_WM_WINDOW_TYPE_DOCK", &_NET_WM_WINDOW_TYPE_DOCK }, + { "_NET_WM_WINDOW_TYPE_SPLASH", &_NET_WM_WINDOW_TYPE_SPLASH }, + { "_NET_WM_WINDOW_TYPE_DIALOG", &_NET_WM_WINDOW_TYPE_DIALOG }, + { "_NET_WM_ICON", &_NET_WM_ICON }, + { "_NET_WM_PID", &_NET_WM_PID }, + { "_NET_WM_STATE", &_NET_WM_STATE }, + { "_NET_WM_STATE_STICKY", &_NET_WM_STATE_STICKY }, + { "_NET_WM_STATE_SKIP_TASKBAR", &_NET_WM_STATE_SKIP_TASKBAR }, + { "_NET_WM_STATE_FULLSCREEN", &_NET_WM_STATE_FULLSCREEN }, + { "_NET_WM_STATE_ABOVE", &_NET_WM_STATE_ABOVE }, + { "_NET_WM_STATE_BELOW", &_NET_WM_STATE_BELOW }, + { "_NET_WM_STATE_MODAL", &_NET_WM_STATE_MODAL }, + { "_NET_WM_STATE_HIDDEN", &_NET_WM_STATE_HIDDEN }, + { "_NET_WM_STATE_DEMANDS_ATTENTION", &_NET_WM_STATE_DEMANDS_ATTENTION }, { "UTF8_STRING", &UTF8_STRING }, + { "_AWESOME_PROPERTIES", &_AWESOME_PROPERTIES }, + { "WM_PROTOCOLS", &WM_PROTOCOLS }, + { "WM_DELETE_WINDOW", &WM_DELETE_WINDOW }, + { "_XEMBED", &_XEMBED }, + { "_XEMBED_INFO", &_XEMBED_INFO }, + { "_NET_SYSTEM_TRAY_OPCODE", &_NET_SYSTEM_TRAY_OPCODE }, + { "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", &_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR }, + { "MANAGER", &MANAGER }, + { "_XROOTPMAP_ID", &_XROOTPMAP_ID }, + { "WM_STATE", &WM_STATE }, + { "_NET_WM_WINDOW_OPACITY", &_NET_WM_WINDOW_OPACITY }, + { "_NET_SYSTEM_TRAY_ORIENTATION", &_NET_SYSTEM_TRAY_ORIENTATION }, }; void diff --git a/common/atoms.h b/common/atoms.h index f763d3cc..dfd2c6cb 100644 --- a/common/atoms.h +++ b/common/atoms.h @@ -24,39 +24,51 @@ #include -extern xcb_atom_t NET_SUPPORTED; -extern xcb_atom_t NET_CLIENT_LIST; -extern xcb_atom_t NET_CLIENT_LIST_STACKING; -extern xcb_atom_t NET_NUMBER_OF_DESKTOPS; -extern xcb_atom_t NET_CURRENT_DESKTOP; -extern xcb_atom_t NET_DESKTOP_NAMES; -extern xcb_atom_t NET_ACTIVE_WINDOW; -extern xcb_atom_t NET_WORKAREA; -extern xcb_atom_t NET_SUPPORTING_WM_CHECK; -extern xcb_atom_t NET_CLOSE_WINDOW; -extern xcb_atom_t NET_WM_NAME; -extern xcb_atom_t NET_WM_VISIBLE_NAME; -extern xcb_atom_t NET_WM_DESKTOP; -extern xcb_atom_t NET_WM_ICON_NAME; -extern xcb_atom_t NET_WM_VISIBLE_ICON_NAME; -extern xcb_atom_t NET_WM_WINDOW_TYPE; -extern xcb_atom_t NET_WM_WINDOW_TYPE_NORMAL; -extern xcb_atom_t NET_WM_WINDOW_TYPE_DESKTOP; -extern xcb_atom_t NET_WM_WINDOW_TYPE_DOCK; -extern xcb_atom_t NET_WM_WINDOW_TYPE_SPLASH; -extern xcb_atom_t NET_WM_WINDOW_TYPE_DIALOG; -extern xcb_atom_t NET_WM_ICON; -extern xcb_atom_t NET_WM_PID; -extern xcb_atom_t NET_WM_STATE; -extern xcb_atom_t NET_WM_STATE_STICKY; -extern xcb_atom_t NET_WM_STATE_SKIP_TASKBAR; -extern xcb_atom_t NET_WM_STATE_FULLSCREEN; -extern xcb_atom_t NET_WM_STATE_ABOVE; -extern xcb_atom_t NET_WM_STATE_BELOW; -extern xcb_atom_t NET_WM_STATE_MODAL; -extern xcb_atom_t NET_WM_STATE_HIDDEN; -extern xcb_atom_t NET_WM_STATE_DEMANDS_ATTENTION; +extern xcb_atom_t _NET_SUPPORTED; +extern xcb_atom_t _NET_CLIENT_LIST; +extern xcb_atom_t _NET_CLIENT_LIST_STACKING; +extern xcb_atom_t _NET_NUMBER_OF_DESKTOPS; +extern xcb_atom_t _NET_CURRENT_DESKTOP; +extern xcb_atom_t _NET_DESKTOP_NAMES; +extern xcb_atom_t _NET_ACTIVE_WINDOW; +extern xcb_atom_t _NET_WORKAREA; +extern xcb_atom_t _NET_SUPPORTING_WM_CHECK; +extern xcb_atom_t _NET_CLOSE_WINDOW; +extern xcb_atom_t _NET_WM_NAME; +extern xcb_atom_t _NET_WM_VISIBLE_NAME; +extern xcb_atom_t _NET_WM_DESKTOP; +extern xcb_atom_t _NET_WM_ICON_NAME; +extern xcb_atom_t _NET_WM_VISIBLE_ICON_NAME; +extern xcb_atom_t _NET_WM_WINDOW_TYPE; +extern xcb_atom_t _NET_WM_WINDOW_TYPE_NORMAL; +extern xcb_atom_t _NET_WM_WINDOW_TYPE_DESKTOP; +extern xcb_atom_t _NET_WM_WINDOW_TYPE_DOCK; +extern xcb_atom_t _NET_WM_WINDOW_TYPE_SPLASH; +extern xcb_atom_t _NET_WM_WINDOW_TYPE_DIALOG; +extern xcb_atom_t _NET_WM_ICON; +extern xcb_atom_t _NET_WM_PID; +extern xcb_atom_t _NET_WM_STATE; +extern xcb_atom_t _NET_WM_STATE_STICKY; +extern xcb_atom_t _NET_WM_STATE_SKIP_TASKBAR; +extern xcb_atom_t _NET_WM_STATE_FULLSCREEN; +extern xcb_atom_t _NET_WM_STATE_ABOVE; +extern xcb_atom_t _NET_WM_STATE_BELOW; +extern xcb_atom_t _NET_WM_STATE_MODAL; +extern xcb_atom_t _NET_WM_STATE_HIDDEN; +extern xcb_atom_t _NET_WM_STATE_DEMANDS_ATTENTION; extern xcb_atom_t UTF8_STRING; +extern xcb_atom_t _AWESOME_PROPERTIES; +extern xcb_atom_t WM_PROTOCOLS; +extern xcb_atom_t WM_DELETE_WINDOW; +extern xcb_atom_t _XEMBED; +extern xcb_atom_t _XEMBED_INFO; +extern xcb_atom_t _NET_SYSTEM_TRAY_OPCODE; +extern xcb_atom_t _KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR; +extern xcb_atom_t MANAGER; +extern xcb_atom_t _XROOTPMAP_ID; +extern xcb_atom_t WM_STATE; +extern xcb_atom_t _NET_WM_WINDOW_OPACITY; +extern xcb_atom_t _NET_SYSTEM_TRAY_ORIENTATION; void atoms_init(xcb_connection_t *); diff --git a/common/xembed.c b/common/xembed.c index 303434aa..6bdce82a 100644 --- a/common/xembed.c +++ b/common/xembed.c @@ -23,6 +23,7 @@ #include "common/xembed.h" #include "common/xutil.h" #include "common/util.h" +#include "common/atoms.h" /** Have the embedder end XEMBED protocol communication with a child. * \param connection The X connection. @@ -59,10 +60,8 @@ xembed_message_send(xcb_connection_t *connection, xcb_window_t towin, long message, long d1, long d2, long d3) { xcb_client_message_event_t ev; - xutil_intern_atom_request_t atom_q; /** \todo use atom cache */ - atom_q = xutil_intern_atom(connection, NULL, "_XEMBED"); p_clear(&ev, 1); ev.response_type = XCB_CLIENT_MESSAGE; ev.window = towin; @@ -72,7 +71,7 @@ xembed_message_send(xcb_connection_t *connection, xcb_window_t towin, ev.data.data32[2] = d1; ev.data.data32[3] = d2; ev.data.data32[4] = d3; - ev.type = xutil_intern_atom_reply(connection, NULL, atom_q); + ev.type = _XEMBED; xcb_send_event(connection, false, towin, XCB_EVENT_MASK_NO_EVENT, (char *) &ev); } @@ -84,18 +83,13 @@ xembed_message_send(xcb_connection_t *connection, xcb_window_t towin, bool xembed_info_get(xcb_connection_t *connection, xcb_window_t win, xembed_info_t *info) { - xutil_intern_atom_request_t atom_q; - xcb_atom_t atom; xcb_get_property_cookie_t prop_c; xcb_get_property_reply_t *prop_r; uint32_t *data; bool ret = false; /** \todo use atom cache */ - atom_q = xutil_intern_atom(connection, NULL, "_XEMBED_INFO"); - atom = xutil_intern_atom_reply(connection, NULL, atom_q); - - prop_c = xcb_get_property_unchecked(connection, false, win, atom, + prop_c = xcb_get_property_unchecked(connection, false, win, _XEMBED_INFO, XCB_GET_PROPERTY_TYPE_ANY, 0L, 2); prop_r = xcb_get_property_reply(connection, prop_c, NULL); diff --git a/common/xutil.c b/common/xutil.c index 4c0386ef..2c017118 100644 --- a/common/xutil.c +++ b/common/xutil.c @@ -29,19 +29,17 @@ #include "common/util.h" #include "common/xutil.h" +#include "common/atoms.h" /** Get the string value of an atom. * \param conn X connection * \param w window - * \param atoms atoms cache * \param atom the atom * \param text buffer to fill * \return true on sucess, falsse on failure */ bool -xutil_gettextprop(xcb_connection_t *conn, xcb_window_t w, - xutil_atom_cache_array_t *atoms, - xcb_atom_t atom, char **text) +xutil_gettextprop(xcb_connection_t *conn, xcb_window_t w, xcb_atom_t atom, char **text) { xcb_get_property_cookie_t prop_c; xcb_get_property_reply_t *prop_r; @@ -68,10 +66,7 @@ xutil_gettextprop(xcb_connection_t *conn, xcb_window_t w, /* Check whether the returned property value is just an ascii * string or utf8 string. At the moment it doesn't handle * COMPOUND_TEXT and multibyte but it's not needed... */ - if(prop_r->type == STRING || - prop_r->type == xutil_intern_atom_reply(conn, atoms, - xutil_intern_atom(conn, atoms, - "UTF8_STRING"))) + if(prop_r->type == STRING || prop_r->type == UTF8_STRING) { *text = p_new(char, prop_r->value_len + 1); /* use memcpy() because prop_val may not be \0 terminated */ @@ -156,127 +151,6 @@ xutil_get_transient_for_hint(xcb_connection_t *c, xcb_window_t win, return true; } -/** Send an unchecked InternAtom request if it is not already in the - * cache, in the second case it stores the cache entry (an ordered - * array). - * \param c X connection. - * \param atoms Atoms cache, or NULL if no cache. - * \param name Atom name. - * \return A request structure. - */ -xutil_intern_atom_request_t -xutil_intern_atom(xcb_connection_t *c, - xutil_atom_cache_array_t *atoms, - const char *name) -{ - xutil_intern_atom_request_t atom_req; - int l = 0, r; - - p_clear(&atom_req, 1); - - /* Check if this atom is present in the cache ordered array */ - if(atoms) - { - r = atoms->len; - while (l < r) - { - int i = (r + l) / 2; - switch (a_strcmp(name, atoms->tab[i]->name)) - { - case -1: /* ev < atoms->tab[i] */ - r = i; - break; - case 0: /* ev == atoms->tab[i] */ - atom_req.cache_hit = true; - atom_req.cache = atoms->tab[i]; - return atom_req; - case 1: /* ev > atoms->tab[i] */ - l = i + 1; - break; - } - } - } - - /* Otherwise send an InternAtom request to the server */ - atom_req.name = a_strdup(name); - atom_req.cookie = xcb_intern_atom_unchecked(c, false, a_strlen(name), name); - - return atom_req; -} - -/** Treat the reply which may be a cache entry or a reply from - * InternAtom request (cookie), in the second case, add the atom to - * the cache. - * \param c X connection. - * \param atoms Atoms cache or NULL if no cache. - * \param atom_req Atom request. - * \return A brand new xcb_atom_t. - */ -xcb_atom_t -xutil_intern_atom_reply(xcb_connection_t *c, - xutil_atom_cache_array_t *atoms, - xutil_intern_atom_request_t atom_req) -{ - xcb_intern_atom_reply_t *atom_rep; - xutil_atom_cache_t *atom_cache; - xcb_atom_t atom = 0; - int l = 0, r; - - /* If the atom is present in the cache, just returns the - * atom... */ - if(atom_req.cache_hit) - return atom_req.cache->atom; - - /* Get the reply from InternAtom request */ - if(!(atom_rep = xcb_intern_atom_reply(c, atom_req.cookie, NULL))) - goto bailout; - - atom = atom_rep->atom; - - if(atoms) - { - r = atoms->len; - - /* Create a new atom cache entry */ - atom_cache = p_new(xutil_atom_cache_t, 1); - atom_cache->atom = atom_rep->atom; - atom_cache->name = atom_req.name; - - while (l < r) - { - int i = (r + l) / 2; - switch(a_strcmp(atom_cache->name, atoms->tab[i]->name)) - { - case -1: /* k < atoms->tab[i] */ - r = i; - break; - case 0: /* k == atoms->tab[i] cannot append */ - assert(0); - case 1: /* k > atoms->tab[i] */ - l = i + 1; - break; - } - } - - xutil_atom_cache_array_splice(atoms, r, 0, &atom_cache, 1); - } - -bailout: - p_delete(&atom_rep); - - return atom; -} - -/* Delete a atom cache entry. - * \param entry A cache entry. - */ -void -xutil_atom_cache_delete(xutil_atom_cache_t **entry) -{ - p_delete(&(*entry)->name); - p_delete(entry); -} - class_hint_t * xutil_get_class_hint(xcb_connection_t *conn, xcb_window_t win) { diff --git a/common/xutil.h b/common/xutil.h index 3228a090..a0f393b5 100644 --- a/common/xutil.h +++ b/common/xutil.h @@ -96,44 +96,7 @@ typedef struct class_hint_t *xutil_get_class_hint(xcb_connection_t *, xcb_window_t); -/** Cache entry */ -typedef struct -{ - /** Atom X identifier */ - xcb_atom_t atom; - /** Atom name */ - char *name; -} xutil_atom_cache_t; - -void xutil_atom_cache_delete(xutil_atom_cache_t **); - -DO_ARRAY(xutil_atom_cache_t *, xutil_atom_cache, xutil_atom_cache_delete) - -/** InternAtom request data structure which may hold the cookie if the - * atom is not already present in the cache */ -typedef struct -{ - /* Cache hit */ - bool cache_hit; - /* Atom string name */ - char *name; - union - { - /* Cookie of the InternAtom request */ - xcb_intern_atom_cookie_t cookie; - /* Cache entry */ - xutil_atom_cache_t *cache; - }; -} xutil_intern_atom_request_t; - -xutil_intern_atom_request_t xutil_intern_atom(xcb_connection_t *, xutil_atom_cache_array_t *, - const char *); - -xcb_atom_t xutil_intern_atom_reply(xcb_connection_t *, xutil_atom_cache_array_t *, - xutil_intern_atom_request_t); - -bool xutil_gettextprop(xcb_connection_t *, xcb_window_t, xutil_atom_cache_array_t *, - xcb_atom_t, char **); +bool xutil_gettextprop(xcb_connection_t *, xcb_window_t, xcb_atom_t, char **); void xutil_getlockmask(xcb_connection_t *, xcb_key_symbols_t *, unsigned int *, unsigned int *, unsigned int *); diff --git a/event.c b/event.c index ae8e94d5..fe852abb 100644 --- a/event.c +++ b/event.c @@ -35,6 +35,7 @@ #include "lua.h" #include "systray.h" #include "layouts/floating.h" +#include "common/atoms.h" extern awesome_t globalconf; @@ -530,11 +531,7 @@ event_handle_propertynotify(void *data __attribute__ ((unused)), else if (ev->atom == WM_HINTS) client_updatewmhints(c); - if(ev->atom == WM_NAME - || ev->atom == xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, - xutil_intern_atom(globalconf.connection, - &globalconf.atoms, - "_NET_WM_NAME"))) + if(ev->atom == WM_NAME || ev->atom == _NET_WM_NAME) client_updatetitle(c); } @@ -620,18 +617,9 @@ event_handle_clientmessage(void *data __attribute__ ((unused)), xcb_connection_t *connection, xcb_client_message_event_t *ev) { - xutil_intern_atom_request_t atom_xem_q, atom_systray_q; - xcb_atom_t atom_xem, atom_systray; - - atom_xem_q = xutil_intern_atom(connection, &globalconf.atoms, "_XEMBED"); - atom_systray_q = xutil_intern_atom(connection, &globalconf.atoms, "_NET_SYSTEM_TRAY_OPCODE"); - - atom_xem = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, atom_xem_q); - atom_systray = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, atom_systray_q); - - if(ev->type == atom_xem) + if(ev->type == _XEMBED) return xembed_process_client_message(ev); - else if(ev->type == atom_systray) + else if(ev->type == _NET_SYSTEM_TRAY_OPCODE) return systray_process_client_message(ev); return ewmh_process_client_message(ev); } diff --git a/ewmh.c b/ewmh.c index e826da5c..141ae575 100644 --- a/ewmh.c +++ b/ewmh.c @@ -48,42 +48,42 @@ ewmh_init(int phys_screen) xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen); xcb_atom_t atom[] = { - NET_SUPPORTED, - NET_SUPPORTING_WM_CHECK, - NET_CLIENT_LIST, - NET_CLIENT_LIST_STACKING, - NET_NUMBER_OF_DESKTOPS, - NET_CURRENT_DESKTOP, - NET_DESKTOP_NAMES, - NET_ACTIVE_WINDOW, - NET_WORKAREA, - NET_CLOSE_WINDOW, - NET_WM_NAME, - NET_WM_ICON_NAME, - NET_WM_VISIBLE_ICON_NAME, - NET_WM_DESKTOP, - NET_WM_WINDOW_TYPE, - NET_WM_WINDOW_TYPE_NORMAL, - NET_WM_WINDOW_TYPE_DESKTOP, - NET_WM_WINDOW_TYPE_DOCK, - NET_WM_WINDOW_TYPE_SPLASH, - NET_WM_WINDOW_TYPE_DIALOG, - NET_WM_ICON, - NET_WM_PID, - NET_WM_STATE, - NET_WM_STATE_STICKY, - NET_WM_STATE_SKIP_TASKBAR, - NET_WM_STATE_FULLSCREEN, - NET_WM_STATE_ABOVE, - NET_WM_STATE_BELOW, - NET_WM_STATE_MODAL, - NET_WM_STATE_HIDDEN, - NET_WM_STATE_DEMANDS_ATTENTION + _NET_SUPPORTED, + _NET_SUPPORTING_WM_CHECK, + _NET_CLIENT_LIST, + _NET_CLIENT_LIST_STACKING, + _NET_NUMBER_OF_DESKTOPS, + _NET_CURRENT_DESKTOP, + _NET_DESKTOP_NAMES, + _NET_ACTIVE_WINDOW, + _NET_WORKAREA, + _NET_CLOSE_WINDOW, + _NET_WM_NAME, + _NET_WM_ICON_NAME, + _NET_WM_VISIBLE_ICON_NAME, + _NET_WM_DESKTOP, + _NET_WM_WINDOW_TYPE, + _NET_WM_WINDOW_TYPE_NORMAL, + _NET_WM_WINDOW_TYPE_DESKTOP, + _NET_WM_WINDOW_TYPE_DOCK, + _NET_WM_WINDOW_TYPE_SPLASH, + _NET_WM_WINDOW_TYPE_DIALOG, + _NET_WM_ICON, + _NET_WM_PID, + _NET_WM_STATE, + _NET_WM_STATE_STICKY, + _NET_WM_STATE_SKIP_TASKBAR, + _NET_WM_STATE_FULLSCREEN, + _NET_WM_STATE_ABOVE, + _NET_WM_STATE_BELOW, + _NET_WM_STATE_MODAL, + _NET_WM_STATE_HIDDEN, + _NET_WM_STATE_DEMANDS_ATTENTION }; int i; xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, - xscreen->root, NET_SUPPORTED, ATOM, 32, + xscreen->root, _NET_SUPPORTED, ATOM, 32, countof(atom), atom); /* create our own window */ @@ -93,21 +93,21 @@ ewmh_init(int phys_screen) XCB_COPY_FROM_PARENT, xscreen->root_visual, 0, NULL); xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, - xscreen->root, NET_SUPPORTING_WM_CHECK, WINDOW, 32, + xscreen->root, _NET_SUPPORTING_WM_CHECK, WINDOW, 32, 1, &father); xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, - father, NET_SUPPORTING_WM_CHECK, WINDOW, 32, + father, _NET_SUPPORTING_WM_CHECK, WINDOW, 32, 1, &father); /* set the window manager name */ xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, - father, NET_WM_NAME, UTF8_STRING, 8, 7, "awesome"); + father, _NET_WM_NAME, UTF8_STRING, 8, 7, "awesome"); /* set the window manager PID */ i = getpid(); xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, - father, NET_WM_PID, CARDINAL, 32, 1, &i); + father, _NET_WM_PID, CARDINAL, 32, 1, &i); } void @@ -128,7 +128,7 @@ ewmh_update_net_client_list(int phys_screen) xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xutil_screen_get(globalconf.connection, phys_screen)->root, - NET_CLIENT_LIST, WINDOW, 32, n, wins); + _NET_CLIENT_LIST, WINDOW, 32, n, wins); p_delete(&wins); } @@ -154,7 +154,7 @@ ewmh_update_net_client_list_stacking(int phys_screen) xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xutil_screen_get(globalconf.connection, phys_screen)->root, - NET_CLIENT_LIST_STACKING, WINDOW, 32, n, wins); + _NET_CLIENT_LIST_STACKING, WINDOW, 32, n, wins); p_delete(&wins); } @@ -166,7 +166,7 @@ ewmh_update_net_numbers_of_desktop(int phys_screen) xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xutil_screen_get(globalconf.connection, phys_screen)->root, - NET_NUMBER_OF_DESKTOPS, CARDINAL, 32, 1, &count); + _NET_NUMBER_OF_DESKTOPS, CARDINAL, 32, 1, &count); } void @@ -180,7 +180,7 @@ ewmh_update_net_current_desktop(int phys_screen) xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xutil_screen_get(globalconf.connection, phys_screen)->root, - NET_CURRENT_DESKTOP, CARDINAL, 32, 1, &count); + _NET_CURRENT_DESKTOP, CARDINAL, 32, 1, &count); p_delete(&curtags); } @@ -201,7 +201,7 @@ ewmh_update_net_desktop_names(int phys_screen) xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xutil_screen_get(globalconf.connection, phys_screen)->root, - NET_DESKTOP_NAMES, UTF8_STRING, 8, buf.len, buf.s); + _NET_DESKTOP_NAMES, UTF8_STRING, 8, buf.len, buf.s); buffer_wipe(&buf); } @@ -228,7 +228,7 @@ ewmh_update_workarea(int phys_screen) xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xutil_screen_get(globalconf.connection, phys_screen)->root, - NET_WORKAREA, CARDINAL, 32, tags->len * 4, area); + _NET_WORKAREA, CARDINAL, 32, tags->len * 4, area); } void @@ -241,19 +241,19 @@ ewmh_update_net_active_window(int phys_screen) xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xutil_screen_get(globalconf.connection, phys_screen)->root, - NET_ACTIVE_WINDOW, WINDOW, 32, 1, &win); + _NET_ACTIVE_WINDOW, WINDOW, 32, 1, &win); } static void ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) { - if(state == NET_WM_STATE_STICKY) + if(state == _NET_WM_STATE_STICKY) { tag_array_t *tags = &globalconf.screens[c->screen].tags; for(int i = 0; i < tags->len; i++) tag_client(c, tags->tab[i]); } - else if(state == NET_WM_STATE_SKIP_TASKBAR) + else if(state == _NET_WM_STATE_SKIP_TASKBAR) { if(set == _NET_WM_STATE_REMOVE) { @@ -266,7 +266,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) c->skip = true; } } - else if(state == NET_WM_STATE_FULLSCREEN) + else if(state == _NET_WM_STATE_FULLSCREEN) { area_t geometry = c->geometry; if(set == _NET_WM_STATE_REMOVE) @@ -305,7 +305,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); client_resize(c, geometry, false); } - else if(state == NET_WM_STATE_ABOVE) + else if(state == _NET_WM_STATE_ABOVE) { if(set == _NET_WM_STATE_REMOVE) client_setlayer(c, c->oldlayer); @@ -315,7 +315,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) client_setlayer(c, LAYER_ABOVE); } } - else if(state == NET_WM_STATE_BELOW) + else if(state == _NET_WM_STATE_BELOW) { if(set == _NET_WM_STATE_REMOVE) client_setlayer(c, c->oldlayer); @@ -325,7 +325,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) client_setlayer(c, LAYER_BELOW); } } - else if(state == NET_WM_STATE_MODAL) + else if(state == _NET_WM_STATE_MODAL) { if(set == _NET_WM_STATE_REMOVE) client_setlayer(c, c->oldlayer); @@ -335,7 +335,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) client_setlayer(c, LAYER_MODAL); } } - else if(state == NET_WM_STATE_HIDDEN) + else if(state == _NET_WM_STATE_HIDDEN) { if(set == _NET_WM_STATE_REMOVE) c->ishidden = false; @@ -343,7 +343,7 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) c->ishidden = true; globalconf.screens[c->screen].need_arrange = true; } - else if(state == NET_WM_STATE_DEMANDS_ATTENTION) + else if(state == _NET_WM_STATE_DEMANDS_ATTENTION) { if(set == _NET_WM_STATE_REMOVE) c->isurgent = false; @@ -361,12 +361,12 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) static void ewmh_process_window_type_atom(client_t *c, xcb_atom_t state) { - if(state == NET_WM_WINDOW_TYPE_NORMAL) + if(state == _NET_WM_WINDOW_TYPE_NORMAL) { /* do nothing. this is REALLY IMPORTANT */ } - else if(state == NET_WM_WINDOW_TYPE_DOCK - || state == NET_WM_WINDOW_TYPE_SPLASH) + else if(state == _NET_WM_WINDOW_TYPE_DOCK + || state == _NET_WM_WINDOW_TYPE_SPLASH) { c->skip = true; c->isfixed = true; @@ -380,12 +380,12 @@ ewmh_process_window_type_atom(client_t *c, xcb_atom_t state) client_setlayer(c, LAYER_ABOVE); client_setfloating(c, true); } - else if(state == NET_WM_WINDOW_TYPE_DIALOG) + else if(state == _NET_WM_WINDOW_TYPE_DIALOG) { client_setlayer(c, LAYER_MODAL); client_setfloating(c, true); } - else if(state == NET_WM_WINDOW_TYPE_DESKTOP) + else if(state == _NET_WM_WINDOW_TYPE_DESKTOP) { tag_array_t *tags = &globalconf.screens[c->screen].tags; c->noborder = true; @@ -403,7 +403,7 @@ ewmh_process_client_message(xcb_client_message_event_t *ev) client_t *c; int screen; - if(ev->type == NET_CURRENT_DESKTOP) + if(ev->type == _NET_CURRENT_DESKTOP) for(screen = 0; screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); screen++) @@ -411,12 +411,12 @@ ewmh_process_client_message(xcb_client_message_event_t *ev) if(ev->window == xutil_screen_get(globalconf.connection, screen)->root) tag_view_only_byindex(screen, ev->data.data32[0]); } - else if(ev->type == NET_CLOSE_WINDOW) + else if(ev->type == _NET_CLOSE_WINDOW) { if((c = client_getbywin(ev->window))) client_kill(c); } - else if(ev->type == NET_WM_DESKTOP) + else if(ev->type == _NET_WM_DESKTOP) { if((c = client_getbywin(ev->window))) { @@ -433,7 +433,7 @@ ewmh_process_client_message(xcb_client_message_event_t *ev) untag_client(c, tags->tab[i]); } } - else if(ev->type == NET_WM_STATE) + else if(ev->type == _NET_WM_STATE) { if((c = client_getbywin(ev->window))) { @@ -458,13 +458,13 @@ ewmh_check_client_hints(client_t *c) /* Send the GetProperty requests which will be processed later */ c0 = xcb_get_property_unchecked(globalconf.connection, false, c->win, - NET_WM_DESKTOP, XCB_GET_PROPERTY_TYPE_ANY, 0, 1); + _NET_WM_DESKTOP, XCB_GET_PROPERTY_TYPE_ANY, 0, 1); c1 = xcb_get_property_unchecked(globalconf.connection, false, c->win, - NET_WM_STATE, ATOM, 0, UINT32_MAX); + _NET_WM_STATE, ATOM, 0, UINT32_MAX); c2 = xcb_get_property_unchecked(globalconf.connection, false, c->win, - NET_WM_WINDOW_TYPE, ATOM, 0, UINT32_MAX); + _NET_WM_WINDOW_TYPE, ATOM, 0, UINT32_MAX); reply = xcb_get_property_reply(globalconf.connection, c0, NULL); if(reply && reply->value_len && (data = xcb_get_property_value(reply))) @@ -518,7 +518,7 @@ ewmh_get_window_icon(xcb_window_t w) r = xcb_get_property_reply(globalconf.connection, xcb_get_property_unchecked(globalconf.connection, false, w, - NET_WM_ICON, CARDINAL, 0, UINT32_MAX), + _NET_WM_ICON, CARDINAL, 0, UINT32_MAX), NULL); if(!r || r->type != CARDINAL || r->format != 32 || r->length < 2 || !(data = (uint32_t *) xcb_get_property_value(r))) diff --git a/structs.h b/structs.h index addcd545..a75353df 100644 --- a/structs.h +++ b/structs.h @@ -423,8 +423,6 @@ struct awesome_t char *argv; /** Last XMotionEvent coords */ int pointer_x, pointer_y; - /** Atoms cache */ - xutil_atom_cache_array_t atoms; /** Lua VM state */ lua_State *L; /** Default colors */ diff --git a/systray.c b/systray.c index 67ea61a1..72d129ae 100644 --- a/systray.c +++ b/systray.c @@ -26,6 +26,7 @@ #include "systray.h" #include "window.h" #include "widget.h" +#include "common/atoms.h" #define SYSTEM_TRAY_REQUEST_DOCK 0 /* Begin icon docking */ @@ -34,16 +35,17 @@ extern awesome_t globalconf; void systray_init(int phys_screen) { - xutil_intern_atom_request_t atom_systray_q, atom_manager_q; - xcb_atom_t atom_systray; xcb_client_message_event_t ev; xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen); char atom_name[22]; + xcb_intern_atom_cookie_t atom_systray_q; + xcb_intern_atom_reply_t *atom_systray_r; + xcb_atom_t atom_systray; /* Send requests */ - atom_manager_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "MANAGER"); snprintf(atom_name, sizeof(atom_name), "_NET_SYSTEM_TRAY_S%d", phys_screen); - atom_systray_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, atom_name); + atom_systray_q = xcb_intern_atom_unchecked(globalconf.connection, false, + a_strlen(atom_name), atom_name); globalconf.screens[phys_screen].systray.window = xcb_generate_id(globalconf.connection); xcb_create_window(globalconf.connection, xscreen->root_depth, @@ -57,15 +59,20 @@ systray_init(int phys_screen) ev.response_type = XCB_CLIENT_MESSAGE; ev.window = xscreen->root; ev.format = 32; + ev.type = MANAGER; ev.data.data32[0] = XCB_CURRENT_TIME; ev.data.data32[2] = globalconf.screens[phys_screen].systray.window; ev.data.data32[3] = ev.data.data32[4] = 0; - ev.type = xutil_intern_atom_reply(globalconf.connection, - &globalconf.atoms, atom_manager_q); - ev.data.data32[1] = atom_systray = xutil_intern_atom_reply(globalconf.connection, - &globalconf.atoms, - atom_systray_q); + if(!(atom_systray_r = xcb_intern_atom_reply(globalconf.connection, atom_systray_q, NULL))) + { + warn("error getting systray atom"); + return; + } + + ev.data.data32[1] = atom_systray = atom_systray_r->atom; + + p_delete(&atom_systray_r); xcb_set_selection_owner(globalconf.connection, globalconf.screens[phys_screen].systray.window, @@ -171,26 +178,14 @@ systray_process_client_message(xcb_client_message_event_t *ev) bool systray_iskdedockapp(xcb_window_t w) { - xcb_atom_t kde_net_wm_sytem_tray_window_for; - xutil_intern_atom_request_t kde_net_wm_sytem_tray_window_for_q; xcb_get_property_cookie_t kde_check_q; xcb_get_property_reply_t *kde_check; bool ret; /* Check if that is a KDE tray because it does not repect fdo standards, * thanks KDE. */ - kde_net_wm_sytem_tray_window_for_q = - xutil_intern_atom(globalconf.connection, - &globalconf.atoms, - "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR"); - - kde_net_wm_sytem_tray_window_for = - xutil_intern_atom_reply(globalconf.connection, - &globalconf.atoms, - kde_net_wm_sytem_tray_window_for_q); - kde_check_q = xcb_get_property_unchecked(globalconf.connection, false, w, - kde_net_wm_sytem_tray_window_for, + _KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR, WINDOW, 0, 1); kde_check = xcb_get_property_reply(globalconf.connection, kde_check_q, NULL); diff --git a/widget.c b/widget.c index a8df7492..e3dc3552 100644 --- a/widget.c +++ b/widget.c @@ -26,6 +26,7 @@ #include "widget.h" #include "titlebar.h" +#include "common/atoms.h" extern awesome_t globalconf; @@ -103,12 +104,6 @@ widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_gcontext_t gc, xcb_ xcb_get_property_reply_t *prop_r; xcb_get_property_cookie_t prop_c; area_t rectangle = { 0, 0, 0, 0 }; - xcb_atom_t rootpix_atom; - xutil_intern_atom_request_t rootpix_atom_req; - - /* Send requests needed for transparency */ - if(ctx->bg.alpha != 0xffff) - rootpix_atom_req = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "_XROOTPMAP_ID"); rectangle.width = ctx->width; rectangle.height = ctx->height; @@ -116,8 +111,7 @@ widget_render(widget_node_t *wnode, draw_context_t *ctx, xcb_gcontext_t gc, xcb_ if(ctx->bg.alpha != 0xffff) { s = xutil_screen_get(globalconf.connection, ctx->phys_screen); - rootpix_atom = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, rootpix_atom_req); - prop_c = xcb_get_property_unchecked(globalconf.connection, false, s->root, rootpix_atom, + prop_c = xcb_get_property_unchecked(globalconf.connection, false, s->root, _XROOTPMAP_ID, PIXMAP, 0, 1); if((prop_r = xcb_get_property_reply(globalconf.connection, prop_c, NULL))) { diff --git a/widgets/systray.c b/widgets/systray.c index 9830f60c..b3f68d28 100644 --- a/widgets/systray.c +++ b/widgets/systray.c @@ -25,6 +25,7 @@ #include "widget.h" #include "screen.h" #include "common/xembed.h" +#include "common/atoms.h" #define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0 #define _NET_SYSTEM_TRAY_ORIENTATION_VERT 1 @@ -43,15 +44,9 @@ systray_draw(draw_context_t *ctx, uint32_t orient, config_win_vals[4]; /* p is always a statusbar, titlebars are forbidden */ statusbar_t *sb = (statusbar_t *) p; - xutil_intern_atom_request_t net_system_tray_orientation_q; - xcb_atom_t net_system_tray_orientation; phys_screen = screen_virttophys(screen); - net_system_tray_orientation_q = xutil_intern_atom(globalconf.connection, - &globalconf.atoms, - "_NET_SYSTEM_TRAY_ORIENTATION"); - for(em = globalconf.embedded; em; em = em->next) if(em->phys_screen == phys_screen) i++; @@ -152,13 +147,9 @@ systray_draw(draw_context_t *ctx, /* set statusbar orientation */ /** \todo stop setting that property on each redraw */ - net_system_tray_orientation = xutil_intern_atom_reply(globalconf.connection, - &globalconf.atoms, - net_system_tray_orientation_q); - xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, globalconf.screens[phys_screen].systray.window, - net_system_tray_orientation, CARDINAL, 32, 1, &orient); + _NET_SYSTEM_TRAY_ORIENTATION, CARDINAL, 32, 1, &orient); return w->area.width; } diff --git a/window.c b/window.c index f55aea5a..97527c5d 100644 --- a/window.c +++ b/window.c @@ -23,6 +23,7 @@ #include #include "window.h" +#include "common/atoms.h" extern awesome_t globalconf; @@ -37,13 +38,8 @@ void window_setstate(xcb_window_t win, long state) { long data[] = { state, XCB_NONE }; - const xcb_atom_t wm_state_atom = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, - xutil_intern_atom(globalconf.connection, - &globalconf.atoms, - "WM_STATE")); - xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, win, - wm_state_atom, wm_state_atom, 32, 2, data); + WM_STATE, WM_STATE, 32, 2, data); } /** Get a window state (WM_STATE). @@ -56,14 +52,10 @@ window_getstate(xcb_window_t w) long result = -1; unsigned char *p = NULL; xcb_get_property_cookie_t prop_c; - xcb_atom_t wm_state_atom = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, - xutil_intern_atom(globalconf.connection, - &globalconf.atoms, - "WM_STATE")); xcb_get_property_reply_t *prop_r; prop_c = xcb_get_property_unchecked(globalconf.connection, false, w, - wm_state_atom, wm_state_atom, + WM_STATE, WM_STATE, 0L, 2L); if(!(prop_r = xcb_get_property_reply(globalconf.connection, prop_c, NULL))) @@ -220,24 +212,15 @@ void window_settrans(xcb_window_t win, double opacity) { unsigned int real_opacity = 0xffffffff; - xcb_atom_t wopacity_atom; - xutil_intern_atom_request_t wopacity_atom_q; - - wopacity_atom_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "_NET_WM_WINDOW_OPACITY"); if(opacity >= 0 && opacity <= 1) { real_opacity = opacity * 0xffffffff; - wopacity_atom = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, wopacity_atom_q); xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, win, - wopacity_atom, CARDINAL, 32, 1L, &real_opacity); + _NET_WM_WINDOW_OPACITY, CARDINAL, 32, 1L, &real_opacity); } else - { - wopacity_atom = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, wopacity_atom_q); - xcb_delete_property(globalconf.connection, win, - wopacity_atom); - } + xcb_delete_property(globalconf.connection, win, _NET_WM_WINDOW_OPACITY); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80