yutani: remove kbd_state, use active_modifiers instead

This commit is contained in:
K. Lange 2018-12-08 12:43:01 +09:00
parent 517060eebc
commit 52f35de578
2 changed files with 12 additions and 10 deletions

View File

@ -1435,7 +1435,6 @@ static void window_untile(yutani_globals_t * yg, yutani_server_window_t * window
static void handle_key_event(yutani_globals_t * yg, struct yutani_msg_key_event * ke) {
yg->active_modifiers = ke->event.modifiers;
yutani_server_window_t * focused = get_focused(yg);
memcpy(&yg->kbd_state, &ke->state, sizeof(key_event_state_t));
if (focused) {
#if 1
if ((ke->event.action == KEY_ACTION_DOWN) &&
@ -1770,18 +1769,24 @@ static void handle_mouse_event(yutani_globals_t * yg, struct yutani_msg_mouse_ev
switch (yg->mouse_state) {
case YUTANI_MOUSE_STATE_NORMAL:
{
if ((me->event.buttons & YUTANI_MOUSE_BUTTON_LEFT) && (yg->kbd_state.k_alt)) {
if ((me->event.buttons & YUTANI_MOUSE_BUTTON_LEFT) &&
(yg->active_modifiers & YUTANI_KEY_MODIFIER_ALT)) {
mouse_start_drag(yg, NULL);
} else if ((me->event.buttons & YUTANI_MOUSE_SCROLL_UP) && (yg->kbd_state.k_alt)) {
} else if ((me->event.buttons & YUTANI_MOUSE_SCROLL_UP) &&
(yg->active_modifiers & YUTANI_KEY_MODIFIER_ALT)) {
adjust_window_opacity(yg, 8);
} else if ((me->event.buttons & YUTANI_MOUSE_SCROLL_DOWN) && (yg->kbd_state.k_alt)) {
} else if ((me->event.buttons & YUTANI_MOUSE_SCROLL_DOWN) &&
(yg->active_modifiers & YUTANI_KEY_MODIFIER_ALT)) {
adjust_window_opacity(yg, -8);
} else if ((me->event.buttons & YUTANI_MOUSE_BUTTON_RIGHT) && (yg->kbd_state.k_alt)) {
} else if ((me->event.buttons & YUTANI_MOUSE_BUTTON_RIGHT) &&
(yg->active_modifiers & YUTANI_KEY_MODIFIER_ALT)) {
mouse_start_rotate(yg);
} else if ((me->event.buttons & YUTANI_MOUSE_BUTTON_MIDDLE) && (yg->kbd_state.k_alt)) {
} else if ((me->event.buttons & YUTANI_MOUSE_BUTTON_MIDDLE) &&
(yg->active_modifiers & YUTANI_KEY_MODIFIER_ALT)) {
yg->resizing_button = YUTANI_MOUSE_BUTTON_MIDDLE;
mouse_start_resize(yg, SCALE_AUTO);
} else if ((me->event.buttons & YUTANI_MOUSE_BUTTON_LEFT) && (!yg->kbd_state.k_alt)) {
} else if ((me->event.buttons & YUTANI_MOUSE_BUTTON_LEFT) &&
!(yg->active_modifiers & YUTANI_KEY_MODIFIER_ALT)) {
yg->mouse_state = YUTANI_MOUSE_STATE_DRAGGING;
set_focused_at(yg, yg->mouse_x / MOUSE_SCALE, yg->mouse_y / MOUSE_SCALE);
yg->mouse_window = get_focused(yg);

View File

@ -224,9 +224,6 @@ typedef struct YutaniGlobals {
int32_t mouse_click_x;
int32_t mouse_click_y;
/* Keyboard library state machine state */
key_event_state_t kbd_state;
/* Pointer to window being resized */
yutani_server_window_t * resizing_window;
int32_t resizing_w;