diff --git a/i3bar/include/xcb.h b/i3bar/include/xcb.h index c5a50787..9ed21496 100644 --- a/i3bar/include/xcb.h +++ b/i3bar/include/xcb.h @@ -77,6 +77,17 @@ void clean_xcb(); */ void get_atoms(); +/* + * Reparents all tray clients of the specified output to the root window. This + * is either used when shutting down, when an output appears (xrandr --output + * VGA1 --off) or when the primary output changes. + * + * Applications using the tray will start the protocol from the beginning again + * afterwards. + * + */ +void kick_tray_clients(i3_output *output); + /* * Destroy the bar of the specified output * diff --git a/i3bar/src/ipc.c b/i3bar/src/ipc.c index 8f8174e5..2ebc4c64 100644 --- a/i3bar/src/ipc.c +++ b/i3bar/src/ipc.c @@ -65,6 +65,11 @@ void got_output_reply(char *reply) { DLOG("Reconfiguring Windows...\n"); realloc_sl_buffer(); reconfig_windows(); + + i3_output *o_walk; + SLIST_FOREACH(o_walk, outputs, slist) { + kick_tray_clients(o_walk); + } } /* diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 53ea0d31..9907665e 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -1087,6 +1087,28 @@ void get_atoms() { DLOG("Got Atoms\n"); } +/* + * Reparents all tray clients of the specified output to the root window. This + * is either used when shutting down, when an output appears (xrandr --output + * VGA1 --off) or when the primary output changes. + * + * Applications using the tray will start the protocol from the beginning again + * afterwards. + * + */ +void kick_tray_clients(i3_output *output) { + trayclient *trayclient; + TAILQ_FOREACH(trayclient, output->trayclients, tailq) { + /* Unmap, then reparent (to root) the tray client windows */ + xcb_unmap_window(xcb_connection, trayclient->win); + xcb_reparent_window(xcb_connection, + trayclient->win, + xcb_root, + 0, + 0); + } +} + /* * Destroy the bar of the specified output * @@ -1099,17 +1121,7 @@ void destroy_window(i3_output *output) { return; } - trayclient *trayclient; - TAILQ_FOREACH(trayclient, output->trayclients, tailq) { - /* Unmap, then reparent (to root) the tray client windows */ - xcb_unmap_window(xcb_connection, trayclient->win); - xcb_reparent_window(xcb_connection, - trayclient->win, - xcb_root, - 0, - 0); - } - + kick_tray_clients(output); xcb_destroy_window(xcb_connection, output->bar); output->bar = XCB_NONE; }