mirror of
https://github.com/brl/mutter.git
synced 2024-12-04 13:50:41 -05:00
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>
This commit is contained in:
parent
5e7754f742
commit
32e173c3ce
@ -38,6 +38,7 @@
|
|||||||
* might decide they need to launch it again.
|
* might decide they need to launch it again.
|
||||||
*/
|
*/
|
||||||
#define STARTUP_TIMEOUT_MS 15000
|
#define STARTUP_TIMEOUT_MS 15000
|
||||||
|
#define UPDATE_CURSOR_TIMEOUT_MS 20
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -92,6 +93,8 @@ struct _MetaStartupNotification
|
|||||||
|
|
||||||
GSList *startup_sequences;
|
GSList *startup_sequences;
|
||||||
guint startup_sequence_timeout_id;
|
guint startup_sequence_timeout_id;
|
||||||
|
guint update_cursor_timeout_id;
|
||||||
|
MetaCursor cursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -133,22 +136,53 @@ meta_startup_notification_has_pending_sequences (MetaStartupNotification *sn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_startup_notification_update_feedback (MetaStartupNotification *sn)
|
meta_startup_notification_update_cursor (MetaStartupNotification *sn)
|
||||||
{
|
{
|
||||||
MetaDisplay *display = sn->display;
|
MetaDisplay *display = sn->display;
|
||||||
|
MetaCursor cursor;
|
||||||
|
|
||||||
if (meta_startup_notification_has_pending_sequences (sn))
|
if (meta_startup_notification_has_pending_sequences (sn))
|
||||||
{
|
{
|
||||||
meta_topic (META_DEBUG_STARTUP,
|
meta_topic (META_DEBUG_STARTUP,
|
||||||
"Setting busy cursor");
|
"Setting busy cursor");
|
||||||
meta_display_set_cursor (display, META_CURSOR_BUSY);
|
cursor = META_CURSOR_BUSY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
meta_topic (META_DEBUG_STARTUP,
|
meta_topic (META_DEBUG_STARTUP,
|
||||||
"Setting default cursor");
|
"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
|
static void
|
||||||
@ -631,6 +665,7 @@ meta_startup_notification_finalize (GObject *object)
|
|||||||
MetaStartupNotification *sn = META_STARTUP_NOTIFICATION (object);
|
MetaStartupNotification *sn = META_STARTUP_NOTIFICATION (object);
|
||||||
|
|
||||||
g_clear_handle_id (&sn->startup_sequence_timeout_id, g_source_remove);
|
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);
|
g_slist_free_full (sn->startup_sequences, g_object_unref);
|
||||||
sn->startup_sequences = NULL;
|
sn->startup_sequences = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user