From f418cb0c2ea00ec4c53de66d14eab96eb8e9b297 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 15 Jun 2008 10:25:26 +0200 Subject: [PATCH] systray: attach systray to external window, not statusbar Signed-off-by: Julien Danjou --- awesome.c | 1 + awesomerc.lua.in | 2 +- structs.h | 4 ++-- systray.c | 37 ++++++++++++++++++++++++++++++++++++- systray.h | 1 + widgets/systray.c | 43 ------------------------------------------- 6 files changed, 41 insertions(+), 47 deletions(-) diff --git a/awesome.c b/awesome.c index ed9828917..c9e2d1731 100644 --- a/awesome.c +++ b/awesome.c @@ -413,6 +413,7 @@ main(int argc, char **argv) XCB_CW_EVENT_MASK | XCB_CW_CURSOR, change_win_vals); ewmh_set_supported_hints(screen_nbr); + systray_init(screen_nbr); } /* call this to at least grab root window clicks */ diff --git a/awesomerc.lua.in b/awesomerc.lua.in index 80e7dc45a..9c12a56f2 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -124,9 +124,9 @@ for s = 1, screen.count() do mystatusbar[s]:widget_add(mymenubox) mystatusbar[s]:widget_add(mytextbox) mystatusbar[s]:widget_add(mylayoutbox[s]) - mystatusbar[s]:widget_add(mysystray) mystatusbar[s]:add(s) end +mystatusbar[screen.count()]:widget_add(mysystray) -- }}} -- {{{ Mouse bindings diff --git a/structs.h b/structs.h index acd15ff85..aad60d610 100644 --- a/structs.h +++ b/structs.h @@ -372,8 +372,8 @@ typedef struct statusbar_t *statusbar; /** Padding */ padding_t padding; - /** Statusbar that contains the systray */ - statusbar_t *systray; + /** Window that contains the systray */ + simple_window_t *systray; } screen_t; /** Main configuration structure */ diff --git a/systray.c b/systray.c index 7b9feb800..2072bc1d3 100644 --- a/systray.c +++ b/systray.c @@ -27,11 +27,46 @@ #include "window.h" #include "widget.h" #include "common/xembed.h" +#include "common/swindow.h" #define SYSTEM_TRAY_REQUEST_DOCK 0 /* Begin icon docking */ 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; + char atom_name[22]; + + /* Send requests */ + atom_manager_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, atom_name); + 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); + + globalconf.screens[phys_screen].systray = simplewindow_new(globalconf.connection, phys_screen, + -1, -1, 1, 1, 0); + + /* Fill event */ + ev.format = 32; + 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.response_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); + + xcb_set_selection_owner(globalconf.connection, + globalconf.screens[phys_screen].systray->window, + atom_systray, + XCB_CURRENT_TIME); +} + /** Handle a systray request. * \param embed_win The window to embed. */ @@ -66,7 +101,7 @@ systray_request_handle(xcb_window_t embed_win, int phys_screen, xembed_info_t *i /** \todo we should create a dedicated window for that */ if(globalconf.screens[phys_screen].systray) xembed_embedded_notify(globalconf.connection, em->win, - globalconf.screens[phys_screen].systray->sw->window, + globalconf.screens[phys_screen].systray->window, MIN(XEMBED_VERSION, em->info.version)); if(em->info.flags & XEMBED_MAPPED) diff --git a/systray.h b/systray.h index 7f0988c59..6ece735e8 100644 --- a/systray.h +++ b/systray.h @@ -25,6 +25,7 @@ #include #include "common/xembed.h" +void systray_init(int); int systray_request_handle(xcb_window_t, int, xembed_info_t *); int systray_process_client_message(xcb_client_message_event_t *); int xembed_process_client_message(xcb_client_message_event_t *); diff --git a/widgets/systray.c b/widgets/systray.c index 6641b2532..824d45077 100644 --- a/widgets/systray.c +++ b/widgets/systray.c @@ -27,39 +27,6 @@ extern awesome_t globalconf; -static bool -systray_init(statusbar_t *sb) -{ - xutil_intern_atom_request_t atom_systray_q, atom_manager_q; - xcb_atom_t atom_systray; - xcb_client_message_event_t ev; - char atom_name[22]; - - /* Send requests */ - atom_manager_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, atom_name); - snprintf(atom_name, sizeof(atom_name), "_NET_SYSTEM_TRAY_S%d", sb->sw->phys_screen); - atom_systray_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, atom_name); - - /* Fill event */ - ev.format = 32; - ev.data.data32[0] = XCB_CURRENT_TIME; - ev.data.data32[2] = sb->sw->window; - ev.data.data32[3] = ev.data.data32[4] = 0; - ev.response_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); - - xcb_set_selection_owner(globalconf.connection, - sb->sw->window, - atom_systray, - XCB_CURRENT_TIME); - - return true; -} - static int systray_draw(draw_context_t *ctx, int screen __attribute__ ((unused)), @@ -75,16 +42,6 @@ systray_draw(draw_context_t *ctx, phys_screen = screen_virttophys(screen); - /* only init and take systray handling if noone has it and if we have a - * window to handle others... windows. */ - if(!globalconf.screens[phys_screen].systray && sb->sw) - { - globalconf.screens[phys_screen].systray = sb; - systray_init(sb); - } - else if(globalconf.screens[phys_screen].systray != p) - return (w->area.width = 0); - for(em = globalconf.embedded; em; em = em->next) i++;