From bde62af3e5cd2864cefea26c8d6eb1a322ad08e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20K=C3=BChl?= Date: Fri, 25 Sep 2026 04:25:51 -0300 Subject: [PATCH 1/3] BaseCard: Move focus to the first focusable child on grab_focus --- src/Cards/BaseCard.vala | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Cards/BaseCard.vala b/src/Cards/BaseCard.vala index ffbf8ddd..39085194 100644 --- a/src/Cards/BaseCard.vala +++ b/src/Cards/BaseCard.vala @@ -35,6 +35,16 @@ public abstract class Greeter.BaseCard : Granite.Bin { return base.focus (direction); } + // Gtk4 does not move focus into the children of a widget that is not focusable + public override bool grab_focus () { + if (get_focus_child () != null) { + return true; + } + + // Start from the child: child_focus on this card calls grab_focus on it again + return child?.child_focus (TAB_FORWARD) ?? false; + } + public virtual void on_selected () {} public virtual void on_deselected () {} From ee20bb1f664e2313a4918c71a17c575e3c015e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20K=C3=BChl?= Date: Fri, 25 Sep 2026 04:35:45 -0300 Subject: [PATCH 2/3] UserCard: Grab focus when the form reveal animation ends --- src/Cards/BaseCard.vala | 4 ++-- src/Cards/UserCard.vala | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Cards/BaseCard.vala b/src/Cards/BaseCard.vala index 39085194..2b04e341 100644 --- a/src/Cards/BaseCard.vala +++ b/src/Cards/BaseCard.vala @@ -35,13 +35,13 @@ public abstract class Greeter.BaseCard : Granite.Bin { return base.focus (direction); } - // Gtk4 does not move focus into the children of a widget that is not focusable + // Gtk4 grab_focus () does not move focus into the children of a widget that is not focusable public override bool grab_focus () { if (get_focus_child () != null) { return true; } - // Start from the child: child_focus on this card calls grab_focus on it again + // Do not call child_focus () on this card: it calls grab_focus () again and recurses return child?.child_focus (TAB_FORWARD) ?? false; } diff --git a/src/Cards/UserCard.vala b/src/Cards/UserCard.vala index 1114183e..76546321 100644 --- a/src/Cards/UserCard.vala +++ b/src/Cards/UserCard.vala @@ -102,6 +102,13 @@ public class Greeter.UserCard : Greeter.BaseCard { child = login_stack }; + // Focus cannot move into the form until the reveal animation ends + form_revealer.notify["child-revealed"].connect (() => { + if (form_revealer.child_revealed) { + grab_focus (); + } + }); + main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { margin_bottom = 48, overflow = HIDDEN // Without this, Gtk.Picture won't have rounded corners From d4145a423fc0c8d4aabdf18a51bbaf1e134f5f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20K=C3=BChl?= Date: Wed, 30 Sep 2026 18:57:26 -0300 Subject: [PATCH 3/3] UserCard: Focus the password entry instead of overriding grab_focus --- src/Cards/BaseCard.vala | 10 ---------- src/Cards/UserCard.vala | 3 +-- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Cards/BaseCard.vala b/src/Cards/BaseCard.vala index 2b04e341..ffbf8ddd 100644 --- a/src/Cards/BaseCard.vala +++ b/src/Cards/BaseCard.vala @@ -35,16 +35,6 @@ public abstract class Greeter.BaseCard : Granite.Bin { return base.focus (direction); } - // Gtk4 grab_focus () does not move focus into the children of a widget that is not focusable - public override bool grab_focus () { - if (get_focus_child () != null) { - return true; - } - - // Do not call child_focus () on this card: it calls grab_focus () again and recurses - return child?.child_focus (TAB_FORWARD) ?? false; - } - public virtual void on_selected () {} public virtual void on_deselected () {} diff --git a/src/Cards/UserCard.vala b/src/Cards/UserCard.vala index 76546321..b7c8cac9 100644 --- a/src/Cards/UserCard.vala +++ b/src/Cards/UserCard.vala @@ -102,10 +102,9 @@ public class Greeter.UserCard : Greeter.BaseCard { child = login_stack }; - // Focus cannot move into the form until the reveal animation ends form_revealer.notify["child-revealed"].connect (() => { if (form_revealer.child_revealed) { - grab_focus (); + password_entry.grab_focus_without_selecting (); } });