diff --git a/include/input/seat.h b/include/input/seat.h index d9f3231..355a60f 100644 --- a/include/input/seat.h +++ b/include/input/seat.h @@ -23,6 +23,8 @@ struct kiwmi_seat { struct kiwmi_layer *focused_layer; struct wl_listener request_set_cursor; + struct wl_listener request_set_selection; + struct wl_listener request_set_primary_selection; }; void diff --git a/kiwmi/input/seat.c b/kiwmi/input/seat.c index 7000dbd..323762f 100644 --- a/kiwmi/input/seat.c +++ b/kiwmi/input/seat.c @@ -10,7 +10,9 @@ #include #include +#include #include +#include #include #include @@ -111,6 +113,24 @@ request_set_cursor_notify(struct wl_listener *listener, void *data) cursor->cursor, event->surface, event->hotspot_x, event->hotspot_y); } +static void +request_set_selection_notify(struct wl_listener *listener, void *data) +{ + struct kiwmi_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 +request_set_primary_selection_notify(struct wl_listener *listener, void *data) +{ + struct kiwmi_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); +} + struct kiwmi_seat * seat_create(struct kiwmi_input *input) { @@ -132,6 +152,17 @@ seat_create(struct kiwmi_input *input) wl_signal_add( &seat->seat->events.request_set_cursor, &seat->request_set_cursor); + wl_signal_add( + &seat->seat->events.request_set_selection, + &seat->request_set_selection); + seat->request_set_selection.notify = request_set_selection_notify; + + wl_signal_add( + &seat->seat->events.request_set_primary_selection, + &seat->request_set_primary_selection); + seat->request_set_primary_selection.notify = + request_set_primary_selection_notify; + return seat; } @@ -139,6 +170,8 @@ void seat_destroy(struct kiwmi_seat *seat) { wl_list_remove(&seat->request_set_cursor.link); + wl_list_remove(&seat->request_set_selection.link); + wl_list_remove(&seat->request_set_primary_selection.link); free(seat); } diff --git a/kiwmi/server.c b/kiwmi/server.c index cf01075..a361013 100644 --- a/kiwmi/server.c +++ b/kiwmi/server.c @@ -15,6 +15,9 @@ #include #include #include +#include +#include +#include #include #include @@ -55,6 +58,10 @@ server_init(struct kiwmi_server *server, char *config_path) return false; } + wlr_data_control_manager_v1_create(server->wl_display); + wlr_gamma_control_manager_v1_create(server->wl_display); + wlr_primary_selection_v1_device_manager_create(server->wl_display); + server->socket = wl_display_add_socket_auto(server->wl_display); if (!server->socket) { wlr_log(WLR_ERROR, "Failed to open Wayland socket");