[gtk/wip/carlosg/toggle-osk-sparingly-master] imwayland: Toggle OSK more sparingly
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/toggle-osk-sparingly-master] imwayland: Toggle OSK more sparingly
- Date: Sat, 9 Feb 2019 00:15:54 +0000 (UTC)
commit 37d218b1608b0f0735bd247e2724133898df14f3
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Feb 8 23:11:48 2019 +0100
imwayland: Toggle OSK more sparingly
Specifically it is avoided to be toggled if:
- Just received focus (in order to preserve OSK state across focus changes)
- Moving cursor around. Still allow some jitter as perfect accuracy is not
possible.
Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1277
gtk/gtkimcontextwayland.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
---
diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c
index 7ec3efdb62..adf1722035 100644
--- a/gtk/gtkimcontextwayland.c
+++ b/gtk/gtkimcontextwayland.c
@@ -771,6 +771,8 @@ gtk_im_context_wayland_focus_in (GtkIMContext *context)
if (!global->text_input)
return;
+ if (self->gesture)
+ gtk_event_controller_reset (GTK_EVENT_CONTROLLER (self->gesture));
global->current = context;
if (global->focused)
@@ -806,9 +808,30 @@ gtk_im_context_wayland_set_cursor_location (GtkIMContext *context,
GdkRectangle *rect)
{
GtkIMContextWayland *context_wayland;
+ int side;
context_wayland = GTK_IM_CONTEXT_WAYLAND (context);
+ if (context_wayland->cursor_rect.x == rect->x &&
+ context_wayland->cursor_rect.y == rect->y &&
+ context_wayland->cursor_rect.width == rect->width &&
+ context_wayland->cursor_rect.height == rect->height)
+ return;
+
+ /* Reset the gesture if the cursor changes too far (eg. clicking
+ * between disjoint positions in the text).
+ *
+ * Still Allow some jittering (a square almost double the cursor rect height
+ * on either side) as clicking on the exact same position between characters
+ * is hard.
+ */
+ side = context_wayland->cursor_rect.height;
+
+ if (context_wayland->gesture &&
+ (ABS (rect->x - context_wayland->cursor_rect.x) >= side ||
+ ABS (rect->y - context_wayland->cursor_rect.y) >= side))
+ gtk_event_controller_reset (GTK_EVENT_CONTROLLER (context_wayland->gesture));
+
context_wayland->cursor_rect = *rect;
notify_cursor_location (context_wayland);
commit_state (context_wayland);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]