commit 98df7a63570274c0f7215ba02cf89b45462c315b
parent 590c6d735a5288a855d604264855b89da87b2ddb
Author: Michael Forney <mforney@mforney.org>
Date: Thu, 31 Jul 2014 20:06:46 -0700
Style
Diffstat:
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/libswc/keyboard.c b/libswc/keyboard.c
@@ -59,25 +59,22 @@ static void leave(struct input_focus_handler * handler,
static bool client_handle_key(struct keyboard * keyboard, uint32_t time,
struct press * press, uint32_t state)
{
- uint32_t * client_key;
+ uint32_t * key;
if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
{
- client_key = wl_array_add(&keyboard->client_keys, sizeof *client_key);
-
- if (!client_key)
+ if (!(key = wl_array_add(&keyboard->client_keys, sizeof *key)))
return false;
- *client_key = press->value;
+ *key = press->value;
}
else
{
- wl_array_for_each(client_key, &keyboard->client_keys)
+ wl_array_for_each(key, &keyboard->client_keys)
{
- if (*client_key == press->value)
+ if (*key == press->value)
{
- swc_array_remove(&keyboard->client_keys,
- client_key, sizeof *client_key);
+ swc_array_remove(&keyboard->client_keys, key, sizeof *key);
break;
}
}
@@ -257,9 +254,7 @@ void keyboard_handle_key(struct keyboard * keyboard, uint32_t time,
if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
return;
- key = wl_array_add(&keyboard->keys, sizeof *key);
-
- if (!key)
+ if (!(key = wl_array_add(&keyboard->keys, sizeof *key)))
goto update_xkb_state;
key->press.value = value;