xcb: use predefined XCB_ATOM_ atoms, don’t request them

This commit is contained in:
Michael Stapelberg 2011-08-17 01:41:19 +02:00
parent c8e6de1382
commit 7951445849
8 changed files with 27 additions and 26 deletions

View File

@ -21,14 +21,5 @@ xmacro(UTF8_STRING)
xmacro(WM_STATE) xmacro(WM_STATE)
xmacro(WM_CLIENT_LEADER) xmacro(WM_CLIENT_LEADER)
xmacro(WM_TAKE_FOCUS) xmacro(WM_TAKE_FOCUS)
xmacro(WM_HINTS)
xmacro(WM_NORMAL_HINTS)
xmacro(WM_TRANSIENT_FOR)
xmacro(ATOM)
xmacro(WINDOW)
xmacro(WM_NAME)
xmacro(WM_CLASS)
xmacro(STRING)
xmacro(CARDINAL)
xmacro(I3_SOCKET_PATH) xmacro(I3_SOCKET_PATH)
xmacro(I3_CONFIG_PATH) xmacro(I3_CONFIG_PATH)

View File

@ -22,4 +22,14 @@
#define xcb_icccm_wm_hints_get_urgency xcb_wm_hints_get_urgency #define xcb_icccm_wm_hints_get_urgency xcb_wm_hints_get_urgency
#define xcb_icccm_get_wm_transient_for_from_reply xcb_get_wm_transient_for_from_reply #define xcb_icccm_get_wm_transient_for_from_reply xcb_get_wm_transient_for_from_reply
#define XCB_ATOM_CARDINAL CARDINAL
#define XCB_ATOM_WINDOW WINDOW
#define XCB_ATOM_WM_TRANSIENT_FOR WM_TRANSIENT_FOR
#define XCB_ATOM_WM_NAME WM_NAME
#define XCB_ATOM_WM_CLASS WM_CLASS
#define XCB_ATOM_WM_HINTS WM_HINTS
#define XCB_ATOM_ATOM ATOM
#define XCB_ATOM_WM_NORMAL_HINTS WM_NORMAL_HINTS
#define XCB_ATOM_STRING STRING
#endif #endif

View File

@ -534,7 +534,7 @@ update_netwm_state:
values[num++] = A__NET_WM_STATE_FULLSCREEN; values[num++] = A__NET_WM_STATE_FULLSCREEN;
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->window->id, xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->window->id,
A__NET_WM_STATE, A_ATOM, 32, num, values); A__NET_WM_STATE, XCB_ATOM_ATOM, 32, num, values);
} }
/* /*

View File

@ -31,7 +31,7 @@ void ewmh_update_current_desktop() {
TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) { TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
if (ws == focused_ws) { if (ws == focused_ws) {
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root,
A__NET_CURRENT_DESKTOP, A_CARDINAL, 32, 1, &idx); A__NET_CURRENT_DESKTOP, XCB_ATOM_CARDINAL, 32, 1, &idx);
return; return;
} }
++idx; ++idx;
@ -48,7 +48,7 @@ void ewmh_update_current_desktop() {
*/ */
void ewmh_update_active_window(xcb_window_t window) { void ewmh_update_active_window(xcb_window_t window) {
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root,
A__NET_ACTIVE_WINDOW, A_WINDOW, 32, 1, &window); A__NET_ACTIVE_WINDOW, XCB_ATOM_WINDOW, 32, 1, &window);
} }
/* /*
@ -104,7 +104,7 @@ void ewmh_update_workarea() {
} }
} }
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root,
A__NET_WORKAREA, A_CARDINAL, 32, A__NET_WORKAREA, XCB_ATOM_CARDINAL, 32,
num_workspaces * (sizeof(Rect) / sizeof(uint32_t)), num_workspaces * (sizeof(Rect) / sizeof(uint32_t)),
workarea); workarea);
free(workarea); free(workarea);
@ -122,7 +122,7 @@ void ewmh_update_client_list_stacking(xcb_window_t *stack, int num_windows) {
XCB_PROP_MODE_REPLACE, XCB_PROP_MODE_REPLACE,
root, root,
A__NET_CLIENT_LIST_STACKING, A__NET_CLIENT_LIST_STACKING,
A_WINDOW, XCB_ATOM_WINDOW,
32, 32,
num_windows, num_windows,
stack); stack);

View File

@ -856,7 +856,7 @@ static bool handle_transient_for(void *data, xcb_connection_t *conn, uint8_t sta
if (prop == NULL) { if (prop == NULL) {
prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn, prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
false, window, A_WM_TRANSIENT_FOR, A_WINDOW, 0, 32), NULL); false, window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 0, 32), NULL);
if (prop == NULL) if (prop == NULL)
return false; return false;
} }
@ -887,7 +887,7 @@ static bool handle_clientleader_change(void *data, xcb_connection_t *conn, uint8
if (prop == NULL) { if (prop == NULL) {
prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn, prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
false, window, A_WM_CLIENT_LEADER, A_WINDOW, 0, 32), NULL); false, window, A_WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 32), NULL);
if (prop == NULL) if (prop == NULL)
return false; return false;
} }
@ -961,11 +961,11 @@ static struct property_handler_t property_handlers[] = {
*/ */
void property_handlers_init() { void property_handlers_init() {
property_handlers[0].atom = A__NET_WM_NAME; property_handlers[0].atom = A__NET_WM_NAME;
property_handlers[1].atom = A_WM_HINTS; property_handlers[1].atom = XCB_ATOM_WM_HINTS;
property_handlers[2].atom = A_WM_NAME; property_handlers[2].atom = XCB_ATOM_WM_NAME;
property_handlers[3].atom = A_WM_NORMAL_HINTS; property_handlers[3].atom = XCB_ATOM_WM_NORMAL_HINTS;
property_handlers[4].atom = A_WM_CLIENT_LEADER; property_handlers[4].atom = A_WM_CLIENT_LEADER;
property_handlers[5].atom = A_WM_TRANSIENT_FOR; property_handlers[5].atom = XCB_ATOM_WM_TRANSIENT_FOR;
} }
static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom) { static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom) {

View File

@ -396,9 +396,9 @@ int main(int argc, char *argv[]) {
#include "atoms.xmacro" #include "atoms.xmacro"
#undef xmacro #undef xmacro
}; };
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, A_ATOM, 32, 16, supported_atoms); xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, XCB_ATOM_ATOM, 32, 16, supported_atoms);
/* Set up the window managers name */ /* Set up the window managers name */
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTING_WM_CHECK, A_WINDOW, 32, 1, &root); xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTING_WM_CHECK, XCB_ATOM_WINDOW, 32, 1, &root);
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen("i3"), "i3"); xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen("i3"), "i3");
keysyms = xcb_key_symbols_alloc(conn); keysyms = xcb_key_symbols_alloc(conn);

View File

@ -142,9 +142,9 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
state_cookie = GET_PROPERTY(A__NET_WM_STATE, UINT32_MAX); state_cookie = GET_PROPERTY(A__NET_WM_STATE, UINT32_MAX);
utf8_title_cookie = GET_PROPERTY(A__NET_WM_NAME, 128); utf8_title_cookie = GET_PROPERTY(A__NET_WM_NAME, 128);
leader_cookie = GET_PROPERTY(A_WM_CLIENT_LEADER, UINT32_MAX); leader_cookie = GET_PROPERTY(A_WM_CLIENT_LEADER, UINT32_MAX);
transient_cookie = GET_PROPERTY(A_WM_TRANSIENT_FOR, UINT32_MAX); transient_cookie = GET_PROPERTY(XCB_ATOM_WM_TRANSIENT_FOR, UINT32_MAX);
title_cookie = GET_PROPERTY(A_WM_NAME, 128); title_cookie = GET_PROPERTY(XCB_ATOM_WM_NAME, 128);
class_cookie = GET_PROPERTY(A_WM_CLASS, 128); class_cookie = GET_PROPERTY(XCB_ATOM_WM_CLASS, 128);
/* TODO: also get wm_normal_hints here. implement after we got rid of xcb-event */ /* TODO: also get wm_normal_hints here. implement after we got rid of xcb-event */
DLOG("reparenting!\n"); DLOG("reparenting!\n");

View File

@ -518,7 +518,7 @@ void x_push_node(Con *con) {
DLOG("pushing name %s for con %p\n", state->name, con); DLOG("pushing name %s for con %p\n", state->name, con);
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->frame, xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->frame,
A_WM_NAME, A_STRING, 8, strlen(state->name), state->name); XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, strlen(state->name), state->name);
FREE(state->name); FREE(state->name);
} }