[mutter] cursor-tracker: Only emit 'cursor-moved' if it moved
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cursor-tracker: Only emit 'cursor-moved' if it moved
- Date: Thu, 6 Aug 2020 16:26:40 +0000 (UTC)
commit b24b95db15c84284e7f628eb336010fc0e690403
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Wed Jul 29 11:20:21 2020 +0200
cursor-tracker: Only emit 'cursor-moved' if it moved
This makes it safe to update the position with the same coordinates
without risking 'cursor-moved' being emitted when nothing actually
moved.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1391
src/backends/meta-cursor-tracker.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c
index 39f6b2b007..f9331b6f62 100644
--- a/src/backends/meta-cursor-tracker.c
+++ b/src/backends/meta-cursor-tracker.c
@@ -62,6 +62,9 @@ typedef struct _MetaCursorTrackerPrivate
gboolean is_showing;
+ float x;
+ float y;
+
MetaCursorSprite *effective_cursor; /* May be NULL when hidden */
MetaCursorSprite *displayed_cursor;
@@ -179,6 +182,8 @@ meta_cursor_tracker_init (MetaCursorTracker *tracker)
meta_cursor_tracker_get_instance_private (tracker);
priv->is_showing = TRUE;
+ priv->x = -1.0;
+ priv->y = -1.0;
}
static void
@@ -484,12 +489,25 @@ meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
meta_cursor_tracker_get_instance_private (tracker);
MetaCursorRenderer *cursor_renderer =
meta_backend_get_cursor_renderer (priv->backend);
+ gboolean position_changed;
g_assert (meta_is_wayland_compositor ());
+ if (priv->x != new_x || priv->y != new_y)
+ {
+ position_changed = TRUE;
+ priv->x = new_x;
+ priv->y = new_y;
+ }
+ else
+ {
+ position_changed = FALSE;
+ }
+
meta_cursor_renderer_set_position (cursor_renderer, new_x, new_y);
- g_signal_emit (tracker, signals[CURSOR_MOVED], 0, new_x, new_y);
+ if (position_changed)
+ g_signal_emit (tracker, signals[CURSOR_MOVED], 0, new_x, new_y);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]