mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
clutter/input-pointer-a11y: Trigger dwell detection in a timeout
Restarting the dwell click immediately would result in a contant animation showing. Start dwell detection in its own timeout handler, which has the nice effect of not constantly showing a dwell animation and also making sure that the dwell click timeout is started when pointer movement stops. https://gitlab.gnome.org/GNOME/mutter/merge_requests/747
This commit is contained in:
parent
9b3b5badfb
commit
14e02635ff
@ -80,6 +80,7 @@ typedef struct _ClutterPtrA11yData
|
|||||||
gboolean dwell_drag_started;
|
gboolean dwell_drag_started;
|
||||||
gboolean dwell_gesture_started;
|
gboolean dwell_gesture_started;
|
||||||
guint dwell_timer;
|
guint dwell_timer;
|
||||||
|
guint dwell_position_timer;
|
||||||
|
|
||||||
guint secondary_click_timer;
|
guint secondary_click_timer;
|
||||||
gboolean secondary_click_triggered;
|
gboolean secondary_click_triggered;
|
||||||
|
@ -518,6 +518,36 @@ stop_dwell_timeout (ClutterInputDevice *device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
trigger_dwell_position_timeout (gpointer data)
|
||||||
|
{
|
||||||
|
ClutterInputDevice *device = data;
|
||||||
|
|
||||||
|
device->ptr_a11y_data->dwell_position_timer = 0;
|
||||||
|
|
||||||
|
if (is_dwell_click_enabled (device))
|
||||||
|
{
|
||||||
|
if (!pointer_has_moved (device))
|
||||||
|
start_dwell_timeout (device);
|
||||||
|
}
|
||||||
|
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
start_dwell_position_timeout (ClutterInputDevice *device)
|
||||||
|
{
|
||||||
|
device->ptr_a11y_data->dwell_position_timer =
|
||||||
|
clutter_threads_add_timeout (100, trigger_dwell_position_timeout, device);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
stop_dwell_position_timeout (ClutterInputDevice *device)
|
||||||
|
{
|
||||||
|
g_clear_handle_id (&device->ptr_a11y_data->dwell_position_timer,
|
||||||
|
g_source_remove);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_dwell_position (ClutterInputDevice *device)
|
update_dwell_position (ClutterInputDevice *device)
|
||||||
{
|
{
|
||||||
@ -570,6 +600,7 @@ _clutter_input_pointer_a11y_remove_device (ClutterInputDevice *device)
|
|||||||
if (is_dwell_dragging (device))
|
if (is_dwell_dragging (device))
|
||||||
emit_dwell_click (device, CLUTTER_A11Y_DWELL_CLICK_TYPE_DRAG);
|
emit_dwell_click (device, CLUTTER_A11Y_DWELL_CLICK_TYPE_DRAG);
|
||||||
|
|
||||||
|
stop_dwell_position_timeout (device);
|
||||||
stop_dwell_timeout (device);
|
stop_dwell_timeout (device);
|
||||||
stop_secondary_click_timeout (device);
|
stop_secondary_click_timeout (device);
|
||||||
|
|
||||||
@ -597,11 +628,13 @@ _clutter_input_pointer_a11y_on_motion_event (ClutterInputDevice *device,
|
|||||||
|
|
||||||
if (is_dwell_click_enabled (device))
|
if (is_dwell_click_enabled (device))
|
||||||
{
|
{
|
||||||
|
stop_dwell_position_timeout (device);
|
||||||
|
|
||||||
if (should_stop_dwell (device))
|
if (should_stop_dwell (device))
|
||||||
stop_dwell_timeout (device);
|
stop_dwell_timeout (device);
|
||||||
|
|
||||||
if (should_start_dwell (device))
|
if (should_start_dwell (device))
|
||||||
start_dwell_timeout (device);
|
start_dwell_position_timeout (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_update_dwell_position (device))
|
if (should_update_dwell_position (device))
|
||||||
@ -623,6 +656,8 @@ _clutter_input_pointer_a11y_on_button_event (ClutterInputDevice *device,
|
|||||||
{
|
{
|
||||||
device->ptr_a11y_data->n_btn_pressed++;
|
device->ptr_a11y_data->n_btn_pressed++;
|
||||||
|
|
||||||
|
stop_dwell_position_timeout (device);
|
||||||
|
|
||||||
if (is_dwell_click_enabled (device))
|
if (is_dwell_click_enabled (device))
|
||||||
stop_dwell_timeout (device);
|
stop_dwell_timeout (device);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user