summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/source/window/floatwin.cxx11
-rw-r--r--vcl/source/window/menufloatingwindow.cxx6
2 files changed, 11 insertions, 6 deletions
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index c24706b11efd..e1fb623d72fb 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -793,12 +793,17 @@ void FloatingWindow::ImplEndPopupMode( FloatWinPopupEndFlags nFlags, const VclPt
{
Show( false, ShowFlags::NoFocusChange );
- // maybe pass focus on to a suitable FloatingWindow
- if ( xFocusId != nullptr )
- Window::EndSaveFocus( xFocusId );
+ 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;
}
else
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 52ccac03590c..06024617e68f 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -403,11 +403,11 @@ void MenuFloatingWindow::End()
if (GetParent() && !GetParent()->IsDisposed())
GetParent()->ImplDecModalCount();
- // restore focus
+ // restore focus to previous window if we still have the focus
VclPtr<vcl::Window> xFocusId(xSaveFocusId);
- if (xFocusId != nullptr)
+ xSaveFocusId = nullptr;
+ if (HasChildPathFocus() && xFocusId != nullptr)
{
- xSaveFocusId = nullptr;
ImplGetSVData()->maWinData.mbNoDeactivate = false;
Window::EndSaveFocus(xFocusId);
}