From 145de9193237bf02cb279b551b9b974a2cec53a1 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Fri, 13 Jun 2025 20:08:52 +0100 Subject: [PATCH] config: add ...to enable/disable primary selection clipboard support. This only works on launch. The reason it is useful to be able to disable this is that some clients (like browsers) support middle-button-click to start scrolling up/down. With some clients can be disabled via gsettings set org.gnome.desktop.interface gtk-enable-primary-paste false ...but for others (like chromium and electron based programs) a compositor setting is required. Fixes: #2815 --- docs/labwc-config.5.scd | 7 +++++++ docs/rc.xml.all | 1 + include/config/rcxml.h | 1 + src/config/rcxml.c | 3 +++ src/server.c | 4 +++- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index 90276203..28a319c2 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -177,6 +177,7 @@ this is for compatibility with Openbox. yes no no + yes ``` @@ -235,6 +236,12 @@ this is for compatibility with Openbox. Note: changing this setting requires a restart of labwc. +** [yes|no] + Enable or disable the primary selection clipboard. May only be + configured at launch. This enables autoscroll (middle-click to scroll + up/down) in Chromium and electron based clients without inadvertantly + pasting the primary clipboard. Default is yes. + ## PLACEMENT ``` diff --git a/docs/rc.xml.all b/docs/rc.xml.all index 4d137f80..5ac26e5f 100644 --- a/docs/rc.xml.all +++ b/docs/rc.xml.all @@ -15,6 +15,7 @@ yes no no + yes diff --git a/include/config/rcxml.h b/include/config/rcxml.h index 23312f79..05f75098 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -73,6 +73,7 @@ struct rcxml { bool reuse_output_mode; enum view_placement_policy placement_policy; bool xwayland_persistence; + bool primary_selection; int placement_cascade_offset_x; int placement_cascade_offset_y; diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 717ff311..697f1f78 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -1161,6 +1161,8 @@ entry(xmlNode *node, char *nodename, char *content, struct parser_state *state) set_bool(content, &rc.reuse_output_mode); } else if (!strcasecmp(nodename, "xwaylandPersistence.core")) { set_bool(content, &rc.xwayland_persistence); + } else if (!strcasecmp(nodename, "primarySelection.core")) { + set_bool(content, &rc.primary_selection); } else if (!strcmp(nodename, "policy.placement")) { enum view_placement_policy policy = view_placement_parse(content); if (policy != LAB_PLACE_INVALID) { @@ -1549,6 +1551,7 @@ rcxml_init(void) rc.auto_enable_outputs = true; rc.reuse_output_mode = false; rc.xwayland_persistence = false; + rc.primary_selection = true; init_font_defaults(&rc.font_activewindow); init_font_defaults(&rc.font_inactivewindow); diff --git a/src/server.c b/src/server.c index e7b0cbb8..554398b8 100644 --- a/src/server.c +++ b/src/server.c @@ -632,7 +632,9 @@ server_init(struct server *server) * * https://wayfire.org/2020/08/04/Wayfire-0-5.html */ - wlr_primary_selection_v1_device_manager_create(server->wl_display); + if (rc.primary_selection) { + wlr_primary_selection_v1_device_manager_create(server->wl_display); + } server->input_method_manager = wlr_input_method_manager_v2_create( server->wl_display);