Release pressed keys when dragging outside the keyboard

If no keys are under the touch position when dragging then release all
existing pressed keys. This fixes the problem where the last pressed key
causes events to be sent while the touch position moves outside the
keyboard extent.
This commit is contained in:
David Boddie
2019-08-02 15:31:18 +00:00
parent 4cd15c074e
commit 0057c80b2e

View File

@ -174,16 +174,17 @@ static void drag(EekGtkKeyboard *self,
gdouble x, gdouble y, guint32 time) {
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
EekKey *key = eek_renderer_find_key_by_position (priv->renderer, x, y);
if (key) {
GList *list, *head;
gboolean found = FALSE;
list = eek_keyboard_get_pressed_keys (priv->keyboard);
if (key) {
gboolean found = FALSE;
for (head = list; head; head = g_list_next (head)) {
if (head->data == key)
if (head->data == key) {
found = TRUE;
else {
} else {
eek_keyboard_release_key(priv->keyboard, EEK_KEY(head->data), time);
on_key_released(key, self);
}
@ -194,6 +195,12 @@ static void drag(EekGtkKeyboard *self,
eek_keyboard_press_key(priv->keyboard, key, time);
on_key_pressed(key, self);
}
} else {
for (head = list; head; head = g_list_next (head)) {
eek_keyboard_release_key(priv->keyboard, EEK_KEY(head->data), time);
on_key_released(key, self);
}
g_list_free (list);
}
}