]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Support flicker free boot
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 23 Jan 2023 06:15:55 +0000 (07:15 +0100)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 23 Jan 2023 21:10:22 +0000 (22:10 +0100)
Fixes #724

docs/labwc-config.5.scd
docs/rc.xml.all
include/config/rcxml.h
src/config/rcxml.c
src/output.c

index 070e4c042eec6250b15470b5fc47c426663ae157..8407cc7c5556ffc0cb2258f4702ca3369983583e 100644 (file)
@@ -70,6 +70,13 @@ The rest of this man page describes configuration options.
 *<core><adaptiveSync>* [yes|no]
        Enable adaptive sync. Default is no.
 
+*<core><reuseOutputMode>* [yes|no]
+       Try to re-use the existing output mode (resolution / refresh rate).
+       This may prevent unnecessary screenblank delays when starting labwc
+       (also known as flicker free boot). If the existing output mode can not
+       be used with labwc the preferred mode of the monitor is used instead.
+       Default is no.
+
 *<core><cycleViewPreview>* [yes|no]
        Preview the contents of the selected window when cycling between windows.
        Default is no.
index 2c86fb7da7ae5c9ae8b5856d2dec5f71cd700925..d829f2a11efe0fbb779d932c75be966d04a84260 100644 (file)
@@ -11,6 +11,7 @@
     <decoration>server</decoration>
     <gap>0</gap>
     <adaptiveSync>no</adaptiveSync>
+    <reuseOutputMode>no</reuseOutputMode>
     <cycleViewPreview>no</cycleViewPreview>
     <cycleViewOutlines>yes</cycleViewOutlines>
   </core>
index 975e67549347693c5affdf4ee62cbc5f2129bd30..56586b25383c3508591742aab3e3309b7c2c3b1c 100644 (file)
@@ -18,6 +18,7 @@ struct rcxml {
        bool xdg_shell_server_side_deco;
        int gap;
        bool adaptive_sync;
+       bool reuse_output_mode;
 
        /* focus */
        bool focus_follow_mouse;
index 068e6d3c1d6dc0e8b9bf39e9329b845a31cecaa6..4d3bf6d9d384a876e8998f3a37f3019f2aa5155d 100644 (file)
@@ -400,6 +400,8 @@ entry(xmlNode *node, char *nodename, char *content)
                rc.gap = atoi(content);
        } else if (!strcasecmp(nodename, "adaptiveSync.core")) {
                rc.adaptive_sync = get_bool(content);
+       } else if (!strcasecmp(nodename, "reuseOutputMode.core")) {
+               rc.reuse_output_mode = get_bool(content);
        } else if (!strcmp(nodename, "name.theme")) {
                rc.theme_name = xstrdup(content);
        } else if (!strcmp(nodename, "cornerradius.theme")) {
index 991a165337e1a92f3efc93b4fd49a02794118c66..0ae6f684dd9b509beababcb681fc2a81ae01bff0 100644 (file)
@@ -66,6 +66,12 @@ output_destroy_notify(struct wl_listener *listener, void *data)
 
 static void do_output_layout_change(struct server *server);
 
+static bool
+can_reuse_mode(struct wlr_output *wlr_output)
+{
+       return wlr_output->current_mode && wlr_output_test(wlr_output);
+}
+
 static void
 new_output_notify(struct wl_listener *listener, void *data)
 {
@@ -109,11 +115,17 @@ new_output_notify(struct wl_listener *listener, void *data)
        wlr_log(WLR_DEBUG, "enable output");
        wlr_output_enable(wlr_output, true);
 
-       /* The mode is a tuple of (width, height, refresh rate). */
-       wlr_log(WLR_DEBUG, "set preferred mode");
-       struct wlr_output_mode *preferred_mode =
-               wlr_output_preferred_mode(wlr_output);
-       wlr_output_set_mode(wlr_output, preferred_mode);
+       /*
+        * Try to re-use the existing mode if configured to do so.
+        * Failing that, try to set the preferred mode.
+        */
+       struct wlr_output_mode *preferred_mode = NULL;
+       if (!rc.reuse_output_mode || !can_reuse_mode(wlr_output)) {
+               wlr_log(WLR_DEBUG, "set preferred mode");
+               /* The mode is a tuple of (width, height, refresh rate). */
+               preferred_mode = wlr_output_preferred_mode(wlr_output);
+               wlr_output_set_mode(wlr_output, preferred_mode);
+       }
 
        /*
         * Sometimes the preferred mode is not available due to hardware