]> git.mdlowis.com Git - proto/labwc.git/commitdiff
output: factor out output_set_has_fullscreen_view()
authorJohn Lindgren <john@jlindgren.net>
Sat, 8 Nov 2025 14:40:26 +0000 (09:40 -0500)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 9 Nov 2025 05:46:59 +0000 (06:46 +0100)
include/output.h
src/output.c
src/view-impl-common.c
src/view.c

index 7c34abc5646dbe0dd645ddbfa861de59d19b4aac..fe11b0910d1e649f825665b6659684d7b3d37116 100644 (file)
@@ -69,4 +69,13 @@ void handle_output_power_manager_set_mode(struct wl_listener *listener,
        void *data);
 void output_enable_adaptive_sync(struct output *output, bool enabled);
 
+/**
+ * Notifies whether a fullscreen view is displayed on the given output.
+ * Depending on user config, this may enable/disable adaptive sync.
+ *
+ * Does nothing if output is NULL or disabled.
+ */
+void output_set_has_fullscreen_view(struct output *output,
+       bool has_fullscreen_view);
+
 #endif // LABWC_OUTPUT_H
index 70266d5cc44ce88e950b7c760d9e4e80ec19b7c3..f74a56971d125aeaba89654584a835c48ca80f6c 100644 (file)
@@ -1144,3 +1144,15 @@ output_enable_adaptive_sync(struct output *output, bool enabled)
                        enabled ? "en" : "dis", output->wlr_output->name);
        }
 }
+
+void
+output_set_has_fullscreen_view(struct output *output, bool has_fullscreen_view)
+{
+       if (rc.adaptive_sync != LAB_ADAPTIVE_SYNC_FULLSCREEN
+                       || !output_is_usable(output)) {
+               return;
+       }
+       /* Enable adaptive sync if view is fullscreen */
+       output_enable_adaptive_sync(output, has_fullscreen_view);
+       output_state_commit(output);
+}
index efc749bfc7ea486a6e83721da71383b821163113..2159058828cb1268cfdbf1ee9fa81baf1ad45db1 100644 (file)
@@ -1,11 +1,9 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* view-impl-common.c: common code for shell view->impl functions */
 #include "view-impl-common.h"
-#include "config/rcxml.h"
 #include "foreign-toplevel/foreign.h"
 #include "labwc.h"
 #include "output.h"
-#include "output-state.h"
 #include "view.h"
 #include "window-rules.h"
 
@@ -65,10 +63,8 @@ view_impl_unmap(struct view *view)
         * views. It should probably be combined with the existing
         * logic in desktop_update_top_layer_visibility().
         */
-       if (view->fullscreen && rc.adaptive_sync == LAB_ADAPTIVE_SYNC_FULLSCREEN
-                       && output_is_usable(view->output)) {
-               output_enable_adaptive_sync(view->output, false);
-               output_state_commit(view->output);
+       if (view->fullscreen) {
+               output_set_has_fullscreen_view(view->output, false);
        }
 }
 
index 5dac1f94f393930007293e7ce19f954105958326..f0b053a48888e487a7f45829730dd130a596f518 100644 (file)
@@ -21,7 +21,6 @@
 #include "menu/menu.h"
 #include "osd.h"
 #include "output.h"
-#include "output-state.h"
 #include "placement.h"
 #include "regions.h"
 #include "resize-indicator.h"
@@ -513,20 +512,6 @@ view_discover_output(struct view *view, struct wlr_box *geometry)
        return false;
 }
 
-static void
-set_adaptive_sync_fullscreen(struct view *view)
-{
-       if (!output_is_usable(view->output)) {
-               return;
-       }
-       if (rc.adaptive_sync != LAB_ADAPTIVE_SYNC_FULLSCREEN) {
-               return;
-       }
-       /* Enable adaptive sync if view is fullscreen */
-       output_enable_adaptive_sync(view->output, view->fullscreen);
-       output_state_commit(view->output);
-}
-
 void
 view_set_activated(struct view *view, bool activated)
 {
@@ -548,7 +533,7 @@ view_set_activated(struct view *view, bool activated)
                        keyboard_update_layout(&view->server->seat, view->keyboard_layout);
                }
        }
-       set_adaptive_sync_fullscreen(view);
+       output_set_has_fullscreen_view(view->output, view->fullscreen);
 }
 
 void
@@ -1786,7 +1771,7 @@ view_set_fullscreen(struct view *view, bool fullscreen)
        } else {
                view_apply_special_geometry(view);
        }
-       set_adaptive_sync_fullscreen(view);
+       output_set_has_fullscreen_view(view->output, view->fullscreen);
 }
 
 static bool