mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-16 08:56:26 -05:00
Merge branch 'master' into wayland-backend
This commit is contained in:
commit
e65ca967f9
17 changed files with 353 additions and 17 deletions
|
|
@ -19,6 +19,7 @@ add_library(wlr-backend
|
|||
libinput/pointer.c
|
||||
libinput/touch.c
|
||||
libinput/tablet_tool.c
|
||||
libinput/tablet_pad.c
|
||||
|
||||
multi/backend.c
|
||||
backend.c
|
||||
|
|
|
|||
|
|
@ -296,6 +296,10 @@ static void wlr_drm_cursor_bo_update(struct wlr_output_state *output,
|
|||
wlr_log(L_ERROR, "Failed to create cursor bo");
|
||||
return;
|
||||
}
|
||||
if (!get_fb_for_bo(state->fd, output->cursor_bo[i])) {
|
||||
wlr_log(L_ERROR, "Failed to create cursor fb");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,10 @@ static void handle_device_added(struct wlr_backend_state *state,
|
|||
wl_signal_emit(&state->backend->events.input_add, wlr_device);
|
||||
}
|
||||
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET_PAD)) {
|
||||
// TODO
|
||||
struct wlr_input_device *wlr_device = allocate_device(state,
|
||||
device, devices, WLR_INPUT_DEVICE_TABLET_PAD);
|
||||
wlr_device->tablet_pad = wlr_libinput_tablet_pad_create(device);
|
||||
wl_signal_emit(&state->backend->events.input_add, wlr_device);
|
||||
}
|
||||
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_GESTURE)) {
|
||||
// TODO
|
||||
|
|
@ -169,6 +172,15 @@ void wlr_libinput_event(struct wlr_backend_state *state,
|
|||
case LIBINPUT_EVENT_TABLET_TOOL_BUTTON:
|
||||
handle_tablet_tool_button(event, device);
|
||||
break;
|
||||
case LIBINPUT_EVENT_TABLET_PAD_BUTTON:
|
||||
handle_tablet_pad_button(event, device);
|
||||
break;
|
||||
case LIBINPUT_EVENT_TABLET_PAD_RING:
|
||||
handle_tablet_pad_ring(event, device);
|
||||
break;
|
||||
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
|
||||
handle_tablet_pad_strip(event, device);
|
||||
break;
|
||||
default:
|
||||
wlr_log(L_DEBUG, "Unknown libinput event %d", event_type);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -8,11 +8,32 @@
|
|||
#include "common/log.h"
|
||||
#include "types.h"
|
||||
|
||||
struct wlr_keyboard_state {
|
||||
struct libinput_device *device;
|
||||
};
|
||||
|
||||
static void wlr_libinput_keyboard_set_leds(struct wlr_keyboard_state *kbstate, uint32_t leds) {
|
||||
libinput_device_led_update(kbstate->device, leds);
|
||||
}
|
||||
|
||||
static void wlr_libinput_keyboard_destroy(struct wlr_keyboard_state *kbstate) {
|
||||
libinput_device_unref(kbstate->device);
|
||||
free(kbstate);
|
||||
}
|
||||
|
||||
struct wlr_keyboard_impl impl = {
|
||||
.destroy = wlr_libinput_keyboard_destroy,
|
||||
.led_update = wlr_libinput_keyboard_set_leds
|
||||
};
|
||||
|
||||
struct wlr_keyboard *wlr_libinput_keyboard_create(
|
||||
struct libinput_device *device) {
|
||||
assert(device);
|
||||
struct wlr_keyboard_state *kbstate = calloc(1, sizeof(struct wlr_keyboard_state));
|
||||
kbstate->device = device;
|
||||
libinput_device_ref(device);
|
||||
libinput_device_led_update(device, 0);
|
||||
return wlr_keyboard_create(NULL, NULL);
|
||||
return wlr_keyboard_create(&impl, kbstate);
|
||||
}
|
||||
|
||||
void handle_keyboard_key(struct libinput_event *event,
|
||||
|
|
|
|||
95
backend/libinput/tablet_pad.c
Normal file
95
backend/libinput/tablet_pad.c
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <libinput.h>
|
||||
#include <wlr/session.h>
|
||||
#include <wlr/types.h>
|
||||
#include <wlr/common/list.h>
|
||||
#include "backend/libinput.h"
|
||||
#include "common/log.h"
|
||||
#include "types.h"
|
||||
|
||||
struct wlr_tablet_pad *wlr_libinput_tablet_pad_create(
|
||||
struct libinput_device *device) {
|
||||
assert(device);
|
||||
return wlr_tablet_pad_create(NULL, NULL);
|
||||
}
|
||||
|
||||
void handle_tablet_pad_button(struct libinput_event *event,
|
||||
struct libinput_device *device) {
|
||||
struct wlr_input_device *dev =
|
||||
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_PAD, device);
|
||||
if (!dev) {
|
||||
wlr_log(L_DEBUG, "Got a tablet pad event for a device with no tablet pad?");
|
||||
return;
|
||||
}
|
||||
struct libinput_event_tablet_pad *pevent =
|
||||
libinput_event_get_tablet_pad_event(event);
|
||||
struct wlr_tablet_pad_button *wlr_event =
|
||||
calloc(1, sizeof(struct wlr_tablet_pad_button));
|
||||
wlr_event->time_sec = libinput_event_tablet_pad_get_time(pevent);
|
||||
wlr_event->time_usec = libinput_event_tablet_pad_get_time_usec(pevent);
|
||||
wlr_event->button = libinput_event_tablet_pad_get_button_number(pevent);
|
||||
switch (libinput_event_tablet_pad_get_button_state(pevent)) {
|
||||
case LIBINPUT_BUTTON_STATE_PRESSED:
|
||||
wlr_event->state = WLR_BUTTON_PRESSED;
|
||||
break;
|
||||
case LIBINPUT_BUTTON_STATE_RELEASED:
|
||||
wlr_event->state = WLR_BUTTON_RELEASED;
|
||||
break;
|
||||
}
|
||||
wl_signal_emit(&dev->tablet_pad->events.button, wlr_event);
|
||||
}
|
||||
|
||||
void handle_tablet_pad_ring(struct libinput_event *event,
|
||||
struct libinput_device *device) {
|
||||
struct wlr_input_device *dev =
|
||||
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_PAD, device);
|
||||
if (!dev) {
|
||||
wlr_log(L_DEBUG, "Got a tablet pad event for a device with no tablet pad?");
|
||||
return;
|
||||
}
|
||||
struct libinput_event_tablet_pad *pevent =
|
||||
libinput_event_get_tablet_pad_event(event);
|
||||
struct wlr_tablet_pad_ring *wlr_event =
|
||||
calloc(1, sizeof(struct wlr_tablet_pad_ring));
|
||||
wlr_event->time_sec = libinput_event_tablet_pad_get_time(pevent);
|
||||
wlr_event->time_usec = libinput_event_tablet_pad_get_time_usec(pevent);
|
||||
wlr_event->ring = libinput_event_tablet_pad_get_ring_number(pevent);
|
||||
wlr_event->position = libinput_event_tablet_pad_get_ring_position(pevent);
|
||||
switch (libinput_event_tablet_pad_get_ring_source(pevent)) {
|
||||
case LIBINPUT_TABLET_PAD_RING_SOURCE_UNKNOWN:
|
||||
wlr_event->source = WLR_TABLET_PAD_RING_SOURCE_UNKNOWN;
|
||||
break;
|
||||
case LIBINPUT_TABLET_PAD_RING_SOURCE_FINGER:
|
||||
wlr_event->source = WLR_TABLET_PAD_RING_SOURCE_FINGER;
|
||||
break;
|
||||
}
|
||||
wl_signal_emit(&dev->tablet_pad->events.ring, wlr_event);
|
||||
}
|
||||
|
||||
void handle_tablet_pad_strip(struct libinput_event *event,
|
||||
struct libinput_device *device) {
|
||||
struct wlr_input_device *dev =
|
||||
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_PAD, device);
|
||||
if (!dev) {
|
||||
wlr_log(L_DEBUG, "Got a tablet pad event for a device with no tablet pad?");
|
||||
return;
|
||||
}
|
||||
struct libinput_event_tablet_pad *pevent =
|
||||
libinput_event_get_tablet_pad_event(event);
|
||||
struct wlr_tablet_pad_strip *wlr_event =
|
||||
calloc(1, sizeof(struct wlr_tablet_pad_strip));
|
||||
wlr_event->time_sec = libinput_event_tablet_pad_get_time(pevent);
|
||||
wlr_event->time_usec = libinput_event_tablet_pad_get_time_usec(pevent);
|
||||
wlr_event->strip = libinput_event_tablet_pad_get_strip_number(pevent);
|
||||
wlr_event->position = libinput_event_tablet_pad_get_strip_position(pevent);
|
||||
switch (libinput_event_tablet_pad_get_strip_source(pevent)) {
|
||||
case LIBINPUT_TABLET_PAD_STRIP_SOURCE_UNKNOWN:
|
||||
wlr_event->source = WLR_TABLET_PAD_STRIP_SOURCE_UNKNOWN;
|
||||
break;
|
||||
case LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER:
|
||||
wlr_event->source = WLR_TABLET_PAD_STRIP_SOURCE_FINGER;
|
||||
break;
|
||||
}
|
||||
wl_signal_emit(&dev->tablet_pad->events.strip, wlr_event);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue