diff options
author | emersion <contact@emersion.fr> | 2018-11-29 19:30:04 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-01-24 11:38:23 +0100 |
commit | 4cb0697e576820774013f399c89fe85673e2f338 (patch) | |
tree | 122452c6b0339b7863aaad9626c509c2d66affa7 /rootston | |
parent | c41d01306de59235256d96902cced49a8eef15e9 (diff) |
data-device, primary-selection: add request_set_selection
This makes compositors able to block and/or customize set_selection requests
coming from clients. For instance, it's possible for a compositor to disable
rich selection content (by removing all MIME types except text/plain). This
commit implements the design proposed in [1].
Two new events are added to wlr_seat: request_set_selection and
request_set_primary_selection. Compositors need to listen to these events and
either destroy the source or effectively set the selection.
Fixes https://github.com/swaywm/wlroots/issues/1138
[1]: https://github.com/swaywm/wlroots/issues/1367#issuecomment-442403454
Diffstat (limited to 'rootston')
-rw-r--r-- | rootston/seat.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/rootston/seat.c b/rootston/seat.c index dda2f8df..43760a5e 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -7,9 +7,11 @@ #include <wayland-server.h> #include <wlr/backend/libinput.h> #include <wlr/config.h> +#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_idle.h> #include <wlr/types/wlr_layer_shell_v1.h> -#include "wlr/types/wlr_switch.h" +#include <wlr/types/wlr_primary_selection.h> +#include <wlr/types/wlr_switch.h> #include <wlr/types/wlr_tablet_v2.h> #include <wlr/types/wlr_xcursor_manager.h> #include <wlr/util/log.h> @@ -20,7 +22,6 @@ #include "rootston/text_input.h" #include "rootston/xcursor.h" - static void handle_keyboard_key(struct wl_listener *listener, void *data) { struct roots_keyboard *keyboard = wl_container_of(listener, keyboard, keyboard_key); @@ -536,6 +537,22 @@ static void roots_seat_handle_new_drag_icon(struct wl_listener *listener, roots_drag_icon_update_position(icon); } +static void roots_seat_handle_request_set_selection( + struct wl_listener *listener, void *data) { + struct roots_seat *seat = + wl_container_of(listener, seat, request_set_selection); + struct wlr_seat_request_set_selection_event *event = data; + wlr_seat_set_selection(seat->seat, event->source, event->serial); +} + +static void roots_seat_handle_request_set_primary_selection( + struct wl_listener *listener, void *data) { + struct roots_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->seat, event->source, event->serial); +} + void roots_drag_icon_update_position(struct roots_drag_icon *icon) { roots_drag_icon_damage_whole(icon); @@ -621,6 +638,14 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) { wl_list_insert(&input->seats, &seat->link); + seat->request_set_selection.notify = + roots_seat_handle_request_set_selection; + wl_signal_add(&seat->seat->events.request_set_selection, + &seat->request_set_selection); + seat->request_set_primary_selection.notify = + roots_seat_handle_request_set_primary_selection; + wl_signal_add(&seat->seat->events.request_set_primary_selection, + &seat->request_set_primary_selection); seat->new_drag_icon.notify = roots_seat_handle_new_drag_icon; wl_signal_add(&seat->seat->events.new_drag_icon, &seat->new_drag_icon); seat->destroy.notify = roots_seat_handle_destroy; |