]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: add move_to_output() function
authorJens Peters <jp7677@gmail.com>
Sun, 21 Jan 2024 22:44:27 +0000 (23:44 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 22 Jan 2024 22:27:08 +0000 (22:27 +0000)
include/view.h
src/view.c

index 2b81e609acc17d2bcdb6893bc8503434e9bd8a9a..2f8ffbee45a0d0fdf8989e09282e2fe1ab5a4538 100644 (file)
@@ -445,6 +445,7 @@ void view_shrink_to_edge(struct view *view, enum view_edge direction);
 void view_snap_to_edge(struct view *view, enum view_edge direction,
        bool across_outputs, bool store_natural_geometry);
 void view_snap_to_region(struct view *view, struct region *region, bool store_natural_geometry);
+void view_move_to_output(struct view *view, struct output *output);
 
 void view_move_to_front(struct view *view);
 void view_move_to_back(struct view *view);
index 1788f3ed91784301c295b4c43e8fbf8dd05e00e9..eaff46722daa2366c06b35720246dfdabd8e81ca 100644 (file)
@@ -1792,6 +1792,31 @@ view_snap_to_region(struct view *view, struct region *region,
        view_apply_region_geometry(view);
 }
 
+void
+view_move_to_output(struct view *view, struct output *output)
+{
+       assert(view);
+       if (view->fullscreen) {
+               return;
+       }
+
+       view_invalidate_last_layout_geometry(view);
+       view_set_output(view, output);
+       if (view_is_floating(view)) {
+               struct wlr_box output_area = output_usable_area_in_layout_coords(output);
+               view->pending.x = output_area.x;
+               view->pending.y = output_area.y;
+               view_place_initial(view, /* allow_cursor */ false);
+       } else if (view->maximized != VIEW_AXIS_NONE) {
+               view_apply_maximized_geometry(view);
+       } else if (view->tiled) {
+               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);
+       }
+}
+
 static void
 for_each_subview(struct view *view, void (*action)(struct view *))
 {