aboutsummaryrefslogtreecommitdiff
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorRyan Walklin <ryan@testtoast.com>2019-03-20 14:47:29 +1100
committerBrian Ashworth <bosrsf04@gmail.com>2019-03-19 23:58:47 -0400
commitbdb402404cd6d54242b0b1dc2360cfc5679e52f2 (patch)
tree5a355e025c24b3de0bc69db4b8cc9d002bbd1167 /sway/input/seat.c
parentbfa20e65d846f8e8bf7b967b2440d99d82ca9a86 (diff)
Support WLR_INPUT_DEVICE_SWITCH in sway
This commit adds support for laptop lid and tablet mode switches as provided by evdev/libinput and handled by wlroots. Adds a new bindswitch command with syntax: bindswitch <switch>:<state> <command> Where <switch> is one of: tablet for WLR_SWITCH_TYPE_TABLET_MODE lid for WLR_SWITCH_TYPE_LID <state> is one of: on for WLR_SWITCH_STATE_ON off for WLR_SWITCH_STATE_OFF toggle for WLR_SWITCH_STATE_TOGGLE (Note that WLR_SWITCH_STATE_TOGGLE doesn't map to libinput and will trigger at both on and off events)
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 7fc87ee4..d58ff9e6 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -15,6 +15,7 @@
#include "sway/input/input-manager.h"
#include "sway/input/keyboard.h"
#include "sway/input/seat.h"
+#include "sway/input/switch.h"
#include "sway/ipc-server.h"
#include "sway/layers.h"
#include "sway/output.h"
@@ -482,8 +483,8 @@ static void seat_update_capabilities(struct sway_seat *seat) {
case WLR_INPUT_DEVICE_TABLET_TOOL:
caps |= WL_SEAT_CAPABILITY_POINTER;
break;
- case WLR_INPUT_DEVICE_TABLET_PAD:
case WLR_INPUT_DEVICE_SWITCH:
+ case WLR_INPUT_DEVICE_TABLET_PAD:
break;
}
}
@@ -570,6 +571,15 @@ static void seat_configure_keyboard(struct sway_seat *seat,
}
}
+static void seat_configure_switch(struct sway_seat *seat,
+ struct sway_seat_device *seat_device) {
+ if (!seat_device->switch_device) {
+ sway_switch_create(seat, seat_device);
+ }
+ seat_apply_input_config(seat, seat_device);
+ sway_switch_configure(seat_device->switch_device);
+}
+
static void seat_configure_touch(struct sway_seat *seat,
struct sway_seat_device *sway_device) {
wlr_cursor_attach_input_device(seat->cursor->cursor,
@@ -611,6 +621,9 @@ void seat_configure_device(struct sway_seat *seat,
case WLR_INPUT_DEVICE_KEYBOARD:
seat_configure_keyboard(seat, seat_device);
break;
+ case WLR_INPUT_DEVICE_SWITCH:
+ seat_configure_switch(seat, seat_device);
+ break;
case WLR_INPUT_DEVICE_TOUCH:
seat_configure_touch(seat, seat_device);
break;
@@ -620,9 +633,6 @@ void seat_configure_device(struct sway_seat *seat,
case WLR_INPUT_DEVICE_TABLET_PAD:
sway_log(SWAY_DEBUG, "TODO: configure tablet pad");
break;
- case WLR_INPUT_DEVICE_SWITCH:
- sway_log(SWAY_DEBUG, "TODO: configure switch device");
- break;
}
}