Beautify handle_key_press
This commit is contained in:
parent
656bdc5090
commit
404f19a376
|
@ -41,10 +41,8 @@ int handle_key_release(void *ignored, xcb_connection_t *conn, xcb_key_release_ev
|
|||
}
|
||||
|
||||
/*
|
||||
* There was a key press. We lookup the key symbol and see if there are any bindings
|
||||
* on that. This allows to do things like binding special characters (think of ä) to
|
||||
* functions to get one more modifier while not losing AltGr :-)
|
||||
* TODO: this description needs to be more understandable
|
||||
* There was a key press. We compare this key code with our bindings table and pass
|
||||
* the bound action to parse_command().
|
||||
*
|
||||
*/
|
||||
int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press_event_t *event) {
|
||||
|
@ -59,36 +57,29 @@ int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press_event_
|
|||
|
||||
printf("state %d\n", event->state);
|
||||
|
||||
/* Remove the numlock bit, all other bits are modifiers we can bind to */
|
||||
uint16_t state_filtered = event->state & ~XCB_MOD_MASK_LOCK;
|
||||
|
||||
/* Find the binding */
|
||||
/* TODO: event->state durch eine bitmask filtern und dann direkt vergleichen */
|
||||
Binding *bind, *best_match = TAILQ_END(&bindings);
|
||||
TAILQ_FOREACH(bind, &bindings, bindings) {
|
||||
if (bind->keycode == event->detail &&
|
||||
(bind->mods & event->state) == bind->mods) {
|
||||
if (best_match == TAILQ_END(&bindings) ||
|
||||
bind->mods > best_match->mods)
|
||||
best_match = bind;
|
||||
}
|
||||
}
|
||||
Binding *bind;
|
||||
TAILQ_FOREACH(bind, &bindings, bindings)
|
||||
if (bind->keycode == event->detail && bind->mods == state_filtered)
|
||||
break;
|
||||
|
||||
/* No match? Then it was an actively grabbed key, that is with Mode_switch, and
|
||||
the user did not press Mode_switch, so just pass it… */
|
||||
if (best_match == TAILQ_END(&bindings)) {
|
||||
if (bind == TAILQ_END(&bindings)) {
|
||||
xcb_allow_events(conn, ReplayKeyboard, event->time);
|
||||
xcb_flush(conn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
parse_command(conn, bind->command);
|
||||
if (event->state & 0x2) {
|
||||
printf("that's mode_switch\n");
|
||||
parse_command(conn, best_match->command);
|
||||
printf("ok, hiding this event.\n");
|
||||
printf("Mode_switch -> allow_events(SyncKeyboard)\n");
|
||||
xcb_allow_events(conn, SyncKeyboard, event->time);
|
||||
xcb_flush(conn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
parse_command(conn, best_match->command);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -252,16 +252,12 @@ void render_layout(xcb_connection_t *connection) {
|
|||
int width = r_ws->rect.width;
|
||||
int height = r_ws->rect.height;
|
||||
|
||||
/* Reserve space for dock clients */
|
||||
Client *client;
|
||||
SLIST_FOREACH(client, &(r_ws->dock_clients), dock_clients) {
|
||||
printf("got dock client: %p\n", client);
|
||||
printf("it wants to be this height: %d\n", client->desired_height);
|
||||
SLIST_FOREACH(client, &(r_ws->dock_clients), dock_clients)
|
||||
height -= client->desired_height;
|
||||
}
|
||||
|
||||
printf("got %d rows and %d cols\n", r_ws->rows, r_ws->cols);
|
||||
printf("each of them therefore is %d px width and %d px height\n",
|
||||
width / r_ws->cols, height / r_ws->rows);
|
||||
|
||||
int xoffset[r_ws->rows];
|
||||
int yoffset[r_ws->cols];
|
||||
|
|
Loading…
Reference in New Issue