Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: GitHub noreply@github.com Date: Sun, 16 Jun 2024 17:05:52 UTC Commit: 90027ebf0f7034f0aad61d509c0f1f9a1dda7ea3 https://github.com/geany/geany/commit/90027ebf0f7034f0aad61d509c0f1f9a1dda7e...
Log Message: ----------- Merge pull request #3909 from techee/infobar_fix
Avoid unwanted selection when infobar shows by mouse click in Scintilla
Modified Paths: -------------- src/document.c
Modified: src/document.c 34 lines changed, 26 insertions(+), 8 deletions(-) =================================================================== @@ -3583,19 +3583,23 @@ static void enable_key_intercept(GeanyDocument *doc, GtkWidget *bar) }
-static void monitor_reload_file(GeanyDocument *doc) +static gboolean monitor_reload_file_idle(gpointer data) { + GeanyDocument *doc = data; + + if (doc != document_get_current()) + return G_SOURCE_REMOVE; + if (! doc->changed && file_prefs.reload_clean_doc_on_file_change) { document_reload_force(doc, doc->encoding); - return; + return G_SOURCE_REMOVE; }
- gchar *base_name = g_path_get_basename(doc->file_name); - /* show this message only once */ if (doc->priv->info_bars[MSG_TYPE_RELOAD] == NULL) { + gchar *base_name = g_path_get_basename(doc->file_name); GtkWidget *bar;
bar = document_show_message(doc, GTK_MESSAGE_QUESTION, on_monitor_reload_file_response, @@ -3609,8 +3613,10 @@ static void monitor_reload_file(GeanyDocument *doc) protect_document(doc); doc->priv->info_bars[MSG_TYPE_RELOAD] = bar; enable_key_intercept(doc, bar); + g_free(base_name); } - g_free(base_name); + + return G_SOURCE_REMOVE; }
@@ -3638,8 +3644,13 @@ static void on_monitor_resave_missing_file_response(GtkWidget *bar, }
-static void monitor_resave_missing_file(GeanyDocument *doc) +static gboolean monitor_resave_missing_file_idle(gpointer data) { + GeanyDocument *doc = data; + + if (doc != document_get_current()) + return G_SOURCE_REMOVE; + if (doc->priv->info_bars[MSG_TYPE_RESAVE] == NULL) { GtkWidget *bar = doc->priv->info_bars[MSG_TYPE_RELOAD]; @@ -3663,6 +3674,8 @@ static void monitor_resave_missing_file(GeanyDocument *doc) doc->priv->info_bars[MSG_TYPE_RESAVE] = bar; enable_key_intercept(doc, bar); } + + return G_SOURCE_REMOVE; }
@@ -3704,15 +3717,20 @@ gboolean document_check_disk_status(GeanyDocument *doc, gboolean force) locale_filename = utils_get_locale_from_utf8(doc->file_name); if (!get_mtime(locale_filename, &mtime)) { - monitor_resave_missing_file(doc); + /* document_check_disk_status() call may be a result of a mouse click + * inside Scintilla by which Geany gains focus and showing the info bar + * during the mouse click leads to text selection as Scintilla scrolls + * because the infobar makes the Scintilla widget smaller. */ + g_idle_add(monitor_resave_missing_file_idle, doc); /* doc may be closed now */ ret = TRUE; } else if (doc->priv->mtime < mtime) { /* make sure the user is not prompted again after he cancelled the "reload file?" message */ doc->priv->mtime = mtime; - monitor_reload_file(doc); + /* see above for the idle call explanation */ + g_idle_add(monitor_reload_file_idle, doc); /* doc may be closed now */ ret = TRUE; }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).