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.
* 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
parse_outputs_json(reply);
DLOG("Reconfiguring Windows...\n");
realloc_sl_buffer();
parse_outputs_json(reply);
DLOG("Reconfiguring Windows...\n");
realloc_sl_buffer();
+ reconfig_windows(false);
i3_output *o_walk;
SLIST_FOREACH(o_walk, outputs, slist) {
i3_output *o_walk;
SLIST_FOREACH(o_walk, outputs, slist) {
int old_mode = config.hide_on_modifier;
parse_config_json(event);
if (old_mode != config.hide_on_modifier) {
int old_mode = config.hide_on_modifier;
parse_config_json(event);
if (old_mode != config.hide_on_modifier) {
+ reconfig_windows(true);
*
*/
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)) {
void deregister_xkb_keyevents() {
if (xkb_dpy != NULL) {
ev_io_stop (main_loop, xkb_io);
void deregister_xkb_keyevents() {
if (xkb_dpy != NULL) {
ev_io_stop (main_loop, xkb_io);
+ XCloseDisplay(xkb_dpy);
close(xkb_io->fd);
FREE(xkb_io);
close(xkb_io->fd);
FREE(xkb_io);
* 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 values[5];
static bool tray_configured = false;
uint32_t mask;
uint32_t values[5];
static bool tray_configured = false;
walk->rect.w,
walk->rect.h);
walk->rect.w,
walk->rect.h);
- /* Unmap the window, and draw it again when in dock mode */
- xcb_void_cookie_t umap_cookie = xcb_unmap_window_checked(xcb_connection, walk->bar);
- xcb_void_cookie_t map_cookie;
- if (config.hide_on_modifier == M_DOCK) {
- cont_child();
- map_cookie = xcb_map_window_checked(xcb_connection, walk->bar);
- }
+ xcb_void_cookie_t map_cookie, umap_cookie;
+ if (redraw_bars) {
+ /* Unmap the window, and draw it again when in dock mode */
+ umap_cookie = xcb_unmap_window_checked(xcb_connection, walk->bar);
+ if (config.hide_on_modifier == M_DOCK) {
+ cont_child();
+ map_cookie = xcb_map_window_checked(xcb_connection, walk->bar);
+ } else {
+ stop_child();
+ }
- if (config.hide_on_modifier == M_HIDE) {
- /* Switching to hide mode, register for keyevents */
- register_xkb_keyevents();
- } else {
- /* Switching to dock/invisible mode, deregister from keyevents */
- deregister_xkb_keyevents();
+ if (config.hide_on_modifier == M_HIDE) {
+ /* Switching to hide mode, register for keyevents */
+ register_xkb_keyevents();
+ } else {
+ /* Switching to dock/invisible mode, deregister from keyevents */
+ deregister_xkb_keyevents();
+ }
}
if (xcb_request_failed(cfg_cookie, "Could not reconfigure window") ||
xcb_request_failed(chg_cookie, "Could not change window") ||
xcb_request_failed(pm_cookie, "Could not create pixmap") ||
}
if (xcb_request_failed(cfg_cookie, "Could not reconfigure window") ||
xcb_request_failed(chg_cookie, "Could not change window") ||
xcb_request_failed(pm_cookie, "Could not create pixmap") ||
- xcb_request_failed(umap_cookie, "Could not unmap window") ||
- ((config.hide_on_modifier == M_DOCK) && xcb_request_failed(map_cookie, "Could not map 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"))))) {
}
if (outputs_walk->bar == XCB_NONE) {
/* Oh shit, an active output without an own bar. Create it now! */
}
if (outputs_walk->bar == XCB_NONE) {
/* Oh shit, an active output without an own bar. Create it now! */
+ reconfig_windows(false);
}
/* First things first: clear the backbuffer */
uint32_t color = colors.bar_bg;
}
/* First things first: clear the backbuffer */
uint32_t color = colors.bar_bg;
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_unhide = (config.hidden_state == S_SHOW || (unhide && config.hidden_state == S_HIDE));
bool should_hide = (config.hide_on_modifier == M_INVISIBLE);
- if (!mod_pressed) {
- if ((unhide || should_unhide) && !should_hide) {
- unhide_bars();
- } else if (walks_away || should_hide) {
- FREE(last_urgent_ws);
- hide_bars();
- }
+ if (mod_pressed || (should_unhide && !should_hide)) {
+ unhide_bars();
+ } else if (!mod_pressed && (walks_away || should_hide)) {
+ FREE(last_urgent_ws);
+ hide_bars();