mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
config: add adaptive sync fullscreen option
This commit is contained in:
parent
21234a5763
commit
08045d7843
5 changed files with 63 additions and 12 deletions
|
|
@ -610,6 +610,21 @@ enum_font_place(const char *place)
|
|||
return FONT_PLACE_UNKNOWN;
|
||||
}
|
||||
|
||||
static void
|
||||
set_adaptive_sync_mode(const char *str, enum adaptive_sync_mode *variable)
|
||||
{
|
||||
if (!strcasecmp(str, "fullscreen")) {
|
||||
*variable = LAB_ADAPTIVE_SYNC_FULLSCREEN;
|
||||
} else {
|
||||
int ret = parse_bool(str, -1);
|
||||
if (ret == 1) {
|
||||
*variable = LAB_ADAPTIVE_SYNC_ENABLED;
|
||||
} else {
|
||||
*variable = LAB_ADAPTIVE_SYNC_DISABLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
entry(xmlNode *node, char *nodename, char *content)
|
||||
{
|
||||
|
|
@ -711,7 +726,7 @@ entry(xmlNode *node, char *nodename, char *content)
|
|||
} else if (!strcmp(nodename, "gap.core")) {
|
||||
rc.gap = atoi(content);
|
||||
} else if (!strcasecmp(nodename, "adaptiveSync.core")) {
|
||||
set_bool(content, &rc.adaptive_sync);
|
||||
set_adaptive_sync_mode(content, &rc.adaptive_sync);
|
||||
} else if (!strcasecmp(nodename, "reuseOutputMode.core")) {
|
||||
set_bool(content, &rc.reuse_output_mode);
|
||||
} else if (!strcmp(nodename, "policy.placement")) {
|
||||
|
|
|
|||
33
src/output.c
33
src/output.c
|
|
@ -249,15 +249,8 @@ new_output_notify(struct wl_listener *listener, void *data)
|
|||
}
|
||||
}
|
||||
|
||||
if (rc.adaptive_sync) {
|
||||
wlr_output_enable_adaptive_sync(wlr_output, true);
|
||||
if (!wlr_output_test(wlr_output)) {
|
||||
wlr_output_enable_adaptive_sync(wlr_output, false);
|
||||
wlr_log(WLR_DEBUG,
|
||||
"failed to enable adaptive sync for output %s", wlr_output->name);
|
||||
} else {
|
||||
wlr_log(WLR_INFO, "adaptive sync enabled for output %s", wlr_output->name);
|
||||
}
|
||||
if (rc.adaptive_sync == LAB_ADAPTIVE_SYNC_ENABLED) {
|
||||
output_enable_adaptive_sync(wlr_output, true);
|
||||
}
|
||||
|
||||
wlr_output_commit(wlr_output);
|
||||
|
|
@ -415,7 +408,10 @@ output_config_apply(struct server *server,
|
|||
}
|
||||
wlr_output_set_scale(o, head->state.scale);
|
||||
wlr_output_set_transform(o, head->state.transform);
|
||||
wlr_output_enable_adaptive_sync(o, head->state.adaptive_sync_enabled);
|
||||
if (rc.adaptive_sync == LAB_ADAPTIVE_SYNC_ENABLED) {
|
||||
output_enable_adaptive_sync(o,
|
||||
head->state.adaptive_sync_enabled);
|
||||
}
|
||||
}
|
||||
if (!wlr_output_commit(o)) {
|
||||
wlr_log(WLR_ERROR, "Output config commit failed");
|
||||
|
|
@ -810,3 +806,20 @@ output_remove_virtual(struct server *server, const char *output_name)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
output_enable_adaptive_sync(struct wlr_output *output, bool enabled)
|
||||
{
|
||||
if (output->pending.adaptive_sync_enabled == enabled) {
|
||||
return;
|
||||
}
|
||||
wlr_output_enable_adaptive_sync(output, enabled);
|
||||
if (!wlr_output_test(output)) {
|
||||
wlr_output_enable_adaptive_sync(output, false);
|
||||
wlr_log(WLR_DEBUG,
|
||||
"failed to enable adaptive sync for output %s", output->name);
|
||||
} else {
|
||||
wlr_log(WLR_INFO, "adaptive sync %sabled for output %s",
|
||||
enabled ? "en" : "dis", output->name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16
src/view.c
16
src/view.c
|
|
@ -262,6 +262,17 @@ view_discover_output(struct view *view)
|
|||
view->current.y + view->current.height / 2);
|
||||
}
|
||||
|
||||
static void
|
||||
set_adaptive_sync_fullscreen(struct view *view)
|
||||
{
|
||||
if (rc.adaptive_sync != LAB_ADAPTIVE_SYNC_FULLSCREEN) {
|
||||
return;
|
||||
}
|
||||
/* Enable adaptive sync if view is fullscreen */
|
||||
output_enable_adaptive_sync(view->output->wlr_output, view->fullscreen);
|
||||
wlr_output_commit(view->output->wlr_output);
|
||||
}
|
||||
|
||||
void
|
||||
view_set_activated(struct view *view, bool activated)
|
||||
{
|
||||
|
|
@ -285,6 +296,7 @@ view_set_activated(struct view *view, bool activated)
|
|||
keyboard_update_layout(&view->server->seat, view->keyboard_layout);
|
||||
}
|
||||
}
|
||||
set_adaptive_sync_fullscreen(view);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1186,6 +1198,7 @@ view_set_fullscreen(struct view *view, bool fullscreen)
|
|||
} else {
|
||||
view_apply_special_geometry(view);
|
||||
}
|
||||
set_adaptive_sync_fullscreen(view);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1853,6 +1866,9 @@ view_destroy(struct view *view)
|
|||
if (view->fullscreen && view->output) {
|
||||
view->fullscreen = false;
|
||||
desktop_update_top_layer_visiblity(server);
|
||||
if (rc.adaptive_sync == LAB_ADAPTIVE_SYNC_FULLSCREEN) {
|
||||
wlr_output_enable_adaptive_sync(view->output->wlr_output, false);
|
||||
}
|
||||
}
|
||||
|
||||
/* If we spawned a window menu, close it */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue