diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd
index 6558d0fc..869fee85 100644
--- a/docs/labwc-actions.5.scd
+++ b/docs/labwc-actions.5.scd
@@ -154,6 +154,9 @@ Actions are used in menus and keyboard/mouse bindings.
the usual keybinds will function again until switching back to the
original window. There can be multiple windows with this mode set.
+**
+ Toggles tearing for the focused window.
+
**
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
diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd
index d1e052f6..334e159a 100644
--- a/docs/labwc-config.5.scd
+++ b/docs/labwc-config.5.scd
@@ -129,16 +129,12 @@ this is for compatibility with Openbox.
*fullscreen* enables adaptive sync whenever a window is in fullscreen
mode.
-** [yes|no|fullscreen|always]
+** [yes|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.
-
- *fullscreen* allow tearing if the active window requests it or is in
- fullscreen mode.
-
- *always* allow tearing regardless of window status.
+ *yes* allow tearing if the active window requests it,
+ or its enabled with action ToggleTearing.
** [yes|no]
Try to re-use the existing output mode (resolution / refresh rate).
diff --git a/include/config/rcxml.h b/include/config/rcxml.h
index f3578c17..037d83ec 100644
--- a/include/config/rcxml.h
+++ b/include/config/rcxml.h
@@ -34,13 +34,6 @@ enum adaptive_sync_mode {
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 border margin;
char *output;
@@ -60,7 +53,7 @@ struct rcxml {
bool xdg_shell_server_side_deco;
int gap;
enum adaptive_sync_mode adaptive_sync;
- enum tearing_mode allow_tearing;
+ bool allow_tearing;
bool reuse_output_mode;
enum view_placement_policy placement_policy;
diff --git a/src/action.c b/src/action.c
index 2259ba7d..a034789d 100644
--- a/src/action.c
+++ b/src/action.c
@@ -102,6 +102,7 @@ enum action_type {
ACTION_TYPE_VIRTUAL_OUTPUT_ADD,
ACTION_TYPE_VIRTUAL_OUTPUT_REMOVE,
ACTION_TYPE_AUTO_PLACE,
+ ACTION_TYPE_TOGGLE_TEARING,
};
const char *action_names[] = {
@@ -149,6 +150,7 @@ const char *action_names[] = {
"VirtualOutputAdd",
"VirtualOutputRemove",
"AutoPlace",
+ "ToggleTearing",
NULL
};
@@ -951,6 +953,12 @@ actions_run(struct view *activator, struct server *server,
}
}
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:
wlr_log(WLR_ERROR, "Not executing unknown action");
break;
diff --git a/src/config/rcxml.c b/src/config/rcxml.c
index 11bd7f77..da2d20b0 100644
--- a/src/config/rcxml.c
+++ b/src/config/rcxml.c
@@ -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
entry(xmlNode *node, char *nodename, char *content)
{
@@ -750,7 +728,11 @@ entry(xmlNode *node, char *nodename, char *content)
} else if (!strcasecmp(nodename, "adaptiveSync.core")) {
set_adaptive_sync_mode(content, &rc.adaptive_sync);
} 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")) {
set_bool(content, &rc.reuse_output_mode);
} else if (!strcmp(nodename, "policy.placement")) {
diff --git a/src/output.c b/src/output.c
index 0f0bb10b..1a698911 100644
--- a/src/output.c
+++ b/src/output.c
@@ -33,31 +33,21 @@ get_tearing_preference(struct output *output)
struct server *server = output->server;
/* Never allow tearing when disabled */
- if (rc.allow_tearing == LAB_TEARING_DISABLED) {
+ if (!rc.allow_tearing) {
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 */
if (!server->active_view || server->active_view->output != output) {
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) {
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;
}
diff --git a/src/tearing.c b/src/tearing.c
index 443149bc..dc9f7439 100644
--- a/src/tearing.c
+++ b/src/tearing.c
@@ -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 view *view = view_from_wlr_surface(controller->tearing_control->surface);
- if (view) {
- view->tearing_hint = controller->tearing_control->hint;
+ if (view && controller->tearing_control->hint) {
+ view->tearing_hint = true;
}
}