diff --git a/include/view.h b/include/view.h index fae462db..d2ff5ddf 100644 --- a/include/view.h +++ b/include/view.h @@ -512,8 +512,7 @@ void view_constrain_size_to_that_of_usable_area(struct view *view); void view_set_maximized(struct view *view, enum view_axis maximized); void view_set_untiled(struct view *view); -void view_maximize(struct view *view, enum view_axis axis, - bool store_natural_geometry); +void view_maximize(struct view *view, enum view_axis axis); void view_set_fullscreen(struct view *view, bool fullscreen); void view_toggle_maximize(struct view *view, enum view_axis axis); bool view_wants_decorations(struct view *view); @@ -540,8 +539,8 @@ void view_move_to_edge(struct view *view, enum lab_edge direction, bool snap_to_ void view_grow_to_edge(struct view *view, enum lab_edge direction); void view_shrink_to_edge(struct view *view, enum lab_edge direction); void view_snap_to_edge(struct view *view, enum lab_edge direction, - bool across_outputs, bool combine, bool store_natural_geometry); -void view_snap_to_region(struct view *view, struct region *region, bool store_natural_geometry); + bool across_outputs, bool combine); +void view_snap_to_region(struct view *view, struct region *region); void view_move_to_output(struct view *view, struct output *output); void view_move_to_front(struct view *view); diff --git a/src/action.c b/src/action.c index 5a01d157..7f974917 100644 --- a/src/action.c +++ b/src/action.c @@ -1146,7 +1146,7 @@ run_action(struct view *view, struct server *server, struct action *action, } bool combine = action_get_bool(action, "combine", false); view_snap_to_edge(view, edge, /*across_outputs*/ true, - combine, /*store_natural_geometry*/ true); + combine); } break; case ACTION_TYPE_GROW_TO_EDGE: @@ -1203,16 +1203,14 @@ run_action(struct view *view, struct server *server, struct action *action, if (view) { enum view_axis axis = action_get_int(action, "direction", VIEW_AXIS_BOTH); - view_maximize(view, axis, - /*store_natural_geometry*/ true); + view_maximize(view, axis); } break; case ACTION_TYPE_UNMAXIMIZE: if (view) { enum view_axis axis = action_get_int(action, "direction", VIEW_AXIS_BOTH); - view_maximize(view, view->maximized & ~axis, - /*store_natural_geometry*/ true); + view_maximize(view, view->maximized & ~axis); } break; case ACTION_TYPE_TOGGLE_FULLSCREEN: @@ -1426,8 +1424,7 @@ run_action(struct view *view, struct server *server, struct action *action, view_apply_natural_geometry(view); break; } - view_snap_to_region(view, region, - /*store_natural_geometry*/ true); + view_snap_to_region(view, region); } else { wlr_log(WLR_ERROR, "Invalid SnapToRegion id: '%s'", region_name); } @@ -1435,8 +1432,7 @@ run_action(struct view *view, struct server *server, struct action *action, } case ACTION_TYPE_UNSNAP: if (view && !view->fullscreen && !view_is_floating(view)) { - view_maximize(view, VIEW_AXIS_NONE, - /* store_natural_geometry */ false); + view_maximize(view, VIEW_AXIS_NONE); view_set_untiled(view); view_apply_natural_geometry(view); } diff --git a/src/foreign-toplevel/wlr-foreign.c b/src/foreign-toplevel/wlr-foreign.c index f5b58110..70ce0890 100644 --- a/src/foreign-toplevel/wlr-foreign.c +++ b/src/foreign-toplevel/wlr-foreign.c @@ -26,8 +26,7 @@ handle_request_maximize(struct wl_listener *listener, void *data) struct wlr_foreign_toplevel_handle_v1_maximized_event *event = data; view_maximize(wlr_toplevel->view, - event->maximized ? VIEW_AXIS_BOTH : VIEW_AXIS_NONE, - /*store_natural_geometry*/ true); + event->maximized ? VIEW_AXIS_BOTH : VIEW_AXIS_NONE); } static void diff --git a/src/interactive.c b/src/interactive.c index 03c4ad53..4bbecb9a 100644 --- a/src/interactive.c +++ b/src/interactive.c @@ -273,17 +273,12 @@ snap_to_edge(struct view *view) enum lab_edge edge = edge1 | edge2; view_set_output(view, output); - /* - * Don't store natural geometry here (it was - * stored already in interactive_begin()) - */ if (edge == LAB_EDGE_TOP && rc.snap_top_maximize) { /* */ - view_maximize(view, VIEW_AXIS_BOTH, - /*store_natural_geometry*/ false); + view_maximize(view, VIEW_AXIS_BOTH); } else { view_snap_to_edge(view, edge, /*across_outputs*/ false, - /*combine*/ false, /*store_natural_geometry*/ false); + /*combine*/ false); } return true; @@ -298,8 +293,7 @@ snap_to_region(struct view *view) struct region *region = regions_from_cursor(view->server); if (region) { - view_snap_to_region(view, region, - /*store_natural_geometry*/ false); + view_snap_to_region(view, region); return true; } return false; diff --git a/src/view.c b/src/view.c index c439b443..20f3bbdc 100644 --- a/src/view.c +++ b/src/view.c @@ -614,7 +614,7 @@ view_move_relative(struct view *view, int x, int y) if (view->fullscreen) { return; } - view_maximize(view, VIEW_AXIS_NONE, /*store_natural_geometry*/ false); + view_maximize(view, VIEW_AXIS_NONE); if (view_is_tiled(view)) { view_set_untiled(view); view_move_resize(view, view->natural_geometry); @@ -632,7 +632,7 @@ view_move_to_cursor(struct view *view) return; } view_set_fullscreen(view, false); - view_maximize(view, VIEW_AXIS_NONE, /*store_natural_geometry*/ false); + view_maximize(view, VIEW_AXIS_NONE); if (view_is_tiled(view)) { view_set_untiled(view); view_move_resize(view, view->natural_geometry); @@ -1375,9 +1375,15 @@ view_set_untiled(struct view *view) view_notify_tiled(view); } +static bool +in_interactive_move(struct view *view) +{ + return (view->server->input_mode == LAB_INPUT_STATE_MOVE + && view->server->grabbed_view == view); +} + void -view_maximize(struct view *view, enum view_axis axis, - bool store_natural_geometry) +view_maximize(struct view *view, enum view_axis axis) { assert(view); @@ -1389,6 +1395,7 @@ view_maximize(struct view *view, enum view_axis axis, return; } + bool store_natural_geometry = !in_interactive_move(view); view_set_shade(view, false); if (axis != VIEW_AXIS_NONE) { @@ -1440,8 +1447,7 @@ view_toggle_maximize(struct view *view, enum view_axis axis) case VIEW_AXIS_HORIZONTAL: case VIEW_AXIS_VERTICAL: /* Toggle one axis (XOR) */ - view_maximize(view, view->maximized ^ axis, - /*store_natural_geometry*/ true); + view_maximize(view, view->maximized ^ axis); break; case VIEW_AXIS_BOTH: /* @@ -1449,8 +1455,7 @@ view_toggle_maximize(struct view *view, enum view_axis axis) * maximized, otherwise unmaximize. */ view_maximize(view, (view->maximized == VIEW_AXIS_BOTH) ? - VIEW_AXIS_NONE : VIEW_AXIS_BOTH, - /*store_natural_geometry*/ true); + VIEW_AXIS_NONE : VIEW_AXIS_BOTH); break; default: break; @@ -2064,7 +2069,7 @@ view_placement_parse(const char *policy) void view_snap_to_edge(struct view *view, enum lab_edge edge, - bool across_outputs, bool combine, bool store_natural_geometry) + bool across_outputs, bool combine) { assert(view); @@ -2078,6 +2083,7 @@ view_snap_to_edge(struct view *view, enum lab_edge edge, return; } + bool store_natural_geometry = !in_interactive_move(view); view_set_shade(view, false); if (lab_edge_is_cardinal(edge) && view->maximized == VIEW_AXIS_NONE @@ -2124,8 +2130,7 @@ view_snap_to_edge(struct view *view, enum lab_edge edge, if (view->maximized != VIEW_AXIS_NONE) { /* Unmaximize + keep using existing natural_geometry */ - view_maximize(view, VIEW_AXIS_NONE, - /*store_natural_geometry*/ false); + view_maximize(view, VIEW_AXIS_NONE); } else if (store_natural_geometry) { /* store current geometry as new natural_geometry */ view_store_natural_geometry(view); @@ -2139,8 +2144,7 @@ view_snap_to_edge(struct view *view, enum lab_edge edge, } void -view_snap_to_region(struct view *view, struct region *region, - bool store_natural_geometry) +view_snap_to_region(struct view *view, struct region *region) { assert(view); assert(region); @@ -2155,12 +2159,12 @@ view_snap_to_region(struct view *view, struct region *region, return; } + bool store_natural_geometry = !in_interactive_move(view); view_set_shade(view, false); if (view->maximized != VIEW_AXIS_NONE) { /* Unmaximize + keep using existing natural_geometry */ - view_maximize(view, VIEW_AXIS_NONE, - /*store_natural_geometry*/ false); + view_maximize(view, VIEW_AXIS_NONE); } else if (store_natural_geometry) { /* store current geometry as new natural_geometry */ view_store_natural_geometry(view); @@ -2193,7 +2197,7 @@ view_move_to_output(struct view *view, struct output *output) view_apply_tiled_geometry(view); } else if (view->tiled_region) { struct region *region = regions_from_name(view->tiled_region->name, output); - view_snap_to_region(view, region, /*store_natural_geometry*/ false); + view_snap_to_region(view, region); } } diff --git a/src/xdg.c b/src/xdg.c index 9ff24541..b239e8da 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -225,8 +225,7 @@ handle_commit(struct wl_listener *listener, void *data) set_fullscreen_from_request(view, &toplevel->requested); } if (toplevel->requested.maximized) { - view_maximize(view, VIEW_AXIS_BOTH, - /*store_natural_geometry*/ true); + view_maximize(view, VIEW_AXIS_BOTH); } return; } @@ -505,8 +504,7 @@ handle_request_maximize(struct wl_listener *listener, void *data) view_set_output(view, output_nearest_to_cursor(view->server)); } bool maximized = toplevel->requested.maximized; - view_maximize(view, maximized ? VIEW_AXIS_BOTH : VIEW_AXIS_NONE, - /*store_natural_geometry*/ true); + view_maximize(view, maximized ? VIEW_AXIS_BOTH : VIEW_AXIS_NONE); } static void diff --git a/src/xwayland.c b/src/xwayland.c index 17eb995e..5984a31b 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -470,7 +470,7 @@ handle_request_maximize(struct wl_listener *listener, void *data) if (surf->maximized_horz) { maximize |= VIEW_AXIS_HORIZONTAL; } - view_maximize(view, maximize, /*store_natural_geometry*/ true); + view_maximize(view, maximize); } static void @@ -704,7 +704,7 @@ handle_map_request(struct wl_listener *listener, void *data) if (xsurface->maximized_vert) { axis |= VIEW_AXIS_VERTICAL; } - view_maximize(view, axis, /*store_natural_geometry*/ true); + view_maximize(view, axis); /* * We could also call set_initial_position() here, but it's not * really necessary until the view is actually mapped (and at