]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: Rediscover output in view_adjust_for_layout_change()
authorJohn Lindgren <john@jlindgren.net>
Mon, 20 Feb 2023 17:53:00 +0000 (12:53 -0500)
committerJohn Lindgren <john@jlindgren.net>
Mon, 20 Feb 2023 18:45:40 +0000 (13:45 -0500)
src/view.c

index e557ea641b80f8fd0b8a39666188d3ac389d17a5..98c19654326b4ed3d1910a372a83c6fdfa3e9079 100644 (file)
@@ -740,19 +740,26 @@ void
 view_adjust_for_layout_change(struct view *view)
 {
        assert(view);
-       if (view->fullscreen) {
-               if (output_is_usable(view->output)) {
-                       /* recompute fullscreen geometry */
-                       view_apply_fullscreen_geometry(view);
+
+       /* Exit fullscreen if output is lost */
+       bool was_fullscreen = view->fullscreen;
+       if (was_fullscreen && !output_is_usable(view->output)) {
+               set_fullscreen(view, false);
+       }
+
+       /* Rediscover nearest output as it may have changed */
+       view_discover_output(view);
+
+       if (!view_apply_special_geometry(view)) {
+               if (was_fullscreen) {
+                       view_apply_natural_geometry(view);
                } else {
-                       /* output is gone, exit fullscreen */
-                       view_set_fullscreen(view, false, NULL);
-               }
-       } else if (!view_apply_special_geometry(view)) {
-               /* reposition view if it's offscreen */
-               if (!wlr_output_layout_intersects(view->server->output_layout,
-                               NULL, &view->pending)) {
-                       view_center(view, NULL, NULL);
+                       /* reposition view if it's offscreen */
+                       if (!wlr_output_layout_intersects(
+                                       view->server->output_layout,
+                                       NULL, &view->pending)) {
+                               view_center(view, NULL, NULL);
+                       }
                }
        }
        if (view->toplevel.handle) {