diff --git a/awesome.c b/awesome.c index ff4ddf92..656a6318 100644 --- a/awesome.c +++ b/awesome.c @@ -56,6 +56,7 @@ awesome_atexit(void) { client_t *c; xembed_window_t *em; + int screen_nbr; a_dbus_cleanup(); luaA_cs_cleanup(); @@ -64,9 +65,15 @@ awesome_atexit(void) for(em = globalconf.embedded; em; em = em->next) { xcb_screen_t *s = xutil_screen_get(globalconf.connection, em->phys_screen); - xcb_reparent_window(globalconf.connection, em->win, s->root, 0, 0); + xembed_window_unembed(globalconf.connection, em->win, s->root); } + /* do this only for real screen */ + for(screen_nbr = 0; + screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); + screen_nbr++) + systray_cleanup(screen_nbr); + /* remap all clients since some WM won't handle them otherwise */ for(c = globalconf.clients; c; c = c->next) client_unban(c); diff --git a/common/xembed.c b/common/xembed.c index a2840aef..1fec16ac 100644 --- a/common/xembed.c +++ b/common/xembed.c @@ -25,28 +25,6 @@ #include "common/util.h" #include "common/atoms.h" -/** Have the embedder end XEMBED protocol communication with a child. - * \param connection The X connection. - * \param child The window to unembed. - * \param root The root window to reparent to. - */ -static inline void -xembed_window_unembed(xcb_connection_t *connection, xcb_window_t child, xcb_window_t root) -{ - xcb_unmap_window(connection, child); - xcb_reparent_window(connection, child, root, 0, 0); -} - -/** Indicate to an embedded window that it has lost focus. - * \param c The X connection. - * \param client The client to send message to. - */ -static inline void -xembed_focus_out(xcb_connection_t *c, xcb_window_t client) -{ - xembed_message_send(c, client, XEMBED_FOCUS_OUT, 0, 0, 0); -} - /** Send an XEMBED message to a window. * \param connection Connection to the X server. * \param towin Destination window diff --git a/common/xembed.h b/common/xembed.h index ec9f3b96..4bbac7b9 100644 --- a/common/xembed.h +++ b/common/xembed.h @@ -145,5 +145,27 @@ xembed_embedded_notify(xcb_connection_t *c, xembed_message_send(c, client, XEMBED_EMBEDDED_NOTIFY, 0, embedder, version); } +/** Have the embedder end XEMBED protocol communication with a child. + * \param connection The X connection. + * \param child The window to unembed. + * \param root The root window to reparent to. + */ +static inline void +xembed_window_unembed(xcb_connection_t *connection, xcb_window_t child, xcb_window_t root) +{ + xcb_reparent_window(connection, child, root, 0, 0); +} + +/** Indicate to an embedded window that it has lost focus. + * \param c The X connection. + * \param client The client to send message to. + */ +static inline void +xembed_focus_out(xcb_connection_t *c, xcb_window_t client) +{ + xembed_message_send(c, client, XEMBED_FOCUS_OUT, 0, 0, 0); +} + + #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/systray.c b/systray.c index 652e6029..f1d7dbc6 100644 --- a/systray.c +++ b/systray.c @@ -32,6 +32,9 @@ extern awesome_t globalconf; +/** Initialize systray information in X. + * \param phys_screen Physical screen. + */ void systray_init(int phys_screen) { @@ -82,6 +85,34 @@ systray_init(int phys_screen) xcb_send_event(globalconf.connection, false, xscreen->root, 0xFFFFFF, (char *) &ev); } +/** Remove systray information in X. + * \param phys_screen Physical screen. + */ +void +systray_cleanup(int phys_screen) +{ + xcb_intern_atom_cookie_t atom_systray_q; + xcb_intern_atom_reply_t *atom_systray_r; + ssize_t len; + char atom_name[22]; + + len = snprintf(atom_name, sizeof(atom_name), "_NET_SYSTEM_TRAY_S%d", phys_screen); + atom_systray_q = xcb_intern_atom_unchecked(globalconf.connection, false, len, atom_name); + + if(!(atom_systray_r = xcb_intern_atom_reply(globalconf.connection, atom_systray_q, NULL))) + { + warn("error getting systray atom"); + return; + } + + xcb_set_selection_owner(globalconf.connection, + XCB_NONE, + atom_systray_r->atom, + XCB_CURRENT_TIME); + + p_delete(&atom_systray_r); +} + /** Handle a systray request. * \param embed_win The window to embed. */ diff --git a/systray.h b/systray.h index 278cb394..f877599a 100644 --- a/systray.h +++ b/systray.h @@ -26,6 +26,7 @@ #include "common/xembed.h" void systray_init(int); +void systray_cleanup(int); int systray_request_handle(xcb_window_t, int, xembed_info_t *); bool systray_iskdedockapp(xcb_window_t); int systray_process_client_message(xcb_client_message_event_t *);