Commit e3984305 authored by Dorota Czaplejewicz's avatar Dorota Czaplejewicz
Browse files

Keep keyboard visible when buttons are pressed.

This fixes momentary clicks which hide the keyboard, causing the button press never to be released.

It's still possible to get keys stuck by drag-and-dropping away from the original key.

Addresses the root cause of #18
parent db86ec81
Pipeline #2422 passed with stage
in 55 seconds
......@@ -89,6 +89,7 @@ struct virtual_keyboard {
char *preferred_layout;
uint32_t buttons_held;
bool scheduled_hidden; // the keyboard should hide as soon as buttons_held == 0
};
/// Modifiers passed to the virtual_keyboard protocol.
......@@ -694,6 +695,9 @@ static void keyboard_update_mods(struct keyboard *keyboard) {
mods, 0, locked, 0);
}
static void
try_hide(struct virtual_keyboard *keyboard);
static void
keyboard_handle_key(struct keyboard *keyboard, const struct layout *layout,
uint32_t time, const struct key *key,
......@@ -863,6 +867,11 @@ keyboard_handle_key(struct keyboard *keyboard, const struct layout *layout,
default:
dbg("Keytype invalid\n");
}
if (keyboard->keyboard->scheduled_hidden
&& keyboard->keyboard->buttons_held == 0) {
try_hide(keyboard->keyboard);
}
}
static int
......@@ -971,6 +980,9 @@ button_handler(struct widget *widget, struct input *input, uint32_t time,
break;
}
}
if (!keyboard->window) {
return;
}
if (!keyboard->window) {
return;
......@@ -1151,6 +1163,19 @@ make_hidden(struct virtual_keyboard *keyboard) {
notify_visible(false);
}
/** Checks for clicked buttons and hides when they are all unclicked.
*/
static void
try_hide(struct virtual_keyboard *keyboard) {
if (keyboard->buttons_held) {
keyboard->scheduled_hidden = true;
} else {
keyboard->scheduled_hidden = false;
make_hidden(keyboard);
return;
}
}
static void
handle_input_method_activate(void *data, struct zwp_input_method_v2 *input_method)
{
......@@ -1216,7 +1241,7 @@ handle_commit_state(void *data, struct zwp_input_method_v2 *input_method)
if (keyboard->current.active) {
make_visible(keyboard);
} else {
make_hidden(keyboard);
try_hide(keyboard);
}
}
......@@ -1229,7 +1254,7 @@ handle_unavailable(void *data, struct zwp_input_method_v2 *zwp_input_method_v2)
keyboard->current.active = false;
zwp_input_method_v2_destroy(keyboard->input_method);
keyboard->input_method = NULL;
make_hidden(keyboard);
try_hide(keyboard);
}
static const struct zwp_input_method_v2_listener input_method_listener = {
......@@ -1362,7 +1387,7 @@ handle_set_visible(SmPuriOSK0 *object, GDBusMethodInvocation *invocation,
if (arg_visible) {
make_visible(keyboard);
} else {
make_hidden(keyboard);
try_hide(keyboard);
}
sm_puri_osk0_complete_set_visible(object, invocation);
return TRUE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment