]> git.sur5r.net Git - i3/i3/commitdiff
Clicking the root window should try to focus the relevant workspace.
authorDeiz <silverwraithii@gmail.com>
Sun, 23 Sep 2012 14:35:52 +0000 (10:35 -0400)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 23 Sep 2012 14:39:35 +0000 (16:39 +0200)
src/click.c
src/main.c

index 23b6be4f15483d417101221f8f7a778c9cf0c2c5..a1da00ac90296758e4deafa32ca8be1bc0467da5 100644 (file)
@@ -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);
index a4bd1b9ba37aee2b65a217273be2389aba5cda6c..65db1711c40845710233535463ab8a465c9cc5ae 100644 (file)
@@ -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 */