From 0bd4eb8ff36141c7d6a465dfcf1247c186316954 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 9 May 2020 22:45:22 -0500 Subject: add primary selection support too! --- dwl.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index 33ab933..c5230de 100644 --- a/dwl.c +++ b/dwl.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -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 */ @@ -1111,17 +1115,6 @@ setcursor(struct wl_listener *listener, void *data) event->hotspot_x, event->hotspot_y); } -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) { @@ -1183,6 +1176,28 @@ setmon(Client *c, Monitor *m, unsigned int newtags) focusclient(lastfocused(), NULL, 1); } +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) { @@ -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 -- cgit v1.2.3