Support flicker free boot

Fixes #724
This commit is contained in:
Consolatis 2023-01-23 07:15:55 +01:00
parent 5ebaf3ff52
commit 6c42aced3d
5 changed files with 28 additions and 5 deletions

View 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.

View file

@ -11,6 +11,7 @@
<decoration>server</decoration>
<gap>0</gap>
<adaptiveSync>no</adaptiveSync>
<reuseOutputMode>no</reuseOutputMode>
<cycleViewPreview>no</cycleViewPreview>
<cycleViewOutlines>yes</cycleViewOutlines>
</core>

View 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;

View 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")) {

View 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