spkp

Stacking wayland compositor
git clone git://git.z3bra.org/sp:kp.git
Log | Files | Refs

commit 2ca5e2f73d99654f5295056e2f76947c4b1eed64
parent 13990de6158e0d499c413cb104bd0b511fb447f1
Author: Willy Goiffon <dev@z3bra.org>
Date:   Fri, 13 Nov 2020 17:12:24 +0100

Add support for setting selection

Diffstat:
Mcompositor.c | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/compositor.c b/compositor.c @@ -67,6 +67,7 @@ struct state { struct wl_listener new_output; struct wl_listener new_window; struct wl_listener new_chrome; + struct wl_listener copy; /* cursor related events */ struct wl_listener req_cursor; @@ -168,6 +169,7 @@ static void cb_destroy_output(struct wl_listener *, void *); static void cb_frame_output(struct wl_listener *, void *); static void cb_new_window(struct wl_listener *, void *); static void cb_new_decoration(struct wl_listener *, void *); +static void cb_copy(struct wl_listener *, void *); static void cb_map_window(struct wl_listener *, void *); static void cb_unmap_window(struct wl_listener *, void *); @@ -430,6 +432,21 @@ cb_new_decoration(struct wl_listener *listener, void *data) } /* + * Request setting selection from the client. This happens when the user + * copies something from a client window. + */ +void +cb_copy(struct wl_listener *listener, void *data) +{ + struct state *server; + struct wlr_seat_request_set_selection_event *ev; + + server = wl_container_of(listener, server, copy); + ev = data; + wlr_seat_set_selection(server->seat, ev->source, ev->serial); +} + +/* * Request from a client to be mapped on-screen. */ void @@ -1125,6 +1142,7 @@ main(int argc, char *argv[]) server.new_input.notify = cb_new_input; server.new_output.notify = cb_new_output; server.new_chrome.notify = cb_new_decoration; + server.copy.notify = cb_copy; server.click.notify = cb_click; server.scroll.notify = cb_scroll; @@ -1137,6 +1155,7 @@ main(int argc, char *argv[]) wl_signal_add(&server.shell->events.new_surface, &server.new_window); wl_signal_add(&server.backend->events.new_input, &server.new_input); wl_signal_add(&server.chrome_mgr->events.new_toplevel_decoration, &server.new_chrome); + wl_signal_add(&server.seat->events.request_set_selection, &server.copy); wl_signal_add(&server.cursor->events.button, &server.click); wl_signal_add(&server.cursor->events.axis, &server.scroll);