mirror of
https://github.com/wizbright/waybox.git
synced 2025-10-29 05:40:20 -04:00
Merge pull request #20 from keithbowes/primary-selection
Implemented primary-selection support
This commit is contained in:
commit
69ac866970
4 changed files with 32 additions and 2 deletions
|
|
@ -2,6 +2,8 @@
|
|||
#define _WB_SEAT_H
|
||||
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
#include <wlr/types/wlr_primary_selection.h>
|
||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
|
||||
#include "waybox/server.h"
|
||||
|
|
@ -10,6 +12,9 @@ struct wb_seat {
|
|||
struct wlr_seat *seat;
|
||||
|
||||
struct wl_list keyboards;
|
||||
|
||||
struct wl_listener request_set_primary_selection;
|
||||
struct wl_listener request_set_selection;
|
||||
};
|
||||
|
||||
struct wb_keyboard {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
#include <wlr/types/wlr_screencopy_v1.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/types/wlr_gamma_control_v1.h>
|
||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
|
|
|||
|
|
@ -147,6 +147,22 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
|
|||
wlr_seat_set_capabilities(server->seat->seat, caps);
|
||||
}
|
||||
|
||||
static void handle_request_set_primary_selection(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct wb_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);
|
||||
}
|
||||
|
||||
static void handle_request_set_selection(struct wl_listener *listener, void
|
||||
*data) {
|
||||
struct wb_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);
|
||||
}
|
||||
|
||||
struct wb_seat *wb_seat_create(struct wb_server *server) {
|
||||
struct wb_seat *seat = malloc(sizeof(struct wb_seat));
|
||||
|
||||
|
|
@ -155,10 +171,21 @@ struct wb_seat *wb_seat_create(struct wb_server *server) {
|
|||
wl_signal_add(&server->backend->events.new_input, &server->new_input);
|
||||
seat->seat = wlr_seat_create(server->wl_display, "seat0");
|
||||
|
||||
wlr_primary_selection_v1_device_manager_create(server->wl_display);
|
||||
seat->request_set_primary_selection.notify =
|
||||
handle_request_set_primary_selection;
|
||||
wl_signal_add(&seat->seat->events.request_set_primary_selection,
|
||||
&seat->request_set_primary_selection);
|
||||
seat->request_set_selection.notify = handle_request_set_selection;
|
||||
wl_signal_add(&seat->seat->events.request_set_selection,
|
||||
&seat->request_set_selection);
|
||||
|
||||
return seat;
|
||||
}
|
||||
|
||||
void wb_seat_destroy(struct wb_seat *seat) {
|
||||
wl_list_remove(&seat->request_set_primary_selection.link);
|
||||
wl_list_remove(&seat->request_set_selection.link);
|
||||
wlr_seat_destroy(seat->seat);
|
||||
free(seat);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ bool wb_start_server(struct wb_server* server) {
|
|||
|
||||
wlr_gamma_control_manager_v1_create(server->wl_display);
|
||||
wlr_screencopy_manager_v1_create(server->wl_display);
|
||||
wlr_primary_selection_v1_device_manager_create(server->wl_display);
|
||||
wlr_idle_create(server->wl_display);
|
||||
|
||||
wlr_data_device_manager_create(server->wl_display);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue