diff --git a/globalconf.h b/globalconf.h index fd458ebc3..15ed6da7b 100644 --- a/globalconf.h +++ b/globalconf.h @@ -98,6 +98,15 @@ typedef struct SnDisplay *sndisplay; /** Latest timestamp we got from the X server */ xcb_timestamp_t timestamp; + /** Window that contains the systray */ + struct + { + xcb_window_t window; + /** Systray window parent */ + xcb_window_t parent; + /** Is awesome the systray owner? */ + bool registered; + } systray; } awesome_t; extern awesome_t globalconf; diff --git a/objects/wibox.c b/objects/wibox.c index 8bc21c070..4d5b56778 100644 --- a/objects/wibox.c +++ b/objects/wibox.c @@ -40,16 +40,16 @@ wibox_systray_kickout(void) { xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen); - if(globalconf.screens.tab[0].systray.parent != s->root) + if(globalconf.systray.parent != s->root) { /* Who! Check that we're not deleting a wibox with a systray, because it * may be its parent. If so, we reparent to root before, otherwise it will * hurt very much. */ xcb_reparent_window(globalconf.connection, - globalconf.screens.tab[0].systray.window, + globalconf.systray.window, s->root, -512, -512); - globalconf.screens.tab[0].systray.parent = s->root; + globalconf.systray.parent = s->root; } } @@ -64,7 +64,7 @@ wibox_wipe_resources(wibox_t *w) /* Activate BMA */ client_ignore_enterleave_events(); /* Make sure we don't accidentally kill the systray window */ - if(globalconf.screens.tab[0].systray.parent == w->window) + if(globalconf.systray.parent == w->window) wibox_systray_kickout(); xcb_destroy_window(globalconf.connection, w->window); /* Deactivate BMA */ @@ -429,10 +429,10 @@ wibox_systray_refresh(wibox_t *wibox) { /* Set background of the systray window. */ xcb_change_window_attributes(globalconf.connection, - globalconf.screens.tab[0].systray.window, + globalconf.systray.window, XCB_CW_BACK_PIXEL, config_back); /* Map it. */ - xcb_map_window(globalconf.connection, globalconf.screens.tab[0].systray.window); + xcb_map_window(globalconf.connection, globalconf.systray.window); /* Move it. */ switch(wibox->orientation) { @@ -456,16 +456,16 @@ wibox_systray_refresh(wibox_t *wibox) break; } /* reparent */ - if(globalconf.screens.tab[0].systray.parent != wibox->window) + if(globalconf.systray.parent != wibox->window) { xcb_reparent_window(globalconf.connection, - globalconf.screens.tab[0].systray.window, + globalconf.systray.window, wibox->window, config_win_vals[0], config_win_vals[1]); - globalconf.screens.tab[0].systray.parent = wibox->window; + globalconf.systray.parent = wibox->window; } xcb_configure_window(globalconf.connection, - globalconf.screens.tab[0].systray.window, + globalconf.systray.window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH diff --git a/objects/widgets/systray.c b/objects/widgets/systray.c index c47d613a2..556d74a8e 100644 --- a/objects/widgets/systray.c +++ b/objects/widgets/systray.c @@ -72,7 +72,7 @@ systray_draw(widget_t *widget, draw_context_t *ctx, /* set wibox orientation */ /** \todo stop setting that property on each redraw */ xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, - globalconf.screens.tab[0].systray.window, + globalconf.systray.window, _NET_SYSTEM_TRAY_ORIENTATION, XCB_ATOM_CARDINAL, 32, 1, &orient); } diff --git a/screen.h b/screen.h index 717e9f722..1d777c0f6 100644 --- a/screen.h +++ b/screen.h @@ -34,15 +34,6 @@ struct a_screen area_t geometry; /** Tag list */ tag_array_t tags; - /** Window that contains the systray */ - struct - { - xcb_window_t window; - /** Systray window parent */ - xcb_window_t parent; - /** Is awesome the systray owner? */ - bool registered; - } systray; /** Previously focused client */ client_t *prev_client_focus; /** Focused client */ diff --git a/systray.c b/systray.c index bac01846c..477df744a 100644 --- a/systray.c +++ b/systray.c @@ -41,9 +41,9 @@ systray_init(void) { xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, globalconf.default_screen); - globalconf.screens.tab[0].systray.window = xcb_generate_id(globalconf.connection); + globalconf.systray.window = xcb_generate_id(globalconf.connection); xcb_create_window(globalconf.connection, xscreen->root_depth, - globalconf.screens.tab[0].systray.window, + globalconf.systray.window, xscreen->root, -1, -1, 1, 1, 0, XCB_COPY_FROM_PARENT, xscreen->root_visual, 0, NULL); @@ -81,9 +81,9 @@ systray_register(void) xcb_atom_t atom_systray; /* Set registered even if it fails to don't try again unless forced */ - if(globalconf.screens.tab[0].systray.registered) + if(globalconf.systray.registered) return; - globalconf.screens.tab[0].systray.registered = true; + globalconf.systray.registered = true; /* Send requests */ if(!(atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", globalconf.default_screen))) @@ -104,7 +104,7 @@ systray_register(void) ev.format = 32; ev.type = MANAGER; ev.data.data32[0] = XCB_CURRENT_TIME; - ev.data.data32[2] = globalconf.screens.tab[0].systray.window; + ev.data.data32[2] = globalconf.systray.window; ev.data.data32[3] = ev.data.data32[4] = 0; if(!(atom_systray_r = xcb_intern_atom_reply(globalconf.connection, atom_systray_q, NULL))) @@ -118,7 +118,7 @@ systray_register(void) p_delete(&atom_systray_r); xcb_set_selection_owner(globalconf.connection, - globalconf.screens.tab[0].systray.window, + globalconf.systray.window, atom_systray, XCB_CURRENT_TIME); @@ -133,9 +133,9 @@ systray_cleanup(void) xcb_intern_atom_reply_t *atom_systray_r; char *atom_name; - if(!globalconf.screens.tab[0].systray.registered) + if(!globalconf.systray.registered) return; - globalconf.screens.tab[0].systray.registered = false; + globalconf.systray.registered = false; if(!(atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", globalconf.default_screen)) || !(atom_systray_r = xcb_intern_atom_reply(globalconf.connection, @@ -195,7 +195,7 @@ systray_request_handle(xcb_window_t embed_win, xembed_info_t *info) */ xcb_change_save_set(globalconf.connection, XCB_SET_MODE_INSERT, embed_win); xcb_reparent_window(globalconf.connection, embed_win, - globalconf.screens.tab[0].systray.window, + globalconf.systray.window, 0, 0); em.win = embed_win; @@ -206,7 +206,7 @@ systray_request_handle(xcb_window_t embed_win, xembed_info_t *info) xembed_info_get_reply(globalconf.connection, em_cookie, &em.info); xembed_embedded_notify(globalconf.connection, em.win, - globalconf.screens.tab[0].systray.window, + globalconf.systray.window, MIN(XEMBED_VERSION, em.info.version)); xembed_window_array_append(&globalconf.embedded, em);