vcl/unx/gtk3/gtkinst.cxx |    8 ++++++++
 1 file changed, 8 insertions(+)

New commits:
commit ac3c1de61e7cf069d3022907570832130235fa32
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sat Nov 6 21:32:21 2021 +0000
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Nov 15 12:31:41 2021 +0100

    Resolves: tdf#145567 restore focus to the usual frame focus widget
    
    when tearing down the start center. Don't leave the focus in an
    arbitrary widget.
    
    Change-Id: I82c30c94121dc43b2ea1b4fbc66a0a3e79f7e664
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124703
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 6b592b341ea0..78c3b09789c1 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -21803,6 +21803,14 @@ private:
         // rehook handler and let vcl cycle its own way through this widget's
         // children
         pFrame->AllowCycleFocusOut();
+
+        // tdf#145567 if the focus is in this hierarchy then, now that we are 
tearing down,
+        // move focus to the usual focus candidate for the frame
+        GtkWindow* pFocusWin = get_active_window();
+        GtkWidget* pFocus = pFocusWin ? gtk_window_get_focus(pFocusWin) : 
nullptr;
+        bool bHasFocus = pFocus && gtk_widget_is_ancestor(pFocus, pTopLevel);
+        if (bHasFocus)
+            pFrame->GrabFocus();
     }
 
     static void signalUnmap(GtkWidget*, gpointer user_data)

Reply via email to