diff options
| author | Vito Caputo <vcaputo@pengaru.com> | 2022-03-30 14:52:40 -0700 | 
|---|---|---|
| committer | Vito Caputo <vcaputo@pengaru.com> | 2022-03-30 14:58:57 -0700 | 
| commit | 6edde492d901a7f8ae071580bb06f1851a631387 (patch) | |
| tree | bced59c6a1cc2d88cd051ad4368d84b63056b0a7 /src | |
| parent | 7f21f754609495d26579ec73f954cfcf8ef228be (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 9 | 
1 files changed, 8 insertions, 1 deletions
@@ -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;  }  | 
