From 75406bb93b96091d30e52922d0f319530fe65471 Mon Sep 17 00:00:00 2001 From: emersion Date: Sun, 2 Dec 2018 22:57:05 +0100 Subject: [PATCH] Update for swaywm/wlroots#1402 --- include/sway/input/seat.h | 2 ++ sway/input/seat.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index d2f14895..ef85b67f 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -76,6 +76,8 @@ struct sway_seat { struct wl_listener focus_destroy; struct wl_listener new_node; struct wl_listener new_drag_icon; + struct wl_listener request_set_selection; + struct wl_listener request_set_primary_selection; struct wl_list devices; // sway_seat_device::link diff --git a/sway/input/seat.c b/sway/input/seat.c index 1a4ccd77..fd5eda2d 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -5,10 +5,12 @@ #include #include #include +#include #include +#include #include -#include "log.h" #include "config.h" +#include "log.h" #include "sway/debug.h" #include "sway/desktop.h" #include "sway/input/cursor.h" @@ -44,6 +46,8 @@ void seat_destroy(struct sway_seat *seat) { sway_cursor_destroy(seat->cursor); wl_list_remove(&seat->new_node.link); wl_list_remove(&seat->new_drag_icon.link); + wl_list_remove(&seat->request_set_selection.link); + wl_list_remove(&seat->request_set_primary_selection.link); wl_list_remove(&seat->link); wlr_seat_destroy(seat->wlr_seat); free(seat->prev_workspace_name); @@ -311,6 +315,22 @@ static void handle_new_drag_icon(struct wl_listener *listener, void *data) { seatop_abort(seat); } +static void handle_request_set_selection(struct wl_listener *listener, + void *data) { + struct sway_seat *seat = + wl_container_of(listener, seat, request_set_selection); + struct wlr_seat_request_set_selection_event *event = data; + wlr_seat_set_selection(seat->wlr_seat, event->source, event->serial); +} + +static void handle_request_set_primary_selection(struct wl_listener *listener, + void *data) { + struct sway_seat *seat = + wl_container_of(listener, seat, request_set_primary_selection); + struct wlr_seat_request_set_primary_selection_event *event = data; + wlr_seat_set_primary_selection(seat->wlr_seat, event->source, event->serial); +} + static void collect_focus_iter(struct sway_node *node, void *data) { struct sway_seat *seat = data; struct sway_seat_node *seat_node = seat_node_from_node(seat, node); @@ -371,6 +391,15 @@ struct sway_seat *seat_create(const char *seat_name) { wl_signal_add(&seat->wlr_seat->events.new_drag_icon, &seat->new_drag_icon); seat->new_drag_icon.notify = handle_new_drag_icon; + wl_signal_add(&seat->wlr_seat->events.request_set_selection, + &seat->request_set_selection); + seat->request_set_selection.notify = handle_request_set_selection; + + wl_signal_add(&seat->wlr_seat->events.request_set_primary_selection, + &seat->request_set_primary_selection); + seat->request_set_primary_selection.notify = + handle_request_set_primary_selection; + wl_list_init(&seat->devices); wl_list_insert(&server.input->seats, &seat->link);