i3bar: kick tray clients after output configuration changed

This makes i3bar reflect xrandr --output foo --primary changes immediately.
This commit is contained in:
Michael Stapelberg 2012-04-22 20:43:52 +02:00
parent 189b27b01e
commit 17e4d7ede1
3 changed files with 39 additions and 11 deletions

View File

@ -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
*

View File

@ -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);
}
}
/*

View File

@ -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;
}