Fix wrong placement of i3bar when connecting/disconnecting outputs
When connecting or disconnecting an output, i3bar reconfigures its windows. This also included an unmapping of the bars, and a remapping of all docked bars. Thus, the bars were misplaced when a monitor was disconnected. This commit assures that the remapping of the bars only takes place, when the mode has actually changed. This patch also takes care of an inconsistency when pressing the bar_modifier while switching the mode. Also, the xkbDisplay is now closed correctly, when deregestering the xkb keyevents.
This commit is contained in:
parent
8353a387c9
commit
4937788e8d
|
@ -114,7 +114,7 @@ void realloc_sl_buffer(void);
|
||||||
* Reconfigure all bars and create new for newly activated outputs
|
* Reconfigure all bars and create new for newly activated outputs
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void reconfig_windows(void);
|
void reconfig_windows(bool redraw_bars);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Render the bars, with buttons and statusline
|
* Render the bars, with buttons and statusline
|
||||||
|
|
|
@ -64,7 +64,7 @@ void got_output_reply(char *reply) {
|
||||||
parse_outputs_json(reply);
|
parse_outputs_json(reply);
|
||||||
DLOG("Reconfiguring Windows...\n");
|
DLOG("Reconfiguring Windows...\n");
|
||||||
realloc_sl_buffer();
|
realloc_sl_buffer();
|
||||||
reconfig_windows();
|
reconfig_windows(false);
|
||||||
|
|
||||||
i3_output *o_walk;
|
i3_output *o_walk;
|
||||||
SLIST_FOREACH(o_walk, outputs, slist) {
|
SLIST_FOREACH(o_walk, outputs, slist) {
|
||||||
|
@ -167,7 +167,7 @@ void got_bar_config_update(char *event) {
|
||||||
int old_mode = config.hide_on_modifier;
|
int old_mode = config.hide_on_modifier;
|
||||||
parse_config_json(event);
|
parse_config_json(event);
|
||||||
if (old_mode != config.hide_on_modifier) {
|
if (old_mode != config.hide_on_modifier) {
|
||||||
reconfig_windows();
|
reconfig_windows(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_bars(false);
|
draw_bars(false);
|
||||||
|
|
|
@ -198,7 +198,7 @@ void refresh_statusline(void) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void hide_bars(void) {
|
void hide_bars(void) {
|
||||||
if ((config.hide_on_modifier == M_DOCK) || (config.hidden_state == S_SHOW)) {
|
if ((config.hide_on_modifier == M_DOCK) || (config.hidden_state == S_SHOW && config.hide_on_modifier == M_HIDE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1041,9 +1041,10 @@ void register_xkb_keyevents() {
|
||||||
void deregister_xkb_keyevents() {
|
void deregister_xkb_keyevents() {
|
||||||
if (xkb_dpy != NULL) {
|
if (xkb_dpy != NULL) {
|
||||||
ev_io_stop (main_loop, xkb_io);
|
ev_io_stop (main_loop, xkb_io);
|
||||||
|
XCloseDisplay(xkb_dpy);
|
||||||
close(xkb_io->fd);
|
close(xkb_io->fd);
|
||||||
FREE(xkb_io);
|
FREE(xkb_io);
|
||||||
FREE(xkb_dpy);
|
xkb_dpy = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1367,7 +1368,7 @@ void realloc_sl_buffer(void) {
|
||||||
* Reconfigure all bars and create new bars for recently activated outputs
|
* Reconfigure all bars and create new bars for recently activated outputs
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void reconfig_windows(void) {
|
void reconfig_windows(bool redraw_bars) {
|
||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
uint32_t values[5];
|
uint32_t values[5];
|
||||||
static bool tray_configured = false;
|
static bool tray_configured = false;
|
||||||
|
@ -1570,27 +1571,31 @@ void reconfig_windows(void) {
|
||||||
walk->rect.w,
|
walk->rect.w,
|
||||||
walk->rect.h);
|
walk->rect.h);
|
||||||
|
|
||||||
/* Unmap the window, and draw it again when in dock mode */
|
xcb_void_cookie_t map_cookie, umap_cookie;
|
||||||
xcb_void_cookie_t umap_cookie = xcb_unmap_window_checked(xcb_connection, walk->bar);
|
if (redraw_bars) {
|
||||||
xcb_void_cookie_t map_cookie;
|
/* Unmap the window, and draw it again when in dock mode */
|
||||||
if (config.hide_on_modifier == M_DOCK) {
|
umap_cookie = xcb_unmap_window_checked(xcb_connection, walk->bar);
|
||||||
cont_child();
|
if (config.hide_on_modifier == M_DOCK) {
|
||||||
map_cookie = xcb_map_window_checked(xcb_connection, walk->bar);
|
cont_child();
|
||||||
}
|
map_cookie = xcb_map_window_checked(xcb_connection, walk->bar);
|
||||||
|
} else {
|
||||||
|
stop_child();
|
||||||
|
}
|
||||||
|
|
||||||
if (config.hide_on_modifier == M_HIDE) {
|
if (config.hide_on_modifier == M_HIDE) {
|
||||||
/* Switching to hide mode, register for keyevents */
|
/* Switching to hide mode, register for keyevents */
|
||||||
register_xkb_keyevents();
|
register_xkb_keyevents();
|
||||||
} else {
|
} else {
|
||||||
/* Switching to dock/invisible mode, deregister from keyevents */
|
/* Switching to dock/invisible mode, deregister from keyevents */
|
||||||
deregister_xkb_keyevents();
|
deregister_xkb_keyevents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xcb_request_failed(cfg_cookie, "Could not reconfigure window") ||
|
if (xcb_request_failed(cfg_cookie, "Could not reconfigure window") ||
|
||||||
xcb_request_failed(chg_cookie, "Could not change window") ||
|
xcb_request_failed(chg_cookie, "Could not change window") ||
|
||||||
xcb_request_failed(pm_cookie, "Could not create pixmap") ||
|
xcb_request_failed(pm_cookie, "Could not create pixmap") ||
|
||||||
xcb_request_failed(umap_cookie, "Could not unmap window") ||
|
(redraw_bars && (xcb_request_failed(umap_cookie, "Could not unmap window") ||
|
||||||
((config.hide_on_modifier == M_DOCK) && xcb_request_failed(map_cookie, "Could not map window"))) {
|
(config.hide_on_modifier == M_DOCK && xcb_request_failed(map_cookie, "Could not map window"))))) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1618,7 +1623,7 @@ void draw_bars(bool unhide) {
|
||||||
}
|
}
|
||||||
if (outputs_walk->bar == XCB_NONE) {
|
if (outputs_walk->bar == XCB_NONE) {
|
||||||
/* Oh shit, an active output without an own bar. Create it now! */
|
/* Oh shit, an active output without an own bar. Create it now! */
|
||||||
reconfig_windows();
|
reconfig_windows(false);
|
||||||
}
|
}
|
||||||
/* First things first: clear the backbuffer */
|
/* First things first: clear the backbuffer */
|
||||||
uint32_t color = colors.bar_bg;
|
uint32_t color = colors.bar_bg;
|
||||||
|
@ -1768,13 +1773,11 @@ void draw_bars(bool unhide) {
|
||||||
bool should_unhide = (config.hidden_state == S_SHOW || (unhide && config.hidden_state == S_HIDE));
|
bool should_unhide = (config.hidden_state == S_SHOW || (unhide && config.hidden_state == S_HIDE));
|
||||||
bool should_hide = (config.hide_on_modifier == M_INVISIBLE);
|
bool should_hide = (config.hide_on_modifier == M_INVISIBLE);
|
||||||
|
|
||||||
if (!mod_pressed) {
|
if (mod_pressed || (should_unhide && !should_hide)) {
|
||||||
if ((unhide || should_unhide) && !should_hide) {
|
unhide_bars();
|
||||||
unhide_bars();
|
} else if (!mod_pressed && (walks_away || should_hide)) {
|
||||||
} else if (walks_away || should_hide) {
|
FREE(last_urgent_ws);
|
||||||
FREE(last_urgent_ws);
|
hide_bars();
|
||||||
hide_bars();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
redraw_bars();
|
redraw_bars();
|
||||||
|
|
Loading…
Reference in New Issue