aboutsummaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/dwl.c b/dwl.c
index 33ab933..c5230de 100644
--- a/dwl.c
+++ b/dwl.c
@@ -22,6 +22,8 @@
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_pointer.h>
+#include <wlr/types/wlr_primary_selection.h>
+#include <wlr/types/wlr_primary_selection_v1.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_xdg_shell.h>
@@ -168,6 +170,7 @@ static void run(char *startup_cmd);
static void scalebox(struct wlr_box *box, float scale);
static Client *selclient(void);
static void setcursor(struct wl_listener *listener, void *data);
+static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating);
static void setlayout(const Arg *arg);
@@ -221,6 +224,7 @@ static struct wl_listener new_input = {.notify = inputdevice};
static struct wl_listener new_output = {.notify = createmon};
static struct wl_listener new_xdg_surface = {.notify = createnotify};
static struct wl_listener request_cursor = {.notify = setcursor};
+static struct wl_listener request_set_psel = {.notify = setpsel};
static struct wl_listener request_set_sel = {.notify = setsel};
/* configuration, allows nested code to access above variables */
@@ -1112,17 +1116,6 @@ setcursor(struct wl_listener *listener, void *data)
}
void
-setsel(struct wl_listener *listener, void *data)
-{
- /* This event is raised by the seat when a client wants to set the selection,
- * usually when the user copies something. wlroots allows compositors to
- * ignore such requests if they so choose, but in dwl we always honor
- */
- struct wlr_seat_request_set_selection_event *event = data;
- wlr_seat_set_selection(seat, event->source, event->serial);
-}
-
-void
setfloating(Client *c, int floating)
{
if (c->isfloating == floating)
@@ -1184,6 +1177,28 @@ setmon(Client *c, Monitor *m, unsigned int newtags)
}
void
+setpsel(struct wl_listener *listener, void *data)
+{
+ /* This event is raised by the seat when a client wants to set the selection,
+ * usually when the user copies something. wlroots allows compositors to
+ * ignore such requests if they so choose, but in dwl we always honor
+ */
+ struct wlr_seat_request_set_primary_selection_event *event = data;
+ wlr_seat_set_primary_selection(seat, event->source, event->serial);
+}
+
+void
+setsel(struct wl_listener *listener, void *data)
+{
+ /* This event is raised by the seat when a client wants to set the selection,
+ * usually when the user copies something. wlroots allows compositors to
+ * ignore such requests if they so choose, but in dwl we always honor
+ */
+ struct wlr_seat_request_set_selection_event *event = data;
+ wlr_seat_set_selection(seat, event->source, event->serial);
+}
+
+void
setup(void)
{
/* The backend is a wlroots feature which abstracts the underlying input and
@@ -1210,6 +1225,7 @@ setup(void)
* see the setsel() function. */
wlr_compositor_create(dpy, drw);
wlr_data_device_manager_create(dpy);
+ wlr_primary_selection_v1_device_manager_create(dpy);
/* Creates an output layout, which a wlroots utility for working with an
* arrangement of screens in a physical layout. */
@@ -1277,6 +1293,8 @@ setup(void)
&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);
}
void