Merge pull request #4000 from orestisfl/revert-3983-resize-behind-fullscreen

Correctly handle mouse resize in fullscreen containers
This commit is contained in:
Ingo Bürk 2020-04-09 16:41:43 +02:00 committed by GitHub
commit c611b9e0e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 27 deletions

View File

@ -19,4 +19,4 @@
* Then, route_click is called on the appropriate con. * 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);

View File

@ -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); bool res = resize_find_tiling_participants(&first, &second, search_direction, false);
if (!res) { 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; return false;
} }
@ -147,7 +151,7 @@ static bool tiling_resize(Con *con, xcb_button_press_event_t *event, const click
* functions for resizing/dragging. * 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("--> click properties: mod = %d, destination = %d\n", mod_pressed, dest);
DLOG("--> OUTCOME = %p\n", con); DLOG("--> OUTCOME = %p\n", con);
DLOG("type = %d, name = %s\n", con->type, con->name); DLOG("type = %d, name = %s\n", con->type, con->name);
@ -174,7 +178,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
xcb_flush(conn); xcb_flush(conn);
command_result_free(result); command_result_free(result);
return 0; return;
} }
} }
@ -233,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 */ /* 4: floating_modifier plus left mouse button drags */
if (mod_pressed && event->detail == XCB_BUTTON_CLICK_LEFT) { if (mod_pressed && event->detail == XCB_BUTTON_CLICK_LEFT) {
floating_drag_window(floatingcon, event, false); floating_drag_window(floatingcon, event, false);
return 1; return;
} }
/* 5: resize (floating) if this was a (left or right) click on the /* 5: resize (floating) if this was a (left or right) click on the
@ -242,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) { if (mod_pressed && event->detail == XCB_BUTTON_CLICK_RIGHT) {
DLOG("floating resize due to floatingmodifier\n"); DLOG("floating resize due to floatingmodifier\n");
floating_resize_window(floatingcon, proportional, event); floating_resize_window(floatingcon, proportional, event);
return 1; return;
} }
if (!in_stacked && dest == CLICK_DECORATION && if (!in_stacked && dest == CLICK_DECORATION &&
@ -256,34 +260,31 @@ 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) { if (dest == CLICK_DECORATION && event->detail == XCB_BUTTON_CLICK_RIGHT) {
DLOG("floating resize due to decoration right click\n"); DLOG("floating resize due to decoration right click\n");
floating_resize_window(floatingcon, proportional, event); floating_resize_window(floatingcon, proportional, event);
return 1; return;
} }
if (dest == CLICK_BORDER && is_left_or_right_click) { if (dest == CLICK_BORDER && is_left_or_right_click) {
DLOG("floating resize due to border click\n"); DLOG("floating resize due to border click\n");
floating_resize_window(floatingcon, proportional, event); floating_resize_window(floatingcon, proportional, event);
return 1; return;
} }
/* 6: 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) */ * to a resize) */
if (dest == CLICK_DECORATION && event->detail == XCB_BUTTON_CLICK_LEFT) { if (dest == CLICK_DECORATION && event->detail == XCB_BUTTON_CLICK_LEFT) {
floating_drag_window(floatingcon, event, !was_focused); floating_drag_window(floatingcon, event, !was_focused);
return 1; return;
} }
goto done; goto done;
} }
if (fs) {
/* Fullscreen container exists, avoid resizes */
goto done;
}
/* 7: floating modifier pressed, initiate a resize */ /* 7: floating modifier pressed, initiate a resize */
if (dest == CLICK_INSIDE && mod_pressed && event->detail == XCB_BUTTON_CLICK_RIGHT) { if (dest == CLICK_INSIDE && mod_pressed && event->detail == XCB_BUTTON_CLICK_RIGHT) {
if (floating_mod_on_tiled_client(con, event)) floating_mod_on_tiled_client(con, event);
return 1; /* Avoid propagating events to clients, since the user expects
* $mod + click to be handled by i3. */
return;
} }
/* 8: 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) && else if ((dest == CLICK_BORDER || dest == CLICK_DECORATION) &&
@ -300,8 +301,6 @@ done:
xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time); xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time);
xcb_flush(conn); xcb_flush(conn);
tree_render(); tree_render();
return 0;
} }
/* /*
@ -312,7 +311,7 @@ done:
* Then, route_click is called on the appropriate con. * 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; Con *con;
DLOG("Button %d (state %d) %s on window 0x%08x (child 0x%08x) at (%d, %d) (root %d, %d)\n", 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"), event->detail, event->state, (event->response_type == XCB_BUTTON_PRESS ? "press" : "release"),
@ -324,8 +323,10 @@ int handle_button_press(xcb_button_press_event_t *event) {
const uint32_t mod = (config.floating_modifier & 0xFFFF); const uint32_t mod = (config.floating_modifier & 0xFFFF);
const bool mod_pressed = (mod != 0 && (event->state & mod) == mod); const bool mod_pressed = (mod != 0 && (event->state & mod) == mod);
DLOG("floating_mod = %d, detail = %d\n", mod_pressed, event->detail); DLOG("floating_mod = %d, detail = %d\n", mod_pressed, event->detail);
if ((con = con_by_window_id(event->event))) if ((con = con_by_window_id(event->event))) {
return route_click(con, event, mod_pressed, CLICK_INSIDE); route_click(con, event, mod_pressed, CLICK_INSIDE);
return;
}
if (!(con = con_by_frame_id(event->event))) { if (!(con = con_by_frame_id(event->event))) {
/* Run bindings on the root window as well, see #2097. We only run it /* Run bindings on the root window as well, see #2097. We only run it
@ -353,15 +354,15 @@ int handle_button_press(xcb_button_press_event_t *event) {
workspace_show(ws); workspace_show(ws);
tree_render(); tree_render();
} }
return 1; return;
} }
return 0; return;
} }
ELOG("Clicked into unknown window?!\n"); ELOG("Clicked into unknown window?!\n");
xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time); xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time);
xcb_flush(conn); xcb_flush(conn);
return 0; return;
} }
/* Check if the click was on the decoration of a child */ /* Check if the click was on the decoration of a child */
@ -370,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)) if (!rect_contains(child->deco_rect, event->event_x, event->event_y))
continue; continue;
return route_click(child, event, mod_pressed, CLICK_DECORATION); route_click(child, event, mod_pressed, CLICK_DECORATION);
return;
} }
if (event->child != XCB_NONE) { 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"); 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);
} }