From 4922b245c1d5bb5700b104b2c87c2d35a40e76cc Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Thu, 9 Apr 2020 15:11:46 +0200 Subject: [PATCH 1/4] Revert "Avoid resizing fullscreen container" This reverts commit 1a2882d740ecc01312cf26ea5fac608077af7386. As mentioned in https://github.com/i3/i3/issues/3980#issuecomment-611515497, this disables resizing children of fullscreen containers. --- src/click.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/click.c b/src/click.c index f038f290..19076252 100644 --- a/src/click.c +++ b/src/click.c @@ -275,11 +275,6 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod goto done; } - if (fs) { - /* Fullscreen container exists, avoid resizes */ - goto done; - } - /* 7: floating modifier pressed, initiate a resize */ if (dest == CLICK_INSIDE && mod_pressed && event->detail == XCB_BUTTON_CLICK_RIGHT) { if (floating_mod_on_tiled_client(con, event)) From b590ca076c030f07102518b270d78ed8a6da278f Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Thu, 9 Apr 2020 15:47:21 +0200 Subject: [PATCH 2/4] Avoid resizing fullscreen container with non-fullscreen Another option is to modify resize_find_tiling_participants but this would also affect resizing of tiling containers in scripts, so I chose to make this change specific to resizing with the mouse. Follow-up after #3983 Fixes #3980 --- src/click.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/click.c b/src/click.c index 19076252..cc12158a 100644 --- a/src/click.c +++ b/src/click.c @@ -48,7 +48,11 @@ static bool tiling_resize_for_border(Con *con, border_t border, xcb_button_press bool res = resize_find_tiling_participants(&first, &second, search_direction, false); if (!res) { - LOG("No second container in this direction found.\n"); + DLOG("No second container in this direction found.\n"); + return false; + } + if (first->fullscreen_mode != second->fullscreen_mode) { + DLOG("Avoiding resize between containers with different fullscreen modes, %d != %d\n", first->fullscreen_mode, second->fullscreen_mode); return false; } From 93e96f4e6b28486c6b7be003e8db81bab30197ef Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Thu, 9 Apr 2020 16:08:41 +0200 Subject: [PATCH 3/4] Do not propagate $mod+right click to clients --- src/click.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/click.c b/src/click.c index cc12158a..2e622710 100644 --- a/src/click.c +++ b/src/click.c @@ -281,8 +281,10 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod /* 7: floating modifier pressed, initiate a resize */ if (dest == CLICK_INSIDE && mod_pressed && event->detail == XCB_BUTTON_CLICK_RIGHT) { - if (floating_mod_on_tiled_client(con, event)) - return 1; + floating_mod_on_tiled_client(con, event); + /* Avoid propagating events to clients, since the user expects + * $mod + click to be handled by i3. */ + return 1; } /* 8: otherwise, check for border/decoration clicks and resize */ else if ((dest == CLICK_BORDER || dest == CLICK_DECORATION) && From 6fa2cd32a0cd35840dc9fccf3580b9e8b363f563 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Thu, 9 Apr 2020 16:16:30 +0200 Subject: [PATCH 4/4] handle_button_press and route_click do not need to return int --- include/click.h | 2 +- src/click.c | 40 +++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/include/click.h b/include/click.h index 0d57abf7..898f1870 100644 --- a/include/click.h +++ b/include/click.h @@ -19,4 +19,4 @@ * Then, route_click is called on the appropriate con. * */ -int handle_button_press(xcb_button_press_event_t *event); +void handle_button_press(xcb_button_press_event_t *event); diff --git a/src/click.c b/src/click.c index 2e622710..7a3fde36 100644 --- a/src/click.c +++ b/src/click.c @@ -151,7 +151,7 @@ static bool tiling_resize(Con *con, xcb_button_press_event_t *event, const click * functions for resizing/dragging. * */ -static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod_pressed, const click_destination_t dest) { +static void route_click(Con *con, xcb_button_press_event_t *event, const bool mod_pressed, const click_destination_t dest) { DLOG("--> click properties: mod = %d, destination = %d\n", mod_pressed, dest); DLOG("--> OUTCOME = %p\n", con); DLOG("type = %d, name = %s\n", con->type, con->name); @@ -178,7 +178,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod xcb_flush(conn); command_result_free(result); - return 0; + return; } } @@ -237,7 +237,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod /* 4: floating_modifier plus left mouse button drags */ if (mod_pressed && event->detail == XCB_BUTTON_CLICK_LEFT) { floating_drag_window(floatingcon, event, false); - return 1; + return; } /* 5: resize (floating) if this was a (left or right) click on the @@ -246,7 +246,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod if (mod_pressed && event->detail == XCB_BUTTON_CLICK_RIGHT) { DLOG("floating resize due to floatingmodifier\n"); floating_resize_window(floatingcon, proportional, event); - return 1; + return; } if (!in_stacked && dest == CLICK_DECORATION && @@ -260,20 +260,20 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod if (dest == CLICK_DECORATION && event->detail == XCB_BUTTON_CLICK_RIGHT) { DLOG("floating resize due to decoration right click\n"); floating_resize_window(floatingcon, proportional, event); - return 1; + return; } if (dest == CLICK_BORDER && is_left_or_right_click) { DLOG("floating resize due to border click\n"); floating_resize_window(floatingcon, proportional, event); - return 1; + return; } /* 6: dragging, if this was a click on a decoration (which did not lead * to a resize) */ if (dest == CLICK_DECORATION && event->detail == XCB_BUTTON_CLICK_LEFT) { floating_drag_window(floatingcon, event, !was_focused); - return 1; + return; } goto done; @@ -284,7 +284,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod floating_mod_on_tiled_client(con, event); /* Avoid propagating events to clients, since the user expects * $mod + click to be handled by i3. */ - return 1; + return; } /* 8: otherwise, check for border/decoration clicks and resize */ else if ((dest == CLICK_BORDER || dest == CLICK_DECORATION) && @@ -301,8 +301,6 @@ done: xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time); xcb_flush(conn); tree_render(); - - return 0; } /* @@ -313,7 +311,7 @@ done: * Then, route_click is called on the appropriate con. * */ -int handle_button_press(xcb_button_press_event_t *event) { +void handle_button_press(xcb_button_press_event_t *event) { Con *con; DLOG("Button %d (state %d) %s on window 0x%08x (child 0x%08x) at (%d, %d) (root %d, %d)\n", event->detail, event->state, (event->response_type == XCB_BUTTON_PRESS ? "press" : "release"), @@ -325,8 +323,10 @@ int handle_button_press(xcb_button_press_event_t *event) { const uint32_t mod = (config.floating_modifier & 0xFFFF); const bool mod_pressed = (mod != 0 && (event->state & mod) == mod); DLOG("floating_mod = %d, detail = %d\n", mod_pressed, event->detail); - if ((con = con_by_window_id(event->event))) - return route_click(con, event, mod_pressed, CLICK_INSIDE); + if ((con = con_by_window_id(event->event))) { + route_click(con, event, mod_pressed, CLICK_INSIDE); + return; + } if (!(con = con_by_frame_id(event->event))) { /* Run bindings on the root window as well, see #2097. We only run it @@ -354,15 +354,15 @@ int handle_button_press(xcb_button_press_event_t *event) { workspace_show(ws); tree_render(); } - return 1; + return; } - return 0; + return; } ELOG("Clicked into unknown window?!\n"); xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time); xcb_flush(conn); - return 0; + return; } /* Check if the click was on the decoration of a child */ @@ -371,13 +371,15 @@ int handle_button_press(xcb_button_press_event_t *event) { if (!rect_contains(child->deco_rect, event->event_x, event->event_y)) continue; - return route_click(child, event, mod_pressed, CLICK_DECORATION); + route_click(child, event, mod_pressed, CLICK_DECORATION); + return; } if (event->child != XCB_NONE) { DLOG("event->child not XCB_NONE, so this is an event which originated from a click into the application, but the application did not handle it.\n"); - return route_click(con, event, mod_pressed, CLICK_INSIDE); + route_click(con, event, mod_pressed, CLICK_INSIDE); + return; } - return route_click(con, event, mod_pressed, CLICK_BORDER); + route_click(con, event, mod_pressed, CLICK_BORDER); }