From bdb402404cd6d54242b0b1dc2360cfc5679e52f2 Mon Sep 17 00:00:00 2001 From: Ryan Walklin Date: Wed, 20 Mar 2019 14:47:29 +1100 Subject: 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 : Where is one of: tablet for WLR_SWITCH_TYPE_TABLET_MODE lid for WLR_SWITCH_TYPE_LID 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) --- sway/config.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sway/config.c') diff --git a/sway/config.c b/sway/config.c index 48bbd1ea..7104f55d 100644 --- a/sway/config.c +++ b/sway/config.c @@ -56,6 +56,12 @@ static void free_mode(struct sway_mode *mode) { } list_free(mode->mouse_bindings); } + if (mode->switch_bindings) { + for (int i = 0; i < mode->switch_bindings->length; i++) { + free_switch_binding(mode->switch_bindings->items[i]); + } + list_free(mode->switch_bindings); + } free(mode); } @@ -195,6 +201,7 @@ static void config_defaults(struct sway_config *config) { if (!(config->current_mode->keysym_bindings = create_list())) goto cleanup; if (!(config->current_mode->keycode_bindings = create_list())) goto cleanup; if (!(config->current_mode->mouse_bindings = create_list())) goto cleanup; + if (!(config->current_mode->switch_bindings = create_list())) goto cleanup; list_add(config->modes, config->current_mode); config->floating_mod = 0; -- cgit v1.2.3-54-g00ecf