summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Fourdan <ofourdan@redhat.com>2023-02-16 16:31:59 +0100
committerMarge Bot <marge-bot@gnome.org>2023-03-04 09:07:44 +0000
commit32e173c3ce7bb504f836f3d2a91095374909c84e (patch)
tree94d93839f997c3b9b93349238cd888f0c17aba3b
parent5e7754f7424d1314a43cd11a5ac855d8df5ba2ed (diff)
downloadmutter-32e173c3ce7bb504f836f3d2a91095374909c84e.tar.gz
startup-notification: Delay cursor feedback updates
A Wayland client repeatedly requesting activation of its surface using the xdg-activation protocol would make mutter constantly update the cursor. To avoid needlessly updating the cursor back and forth between busy and default, add a timeout to delay the update. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2849>
-rw-r--r--src/core/startup-notification.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/core/startup-notification.c b/src/core/startup-notification.c
index 371ec35ff..21b88dea8 100644
--- a/src/core/startup-notification.c
+++ b/src/core/startup-notification.c
@@ -38,6 +38,7 @@
* might decide they need to launch it again.
*/
#define STARTUP_TIMEOUT_MS 15000
+#define UPDATE_CURSOR_TIMEOUT_MS 20
enum
{
@@ -92,6 +93,8 @@ struct _MetaStartupNotification
GSList *startup_sequences;
guint startup_sequence_timeout_id;
+ guint update_cursor_timeout_id;
+ MetaCursor cursor;
};
typedef struct
@@ -133,22 +136,53 @@ meta_startup_notification_has_pending_sequences (MetaStartupNotification *sn)
}
static void
-meta_startup_notification_update_feedback (MetaStartupNotification *sn)
+meta_startup_notification_update_cursor (MetaStartupNotification *sn)
{
MetaDisplay *display = sn->display;
+ MetaCursor cursor;
if (meta_startup_notification_has_pending_sequences (sn))
{
meta_topic (META_DEBUG_STARTUP,
"Setting busy cursor");
- meta_display_set_cursor (display, META_CURSOR_BUSY);
+ cursor = META_CURSOR_BUSY;
}
else
{
meta_topic (META_DEBUG_STARTUP,
"Setting default cursor");
- meta_display_set_cursor (display, META_CURSOR_DEFAULT);
+ cursor = META_CURSOR_DEFAULT;
}
+
+ if (sn->cursor != cursor)
+ {
+ meta_display_set_cursor (display, cursor);
+ sn->cursor = cursor;
+ }
+}
+
+static gboolean
+meta_startup_notification_cursor_timeout (gpointer user_data)
+{
+ MetaStartupNotification *sn = user_data;
+
+ meta_startup_notification_update_cursor (sn);
+ sn->update_cursor_timeout_id = 0;
+
+ return G_SOURCE_REMOVE;
+}
+
+static void
+meta_startup_notification_update_feedback (MetaStartupNotification *sn)
+{
+ if (sn->update_cursor_timeout_id)
+ return;
+
+ meta_startup_notification_update_cursor (sn);
+ sn->update_cursor_timeout_id =
+ g_timeout_add (UPDATE_CURSOR_TIMEOUT_MS,
+ meta_startup_notification_cursor_timeout,
+ sn);
}
static void
@@ -631,6 +665,7 @@ meta_startup_notification_finalize (GObject *object)
MetaStartupNotification *sn = META_STARTUP_NOTIFICATION (object);
g_clear_handle_id (&sn->startup_sequence_timeout_id, g_source_remove);
+ g_clear_handle_id (&sn->update_cursor_timeout_id, g_source_remove);
g_slist_free_full (sn->startup_sequences, g_object_unref);
sn->startup_sequences = NULL;