[mutter/wip/split-cursor-tracker: 2/2] cursor-tracker: Properly handle invisible cursors
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/split-cursor-tracker: 2/2] cursor-tracker: Properly handle invisible cursors
- Date: Mon, 7 Apr 2014 17:31:05 +0000 (UTC)
commit b9d798c2134f208035edfa8c13fc833486c8b444
Author: Rui Matos <tiagomatos gmail com>
Date: Mon Apr 7 18:40:41 2014 +0200
cursor-tracker: Properly handle invisible cursors
We might be asked to not display the cursor ourselves but we should
still emit cursor-changed signals and hand out the correct sprite and
hot point information when asked so that consumers can still draw an
updated cursor themselves.
This fixes the cursor not showing up in gnome-shell's zoom mode.
src/backends/meta-cursor-tracker-private.h | 6 ++++
src/backends/meta-cursor-tracker.c | 44 ++++++++++++++++++---------
2 files changed, 35 insertions(+), 15 deletions(-)
---
diff --git a/src/backends/meta-cursor-tracker-private.h b/src/backends/meta-cursor-tracker-private.h
index c2a25e9..9564bce 100644
--- a/src/backends/meta-cursor-tracker-private.h
+++ b/src/backends/meta-cursor-tracker-private.h
@@ -46,6 +46,12 @@ struct _MetaCursorTracker {
*/
MetaCursorReference *displayed_cursor;
+ /* This is the cursor that would be displayed if we hadn't been
+ * asked to hide it. i.e. it's the same as displayed_cursor unless
+ * is_showing is false.
+ */
+ MetaCursorReference *current_cursor;
+
MetaCursorReference *grab_cursor;
/* Wayland clients can set a NULL buffer as their cursor
diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c
index c0d5072..a26280b 100644
--- a/src/backends/meta-cursor-tracker.c
+++ b/src/backends/meta-cursor-tracker.c
@@ -157,8 +157,8 @@ meta_cursor_tracker_get_sprite (MetaCursorTracker *tracker)
META_CURSOR_TRACKER_GET_CLASS (tracker)->ensure_cursor (tracker);
- if (tracker->displayed_cursor)
- return meta_cursor_reference_get_cogl_texture (tracker->displayed_cursor, NULL, NULL);
+ if (tracker->current_cursor)
+ return meta_cursor_reference_get_cogl_texture (tracker->current_cursor, NULL, NULL);
else
return NULL;
}
@@ -179,8 +179,8 @@ meta_cursor_tracker_get_hot (MetaCursorTracker *tracker,
META_CURSOR_TRACKER_GET_CLASS (tracker)->ensure_cursor (tracker);
- if (tracker->displayed_cursor)
- meta_cursor_reference_get_cogl_texture (tracker->displayed_cursor, x, y);
+ if (tracker->current_cursor)
+ meta_cursor_reference_get_cogl_texture (tracker->current_cursor, x, y);
else
{
if (x)
@@ -239,11 +239,8 @@ meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
}
static MetaCursorReference *
-get_displayed_cursor (MetaCursorTracker *tracker)
+get_current_cursor (MetaCursorTracker *tracker)
{
- if (!tracker->is_showing)
- return NULL;
-
if (tracker->grab_cursor)
return tracker->grab_cursor;
@@ -253,21 +250,38 @@ get_displayed_cursor (MetaCursorTracker *tracker)
return tracker->root_cursor;
}
+static MetaCursorReference *
+get_displayed_cursor (MetaCursorTracker *tracker)
+{
+ if (!tracker->is_showing)
+ return NULL;
+
+ return get_current_cursor (tracker);
+}
+
void
_meta_cursor_tracker_sync_cursor (MetaCursorTracker *tracker)
{
+ MetaCursorReference *current_cursor = get_current_cursor (tracker);
MetaCursorReference *displayed_cursor = get_displayed_cursor (tracker);
- if (tracker->displayed_cursor == displayed_cursor)
- return;
+ if (tracker->displayed_cursor != displayed_cursor)
+ {
+ g_clear_pointer (&tracker->displayed_cursor, meta_cursor_reference_unref);
+ if (displayed_cursor)
+ tracker->displayed_cursor = meta_cursor_reference_ref (displayed_cursor);
- g_clear_pointer (&tracker->displayed_cursor, meta_cursor_reference_unref);
- if (displayed_cursor)
- tracker->displayed_cursor = meta_cursor_reference_ref (displayed_cursor);
+ META_CURSOR_TRACKER_GET_CLASS (tracker)->sync_cursor (tracker);
+ }
- META_CURSOR_TRACKER_GET_CLASS (tracker)->sync_cursor (tracker);
+ if (tracker->current_cursor != current_cursor)
+ {
+ g_clear_pointer (&tracker->current_cursor, meta_cursor_reference_unref);
+ if (current_cursor)
+ tracker->current_cursor = meta_cursor_reference_ref (current_cursor);
- g_signal_emit (tracker, signals[CURSOR_CHANGED], 0);
+ g_signal_emit (tracker, signals[CURSOR_CHANGED], 0);
+ }
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]