From e03505aa8ea189bf1ecf20d14253f3415814948e Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Tue, 16 Jun 2026 15:27:29 +0100 Subject: [PATCH 1/2] Avoid focus event in searchbar --- src/Widgets/SearchBar.vala | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Widgets/SearchBar.vala b/src/Widgets/SearchBar.vala index 8fb50588d..bdf41c63f 100644 --- a/src/Widgets/SearchBar.vala +++ b/src/Widgets/SearchBar.vala @@ -227,7 +227,11 @@ namespace Scratch.Widgets { // Connecting to some signals search_entry.changed.connect (on_search_parameters_changed); search_entry.key_press_event.connect (on_search_entry_key_press); - search_entry.focus_in_event.connect (on_search_entry_focused_in); + search_entry.notify["is-focus"].connect (() => { + if (search_entry.is_focus) { + on_search_entry_focused_in (); + } + }); search_entry.icon_release.connect ((p0, p1) => { if (p0 == Gtk.EntryIconPosition.PRIMARY) { search_next (); @@ -359,18 +363,12 @@ namespace Scratch.Widgets { update_search_widgets (); } - private bool on_search_entry_focused_in (Gdk.EventFocus event) { - if (text_buffer == null) { - return false; - } - + private void on_search_entry_focused_in () requires (text_buffer != null) { Idle.add (() => { update_search_widgets (); search_entry.select_region (0, -1); return Source.REMOVE; }); - - return Gdk.EVENT_PROPAGATE; } public bool search () { From 7576241b3d915ad19908959f99c4100b43af9921 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Tue, 16 Jun 2026 15:39:03 +0100 Subject: [PATCH 2/2] Avoid focus event in Document --- src/Services/Document.vala | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/Services/Document.vala b/src/Services/Document.vala index 7ac1b5100..f05947a13 100644 --- a/src/Services/Document.vala +++ b/src/Services/Document.vala @@ -256,24 +256,17 @@ namespace Scratch.Services { this.source_view.buffer.create_tag ("highlight_search_all", "background", "yellow", null); - // Focus in event for SourceView - // Check if file changed externally or permissions changed - this.source_view.focus_in_event.connect (() => { - if (!locked && !is_file_temporary) { - check_undoable_actions (); - check_file_status.begin (); - } - - return false; - }); - - // Focus out event for SourceView - this.source_view.focus_out_event.connect (() => { - if (!locked && Scratch.settings.get_boolean ("autosave")) { - save_with_hold.begin (); + this.source_view.notify["is-focus"].connect (() => { + if (source_view.is_focus) { + if (!locked && !is_file_temporary) { + check_undoable_actions (); + check_file_status.begin (); + } + } else { + if (!locked && Scratch.settings.get_boolean ("autosave")) { + save_with_hold.begin (); + } } - - return false; }); source_view.buffer.changed.connect (() => {