remove always and fullscreen tearing options and add ToggleTearing action

This commit is contained in:
Ph42oN 2024-01-04 11:37:29 +02:00
parent 8b7e953a25
commit acbcf4f497
7 changed files with 26 additions and 54 deletions

View file

@ -154,6 +154,9 @@ Actions are used in menus and keyboard/mouse bindings.
the usual keybinds will function again until switching back to the the usual keybinds will function again until switching back to the
original window. There can be multiple windows with this mode set. original window. There can be multiple windows with this mode set.
*<action name="ToggleTearing" />*
Toggles tearing for the focused window.
*<action name="FocusOutput" output="HDMI-A-1" />* *<action name="FocusOutput" output="HDMI-A-1" />*
Give focus to topmost window on given output and warp the cursor Give focus to topmost window on given output and warp the cursor
to the center of the window. If the given output does not contain to the center of the window. If the given output does not contain

View file

@ -129,16 +129,12 @@ this is for compatibility with Openbox.
*fullscreen* enables adaptive sync whenever a window is in fullscreen *fullscreen* enables adaptive sync whenever a window is in fullscreen
mode. mode.
*<core><allowTearing>* [yes|no|fullscreen|always] *<core><allowTearing>* [yes|no]
Allow tearing to reduce input lag. Default is no. Allow tearing to reduce input lag. Default is no.
This open requires setting the environment variable WLR_DRM_NO_ATOMIC=1. This option requires setting the environment variable WLR_DRM_NO_ATOMIC=1.
*yes* allow tearing if the active window requests it. *yes* allow tearing if the active window requests it,
or its enabled with action ToggleTearing.
*fullscreen* allow tearing if the active window requests it or is in
fullscreen mode.
*always* allow tearing regardless of window status.
*<core><reuseOutputMode>* [yes|no] *<core><reuseOutputMode>* [yes|no]
Try to re-use the existing output mode (resolution / refresh rate). Try to re-use the existing output mode (resolution / refresh rate).

View file

@ -34,13 +34,6 @@ enum adaptive_sync_mode {
LAB_ADAPTIVE_SYNC_FULLSCREEN, LAB_ADAPTIVE_SYNC_FULLSCREEN,
}; };
enum tearing_mode {
LAB_TEARING_DISABLED = 0,
LAB_TEARING_ENABLED,
LAB_TEARING_FULLSCREEN,
LAB_TEARING_ALWAYS,
};
struct usable_area_override { struct usable_area_override {
struct border margin; struct border margin;
char *output; char *output;
@ -60,7 +53,7 @@ struct rcxml {
bool xdg_shell_server_side_deco; bool xdg_shell_server_side_deco;
int gap; int gap;
enum adaptive_sync_mode adaptive_sync; enum adaptive_sync_mode adaptive_sync;
enum tearing_mode allow_tearing; bool allow_tearing;
bool reuse_output_mode; bool reuse_output_mode;
enum view_placement_policy placement_policy; enum view_placement_policy placement_policy;

View file

@ -102,6 +102,7 @@ enum action_type {
ACTION_TYPE_VIRTUAL_OUTPUT_ADD, ACTION_TYPE_VIRTUAL_OUTPUT_ADD,
ACTION_TYPE_VIRTUAL_OUTPUT_REMOVE, ACTION_TYPE_VIRTUAL_OUTPUT_REMOVE,
ACTION_TYPE_AUTO_PLACE, ACTION_TYPE_AUTO_PLACE,
ACTION_TYPE_TOGGLE_TEARING,
}; };
const char *action_names[] = { const char *action_names[] = {
@ -149,6 +150,7 @@ const char *action_names[] = {
"VirtualOutputAdd", "VirtualOutputAdd",
"VirtualOutputRemove", "VirtualOutputRemove",
"AutoPlace", "AutoPlace",
"ToggleTearing",
NULL NULL
}; };
@ -951,6 +953,12 @@ actions_run(struct view *activator, struct server *server,
} }
} }
break; break;
case ACTION_TYPE_TOGGLE_TEARING:
if (view) {
view->tearing_hint = !view->tearing_hint;
}
wlr_log(WLR_DEBUG, "tearing: %d", view->tearing_hint);
break;
case ACTION_TYPE_INVALID: case ACTION_TYPE_INVALID:
wlr_log(WLR_ERROR, "Not executing unknown action"); wlr_log(WLR_ERROR, "Not executing unknown action");
break; break;

View file

@ -625,28 +625,6 @@ set_adaptive_sync_mode(const char *str, enum adaptive_sync_mode *variable)
} }
} }
static void
set_tearing_mode(const char *str, enum tearing_mode *variable)
{
if (!strcasecmp(str, "fullscreen")) {
*variable = LAB_TEARING_FULLSCREEN;
} else if (!strcasecmp(str, "always")) {
*variable = LAB_TEARING_ALWAYS;
} else {
int ret = parse_bool(str, -1);
if (ret == 1) {
*variable = LAB_TEARING_ENABLED;
} else {
*variable = LAB_TEARING_DISABLED;
}
}
if (*variable != LAB_TEARING_DISABLED &&
strcmp(getenv("WLR_DRM_NO_ATOMIC"), "1")) {
*variable = LAB_TEARING_DISABLED;
wlr_log(WLR_INFO, "WLR_DRM_NO_ATOMIC is not 1, tearing disabled");
}
}
static void static void
entry(xmlNode *node, char *nodename, char *content) entry(xmlNode *node, char *nodename, char *content)
{ {
@ -750,7 +728,11 @@ entry(xmlNode *node, char *nodename, char *content)
} else if (!strcasecmp(nodename, "adaptiveSync.core")) { } else if (!strcasecmp(nodename, "adaptiveSync.core")) {
set_adaptive_sync_mode(content, &rc.adaptive_sync); set_adaptive_sync_mode(content, &rc.adaptive_sync);
} else if (!strcasecmp(nodename, "allowTearing.core")) { } else if (!strcasecmp(nodename, "allowTearing.core")) {
set_tearing_mode(content, &rc.allow_tearing); set_bool(content, &rc.allow_tearing);
if (rc.allow_tearing && strcmp(getenv("WLR_DRM_NO_ATOMIC"), "1")) {
rc.allow_tearing = false;
wlr_log(WLR_INFO, "WLR_DRM_NO_ATOMIC is not 1, tearing disabled");
}
} else if (!strcasecmp(nodename, "reuseOutputMode.core")) { } else if (!strcasecmp(nodename, "reuseOutputMode.core")) {
set_bool(content, &rc.reuse_output_mode); set_bool(content, &rc.reuse_output_mode);
} else if (!strcmp(nodename, "policy.placement")) { } else if (!strcmp(nodename, "policy.placement")) {

View file

@ -33,31 +33,21 @@ get_tearing_preference(struct output *output)
struct server *server = output->server; struct server *server = output->server;
/* Never allow tearing when disabled */ /* Never allow tearing when disabled */
if (rc.allow_tearing == LAB_TEARING_DISABLED) { if (!rc.allow_tearing) {
return false; return false;
} }
/* Allows allow tearing when forced */
if (rc.allow_tearing == LAB_TEARING_ALWAYS) {
return true;
}
/* Tearing is only allowed for the output with the active view */ /* Tearing is only allowed for the output with the active view */
if (!server->active_view || server->active_view->output != output) { if (!server->active_view || server->active_view->output != output) {
return false; return false;
} }
/* If the active view requests tearing, allow it */ /* If the active view requests tearing, or it
has been requested with action, allow it */
if (server->active_view->tearing_hint) { if (server->active_view->tearing_hint) {
return true; return true;
} }
/* If the active view is fullscreen, allow tearing if configured */
if (rc.allow_tearing == LAB_TEARING_FULLSCREEN &&
server->active_view->fullscreen) {
return true;
}
return false; return false;
} }

View file

@ -14,8 +14,8 @@ set_tearing_hint(struct wl_listener *listener, void *data)
{ {
struct tearing_controller *controller = wl_container_of(listener, controller, set_hint); struct tearing_controller *controller = wl_container_of(listener, controller, set_hint);
struct view *view = view_from_wlr_surface(controller->tearing_control->surface); struct view *view = view_from_wlr_surface(controller->tearing_control->surface);
if (view) { if (view && controller->tearing_control->hint) {
view->tearing_hint = controller->tearing_control->hint; view->tearing_hint = true;
} }
} }