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
This commit is contained in:
parent
2db6dbd192
commit
38a4c4dd37
@ -731,6 +731,8 @@ gtk_im_context_wayland_focus_in (GtkIMContext *context)
|
|||||||
if (!global->text_input)
|
if (!global->text_input)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (context_wayland->gesture)
|
||||||
|
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (context_wayland->gesture));
|
||||||
global->current = context;
|
global->current = context;
|
||||||
|
|
||||||
if (global->focused)
|
if (global->focused)
|
||||||
@ -764,9 +766,30 @@ gtk_im_context_wayland_set_cursor_location (GtkIMContext *context,
|
|||||||
GdkRectangle *rect)
|
GdkRectangle *rect)
|
||||||
{
|
{
|
||||||
GtkIMContextWayland *context_wayland;
|
GtkIMContextWayland *context_wayland;
|
||||||
|
int side;
|
||||||
|
|
||||||
context_wayland = GTK_IM_CONTEXT_WAYLAND (context);
|
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;
|
context_wayland->cursor_rect = *rect;
|
||||||
notify_cursor_location (context_wayland);
|
notify_cursor_location (context_wayland);
|
||||||
commit_state (context_wayland);
|
commit_state (context_wayland);
|
||||||
|
Loading…
Reference in New Issue
Block a user