[mutter/wip/carlosg/sanitize-gestures: 10/14] clutter: Carry accounting on double/triple clicks in ClutterText
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/sanitize-gestures: 10/14] clutter: Carry accounting on double/triple clicks in ClutterText
- Date: Fri, 29 Oct 2021 14:51:51 +0000 (UTC)
commit a235d03550b7a8b7c2b3e7a53bf69a4592a6c4fe
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Sep 27 20:19:29 2021 +0200
clutter: Carry accounting on double/triple clicks in ClutterText
Instead of using the ClutterEvent information.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
clutter/clutter/clutter-text.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
---
diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c
index fe28a9730e..9244fc415b 100644
--- a/clutter/clutter/clutter-text.c
+++ b/clutter/clutter/clutter-text.c
@@ -187,6 +187,11 @@ struct _ClutterTextPrivate
ClutterInputContentHintFlags input_hints;
ClutterInputContentPurpose input_purpose;
+ float last_click_x;
+ float last_click_y;
+ uint32_t last_click_time_ms;
+ int click_count;
+
/* bitfields */
guint alignment : 2;
guint wrap : 1;
@@ -2163,6 +2168,39 @@ clutter_text_select_line (ClutterText *self)
clutter_text_set_selection (self, start_pos, end_pos);
}
+static int
+clutter_text_update_click_count (ClutterText *self,
+ const ClutterEvent *event)
+{
+ ClutterTextPrivate *priv = self->priv;
+ ClutterSettings *settings;
+ int double_click_time, double_click_distance;
+ uint32_t evtime;
+ float x, y;
+
+ settings = clutter_settings_get_default ();
+ clutter_event_get_coords (event, &x, &y);
+ evtime = clutter_event_get_time (event);
+
+ g_object_get (settings,
+ "double-click-distance", &double_click_distance,
+ "double-click-time", &double_click_time,
+ NULL);
+
+ if (evtime > (priv->last_click_time_ms + double_click_time) ||
+ (ABS (x - priv->last_click_x) > double_click_distance) ||
+ (ABS (y - priv->last_click_y) > double_click_distance))
+ priv->click_count = 0;
+
+ priv->last_click_time_ms = evtime;
+ priv->last_click_x = x;
+ priv->last_click_y = y;
+
+ priv->click_count = (priv->click_count % 3) + 1;
+
+ return priv->click_count;
+}
+
static gboolean
clutter_text_press (ClutterActor *actor,
ClutterEvent *event)
@@ -2219,7 +2257,9 @@ clutter_text_press (ClutterActor *actor,
*/
if (type == CLUTTER_BUTTON_PRESS)
{
- gint click_count = clutter_event_get_click_count (event);
+ gint click_count;
+
+ click_count = clutter_text_update_click_count (self, event);
if (click_count == 1)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]