diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 1528bdf4..97d13ec9 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -393,8 +393,20 @@ void handle_button(xcb_button_press_event_t *event) { } x -= cur_ws->name_width + logical_px(11); } + + /* Otherwise, focus our currently visible workspace if it is not + * already focused */ + if (cur_ws == NULL) { + TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) { + if (cur_ws->visible && !cur_ws->focused) + break; + } + } + + /* if there is nothing to focus, we are done */ if (cur_ws == NULL) return; + break; default: return; diff --git a/src/click.c b/src/click.c index 22e70b9f..91964b93 100644 --- a/src/click.c +++ b/src/click.c @@ -171,6 +171,10 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod DLOG("--> OUTCOME = %p\n", con); DLOG("type = %d, name = %s\n", con->type, con->name); + /* don’t handle dockarea cons, they must not be focused */ + if (con->parent->type == CT_DOCKAREA) + goto done; + /* Any click in a workspace should focus that workspace. If the * workspace is on another output we need to do a workspace_show in * order for i3bar (and others) to notice the change in workspace. */ @@ -187,10 +191,6 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod workspace_show(ws); focused_id = XCB_NONE; - /* don’t handle dockarea cons, they must not be focused */ - if (con->parent->type == CT_DOCKAREA) - goto done; - /* get the floating con */ Con *floatingcon = con_inside_floating(con); const bool proportional = (event->state & BIND_SHIFT);