mirror of
https://github.com/swaywm/sway.git
synced 2024-12-25 22:46:31 +01:00
Implement transient seat management
This commit is contained in:
parent
dc9f217307
commit
5a7477cb8f
5 changed files with 41 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
|
||||
#include <wlr/types/wlr_virtual_keyboard_v1.h>
|
||||
#include <wlr/types/wlr_virtual_pointer_v1.h>
|
||||
#include <wlr/types/wlr_transient_seat_v1.h>
|
||||
#include "sway/server.h"
|
||||
#include "sway/config.h"
|
||||
#include "list.h"
|
||||
|
@ -24,6 +25,7 @@ struct sway_input_manager {
|
|||
struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard;
|
||||
struct wlr_virtual_pointer_manager_v1 *virtual_pointer;
|
||||
struct wlr_pointer_gestures_v1 *pointer_gestures;
|
||||
struct wlr_transient_seat_manager_v1 *transient_seat_manager;
|
||||
|
||||
struct wl_listener new_input;
|
||||
struct wl_listener inhibit_activate;
|
||||
|
@ -31,6 +33,7 @@ struct sway_input_manager {
|
|||
struct wl_listener keyboard_shortcuts_inhibit_new_inhibitor;
|
||||
struct wl_listener virtual_keyboard_new;
|
||||
struct wl_listener virtual_pointer_new;
|
||||
struct wl_listener transient_seat_create;
|
||||
};
|
||||
|
||||
struct sway_input_manager *input_manager_create(struct sway_server *server);
|
||||
|
|
|
@ -124,6 +124,7 @@ struct sway_seat {
|
|||
struct wl_listener start_drag;
|
||||
struct wl_listener request_set_selection;
|
||||
struct wl_listener request_set_primary_selection;
|
||||
struct wl_listener destroy;
|
||||
|
||||
struct wl_list devices; // sway_seat_device::link
|
||||
struct wl_list keyboard_groups; // sway_keyboard_group::link
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <wlr/config.h>
|
||||
#include <wlr/backend/libinput.h>
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/types/wlr_keyboard_group.h>
|
||||
#include <wlr/types/wlr_virtual_keyboard_v1.h>
|
||||
|
@ -431,6 +433,20 @@ void handle_virtual_pointer(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
static void handle_transient_seat_manager_create_seat(
|
||||
struct wl_listener *listener, void *data) {
|
||||
struct wlr_transient_seat_v1 *transient_seat = data;
|
||||
static uint64_t i;
|
||||
char name[256];
|
||||
snprintf(name, sizeof(name), "transient-%"PRIx64, i++);
|
||||
struct sway_seat *seat = seat_create(name);
|
||||
if (seat && seat->wlr_seat) {
|
||||
wlr_transient_seat_v1_ready(transient_seat, seat->wlr_seat);
|
||||
} else {
|
||||
wlr_transient_seat_v1_deny(transient_seat);
|
||||
}
|
||||
}
|
||||
|
||||
struct sway_input_manager *input_manager_create(struct sway_server *server) {
|
||||
struct sway_input_manager *input =
|
||||
calloc(1, sizeof(struct sway_input_manager));
|
||||
|
@ -466,6 +482,15 @@ struct sway_input_manager *input_manager_create(struct sway_server *server) {
|
|||
|
||||
input->pointer_gestures = wlr_pointer_gestures_v1_create(server->wl_display);
|
||||
|
||||
input->transient_seat_manager =
|
||||
wlr_transient_seat_manager_v1_create(server->wl_display);
|
||||
assert(input->transient_seat_manager);
|
||||
|
||||
input->transient_seat_create.notify =
|
||||
handle_transient_seat_manager_create_seat;
|
||||
wl_signal_add(&input->transient_seat_manager->events.create_seat,
|
||||
&input->transient_seat_create);
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,12 @@ static void seat_node_destroy(struct sway_seat_node *seat_node) {
|
|||
}
|
||||
|
||||
void seat_destroy(struct sway_seat *seat) {
|
||||
wlr_seat_destroy(seat->wlr_seat);
|
||||
}
|
||||
|
||||
static void handle_seat_destroy(struct wl_listener *listener, void *data) {
|
||||
struct sway_seat *seat = wl_container_of(listener, seat, destroy);
|
||||
|
||||
if (seat == config->handler_context.seat) {
|
||||
config->handler_context.seat = input_manager_get_default_seat();
|
||||
}
|
||||
|
@ -87,7 +93,7 @@ void seat_destroy(struct sway_seat *seat) {
|
|||
wl_list_remove(&seat->request_set_selection.link);
|
||||
wl_list_remove(&seat->request_set_primary_selection.link);
|
||||
wl_list_remove(&seat->link);
|
||||
wlr_seat_destroy(seat->wlr_seat);
|
||||
wl_list_remove(&seat->destroy.link);
|
||||
for (int i = 0; i < seat->deferred_bindings->length; i++) {
|
||||
free_sway_binding(seat->deferred_bindings->items[i]);
|
||||
}
|
||||
|
@ -534,6 +540,9 @@ struct sway_seat *seat_create(const char *seat_name) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
seat->destroy.notify = handle_seat_destroy;
|
||||
wl_signal_add(&seat->wlr_seat->events.destroy, &seat->destroy);
|
||||
|
||||
seat->idle_inhibit_sources = seat->idle_wake_sources =
|
||||
IDLE_SOURCE_KEYBOARD |
|
||||
IDLE_SOURCE_POINTER |
|
||||
|
|
|
@ -112,7 +112,8 @@ static bool is_privileged(const struct wl_global *global) {
|
|||
global == server.session_lock.manager->global ||
|
||||
global == server.input->keyboard_shortcuts_inhibit->global ||
|
||||
global == server.input->virtual_keyboard->global ||
|
||||
global == server.input->virtual_pointer->global;
|
||||
global == server.input->virtual_pointer->global ||
|
||||
global == server.input->transient_seat_manager->global;
|
||||
}
|
||||
|
||||
static bool filter_global(const struct wl_client *client,
|
||||
|
|
Loading…
Reference in a new issue