add primary selection support too!

This commit is contained in:
Devin J. Pohly 2020-05-09 22:45:22 -05:00
parent 0b0dd6b63c
commit 0bd4eb8ff3

40
dwl.c
View file

@ -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 */
@ -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