diff --git a/src/apprt/gtk/class/search_overlay.zig b/src/apprt/gtk/class/search_overlay.zig index 75a28de80..46c489f75 100644 --- a/src/apprt/gtk/class/search_overlay.zig +++ b/src/apprt/gtk/class/search_overlay.zig @@ -187,6 +187,10 @@ pub const SearchOverlay = extern struct { signals.@"stop-search".impl.emit(self, null, .{}, null); } + fn stopSearchButton(_: *gtk.Button, self: *Self) callconv(.c) void { + signals.@"stop-search".impl.emit(self, null, .{}, null); + } + fn searchChanged(entry: *gtk.SearchEntry, self: *Self) callconv(.c) void { const text = entry.as(gtk.Editable).getText(); signals.@"search-changed".impl.emit(self, null, .{text}, null); @@ -262,6 +266,7 @@ pub const SearchOverlay = extern struct { // Template Callbacks class.bindTemplateCallback("stop_search", &stopSearch); + class.bindTemplateCallback("stop_search_button", &stopSearchButton); class.bindTemplateCallback("search_changed", &searchChanged); class.bindTemplateCallback("match_label_closure", &closureMatchLabel); class.bindTemplateCallback("next_match", &nextMatch); diff --git a/src/apprt/gtk/class/surface.zig b/src/apprt/gtk/class/surface.zig index 9a77c4c53..2af53e1ef 100644 --- a/src/apprt/gtk/class/surface.zig +++ b/src/apprt/gtk/class/surface.zig @@ -3197,10 +3197,10 @@ pub const Surface = extern struct { } fn searchStop(_: *SearchOverlay, self: *Self) callconv(.c) void { - // Note: at the time of writing this, this behavior doesn't match - // macOS. But I think it makes more sense on Linux/GTK to do this. - // We may follow suit on macOS in the future. - self.setSearchActive(false); + const surface = self.core() orelse return; + _ = surface.performBindingAction(.end_search) catch |err| { + log.warn("unable to perform end_search action err={}", .{err}); + }; _ = self.private().gl_area.as(gtk.Widget).grabFocus(); } diff --git a/src/apprt/gtk/ui/1.2/search-overlay.blp b/src/apprt/gtk/ui/1.2/search-overlay.blp index 62401959e..0d2dd659b 100644 --- a/src/apprt/gtk/ui/1.2/search-overlay.blp +++ b/src/apprt/gtk/ui/1.2/search-overlay.blp @@ -69,6 +69,7 @@ template $GhosttySearchOverlay: Adw.Bin { Button close_button { icon-name: "window-close-symbolic"; tooltip-text: _("Close"); + clicked => $stop_search_button(); cursor: Gdk.Cursor { name: "pointer";