]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/view.c: store outputs the view is visible on
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 31 Jan 2024 21:07:13 +0000 (22:07 +0100)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 6 Feb 2024 16:23:45 +0000 (17:23 +0100)
include/view.h
src/foreign.c
src/view.c

index 3d300dd6a74accd23398a684e65f9d337a16e697..fdedbe14e909d49ea69232eb42333d3e5103b9ee 100644 (file)
@@ -124,7 +124,7 @@ struct view {
        struct wl_list link;
 
        /*
-        * The output that the view is displayed on. Specifically:
+        * The primary output that the view is displayed on. Specifically:
         *
         *  - For floating views, this is the output nearest to the
         *    center of the view. It is computed automatically when the
@@ -139,6 +139,16 @@ struct view {
         * by calling view_set_output() beforehand.
         */
        struct output *output;
+
+       /*
+        * The outputs that the view is displayed on.
+        * This is used to notify the foreign toplevel
+        * implementation and to update the SSD invisible
+        * resize area.
+        * It is a bitset of output->scene_output->index.
+        */
+       uint64_t outputs;
+
        struct workspace *workspace;
        struct wlr_surface *surface;
        struct wlr_scene_tree *scene_tree;
@@ -460,6 +470,7 @@ void view_move_to_front(struct view *view);
 void view_move_to_back(struct view *view);
 struct view *view_get_root(struct view *view);
 void view_append_children(struct view *view, struct wl_array *children);
+bool view_on_output(struct view *view, struct output *output);
 
 /**
  * view_is_related() - determine if view and surface are owned by the
index 092752b3c8abbb5e9f07910af8d817507657a296..f76144a7ba4889fa29430da8c8beb1251b2291f2 100644 (file)
@@ -107,11 +107,10 @@ void
 foreign_toplevel_update_outputs(struct view *view)
 {
        assert(view->toplevel.handle);
-       struct wlr_output_layout *layout = view->server->output_layout;
+
        struct output *output;
        wl_list_for_each(output, &view->server->outputs, link) {
-               if (output_is_usable(output) && wlr_output_layout_intersects(
-                               layout, output->wlr_output, &view->current)) {
+               if (view_on_output(view, output)) {
                        wlr_foreign_toplevel_handle_v1_output_enter(
                                view->toplevel.handle, output->wlr_output);
                } else {
index 9773e07074ead6532cd8c8838f2423d880d7df12..066d4fa3dfcbeb4d00a5e7219ec45bfb15fd656c 100644 (file)
@@ -333,6 +333,34 @@ view_close(struct view *view)
        }
 }
 
+static void
+view_update_outputs(struct view *view)
+{
+       struct output *output;
+       struct wlr_output_layout *layout = view->server->output_layout;
+
+       view->outputs = 0;
+       wl_list_for_each(output, &view->server->outputs, link) {
+               if (output_is_usable(output) && wlr_output_layout_intersects(
+                               layout, output->wlr_output, &view->current)) {
+                       view->outputs |= (1ull << output->scene_output->index);
+               }
+       }
+
+       if (view->toplevel.handle) {
+               foreign_toplevel_update_outputs(view);
+       }
+}
+
+bool
+view_on_output(struct view *view, struct output *output)
+{
+       assert(view);
+       assert(output);
+       return output->scene_output
+                       && (view->outputs & (1ull << output->scene_output->index));
+}
+
 void
 view_move(struct view *view, int x, int y)
 {
@@ -358,11 +386,9 @@ view_moved(struct view *view)
        if (view_is_floating(view)) {
                view_discover_output(view, NULL);
        }
+       view_update_outputs(view);
        ssd_update_geometry(view->ssd);
        cursor_update_focus(view->server);
-       if (view->toplevel.handle) {
-               foreign_toplevel_update_outputs(view);
-       }
        if (rc.resize_indicator && view->server->grabbed_view == view) {
                resize_indicator_update(view);
        }
@@ -1467,9 +1493,7 @@ view_adjust_for_layout_change(struct view *view)
                }
        }
 
-       if (view->toplevel.handle) {
-               foreign_toplevel_update_outputs(view);
-       }
+       view_update_outputs(view);
 }
 
 void