systray: rely on xcb_atom_name_by_screen available since xcb-util 0.3.0

This commit is contained in:
Arnaud Fontaine 2008-09-16 13:42:17 +01:00
parent 99b8fe74ba
commit d1f8bff99d
1 changed files with 22 additions and 11 deletions

View File

@ -40,15 +40,22 @@ systray_init(int phys_screen)
{ {
xcb_client_message_event_t ev; xcb_client_message_event_t ev;
xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen); xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen);
char atom_name[22]; char *atom_name;
xcb_intern_atom_cookie_t atom_systray_q; xcb_intern_atom_cookie_t atom_systray_q;
xcb_intern_atom_reply_t *atom_systray_r; xcb_intern_atom_reply_t *atom_systray_r;
xcb_atom_t atom_systray; xcb_atom_t atom_systray;
ssize_t len;
/* Send requests */ /* Send requests */
len = snprintf(atom_name, sizeof(atom_name), "_NET_SYSTEM_TRAY_S%d", phys_screen); if(!(atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", phys_screen)))
atom_systray_q = xcb_intern_atom_unchecked(globalconf.connection, false, len, atom_name); {
warn("error getting systray atom");
return;
}
atom_systray_q = xcb_intern_atom_unchecked(globalconf.connection, false,
strlen(atom_name), atom_name);
p_delete(&atom_name);
globalconf.screens[phys_screen].systray.window = xcb_generate_id(globalconf.connection); globalconf.screens[phys_screen].systray.window = xcb_generate_id(globalconf.connection);
xcb_create_window(globalconf.connection, xscreen->root_depth, xcb_create_window(globalconf.connection, xscreen->root_depth,
@ -91,20 +98,24 @@ systray_init(int phys_screen)
void void
systray_cleanup(int phys_screen) systray_cleanup(int phys_screen)
{ {
xcb_intern_atom_cookie_t atom_systray_q;
xcb_intern_atom_reply_t *atom_systray_r; xcb_intern_atom_reply_t *atom_systray_r;
ssize_t len; char *atom_name;
char atom_name[22];
len = snprintf(atom_name, sizeof(atom_name), "_NET_SYSTEM_TRAY_S%d", phys_screen); if(!(atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", phys_screen))
atom_systray_q = xcb_intern_atom_unchecked(globalconf.connection, false, len, atom_name); || !(atom_systray_r = xcb_intern_atom_reply(globalconf.connection,
xcb_intern_atom_unchecked(globalconf.connection,
if(!(atom_systray_r = xcb_intern_atom_reply(globalconf.connection, atom_systray_q, NULL))) false,
strlen(atom_name),
atom_name),
NULL)))
{ {
warn("error getting systray atom"); warn("error getting systray atom");
p_delete(&atom_name);
return; return;
} }
p_delete(&atom_name);
xcb_set_selection_owner(globalconf.connection, xcb_set_selection_owner(globalconf.connection,
XCB_NONE, XCB_NONE,
atom_systray_r->atom, atom_systray_r->atom,