From 6edde492d901a7f8ae071580bb06f1851a631387 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 30 Mar 2022 14:52:40 -0700 Subject: glimmer: suppress re-rebuild from focus-out-event When rebuilding the settings, an unnecessary focus-out-event is produced that we don't want to queue another rebuild from. In order to suppress the re-queueing of another rebuild, which produces a sort of perpetual endless rebuild situation, use a global flag for suppressing the rebuild queuing from the focus-out-event callback. The rebuild code sets this flag during the rebuild, and the callback will skip queueing a rebuild when it's true. There's probably a more elegant solution, but I didn't see a convenient way to suppress the focus events temporarily via gtk/glib for the duration of the rebuild. This works for now, and fixes the CPU burning behavior observed on activated GtkEntry settings boxes. --- src/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 4ecbd2e..1737c28 100644 --- a/src/main.c +++ b/src/main.c @@ -188,6 +188,8 @@ static void glimmer_entry_setting_activated_cb(GtkEntry *entry, gpointer user_da } +static int glimmer_settings_rebuilding; + static gboolean glimmer_entry_setting_unfocused_cb(GtkEntry *entry, GdkEventFocus *event, gpointer user_data) { til_setting_t *setting = user_data; @@ -196,7 +198,8 @@ static gboolean glimmer_entry_setting_unfocused_cb(GtkEntry *entry, GdkEventFocu * though that probably shouldn't happen here. */ setting->value = strdup(gtk_entry_get_text(entry)); - g_idle_add(glimmer_active_settings_rebuild_cb, NULL); + if (!glimmer_settings_rebuilding) + g_idle_add(glimmer_active_settings_rebuild_cb, NULL); return FALSE; } @@ -216,6 +219,8 @@ static void glimmer_settings_rebuild(const til_module_t *module, til_settings_t til_setting_t *setting; const til_setting_desc_t *desc; + glimmer_settings_rebuilding = 1; + /* Always create a new settings vbox on rebuild, migrating preexisting shboxes, * leaving behind no longer visible shboxes, adding newly visible shboxes. * @@ -299,6 +304,8 @@ static void glimmer_settings_rebuild(const til_module_t *module, til_settings_t gtk_window_set_focus(GTK_WINDOW(glimmer.window), focused); gtk_widget_show_all(svbox); + + glimmer_settings_rebuilding = 0; } -- cgit v1.2.3