[WIP][DONTMERGE]Add support for libinput_switch input devices

These are used primarily by laptops to signal
the state of the lid (open/closed) and tablet
mode if supported, based on ACPI events.
This commit is contained in:
Ryan Walklin 2018-11-14 23:24:55 +00:00 committed by Ryan Walklin
parent 8a56b96c55
commit 2a3c62b4d2
18 changed files with 261 additions and 1 deletions

View file

@ -54,6 +54,7 @@ lib_wlr_types = static_library(
'wlr_screenshooter.c',
'wlr_server_decoration.c',
'wlr_surface.c',
'wlr_switch.c',
'wlr_tablet_pad.c',
'wlr_tablet_tool.c',
'wlr_text_input_v3.c',

View file

@ -5,6 +5,7 @@
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/interfaces/wlr_switch.h>
#include <wlr/interfaces/wlr_tablet_pad.h>
#include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/interfaces/wlr_touch.h>
@ -40,6 +41,9 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
case WLR_INPUT_DEVICE_POINTER:
wlr_pointer_destroy(dev->pointer);
break;
case WLR_INPUT_DEVICE_SWITCH:
wlr_switch_destroy(dev->lid_switch);
break;
case WLR_INPUT_DEVICE_TOUCH:
wlr_touch_destroy(dev->touch);
break;

22
types/wlr_switch.c Normal file
View file

@ -0,0 +1,22 @@
#include <stdlib.h>
#include <string.h>
#include <wayland-server.h>
#include <wlr/interfaces/wlr_switch.h>
#include <wlr/types/wlr_switch.h>
void wlr_switch_init(struct wlr_switch *lid_switch,
struct wlr_switch_impl *impl) {
lid_switch->impl = impl;
wl_signal_init(&lid_switch->events.toggle);
}
void wlr_switch_destroy(struct wlr_switch *lid_switch) {
if (!lid_switch) {
return;
}
if (lid_switch->impl && lid_switch->impl->destroy) {
lid_switch->impl->destroy(lid_switch);
} else {
free(lid_switch);
}
}