include/vcl/toolkit/dialog.hxx |    2 ++
 vcl/source/window/dialog.cxx   |   13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 55fe27bf56360c63b4349f2889734e964a2a0b68
Author:     Szymon Kłos <[email protected]>
AuthorDate: Thu Dec 9 09:41:50 2021 +0100
Commit:     Szymon Kłos <[email protected]>
CommitDate: Fri Dec 10 14:26:04 2021 +0100

    jsdialog: send info about initial focus in dialog
    
    Change-Id: I9daef497cb083e863d45a2acfd7eee3ee92bdc38
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126565
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Mert Tumer <[email protected]>

diff --git a/include/vcl/toolkit/dialog.hxx b/include/vcl/toolkit/dialog.hxx
index bab25f2d15f3..32317d514aa9 100644
--- a/include/vcl/toolkit/dialog.hxx
+++ b/include/vcl/toolkit/dialog.hxx
@@ -127,6 +127,8 @@ private:
     bool            ImplStartExecute();
     static void     ImplEndExecuteModal();
     void            ImplSetModalInputMode(bool bModal);
+
+    vcl::Window*    GetFirstControlForFocus();
 public:
 
     /// Commence execution of a modal dialog, disposes owner on failure
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 54d12e8945db..4adcce7180d1 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -1299,7 +1299,7 @@ void Dialog::ImplSetModalInputMode( bool bModal )
     }
 }
 
-void Dialog::GrabFocusToFirstControl()
+vcl::Window* Dialog::GetFirstControlForFocus()
 {
     vcl::Window* pFocusControl = nullptr;
     vcl::Window* pFirstOverlapWindow = ImplGetFirstOverlapWindow();
@@ -1323,6 +1323,13 @@ void Dialog::GrabFocusToFirstControl()
     {
         pFocusControl = ImplGetDlgWindow( 0, GetDlgWindowType::First );
     }
+
+    return pFocusControl;
+}
+
+void Dialog::GrabFocusToFirstControl()
+{
+    vcl::Window* pFocusControl = GetFirstControlForFocus();
     if ( pFocusControl )
         pFocusControl->ImplControlFocus( GetFocusFlags::Init );
 }
@@ -1672,6 +1679,10 @@ void Dialog::DumpAsPropertyTree(tools::JsonWriter& 
rJsonWriter)
             rJsonWriter.put("response", rResponse.second);
         }
     }
+
+    vcl::Window* pFocusControl = GetFirstControlForFocus();
+    if (pFocusControl)
+        rJsonWriter.put("init_focus_id", pFocusControl->get_id());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to