Add clipboard and clipboard management support
This commit is contained in:
parent
4bc201754a
commit
448f78c970
3 changed files with 40 additions and 0 deletions
|
@ -23,6 +23,8 @@ struct kiwmi_seat {
|
||||||
struct kiwmi_layer *focused_layer;
|
struct kiwmi_layer *focused_layer;
|
||||||
|
|
||||||
struct wl_listener request_set_cursor;
|
struct wl_listener request_set_cursor;
|
||||||
|
struct wl_listener request_set_selection;
|
||||||
|
struct wl_listener request_set_primary_selection;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <wlr/types/wlr_cursor.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_layer_shell_v1.h>
|
||||||
|
#include <wlr/types/wlr_primary_selection.h>
|
||||||
#include <wlr/types/wlr_seat.h>
|
#include <wlr/types/wlr_seat.h>
|
||||||
#include <wlr/util/log.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);
|
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 *
|
struct kiwmi_seat *
|
||||||
seat_create(struct kiwmi_input *input)
|
seat_create(struct kiwmi_input *input)
|
||||||
{
|
{
|
||||||
|
@ -132,6 +152,17 @@ seat_create(struct kiwmi_input *input)
|
||||||
wl_signal_add(
|
wl_signal_add(
|
||||||
&seat->seat->events.request_set_cursor, &seat->request_set_cursor);
|
&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;
|
return seat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +170,8 @@ void
|
||||||
seat_destroy(struct kiwmi_seat *seat)
|
seat_destroy(struct kiwmi_seat *seat)
|
||||||
{
|
{
|
||||||
wl_list_remove(&seat->request_set_cursor.link);
|
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);
|
free(seat);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
#include <wlr/backend.h>
|
#include <wlr/backend.h>
|
||||||
#include <wlr/render/wlr_renderer.h>
|
#include <wlr/render/wlr_renderer.h>
|
||||||
|
#include <wlr/types/wlr_data_control_v1.h>
|
||||||
|
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||||
#include <wlr/types/wlr_screencopy_v1.h>
|
#include <wlr/types/wlr_screencopy_v1.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
|
@ -55,6 +57,9 @@ server_init(struct kiwmi_server *server, char *config_path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wlr_data_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);
|
server->socket = wl_display_add_socket_auto(server->wl_display);
|
||||||
if (!server->socket) {
|
if (!server->socket) {
|
||||||
wlr_log(WLR_ERROR, "Failed to open Wayland socket");
|
wlr_log(WLR_ERROR, "Failed to open Wayland socket");
|
||||||
|
|
Loading…
Reference in a new issue