[Libreoffice-commits] core.git: framework/source svtools/source vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 30 22:09:46 UTC 2018


 framework/source/uielement/toolbarmanager.cxx |    5 ++--
 svtools/source/uno/popupwindowcontroller.cxx  |    4 ++-
 vcl/source/window/floatwin.cxx                |   28 ++++++++++----------------
 3 files changed, 17 insertions(+), 20 deletions(-)

New commits:
commit 4b8ef8bd6acfa9c062146bff2168fb0450e9542e
Author:     Maxim Monastirsky <momonasmon at gmail.com>
AuthorDate: Sun Aug 26 23:54:13 2018 +0300
Commit:     Maxim Monastirsky <momonasmon at gmail.com>
CommitDate: Fri Aug 31 00:09:20 2018 +0200

    tdf#119390 Don't focus the toolbar when closing a floating window
    
    Toolbar popup windows have the toolbar as their direct
    parent. This causes problems when such window is teared-off
    and later closed, as Window::dispose will attempt to move the
    focus to its parent which is the toolbar, instead of what
    users expect to have the focus back in the document area, or
    in whatever was the last focused control. As a solution
    reparent the window before dispose, similar to what happens
    with floating toolbars.
    
    Also return the focus to the main window when popup mode ends,
    so we can keep track of the last focused control. This is also
    a good thing by itself, as WB_OWNERDRAWDECORATION windows don't
    get the focus by default, which results in neither the floating
    window nor the document have focus after tear-off.
    
    Change-Id: I060b8c45a64db9c612da58b7c35478bab41a4558
    Reviewed-on: https://gerrit.libreoffice.org/59811
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>

diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index b6fe68308b9b..5ca1bb8daa69 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -234,8 +234,9 @@ void ToolBarManager::Destroy()
 
     // Hide toolbar as lazy delete can destroy the toolbar much later.
     m_pToolBar->Hide();
-    /* #i99167# removed change for i93173 since there is some weird crash */
-        // #i93173# delete toolbar lazily as we can still be in one of its handlers
+    // #i93173# delete toolbar lazily as we can still be in one of its handlers
+    // tdf#119390 this will reparent the toolbar, so focus is restored from a
+    // floating toolbar to the last focused control of the application window.
     m_pToolBar->doLazyDelete();
 
     m_pToolBar->SetSelectHdl( Link<ToolBox *, void>() );
diff --git a/svtools/source/uno/popupwindowcontroller.cxx b/svtools/source/uno/popupwindowcontroller.cxx
index 51f2b6e10f42..264afc41ce75 100644
--- a/svtools/source/uno/popupwindowcontroller.cxx
+++ b/svtools/source/uno/popupwindowcontroller.cxx
@@ -79,7 +79,9 @@ void PopupWindowControllerImpl::SetFloatingWindow()
     if( mpFloatingWindow )
     {
         mpFloatingWindow->RemoveEventListener( LINK( this, PopupWindowControllerImpl, WindowEventListener ) );
-        mpFloatingWindow.disposeAndClear();
+        // tdf#119390 reparent the window, so focus is restored
+        // to the last focused control of the application window.
+        mpFloatingWindow->doLazyDelete();
     }
     mpFloatingWindow = mpPopupWindow;
     mpPopupWindow.clear();
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index 5acbf1cc8bc2..86a7140cce43 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -829,29 +829,23 @@ void FloatingWindow::ImplEndPopupMode( FloatWinPopupEndFlags nFlags, const VclPt
     mpNextFloat = nullptr;
 
     FloatWinPopupFlags nPopupModeFlags = mnPopupModeFlags;
+    mbPopupModeTearOff = nFlags & FloatWinPopupEndFlags::TearOff &&
+                         nPopupModeFlags & FloatWinPopupFlags::AllowTearOff;
 
     // hide window again if it was not deleted
-    if ( !(nFlags & FloatWinPopupEndFlags::TearOff) ||
-         !(nPopupModeFlags & FloatWinPopupFlags::AllowTearOff) )
-    {
+    if (!mbPopupModeTearOff)
         Show( false, ShowFlags::NoFocusChange );
 
-        if (HasChildPathFocus() && xFocusId != nullptr)
-        {
-            // restore focus to previous focus window if we still have the focus
-            Window::EndSaveFocus(xFocusId);
-        }
-        else if ( pSVData->maWinData.mpFocusWin && pSVData->maWinData.mpFirstFloat &&
-                  ImplIsWindowOrChild( pSVData->maWinData.mpFocusWin ) )
-        {
-            // maybe pass focus on to a suitable FloatingWindow
-            pSVData->maWinData.mpFirstFloat->GrabFocus();
-        }
-        mbPopupModeTearOff = false;
+    if (HasChildPathFocus() && xFocusId != nullptr)
+    {
+        // restore focus to previous focus window if we still have the focus
+        Window::EndSaveFocus(xFocusId);
     }
-    else
+    else if ( pSVData->maWinData.mpFocusWin && pSVData->maWinData.mpFirstFloat &&
+              ImplIsWindowOrChild( pSVData->maWinData.mpFocusWin ) )
     {
-        mbPopupModeTearOff = true;
+        // maybe pass focus on to a suitable FloatingWindow
+        pSVData->maWinData.mpFirstFloat->GrabFocus();
     }
 
     mbPopupModeCanceled = bool(nFlags & FloatWinPopupEndFlags::Cancel);


More information about the Libreoffice-commits mailing list