]> git.sur5r.net Git - i3/i3/blobdiff - src/click.c
re-implement assignments of workspace to specific outputs
[i3/i3] / src / click.c
index 8c0d7f661b186a0c6e5b70c9e1a704a7f055b46a..74e5988547732b4af0c0f0f63a3b3bcd20f09e6e 100644 (file)
@@ -39,9 +39,12 @@ static bool tiling_resize_for_border(Con *con, border_t border, xcb_button_press
     Con *first = NULL, *second = NULL;
     Con *resize_con = con;
     while (resize_con->type != CT_WORKSPACE &&
-        resize_con->parent->orientation != orientation)
+           resize_con->type != CT_FLOATING_CON &&
+           resize_con->parent->orientation != orientation)
         resize_con = resize_con->parent;
+
     if (resize_con->type != CT_WORKSPACE &&
+        resize_con->type != CT_FLOATING_CON &&
         resize_con->parent->orientation == orientation) {
         first = resize_con;
         second = (way == 'n') ? TAILQ_NEXT(first, nodes) : TAILQ_PREV(first, nodes_head, nodes);
@@ -150,26 +153,42 @@ static int route_click(Con *con, xcb_button_press_event_t *event, bool mod_press
     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;
+
     /* get the floating con */
     Con *floatingcon = con_inside_floating(con);
     const bool proportional = (event->state & BIND_SHIFT);
+    const bool in_stacked = (con->parent->layout == L_STACKED || con->parent->layout == L_TABBED);
 
-    /* 1: focus this con */
-    con_focus(con);
+    /* 1: see if the user scrolled on the decoration of a stacked/tabbed con */
+    if (in_stacked &&
+        dest == CLICK_DECORATION &&
+        (event->detail == XCB_BUTTON_INDEX_4 ||
+         event->detail == XCB_BUTTON_INDEX_5)) {
+        DLOG("Scrolling on a window decoration\n");
+        orientation_t orientation = (con->parent->layout == L_STACKED ? VERT : HORIZ);
+        if (event->detail == XCB_BUTTON_INDEX_4)
+            tree_next('p', orientation);
+        else tree_next('n', orientation);
+        goto done;
+    }
 
-    const bool in_stacked = (con->parent->layout == L_STACKED || con->parent->layout == L_TABBED);
+    /* 2: focus this con */
+    con_focus(con);
 
-    /* 2: for floating containers, we also want to raise them on click */
+    /* 3: for floating containers, we also want to raise them on click */
     if (floatingcon != NULL) {
         floating_raise_con(floatingcon);
 
-        /* 3: floating_modifier plus left mouse button drags */
+        /* 4: floating_modifier plus left mouse button drags */
         if (mod_pressed && event->detail == 1) {
             floating_drag_window(floatingcon, event);
             return 1;
         }
 
-        /* 3: resize (floating) if this was a click on the left/right/bottom
+        /* 5: resize (floating) if this was a click on the left/right/bottom
          * border. also try resizing (tiling) if it was a click on the top
          * border, but continue if that does not work */
         if (mod_pressed && event->detail == 3) {
@@ -191,7 +210,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, bool mod_press
             return 1;
         }
 
-        /* 4: dragging, if this was a click on a decoration (which did not lead
+        /* 6: dragging, if this was a click on a decoration (which did not lead
          * to a resize) */
         if (!in_stacked && dest == CLICK_DECORATION) {
             floating_drag_window(floatingcon, event);
@@ -210,12 +229,12 @@ static int route_click(Con *con, xcb_button_press_event_t *event, bool mod_press
         goto done;
     }
 
-    /* 3: floating modifier pressed, initiate a resize */
+    /* 7: floating modifier pressed, initiate a resize */
     if (mod_pressed && event->detail == 3) {
         if (floating_mod_on_tiled_client(con, event))
             return 1;
     }
-    /* 4: otherwise, check for border/decoration clicks and resize */
+    /* 8: otherwise, check for border/decoration clicks and resize */
     else if (dest == CLICK_BORDER || dest == CLICK_DECORATION) {
         DLOG("Should trry resizing (tiling)\n");
         tiling_resize(con, event, dest);
@@ -236,7 +255,7 @@ done:
  * Then, route_click is called on the appropriate con.
  *
  */
-int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_event_t *event) {
+int handle_button_press(xcb_button_press_event_t *event) {
     Con *con;
     DLOG("Button %d pressed on window 0x%08x\n", event->state, event->event);