From 57d50147a2ffd91e6c10c12162dd4a55c451485c Mon Sep 17 00:00:00 2001
From: nullsystem <nullsystem@noreply.codeberg.org>
Date: Wed, 19 Nov 2025 22:35:24 +0000
Subject: [PATCH] [PATCH] primaryselection - disable/enable primary selection

* Just simply adds a config to disable/enable primary selection
* 2025-11-19 update
---
 config.def.h | 1 +
 dwl.c        | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/config.def.h b/config.def.h
index 95c2afa..1d143db 100644
--- a/config.def.h
+++ b/config.def.h
@@ -71,6 +71,7 @@ static const int natural_scrolling = 0;
 static const int disable_while_typing = 1;
 static const int left_handed = 0;
 static const int middle_button_emulation = 0;
+static const int enable_primary_selection = 0;
 /* You can choose between:
 LIBINPUT_CONFIG_SCROLL_NO_SCROLL
 LIBINPUT_CONFIG_SCROLL_2FG
diff --git a/dwl.c b/dwl.c
index 12f441e..3a026b4 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2517,7 +2517,8 @@ setup(void)
 	wlr_export_dmabuf_manager_v1_create(dpy);
 	wlr_screencopy_manager_v1_create(dpy);
 	wlr_data_control_manager_v1_create(dpy);
-	wlr_primary_selection_v1_device_manager_create(dpy);
+	if (enable_primary_selection)
+		wlr_primary_selection_v1_device_manager_create(dpy);
 	wlr_viewporter_create(dpy);
 	wlr_single_pixel_buffer_manager_v1_create(dpy);
 	wlr_fractional_scale_manager_v1_create(dpy, 1);
@@ -2634,7 +2635,8 @@ setup(void)
 	seat = wlr_seat_create(dpy, "seat0");
 	wl_signal_add(&seat->events.request_set_cursor, &request_cursor);
 	wl_signal_add(&seat->events.request_set_selection, &request_set_sel);
-	wl_signal_add(&seat->events.request_set_primary_selection, &request_set_psel);
+	if (enable_primary_selection)
+		wl_signal_add(&seat->events.request_set_primary_selection, &request_set_psel);
 	wl_signal_add(&seat->events.request_start_drag, &request_start_drag);
 	wl_signal_add(&seat->events.start_drag, &start_drag);
 
-- 
2.52.0

