]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: move MoveRelative code from action.c and restore natural geometry
authorPh42oN <julle.ys.57@gmail.com>
Sun, 23 Jul 2023 09:04:36 +0000 (12:04 +0300)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 23 Jul 2023 22:55:08 +0000 (00:55 +0200)
include/view.h
src/action.c
src/view.c

index e5e5d36fb112f4160fa9944c6078d61646086b7d..128a4da0ab5653ba2946acef7aeec1f6b475c696 100644 (file)
@@ -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);
index 04abe1c661182faaaa361b5d6b799ad1b96e859f..f7920b31a8b04b3d6f30882cb5b09d9dfbf5a90f 100644 (file)
@@ -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:
index f41e078494145698d5fe28635ff102307229c3de..9f6c34b719897fc1a0c792bb46763b5e4d2dc26f 100644 (file)
@@ -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)
 {