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)
This commit is contained in:
Ryan Walklin 2019-03-20 14:47:29 +11:00 committed by Brian Ashworth
parent bfa20e65d8
commit bdb402404c
14 changed files with 339 additions and 9 deletions

View file

@ -47,6 +47,7 @@ static struct cmd_handler handlers[] = {
{ "assign", cmd_assign },
{ "bar", cmd_bar },
{ "bindcode", cmd_bindcode },
{ "bindswitch", cmd_bindswitch },
{ "bindsym", cmd_bindsym },
{ "client.background", cmd_client_noop },
{ "client.focused", cmd_client_focused },
@ -386,6 +387,7 @@ struct cmd_results *config_command(char *exec, char **new_block) {
&& handler->handle != cmd_mode
&& handler->handle != cmd_bindsym
&& handler->handle != cmd_bindcode
&& handler->handle != cmd_bindswitch
&& handler->handle != cmd_set
&& handler->handle != cmd_for_window
&& (*argv[i] == '\"' || *argv[i] == '\'')) {