From: Deiz Date: Sun, 23 Sep 2012 14:35:52 +0000 (-0400) Subject: Clicking the root window should try to focus the relevant workspace. X-Git-Tag: 4.4~114 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e582e19ffd90dee05c3580911b9ffe5e6794d728;p=i3%2Fi3 Clicking the root window should try to focus the relevant workspace. --- diff --git a/src/click.c b/src/click.c index 23b6be4f..a1da00ac 100644 --- a/src/click.c +++ b/src/click.c @@ -309,6 +309,25 @@ int handle_button_press(xcb_button_press_event_t *event) { return route_click(con, event, mod_pressed, CLICK_INSIDE); if (!(con = con_by_frame_id(event->event))) { + /* If the root window is clicked, find the relevant output from the + * click coordinates and focus the output's active workspace. */ + if (event->event == root) { + Con *output, *ws; + TAILQ_FOREACH(output, &(croot->nodes_head), nodes) { + if (con_is_internal(output) || + !rect_contains(output->rect, event->event_x, event->event_y)) + continue; + + ws = TAILQ_FIRST(&(output_get_content(output)->focus_head)); + if (ws != con_get_workspace(focused)) { + workspace_show(ws); + tree_render(); + } + return 1; + } + return 0; + } + ELOG("Clicked into unknown window?!\n"); xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time); xcb_flush(conn); diff --git a/src/main.c b/src/main.c index a4bd1b9b..65db1711 100644 --- a/src/main.c +++ b/src/main.c @@ -544,6 +544,7 @@ int main(int argc, char *argv[]) { uint32_t mask = XCB_CW_EVENT_MASK; uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | + XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_STRUCTURE_NOTIFY | /* when the user adds a screen (e.g. video projector), the root window gets a ConfigureNotify */