From: Tony Crisci Date: Wed, 30 Apr 2014 01:29:17 +0000 (-0400) Subject: Delegate click handling to dock clients X-Git-Tag: 4.8~60 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ab0fae400b68d802aa73e81208a441a1917d3054;p=i3%2Fi3 Delegate click handling to dock clients Do not handle click events on dock clients because they are not managed windows. Dock clients are responsible for sending the message to i3 to focus a workspace if that is appropriate. i3bar now sends the message to focus the correct workspace when that is appropriate. Otherwise, it could interfere with the dock clients own click handling, which could be an action to focus a different workspace than i3 had assumed, such as would be the case with a workspace widget. --- 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);