30f8469da0
This is needed in order for wlroots to interpret some values (mostly coords of absolute input events) correctly. It for example fixes how the pointer behaves with WLR_WL_OUTPUTS=2. In order to also map the pointer/output pair when the pointer is created before the output, a list of pointers has to be managed, which wasn't needed until now.
67 lines
1.7 KiB
C
67 lines
1.7 KiB
C
/* Copyright (c), Charlotte Meyer <dev@buffet.sh>
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include "input/pointer.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <wayland-server.h>
|
|
#include <wlr/types/wlr_cursor.h>
|
|
#include <wlr/types/wlr_input_device.h>
|
|
|
|
#include "desktop/output.h"
|
|
#include "input/cursor.h"
|
|
#include "input/input.h"
|
|
#include "server.h"
|
|
|
|
static void
|
|
pointer_destroy_notify(struct wl_listener *listener, void *UNUSED(data))
|
|
{
|
|
struct kiwmi_pointer *pointer =
|
|
wl_container_of(listener, pointer, device_destroy);
|
|
|
|
pointer_destroy(pointer);
|
|
}
|
|
|
|
struct kiwmi_pointer *
|
|
pointer_create(struct kiwmi_server *server, struct wlr_input_device *device)
|
|
{
|
|
wlr_cursor_attach_input_device(server->input.cursor->cursor, device);
|
|
|
|
struct kiwmi_pointer *pointer = malloc(sizeof(*pointer));
|
|
if (!pointer) {
|
|
return NULL;
|
|
}
|
|
|
|
pointer->device = device;
|
|
|
|
pointer->device_destroy.notify = pointer_destroy_notify;
|
|
wl_signal_add(&device->events.destroy, &pointer->device_destroy);
|
|
|
|
if (device->output_name) {
|
|
struct kiwmi_output *output;
|
|
wl_list_for_each (output, &server->desktop.outputs, link) {
|
|
if (strcmp(device->output_name, output->wlr_output->name) == 0) {
|
|
wlr_cursor_map_input_to_output(
|
|
server->input.cursor->cursor, device, output->wlr_output);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return pointer;
|
|
}
|
|
|
|
void
|
|
pointer_destroy(struct kiwmi_pointer *pointer)
|
|
{
|
|
wl_list_remove(&pointer->device_destroy.link);
|
|
wl_list_remove(&pointer->link);
|
|
|
|
free(pointer);
|
|
}
|