diff options
Diffstat (limited to 'sway/input/keyboard.c')
-rw-r--r-- | sway/input/keyboard.c | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index ede38519..49241db8 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c | |||
@@ -3,11 +3,11 @@ | |||
3 | #include <wlr/backend/multi.h> | 3 | #include <wlr/backend/multi.h> |
4 | #include <wlr/backend/session.h> | 4 | #include <wlr/backend/session.h> |
5 | #include <wlr/types/wlr_idle.h> | 5 | #include <wlr/types/wlr_idle.h> |
6 | #include "sway/commands.h" | ||
6 | #include "sway/desktop/transaction.h" | 7 | #include "sway/desktop/transaction.h" |
7 | #include "sway/input/seat.h" | ||
8 | #include "sway/input/keyboard.h" | ||
9 | #include "sway/input/input-manager.h" | 8 | #include "sway/input/input-manager.h" |
10 | #include "sway/commands.h" | 9 | #include "sway/input/keyboard.h" |
10 | #include "sway/input/seat.h" | ||
11 | #include "log.h" | 11 | #include "log.h" |
12 | 12 | ||
13 | /** | 13 | /** |
@@ -88,11 +88,13 @@ static void get_active_binding(const struct sway_shortcut_state *state, | |||
88 | uint32_t modifiers, bool release, bool locked) { | 88 | uint32_t modifiers, bool release, bool locked) { |
89 | for (int i = 0; i < bindings->length; ++i) { | 89 | for (int i = 0; i < bindings->length; ++i) { |
90 | struct sway_binding *binding = bindings->items[i]; | 90 | struct sway_binding *binding = bindings->items[i]; |
91 | bool binding_locked = binding->flags & BINDING_LOCKED; | ||
92 | bool binding_release = binding->flags & BINDING_RELEASE; | ||
91 | 93 | ||
92 | if (modifiers ^ binding->modifiers || | 94 | if (modifiers ^ binding->modifiers || |
93 | state->npressed != (size_t)binding->keys->length || | 95 | state->npressed != (size_t)binding->keys->length || |
94 | locked > binding->locked || | 96 | release != binding_release || |
95 | release != binding->release) { | 97 | locked > binding_locked) { |
96 | continue; | 98 | continue; |
97 | } | 99 | } |
98 | 100 | ||
@@ -119,23 +121,6 @@ static void get_active_binding(const struct sway_shortcut_state *state, | |||
119 | } | 121 | } |
120 | 122 | ||
121 | /** | 123 | /** |
122 | * Execute the command associated to a binding | ||
123 | */ | ||
124 | static void keyboard_execute_command(struct sway_keyboard *keyboard, | ||
125 | struct sway_binding *binding) { | ||
126 | wlr_log(WLR_DEBUG, "running command for binding: %s", | ||
127 | binding->command); | ||
128 | config->handler_context.seat = keyboard->seat_device->sway_seat; | ||
129 | struct cmd_results *results = execute_command(binding->command, NULL); | ||
130 | transaction_commit_dirty(); | ||
131 | if (results->status != CMD_SUCCESS) { | ||
132 | wlr_log(WLR_DEBUG, "could not run command for binding: %s (%s)", | ||
133 | binding->command, results->error); | ||
134 | } | ||
135 | free_cmd_results(results); | ||
136 | } | ||
137 | |||
138 | /** | ||
139 | * Execute a built-in, hardcoded compositor binding. These are triggered from a | 124 | * Execute a built-in, hardcoded compositor binding. These are triggered from a |
140 | * single keysym. | 125 | * single keysym. |
141 | * | 126 | * |
@@ -211,12 +196,13 @@ static size_t keyboard_keysyms_raw(struct sway_keyboard *keyboard, | |||
211 | static void handle_keyboard_key(struct wl_listener *listener, void *data) { | 196 | static void handle_keyboard_key(struct wl_listener *listener, void *data) { |
212 | struct sway_keyboard *keyboard = | 197 | struct sway_keyboard *keyboard = |
213 | wl_container_of(listener, keyboard, keyboard_key); | 198 | wl_container_of(listener, keyboard, keyboard_key); |
214 | struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat; | 199 | struct sway_seat* seat = keyboard->seat_device->sway_seat; |
200 | struct wlr_seat *wlr_seat = seat->wlr_seat; | ||
215 | struct wlr_input_device *wlr_device = | 201 | struct wlr_input_device *wlr_device = |
216 | keyboard->seat_device->input_device->wlr_device; | 202 | keyboard->seat_device->input_device->wlr_device; |
217 | wlr_idle_notify_activity(keyboard->seat_device->sway_seat->input->server->idle, wlr_seat); | 203 | wlr_idle_notify_activity(seat->input->server->idle, wlr_seat); |
218 | struct wlr_event_keyboard_key *event = data; | 204 | struct wlr_event_keyboard_key *event = data; |
219 | bool input_inhibited = keyboard->seat_device->sway_seat->exclusive_client != NULL; | 205 | bool input_inhibited = seat->exclusive_client != NULL; |
220 | 206 | ||
221 | // Identify new keycode, raw keysym(s), and translated keysym(s) | 207 | // Identify new keycode, raw keysym(s), and translated keysym(s) |
222 | xkb_keycode_t keycode = event->keycode + 8; | 208 | xkb_keycode_t keycode = event->keycode + 8; |
@@ -266,7 +252,7 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) { | |||
266 | // Execute stored release binding once no longer active | 252 | // Execute stored release binding once no longer active |
267 | if (keyboard->held_binding && binding_released != keyboard->held_binding && | 253 | if (keyboard->held_binding && binding_released != keyboard->held_binding && |
268 | event->state == WLR_KEY_RELEASED) { | 254 | event->state == WLR_KEY_RELEASED) { |
269 | keyboard_execute_command(keyboard, keyboard->held_binding); | 255 | seat_execute_command(seat, keyboard->held_binding); |
270 | handled = true; | 256 | handled = true; |
271 | } | 257 | } |
272 | if (binding_released != keyboard->held_binding) { | 258 | if (binding_released != keyboard->held_binding) { |
@@ -290,7 +276,7 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) { | |||
290 | raw_modifiers, false, input_inhibited); | 276 | raw_modifiers, false, input_inhibited); |
291 | 277 | ||
292 | if (binding_pressed) { | 278 | if (binding_pressed) { |
293 | keyboard_execute_command(keyboard, binding_pressed); | 279 | seat_execute_command(seat, binding_pressed); |
294 | handled = true; | 280 | handled = true; |
295 | } | 281 | } |
296 | } | 282 | } |
@@ -312,6 +298,8 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) { | |||
312 | wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec, | 298 | wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec, |
313 | event->keycode, event->state); | 299 | event->keycode, event->state); |
314 | } | 300 | } |
301 | |||
302 | transaction_commit_dirty(); | ||
315 | } | 303 | } |
316 | 304 | ||
317 | static void handle_keyboard_modifiers(struct wl_listener *listener, | 305 | static void handle_keyboard_modifiers(struct wl_listener *listener, |