aboutsummaryrefslogtreecommitdiff
path: root/tinywl
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2020-04-25 01:44:45 +0200
committerSimon Ser <contact@emersion.fr>2020-04-28 09:19:22 +0200
commitfa5d709fc3ea96b14163cdad435caccdbdd5bbda (patch)
tree7a50ecdd17ff21ea02b3d8a4aef2171f8a7918f8 /tinywl
parent9d650a7c1aece894a1366c7ad8f8e1c4ee8565a9 (diff)
tinywl: handle request set selection
Diffstat (limited to 'tinywl')
-rw-r--r--tinywl/tinywl.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c
index 3fe65c16..70e13233 100644
--- a/tinywl/tinywl.c
+++ b/tinywl/tinywl.c
@@ -50,6 +50,7 @@ struct tinywl_server {
struct wlr_seat *seat;
struct wl_listener new_input;
struct wl_listener request_cursor;
+ struct wl_listener request_set_selection;
struct wl_list keyboards;
enum tinywl_cursor_mode cursor_mode;
struct tinywl_view *grabbed_view;
@@ -298,6 +299,17 @@ static void seat_request_cursor(struct wl_listener *listener, void *data) {
}
}
+static void seat_request_set_selection(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 tinywl we always honor
+ */
+ struct tinywl_server *server = wl_container_of(
+ listener, server, request_set_selection);
+ struct wlr_seat_request_set_selection_event *event = data;
+ wlr_seat_set_selection(server->seat, event->source, event->serial);
+}
+
static bool view_at(struct tinywl_view *view,
double lx, double ly, struct wlr_surface **surface,
double *sx, double *sy) {
@@ -827,7 +839,9 @@ int main(int argc, char *argv[]) {
/* This creates some hands-off wlroots interfaces. The compositor is
* necessary for clients to allocate surfaces and the data device manager
* handles the clipboard. Each of these wlroots interfaces has room for you
- * to dig your fingers in and play with their behavior if you want. */
+ * to dig your fingers in and play with their behavior if you want. Note that
+ * the clients cannot set the selection directly without compositor approval,
+ * see the handling of the request_set_selection event below.*/
wlr_compositor_create(server.wl_display, server.renderer);
wlr_data_device_manager_create(server.wl_display);
@@ -904,6 +918,9 @@ int main(int argc, char *argv[]) {
server.request_cursor.notify = seat_request_cursor;
wl_signal_add(&server.seat->events.request_set_cursor,
&server.request_cursor);
+ server.request_set_selection.notify = seat_request_set_selection;
+ wl_signal_add(&server.seat->events.request_set_selection,
+ &server.request_set_selection);
/* Add a Unix socket to the Wayland display. */
const char *socket = wl_display_add_socket_auto(server.wl_display);