From cb4afadd0143f599f39603d3685723e16c9df401 Mon Sep 17 00:00:00 2001 From: Ph42oN Date: Sun, 23 Jul 2023 12:04:36 +0300 Subject: [PATCH] view: move MoveRelative code from action.c and restore natural geometry --- include/view.h | 1 + src/action.c | 5 ++--- src/view.c | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/view.h b/include/view.h index e5e5d36fb..128a4da0a 100644 --- a/include/view.h +++ b/include/view.h @@ -165,6 +165,7 @@ void view_close(struct view *view); void view_move_resize(struct view *view, struct wlr_box geo); void view_resize_relative(struct view *view, int left, int right, int top, int bottom); +void view_move_relative(struct view *view, int x, int y); void view_move(struct view *view, int x, int y); void view_moved(struct view *view); void view_minimize(struct view *view, bool minimized); diff --git a/src/action.c b/src/action.c index 04abe1c66..f7920b31a 100644 --- a/src/action.c +++ b/src/action.c @@ -667,11 +667,10 @@ actions_run(struct view *activator, struct server *server, } break; case ACTION_TYPE_MOVE_RELATIVE: - if (view && !view->fullscreen) { + if (view) { int x = get_arg_value_int(action, "x", 0); int y = get_arg_value_int(action, "y", 0); - view_maximize(view, false, false); - view_move(view, view->pending.x + x, view->pending.y + y); + view_move_relative(view, x, y); } break; case ACTION_TYPE_SEND_TO_DESKTOP: diff --git a/src/view.c b/src/view.c index f41e07849..9f6c34b71 100644 --- a/src/view.c +++ b/src/view.c @@ -206,8 +206,9 @@ view_move_resize(struct view *view, struct wlr_box geo) void view_resize_relative(struct view *view, int left, int right, int top, int bottom) { - if (view->fullscreen || view->maximized) + if (view->fullscreen || view->maximized) { return; + } struct wlr_box newgeo = view->pending; newgeo.x -= left; newgeo.width += left + right; @@ -217,6 +218,20 @@ view_resize_relative(struct view *view, int left, int right, int top, int bottom view_set_untiled(view); } +void +view_move_relative(struct view *view, int x, int y) +{ + if (view->fullscreen) { + return; + } + view_maximize(view, false, /*store_natural_geometry*/ false); + if (view_is_tiled(view)) { + view_set_untiled(view); + view_restore_to(view, view->natural_geometry); + } + view_move(view, view->pending.x + x, view->pending.y + y); +} + void view_adjust_size(struct view *view, int *w, int *h) {