2021-09-24 21:45:48 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2020-10-05 20:27:52 +01:00
|
|
|
#include <assert.h>
|
2022-03-19 11:34:11 +00:00
|
|
|
#include <stdbool.h>
|
2021-10-15 10:26:00 -04:00
|
|
|
#include <strings.h>
|
2020-12-30 11:09:36 +00:00
|
|
|
#include <wlr/backend/libinput.h>
|
2022-03-19 11:34:11 +00:00
|
|
|
#include <wlr/types/wlr_input_device.h>
|
2022-06-25 15:57:04 +02:00
|
|
|
#include <wlr/types/wlr_keyboard.h>
|
|
|
|
|
#include <wlr/types/wlr_pointer.h>
|
|
|
|
|
#include <wlr/types/wlr_touch.h>
|
2020-10-02 21:19:56 +01:00
|
|
|
#include <wlr/util/log.h>
|
2022-09-16 18:41:02 -04:00
|
|
|
#include "common/mem.h"
|
2020-09-04 20:25:20 +01:00
|
|
|
#include "labwc.h"
|
|
|
|
|
|
2020-10-02 21:19:56 +01:00
|
|
|
static void
|
|
|
|
|
input_device_destroy(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct input *input = wl_container_of(listener, input, destroy);
|
|
|
|
|
wl_list_remove(&input->link);
|
2021-12-27 09:44:03 -05:00
|
|
|
wl_list_remove(&input->destroy.link);
|
2020-10-02 21:19:56 +01:00
|
|
|
free(input);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-19 11:34:11 +00:00
|
|
|
static bool
|
|
|
|
|
is_touch_device(struct wlr_input_device *wlr_input_device)
|
|
|
|
|
{
|
|
|
|
|
switch (wlr_input_device->type) {
|
|
|
|
|
case WLR_INPUT_DEVICE_TOUCH:
|
|
|
|
|
case WLR_INPUT_DEVICE_TABLET_TOOL:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-06 15:47:51 +00:00
|
|
|
static void
|
|
|
|
|
configure_libinput(struct wlr_input_device *wlr_input_device)
|
2020-10-02 21:19:56 +01:00
|
|
|
{
|
2021-02-06 15:47:51 +00:00
|
|
|
if (!wlr_input_device) {
|
2021-07-23 21:15:55 +01:00
|
|
|
wlr_log(WLR_ERROR, "no wlr_input_device");
|
2021-02-06 15:47:51 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2020-12-30 11:09:36 +00:00
|
|
|
struct libinput_device *libinput_dev =
|
2021-02-06 15:47:51 +00:00
|
|
|
wlr_libinput_get_device_handle(wlr_input_device);
|
|
|
|
|
if (!libinput_dev) {
|
2021-07-23 21:15:55 +01:00
|
|
|
wlr_log(WLR_ERROR, "no libinput_dev");
|
2021-02-06 15:47:51 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2021-10-09 09:10:26 -04:00
|
|
|
|
2021-10-15 10:26:00 -04:00
|
|
|
enum device_type current_type;
|
2022-03-19 11:34:11 +00:00
|
|
|
current_type = is_touch_device(wlr_input_device)
|
|
|
|
|
? TOUCH_DEVICE : NON_TOUCH_DEVICE;
|
2021-10-15 10:26:00 -04:00
|
|
|
|
|
|
|
|
struct libinput_category *device_category, *dc = NULL;
|
|
|
|
|
wl_list_for_each(device_category, &rc.libinput_categories, link) {
|
|
|
|
|
if (device_category->name) {
|
2022-03-19 11:34:11 +00:00
|
|
|
if (!strcasecmp(wlr_input_device->name,
|
|
|
|
|
device_category->name)) {
|
2021-10-15 10:26:00 -04:00
|
|
|
dc = device_category;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else if (device_category->type == current_type) {
|
|
|
|
|
dc = device_category;
|
|
|
|
|
} else if (device_category->type == DEFAULT_DEVICE && !dc) {
|
|
|
|
|
dc = device_category;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dc) {
|
|
|
|
|
wlr_log(WLR_INFO, "Skipping libinput configuration for device");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-06 15:47:51 +00:00
|
|
|
if (libinput_device_config_tap_get_finger_count(libinput_dev) <= 0) {
|
2021-10-09 09:10:26 -04:00
|
|
|
wlr_log(WLR_INFO, "tap unavailable");
|
|
|
|
|
} else {
|
|
|
|
|
wlr_log(WLR_INFO, "tap configured");
|
2021-10-15 10:26:00 -04:00
|
|
|
libinput_device_config_tap_set_enabled(libinput_dev, dc->tap);
|
2022-04-04 20:53:36 +01:00
|
|
|
libinput_device_config_tap_set_button_map(libinput_dev,
|
|
|
|
|
dc->tap_button_map);
|
2021-10-09 09:10:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_scroll_has_natural_scroll(libinput_dev) <= 0
|
2021-10-15 10:26:00 -04:00
|
|
|
|| dc->natural_scroll < 0) {
|
2021-10-09 09:10:26 -04:00
|
|
|
wlr_log(WLR_INFO, "natural scroll not configured");
|
|
|
|
|
} else {
|
|
|
|
|
wlr_log(WLR_INFO, "natural scroll configured");
|
|
|
|
|
libinput_device_config_scroll_set_natural_scroll_enabled(
|
2021-10-15 10:26:00 -04:00
|
|
|
libinput_dev, dc->natural_scroll);
|
2021-10-09 09:10:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_left_handed_is_available(libinput_dev) <= 0
|
2021-10-15 10:26:00 -04:00
|
|
|
|| dc->left_handed < 0) {
|
2021-10-09 09:10:26 -04:00
|
|
|
wlr_log(WLR_INFO, "left-handed mode not configured");
|
|
|
|
|
} else {
|
|
|
|
|
wlr_log(WLR_INFO, "left-handed mode configured");
|
|
|
|
|
libinput_device_config_left_handed_set(libinput_dev,
|
2021-10-15 10:26:00 -04:00
|
|
|
dc->left_handed);
|
2021-10-09 09:10:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_accel_is_available(libinput_dev) == 0) {
|
|
|
|
|
wlr_log(WLR_INFO, "pointer acceleration unavailable");
|
|
|
|
|
} else {
|
|
|
|
|
wlr_log(WLR_INFO, "pointer acceleration configured");
|
2021-10-15 10:26:00 -04:00
|
|
|
if (dc->pointer_speed > -1) {
|
2021-10-15 20:52:36 +01:00
|
|
|
libinput_device_config_accel_set_speed(libinput_dev,
|
2021-10-15 10:26:00 -04:00
|
|
|
dc->pointer_speed);
|
2021-10-09 09:10:26 -04:00
|
|
|
}
|
2021-10-15 10:26:00 -04:00
|
|
|
if (dc->accel_profile > 0) {
|
2021-10-09 09:10:26 -04:00
|
|
|
libinput_device_config_accel_set_profile(libinput_dev,
|
2021-10-15 10:26:00 -04:00
|
|
|
dc->accel_profile);
|
2021-10-09 09:10:26 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_middle_emulation_is_available(libinput_dev)
|
2021-10-15 10:26:00 -04:00
|
|
|
== 0 || dc->middle_emu < 0) {
|
2021-10-09 09:10:26 -04:00
|
|
|
wlr_log(WLR_INFO, "middle emulation not configured");
|
|
|
|
|
} else {
|
|
|
|
|
wlr_log(WLR_INFO, "middle emulation configured");
|
|
|
|
|
libinput_device_config_middle_emulation_set_enabled(
|
2021-10-15 10:26:00 -04:00
|
|
|
libinput_dev, dc->middle_emu);
|
2021-10-09 09:10:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_dwt_is_available(libinput_dev) == 0
|
2021-10-15 10:26:00 -04:00
|
|
|
|| dc->dwt < 0) {
|
2021-10-09 09:10:26 -04:00
|
|
|
wlr_log(WLR_INFO, "dwt not configured");
|
|
|
|
|
} else {
|
|
|
|
|
wlr_log(WLR_INFO, "dwt configured");
|
2021-10-15 10:26:00 -04:00
|
|
|
libinput_device_config_dwt_set_enabled(libinput_dev, dc->dwt);
|
2021-02-06 15:47:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-06 21:40:10 +00:00
|
|
|
static struct wlr_output *
|
|
|
|
|
output_by_name(struct server *server, const char *name)
|
|
|
|
|
{
|
2022-04-04 20:53:36 +01:00
|
|
|
assert(name);
|
2022-01-06 21:40:10 +00:00
|
|
|
struct output *output;
|
|
|
|
|
wl_list_for_each(output, &server->outputs, link) {
|
|
|
|
|
if (!strcasecmp(output->wlr_output->name, name)) {
|
|
|
|
|
return output->wlr_output;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-06 15:47:51 +00:00
|
|
|
void
|
|
|
|
|
new_pointer(struct seat *seat, struct input *input)
|
|
|
|
|
{
|
2022-01-06 21:40:10 +00:00
|
|
|
struct wlr_input_device *dev = input->wlr_input_device;
|
|
|
|
|
if (wlr_input_device_is_libinput(dev)) {
|
|
|
|
|
configure_libinput(dev);
|
2021-02-06 15:47:51 +00:00
|
|
|
}
|
2022-01-06 21:40:10 +00:00
|
|
|
wlr_cursor_attach_input_device(seat->cursor, dev);
|
|
|
|
|
|
|
|
|
|
/* In support of running with WLR_WL_OUTPUTS set to >=2 */
|
2022-03-19 11:34:11 +00:00
|
|
|
if (dev->type == WLR_INPUT_DEVICE_POINTER) {
|
2022-03-20 22:07:14 +00:00
|
|
|
struct wlr_output *output = NULL;
|
2022-06-25 15:57:04 +02:00
|
|
|
struct wlr_pointer *pointer = wlr_pointer_from_input_device(dev);
|
|
|
|
|
wlr_log(WLR_INFO, "map pointer to output %s\n", pointer->output_name);
|
|
|
|
|
if (pointer->output_name) {
|
|
|
|
|
output = output_by_name(seat->server, pointer->output_name);
|
2022-03-20 22:07:14 +00:00
|
|
|
}
|
2022-01-17 23:02:59 +01:00
|
|
|
wlr_cursor_map_input_to_output(seat->cursor, dev, output);
|
|
|
|
|
wlr_cursor_map_input_to_region(seat->cursor, dev, NULL);
|
|
|
|
|
}
|
2020-10-02 21:19:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
new_keyboard(struct seat *seat, struct input *input)
|
|
|
|
|
{
|
2022-06-25 15:57:04 +02:00
|
|
|
struct wlr_keyboard *kb =
|
|
|
|
|
wlr_keyboard_from_input_device(input->wlr_input_device);
|
2020-10-02 21:19:56 +01:00
|
|
|
wlr_keyboard_set_keymap(kb, seat->keyboard_group->keyboard.keymap);
|
|
|
|
|
wlr_keyboard_group_add_keyboard(seat->keyboard_group, kb);
|
2022-03-28 20:41:53 +01:00
|
|
|
wlr_seat_set_keyboard(seat->seat, kb);
|
2020-10-02 21:19:56 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-31 23:50:31 +00:00
|
|
|
void
|
|
|
|
|
new_touch(struct seat *seat, struct input *input)
|
|
|
|
|
{
|
|
|
|
|
struct wlr_input_device *dev = input->wlr_input_device;
|
|
|
|
|
if (wlr_input_device_is_libinput(dev)) {
|
|
|
|
|
configure_libinput(dev);
|
|
|
|
|
}
|
|
|
|
|
wlr_cursor_attach_input_device(seat->cursor, dev);
|
|
|
|
|
|
|
|
|
|
/* In support of running with WLR_WL_OUTPUTS set to >=2 */
|
|
|
|
|
if (dev->type == WLR_INPUT_DEVICE_TOUCH) {
|
|
|
|
|
struct wlr_output *output = NULL;
|
2022-06-25 15:57:04 +02:00
|
|
|
struct wlr_touch *touch = wlr_touch_from_input_device(dev);
|
|
|
|
|
wlr_log(WLR_INFO, "map touch to output %s\n", touch->output_name);
|
|
|
|
|
if (touch->output_name) {
|
|
|
|
|
output = output_by_name(seat->server, touch->output_name);
|
2021-12-31 23:50:31 +00:00
|
|
|
}
|
|
|
|
|
wlr_cursor_map_input_to_output(seat->cursor, dev, output);
|
|
|
|
|
wlr_cursor_map_input_to_region(seat->cursor, dev, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-02 21:19:56 +01:00
|
|
|
static void
|
|
|
|
|
new_input_notify(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct seat *seat = wl_container_of(listener, seat, new_input);
|
|
|
|
|
struct wlr_input_device *device = data;
|
2022-09-18 15:22:26 -04:00
|
|
|
struct input *input = znew(*input);
|
2020-10-02 21:19:56 +01:00
|
|
|
input->wlr_input_device = device;
|
|
|
|
|
input->seat = seat;
|
|
|
|
|
|
|
|
|
|
switch (device->type) {
|
|
|
|
|
case WLR_INPUT_DEVICE_KEYBOARD:
|
|
|
|
|
new_keyboard(seat, input);
|
|
|
|
|
break;
|
|
|
|
|
case WLR_INPUT_DEVICE_POINTER:
|
|
|
|
|
new_pointer(seat, input);
|
|
|
|
|
break;
|
2021-12-31 23:50:31 +00:00
|
|
|
case WLR_INPUT_DEVICE_TOUCH:
|
|
|
|
|
new_touch(seat, input);
|
|
|
|
|
break;
|
2020-10-02 21:19:56 +01:00
|
|
|
default:
|
|
|
|
|
wlr_log(WLR_INFO, "unsupported input device");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
input->destroy.notify = input_device_destroy;
|
|
|
|
|
wl_signal_add(&device->events.destroy, &input->destroy);
|
|
|
|
|
wl_list_insert(&seat->inputs, &input->link);
|
|
|
|
|
|
|
|
|
|
uint32_t caps = 0;
|
|
|
|
|
wl_list_for_each(input, &seat->inputs, link) {
|
|
|
|
|
switch (input->wlr_input_device->type) {
|
|
|
|
|
case WLR_INPUT_DEVICE_KEYBOARD:
|
|
|
|
|
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
|
|
|
|
break;
|
|
|
|
|
case WLR_INPUT_DEVICE_POINTER:
|
|
|
|
|
caps |= WL_SEAT_CAPABILITY_POINTER;
|
|
|
|
|
break;
|
2021-12-31 23:50:31 +00:00
|
|
|
case WLR_INPUT_DEVICE_TOUCH:
|
|
|
|
|
caps |= WL_SEAT_CAPABILITY_TOUCH;
|
|
|
|
|
break;
|
2020-10-02 21:19:56 +01:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wlr_seat_set_capabilities(seat->seat, caps);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-22 16:35:57 -05:00
|
|
|
static void
|
|
|
|
|
destroy_idle_inhibitor(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct idle_inhibitor *idle_inhibitor = wl_container_of(listener,
|
|
|
|
|
idle_inhibitor, destroy);
|
|
|
|
|
struct seat *seat = idle_inhibitor->seat;
|
|
|
|
|
wl_list_remove(&idle_inhibitor->destroy.link);
|
|
|
|
|
wlr_idle_set_enabled(seat->wlr_idle, seat->seat, wl_list_length(
|
|
|
|
|
&seat->wlr_idle_inhibit_manager->inhibitors) <= 1);
|
|
|
|
|
free(idle_inhibitor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
new_idle_inhibitor(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct wlr_idle_inhibitor_v1 *wlr_inhibitor = data;
|
|
|
|
|
struct seat *seat = wl_container_of(listener, seat,
|
|
|
|
|
idle_inhibitor_create);
|
|
|
|
|
|
2022-09-18 15:22:26 -04:00
|
|
|
struct idle_inhibitor *inhibitor = znew(*inhibitor);
|
2021-11-22 16:35:57 -05:00
|
|
|
inhibitor->seat = seat;
|
|
|
|
|
inhibitor->wlr_inhibitor = wlr_inhibitor;
|
|
|
|
|
inhibitor->destroy.notify = destroy_idle_inhibitor;
|
|
|
|
|
wl_signal_add(&wlr_inhibitor->events.destroy, &inhibitor->destroy);
|
|
|
|
|
wlr_idle_set_enabled(seat->wlr_idle, seat->seat, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-02 21:19:56 +01:00
|
|
|
void
|
|
|
|
|
seat_init(struct server *server)
|
|
|
|
|
{
|
|
|
|
|
struct seat *seat = &server->seat;
|
|
|
|
|
seat->server = server;
|
|
|
|
|
|
|
|
|
|
seat->seat = wlr_seat_create(server->wl_display, "seat0");
|
|
|
|
|
if (!seat->seat) {
|
|
|
|
|
wlr_log(WLR_ERROR, "cannot allocate seat");
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:54:35 -04:00
|
|
|
wl_list_init(&seat->constraint_commit.link);
|
2020-10-02 21:19:56 +01:00
|
|
|
wl_list_init(&seat->inputs);
|
|
|
|
|
seat->new_input.notify = new_input_notify;
|
|
|
|
|
wl_signal_add(&server->backend->events.new_input, &seat->new_input);
|
|
|
|
|
|
2021-11-22 16:35:57 -05:00
|
|
|
seat->wlr_idle = wlr_idle_create(server->wl_display);
|
|
|
|
|
seat->wlr_idle_inhibit_manager = wlr_idle_inhibit_v1_create(
|
|
|
|
|
server->wl_display);
|
|
|
|
|
wl_signal_add(&seat->wlr_idle_inhibit_manager->events.new_inhibitor,
|
|
|
|
|
&seat->idle_inhibitor_create);
|
|
|
|
|
seat->idle_inhibitor_create.notify = new_idle_inhibitor;
|
|
|
|
|
|
2020-10-02 21:19:56 +01:00
|
|
|
seat->cursor = wlr_cursor_create();
|
|
|
|
|
if (!seat->cursor) {
|
|
|
|
|
wlr_log(WLR_ERROR, "unable to create cursor");
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
wlr_cursor_attach_output_layout(seat->cursor, server->output_layout);
|
|
|
|
|
|
|
|
|
|
keyboard_init(seat);
|
|
|
|
|
cursor_init(seat);
|
2021-12-31 23:50:31 +00:00
|
|
|
touch_init(seat);
|
2020-10-02 21:19:56 +01:00
|
|
|
}
|
|
|
|
|
|
2020-09-28 20:41:41 +01:00
|
|
|
void
|
2020-10-02 21:19:56 +01:00
|
|
|
seat_finish(struct server *server)
|
2020-09-08 20:18:12 +01:00
|
|
|
{
|
2020-10-02 21:19:56 +01:00
|
|
|
struct seat *seat = &server->seat;
|
|
|
|
|
wl_list_remove(&seat->new_input.link);
|
2021-12-31 23:30:25 +00:00
|
|
|
keyboard_finish(seat);
|
2022-09-15 20:02:06 -04:00
|
|
|
/*
|
|
|
|
|
* Caution - touch_finish() unregisters event listeners from
|
|
|
|
|
* seat->cursor and must come before cursor_finish(), otherwise
|
|
|
|
|
* a use-after-free occurs.
|
|
|
|
|
*/
|
2021-12-31 23:50:31 +00:00
|
|
|
touch_finish(seat);
|
2022-09-15 20:02:06 -04:00
|
|
|
cursor_finish(seat);
|
2020-09-08 20:18:12 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-10 12:03:18 -04:00
|
|
|
void
|
|
|
|
|
seat_reconfigure(struct server *server)
|
|
|
|
|
{
|
|
|
|
|
struct seat *seat = &server->seat;
|
|
|
|
|
struct input *input;
|
|
|
|
|
struct wlr_keyboard *kb = &seat->keyboard_group->keyboard;
|
|
|
|
|
wl_list_for_each(input, &seat->inputs, link) {
|
|
|
|
|
/* We don't configure keyboards by libinput, so skip them */
|
|
|
|
|
if (wlr_input_device_is_libinput(input->wlr_input_device) &&
|
2021-10-15 20:52:36 +01:00
|
|
|
input->wlr_input_device->type ==
|
2021-10-10 12:03:18 -04:00
|
|
|
WLR_INPUT_DEVICE_POINTER) {
|
|
|
|
|
configure_libinput(input->wlr_input_device);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wlr_keyboard_set_repeat_info(kb, rc.repeat_rate, rc.repeat_delay);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-28 20:41:41 +01:00
|
|
|
void
|
2020-10-08 20:22:52 +01:00
|
|
|
seat_focus_surface(struct seat *seat, struct wlr_surface *surface)
|
2020-09-04 20:25:20 +01:00
|
|
|
{
|
|
|
|
|
if (!surface) {
|
2020-10-08 20:22:52 +01:00
|
|
|
wlr_seat_keyboard_notify_clear_focus(seat->seat);
|
2020-09-04 20:25:20 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2020-10-08 20:22:52 +01:00
|
|
|
struct wlr_keyboard *kb = &seat->keyboard_group->keyboard;
|
|
|
|
|
wlr_seat_keyboard_notify_enter(seat->seat, surface, kb->keycodes,
|
2020-10-05 20:27:52 +01:00
|
|
|
kb->num_keycodes, &kb->modifiers);
|
2021-10-17 16:54:35 -04:00
|
|
|
|
|
|
|
|
struct server *server = seat->server;
|
|
|
|
|
struct wlr_pointer_constraint_v1 *constraint =
|
|
|
|
|
wlr_pointer_constraints_v1_constraint_for_surface(server->constraints,
|
|
|
|
|
surface, seat->seat);
|
|
|
|
|
constrain_cursor(server, constraint);
|
2020-09-08 20:18:12 +01:00
|
|
|
}
|
2020-10-31 15:09:13 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
seat_set_focus_layer(struct seat *seat, struct wlr_layer_surface_v1 *layer)
|
|
|
|
|
{
|
|
|
|
|
if (!layer) {
|
|
|
|
|
seat->focused_layer = NULL;
|
|
|
|
|
desktop_focus_topmost_mapped_view(seat->server);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
seat_focus_surface(seat, layer->surface);
|
|
|
|
|
if (layer->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
|
|
|
|
|
seat->focused_layer = layer;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-01 17:50:28 -04:00
|
|
|
|
2022-09-13 10:55:59 -04:00
|
|
|
static void
|
|
|
|
|
pressed_surface_destroy(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct wlr_surface *surface = data;
|
|
|
|
|
struct seat *seat = wl_container_of(listener, seat,
|
|
|
|
|
pressed_surface_destroy);
|
|
|
|
|
|
|
|
|
|
assert(surface == seat->pressed.surface);
|
|
|
|
|
seat_reset_pressed(seat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
seat_set_pressed(struct seat *seat, struct view *view,
|
2022-09-10 01:57:39 -04:00
|
|
|
struct wlr_scene_node *node, struct wlr_surface *surface,
|
2022-09-14 23:09:36 -04:00
|
|
|
struct wlr_surface *toplevel, uint32_t resize_edges)
|
2022-09-13 10:55:59 -04:00
|
|
|
{
|
2022-09-14 23:09:36 -04:00
|
|
|
assert(view || surface);
|
2022-09-13 10:55:59 -04:00
|
|
|
seat_reset_pressed(seat);
|
|
|
|
|
|
|
|
|
|
seat->pressed.view = view;
|
|
|
|
|
seat->pressed.node = node;
|
|
|
|
|
seat->pressed.surface = surface;
|
2022-09-10 01:57:39 -04:00
|
|
|
seat->pressed.toplevel = toplevel;
|
2022-09-14 23:09:36 -04:00
|
|
|
seat->pressed.resize_edges = resize_edges;
|
|
|
|
|
|
|
|
|
|
if (surface) {
|
|
|
|
|
seat->pressed_surface_destroy.notify = pressed_surface_destroy;
|
|
|
|
|
wl_signal_add(&surface->events.destroy,
|
|
|
|
|
&seat->pressed_surface_destroy);
|
|
|
|
|
}
|
2022-09-13 10:55:59 -04:00
|
|
|
}
|
|
|
|
|
|
2022-09-01 17:50:28 -04:00
|
|
|
void
|
|
|
|
|
seat_reset_pressed(struct seat *seat)
|
|
|
|
|
{
|
2022-09-13 10:55:59 -04:00
|
|
|
if (seat->pressed.surface) {
|
|
|
|
|
wl_list_remove(&seat->pressed_surface_destroy.link);
|
|
|
|
|
}
|
2022-09-14 23:09:36 -04:00
|
|
|
|
|
|
|
|
seat->pressed.view = NULL;
|
|
|
|
|
seat->pressed.node = NULL;
|
|
|
|
|
seat->pressed.surface = NULL;
|
|
|
|
|
seat->pressed.toplevel = NULL;
|
|
|
|
|
seat->pressed.resize_edges = 0;
|
2022-09-01 17:50:28 -04:00
|
|
|
}
|