Merge pull request #31 from tiosgz/clipboard

Add clipboard (& other stuff) support
This commit is contained in:
Niclas 2021-08-02 20:44:19 +00:00 committed by GitHub
commit 724923e5ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 0 deletions

View file

@ -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

View file

@ -10,7 +10,9 @@
#include <stdlib.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/util/log.h>
@ -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);
}

View file

@ -15,6 +15,9 @@
#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_gamma_control_v1.h>
#include <wlr/types/wlr_primary_selection_v1.h>
#include <wlr/types/wlr_screencopy_v1.h>
#include <wlr/util/log.h>
@ -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");