summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-11-14 11:33:24 +0000
committerCaolán McNamara <caolanm@redhat.com>2016-11-14 11:36:41 +0000
commit616bc7b854e237aea1962a6750abd7f139e38ac2 (patch)
treee6b0b87a43b115a038abd94c7e9cde717bd1e63f /vcl
parent52040395e3046ac42b8c3dd385c7b1cb26b929f3 (diff)
Resolves: tdf#103914 if menu no longer has focus, leave focus where it is
In the normal course of events, the menu, or its children, has focus when its popped down, in this case continue to restored the focus to the previous focus window which had it when the menu appeared. If some other non-child window of the menu has focus as popdown time, leave the focus where it is. Change-Id: Ia860f90350653ad4d8056738dacbc434fb364989
Diffstat (limited to 'vcl')
-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 465177eb3499..3a680247c2dd 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -771,12 +771,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 83854a6697fd..366aeed1ad1d 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -405,11 +405,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);
}