From: Michael Stapelberg Date: Sun, 22 Apr 2012 18:43:52 +0000 (+0200) Subject: i3bar: kick tray clients after output configuration changed X-Git-Tag: 4.2~10 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=17e4d7ede1e3755d43e51de06782703dedea306e;p=i3%2Fi3 i3bar: kick tray clients after output configuration changed This makes i3bar reflect xrandr --output foo --primary changes immediately. --- 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 @@ -1088,17 +1088,15 @@ void get_atoms() { } /* - * Destroy the bar of the specified output + * 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 destroy_window(i3_output *output) { - if (output == NULL) { - return; - } - if (output->bar == XCB_NONE) { - return; - } - +void kick_tray_clients(i3_output *output) { trayclient *trayclient; TAILQ_FOREACH(trayclient, output->trayclients, tailq) { /* Unmap, then reparent (to root) the tray client windows */ @@ -1109,7 +1107,21 @@ void destroy_window(i3_output *output) { 0, 0); } +} + +/* + * Destroy the bar of the specified output + * + */ +void destroy_window(i3_output *output) { + if (output == NULL) { + return; + } + if (output->bar == XCB_NONE) { + return; + } + kick_tray_clients(output); xcb_destroy_window(xcb_connection, output->bar); output->bar = XCB_NONE; }