gtk-ng: show on-screen keyboard on LMB release

This aligns with VTE behavior when the on-screen keyboard is enabled in
GNOME's accessibility settings.

Closes #7987
pull/8224/head
Leah Amelia Chen 2025-08-14 02:07:49 +08:00
parent 5e3bd92c57
commit 0d0d3118f4
No known key found for this signature in database
1 changed files with 12 additions and 0 deletions

View File

@ -1949,6 +1949,18 @@ pub const Surface = extern struct {
if (priv.core_surface) |surface| {
const gtk_mods = event.getModifierState();
const button = translateMouseButton(gesture.as(gtk.GestureSingle).getCurrentButton());
// Trigger the on-screen keyboard if we have no selection.
//
// This cannot be easily implemented with e.g. bindings or apprt
// actions since the API accepts a gdk.Event, making it inherently
// apprt-specific.
if (button == .left and !surface.hasSelection()) {
if (priv.im_context.as(gtk.IMContext).activateOsk(event) == 0) {
log.warn("failed to activate the on-screen keyboard", .{});
}
}
const mods = gtk_key.translateMods(gtk_mods);
_ = surface.mouseButtonCallback(
.release,