diff options
author | Ryan Walklin <ryan@testtoast.com> | 2019-03-20 14:47:29 +1100 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2019-03-19 23:58:47 -0400 |
commit | bdb402404cd6d54242b0b1dc2360cfc5679e52f2 (patch) | |
tree | 5a355e025c24b3de0bc69db4b8cc9d002bbd1167 /include | |
parent | Clean up focus follows mouse logic (diff) | |
download | sway-bdb402404cd6d54242b0b1dc2360cfc5679e52f2.tar.gz sway-bdb402404cd6d54242b0b1dc2360cfc5679e52f2.tar.zst sway-bdb402404cd6d54242b0b1dc2360cfc5679e52f2.zip |
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 'include')
-rw-r--r-- | include/sway/commands.h | 1 | ||||
-rw-r--r-- | include/sway/config.h | 15 | ||||
-rw-r--r-- | include/sway/input/seat.h | 1 | ||||
-rw-r--r-- | include/sway/input/switch.h | 19 |
4 files changed, 36 insertions, 0 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h index 764821a0..1c147c5a 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h | |||
@@ -101,6 +101,7 @@ struct sway_container *container_find_resize_parent(struct sway_container *con, | |||
101 | sway_cmd cmd_assign; | 101 | sway_cmd cmd_assign; |
102 | sway_cmd cmd_bar; | 102 | sway_cmd cmd_bar; |
103 | sway_cmd cmd_bindcode; | 103 | sway_cmd cmd_bindcode; |
104 | sway_cmd cmd_bindswitch; | ||
104 | sway_cmd cmd_bindsym; | 105 | sway_cmd cmd_bindsym; |
105 | sway_cmd cmd_border; | 106 | sway_cmd cmd_border; |
106 | sway_cmd cmd_client_noop; | 107 | sway_cmd cmd_client_noop; |
diff --git a/include/sway/config.h b/include/sway/config.h index 7c544541..8970696c 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include <string.h> | 5 | #include <string.h> |
6 | #include <time.h> | 6 | #include <time.h> |
7 | #include <wlr/interfaces/wlr_switch.h> | ||
7 | #include <wlr/types/wlr_box.h> | 8 | #include <wlr/types/wlr_box.h> |
8 | #include <xkbcommon/xkbcommon.h> | 9 | #include <xkbcommon/xkbcommon.h> |
9 | #include "../include/config.h" | 10 | #include "../include/config.h" |
@@ -29,6 +30,7 @@ enum binding_input_type { | |||
29 | BINDING_KEYSYM, | 30 | BINDING_KEYSYM, |
30 | BINDING_MOUSECODE, | 31 | BINDING_MOUSECODE, |
31 | BINDING_MOUSESYM, | 32 | BINDING_MOUSESYM, |
33 | BINDING_SWITCH | ||
32 | }; | 34 | }; |
33 | 35 | ||
34 | enum binding_flags { | 36 | enum binding_flags { |
@@ -61,6 +63,16 @@ struct sway_mouse_binding { | |||
61 | }; | 63 | }; |
62 | 64 | ||
63 | /** | 65 | /** |
66 | * A laptop switch binding and an associated command. | ||
67 | */ | ||
68 | struct sway_switch_binding { | ||
69 | enum wlr_switch_type type; | ||
70 | enum wlr_switch_state state; | ||
71 | uint32_t flags; | ||
72 | char *command; | ||
73 | }; | ||
74 | |||
75 | /** | ||
64 | * Focus on window activation. | 76 | * Focus on window activation. |
65 | */ | 77 | */ |
66 | enum sway_fowa { | 78 | enum sway_fowa { |
@@ -78,6 +90,7 @@ struct sway_mode { | |||
78 | list_t *keysym_bindings; | 90 | list_t *keysym_bindings; |
79 | list_t *keycode_bindings; | 91 | list_t *keycode_bindings; |
80 | list_t *mouse_bindings; | 92 | list_t *mouse_bindings; |
93 | list_t *switch_bindings; | ||
81 | bool pango; | 94 | bool pango; |
82 | }; | 95 | }; |
83 | 96 | ||
@@ -603,6 +616,8 @@ int sway_binding_cmp_keys(const void *a, const void *b); | |||
603 | 616 | ||
604 | void free_sway_binding(struct sway_binding *sb); | 617 | void free_sway_binding(struct sway_binding *sb); |
605 | 618 | ||
619 | void free_switch_binding(struct sway_switch_binding *binding); | ||
620 | |||
606 | void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); | 621 | void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); |
607 | 622 | ||
608 | void load_swaybar(struct bar_config *bar); | 623 | void load_swaybar(struct bar_config *bar); |
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index a5361e8c..f2af1066 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -27,6 +27,7 @@ struct sway_seat_device { | |||
27 | struct sway_seat *sway_seat; | 27 | struct sway_seat *sway_seat; |
28 | struct sway_input_device *input_device; | 28 | struct sway_input_device *input_device; |
29 | struct sway_keyboard *keyboard; | 29 | struct sway_keyboard *keyboard; |
30 | struct sway_switch *switch_device; | ||
30 | struct wl_list link; // sway_seat::devices | 31 | struct wl_list link; // sway_seat::devices |
31 | }; | 32 | }; |
32 | 33 | ||
diff --git a/include/sway/input/switch.h b/include/sway/input/switch.h new file mode 100644 index 00000000..19bb1e77 --- /dev/null +++ b/include/sway/input/switch.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef _SWAY_INPUT_SWITCH_H | ||
2 | #define _SWAY_INPUT_SWITCH_H | ||
3 | |||
4 | #include "sway/input/seat.h" | ||
5 | |||
6 | struct sway_switch { | ||
7 | struct sway_seat_device *seat_device; | ||
8 | |||
9 | struct wl_listener switch_toggle; | ||
10 | }; | ||
11 | |||
12 | struct sway_switch *sway_switch_create(struct sway_seat *seat, | ||
13 | struct sway_seat_device *device); | ||
14 | |||
15 | void sway_switch_configure(struct sway_switch *sway_switch); | ||
16 | |||
17 | void sway_switch_destroy(struct sway_switch *sway_switch); | ||
18 | |||
19 | #endif | ||