This commit is contained in:
taiyu 2015-08-20 04:24:39 -07:00
parent 1d9b73ed67
commit ba6034e8c8
2 changed files with 18 additions and 20 deletions

View file

@ -22,11 +22,11 @@ Commands
-------- --------
**bindsym** <key combo> <command>:: **bindsym** <key combo> <command>::
Binds _key combo_ to execute _command_ when pressed. You may use XKB key names Binds _key combo_ to execute _command_ when pressed. You may use XKB key
here (**xev**(1) is a good tool for discovering them). An example bindsym names here (**xev**(1) is a good tool for discovering them). An example
command would be _bindsym Mod1+Shift+f exec firefox_, which would execute bindsym command would be _bindsym Mod1+Shift+f exec firefox_, which would
Firefox if the alt, shift, and F keys are pressed together. Any valid sway execute Firefox if the alt, shift, and F keys are pressed together. Any
command is eligible to be bound to a key combo. valid sway command is eligible to be bound to a key combo.
**exec** <shell command>:: **exec** <shell command>::
Executes _shell command_ with sh. Executes _shell command_ with sh.
@ -41,9 +41,6 @@ Commands
**floating** toggle:: **floating** toggle::
Toggles the "floating" status of the focused view. Toggles the "floating" status of the focused view.
**floating** mode_toggle::
Toggles focus between floating view and tiled view.
**focus** <direction>:: **focus** <direction>::
Direction may be one of _up_, _down_, _left_, _right_, or _parent_. The Direction may be one of _up_, _down_, _left_, _right_, or _parent_. The
directional focus commands will move the focus in that direction. The parent directional focus commands will move the focus in that direction. The parent
@ -51,6 +48,9 @@ Commands
container, which is useful, for example, to open a sibling of the parent container, which is useful, for example, to open a sibling of the parent
container, or to move the entire container around. container, or to move the entire container around.
**focus** mode_toggle::
Toggles focus between floating view and tiled view.
**focus_follows_mouse** <yes|no>:: **focus_follows_mouse** <yes|no>::
If set to _yes_, the currently focused view will change as you move your If set to _yes_, the currently focused view will change as you move your
mouse around the screen to the view that ends up underneath your mouse. mouse around the screen to the view that ends up underneath your mouse.
@ -86,10 +86,10 @@ Commands
**fullscreen**:: **fullscreen**::
Toggles fullscreen status for the focused view. Toggles fullscreen status for the focused view.
**gaps** <amount>**:: **gaps** <amount>::
Adds _amount_ pixels between each view, and around each output. Adds _amount_ pixels between each view, and around each output.
**gaps** <inner|outer> <amount>**:: **gaps** <inner|outer> <amount>::
Adds _amount_ pixels as an _inner_ or _outer_ gap, where the former affects Adds _amount_ pixels as an _inner_ or _outer_ gap, where the former affects
spacing between views and the latter affects the space around each output. spacing between views and the latter affects the space around each output.

View file

@ -4,14 +4,13 @@
#include "input_state.h" #include "input_state.h"
enum { KEY_STATE_MAX_LENGTH = 64 }; #define KEY_STATE_MAX_LENGTH 64
static keycode key_state_array[KEY_STATE_MAX_LENGTH]; static keycode key_state_array[KEY_STATE_MAX_LENGTH];
static uint8_t key_state_length = 0;
static uint8_t find_key(keycode key) { static uint8_t find_key(keycode key) {
int i; int i;
for (i = 0; i < key_state_length; ++i) { for (i = 0; i < KEY_STATE_MAX_LENGTH; ++i) {
if (key_state_array[i] == key) { if (key_state_array[i] == key) {
break; break;
} }
@ -20,26 +19,25 @@ static uint8_t find_key(keycode key) {
} }
bool check_key(keycode key) { bool check_key(keycode key) {
return find_key(key) < key_state_length; return find_key(key) < KEY_STATE_MAX_LENGTH;
} }
void press_key(keycode key) { void press_key(keycode key) {
// Check if key exists // Check if key exists
if (!check_key(key)) { if (!check_key(key)) {
// Check that we dont exceed buffer length // Check that we dont exceed buffer length
if (key_state_length < KEY_STATE_MAX_LENGTH) { int insert = find_key(0);
key_state_array[key_state_length++] = key; if (insert < KEY_STATE_MAX_LENGTH) {
key_state_array[insert] = key;
} }
} }
} }
void release_key(keycode key) { void release_key(keycode key) {
uint8_t index = find_key(key); uint8_t index = find_key(key);
if (index < key_state_length) { if (index < KEY_STATE_MAX_LENGTH) {
//shift it over and remove key //shift it over and remove key
memmove(&key_state_array[index], key_state_array[index] = 0;
&key_state_array[index + 1],
sizeof(*key_state_array) * (--key_state_length - index));
} }
} }