diff options
-rw-r--r-- | sway.5.txt | 20 | ||||
-rw-r--r-- | sway/input_state.c | 18 |
2 files changed, 18 insertions, 20 deletions
@@ -22,11 +22,11 @@ Commands | |||
22 | -------- | 22 | -------- |
23 | 23 | ||
24 | **bindsym** <key combo> <command>:: | 24 | **bindsym** <key combo> <command>:: |
25 | Binds _key combo_ to execute _command_ when pressed. You may use XKB key names | 25 | Binds _key combo_ to execute _command_ when pressed. You may use XKB key |
26 | here (**xev**(1) is a good tool for discovering them). An example bindsym | 26 | names here (**xev**(1) is a good tool for discovering them). An example |
27 | command would be _bindsym Mod1+Shift+f exec firefox_, which would execute | 27 | bindsym command would be _bindsym Mod1+Shift+f exec firefox_, which would |
28 | Firefox if the alt, shift, and F keys are pressed together. Any valid sway | 28 | execute Firefox if the alt, shift, and F keys are pressed together. Any |
29 | command is eligible to be bound to a key combo. | 29 | valid sway command is eligible to be bound to a key combo. |
30 | 30 | ||
31 | **exec** <shell command>:: | 31 | **exec** <shell command>:: |
32 | Executes _shell command_ with sh. | 32 | Executes _shell command_ with sh. |
@@ -41,9 +41,6 @@ Commands | |||
41 | **floating** toggle:: | 41 | **floating** toggle:: |
42 | Toggles the "floating" status of the focused view. | 42 | Toggles the "floating" status of the focused view. |
43 | 43 | ||
44 | **floating** mode_toggle:: | ||
45 | Toggles focus between floating view and tiled view. | ||
46 | |||
47 | **focus** <direction>:: | 44 | **focus** <direction>:: |
48 | Direction may be one of _up_, _down_, _left_, _right_, or _parent_. The | 45 | Direction may be one of _up_, _down_, _left_, _right_, or _parent_. The |
49 | directional focus commands will move the focus in that direction. The parent | 46 | directional focus commands will move the focus in that direction. The parent |
@@ -51,6 +48,9 @@ Commands | |||
51 | container, which is useful, for example, to open a sibling of the parent | 48 | container, which is useful, for example, to open a sibling of the parent |
52 | container, or to move the entire container around. | 49 | container, or to move the entire container around. |
53 | 50 | ||
51 | **focus** mode_toggle:: | ||
52 | Toggles focus between floating view and tiled view. | ||
53 | |||
54 | **focus_follows_mouse** <yes|no>:: | 54 | **focus_follows_mouse** <yes|no>:: |
55 | If set to _yes_, the currently focused view will change as you move your | 55 | If set to _yes_, the currently focused view will change as you move your |
56 | mouse around the screen to the view that ends up underneath your mouse. | 56 | mouse around the screen to the view that ends up underneath your mouse. |
@@ -86,10 +86,10 @@ Commands | |||
86 | **fullscreen**:: | 86 | **fullscreen**:: |
87 | Toggles fullscreen status for the focused view. | 87 | Toggles fullscreen status for the focused view. |
88 | 88 | ||
89 | **gaps** <amount>**:: | 89 | **gaps** <amount>:: |
90 | Adds _amount_ pixels between each view, and around each output. | 90 | Adds _amount_ pixels between each view, and around each output. |
91 | 91 | ||
92 | **gaps** <inner|outer> <amount>**:: | 92 | **gaps** <inner|outer> <amount>:: |
93 | Adds _amount_ pixels as an _inner_ or _outer_ gap, where the former affects | 93 | Adds _amount_ pixels as an _inner_ or _outer_ gap, where the former affects |
94 | spacing between views and the latter affects the space around each output. | 94 | spacing between views and the latter affects the space around each output. |
95 | 95 | ||
diff --git a/sway/input_state.c b/sway/input_state.c index 0769c30f..51213b19 100644 --- a/sway/input_state.c +++ b/sway/input_state.c | |||
@@ -4,14 +4,13 @@ | |||
4 | 4 | ||
5 | #include "input_state.h" | 5 | #include "input_state.h" |
6 | 6 | ||
7 | enum { KEY_STATE_MAX_LENGTH = 64 }; | 7 | #define KEY_STATE_MAX_LENGTH 64 |
8 | 8 | ||
9 | static keycode key_state_array[KEY_STATE_MAX_LENGTH]; | 9 | static keycode key_state_array[KEY_STATE_MAX_LENGTH]; |
10 | static uint8_t key_state_length = 0; | ||
11 | 10 | ||
12 | static uint8_t find_key(keycode key) { | 11 | static uint8_t find_key(keycode key) { |
13 | int i; | 12 | int i; |
14 | for (i = 0; i < key_state_length; ++i) { | 13 | for (i = 0; i < KEY_STATE_MAX_LENGTH; ++i) { |
15 | if (key_state_array[i] == key) { | 14 | if (key_state_array[i] == key) { |
16 | break; | 15 | break; |
17 | } | 16 | } |
@@ -20,26 +19,25 @@ static uint8_t find_key(keycode key) { | |||
20 | } | 19 | } |
21 | 20 | ||
22 | bool check_key(keycode key) { | 21 | bool check_key(keycode key) { |
23 | return find_key(key) < key_state_length; | 22 | return find_key(key) < KEY_STATE_MAX_LENGTH; |
24 | } | 23 | } |
25 | 24 | ||
26 | void press_key(keycode key) { | 25 | void press_key(keycode key) { |
27 | // Check if key exists | 26 | // Check if key exists |
28 | if (!check_key(key)) { | 27 | if (!check_key(key)) { |
29 | // Check that we dont exceed buffer length | 28 | // Check that we dont exceed buffer length |
30 | if (key_state_length < KEY_STATE_MAX_LENGTH) { | 29 | int insert = find_key(0); |
31 | key_state_array[key_state_length++] = key; | 30 | if (insert < KEY_STATE_MAX_LENGTH) { |
31 | key_state_array[insert] = key; | ||
32 | } | 32 | } |
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | void release_key(keycode key) { | 36 | void release_key(keycode key) { |
37 | uint8_t index = find_key(key); | 37 | uint8_t index = find_key(key); |
38 | if (index < key_state_length) { | 38 | if (index < KEY_STATE_MAX_LENGTH) { |
39 | //shift it over and remove key | 39 | //shift it over and remove key |
40 | memmove(&key_state_array[index], | 40 | key_state_array[index] = 0; |
41 | &key_state_array[index + 1], | ||
42 | sizeof(*key_state_array) * (--key_state_length - index)); | ||
43 | } | 41 | } |
44 | } | 42 | } |
45 | 43 | ||