summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2018-08-26 23:54:13 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2018-08-31 00:09:20 +0200
commit4b8ef8bd6acfa9c062146bff2168fb0450e9542e (patch)
treecb722bc05431c0273a202b106f461931960f1724 /vcl
parente2ecce7e01038baac502f4b69c7ad47e82cd1ab4 (diff)
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@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/floatwin.cxx28
1 files changed, 11 insertions, 17 deletions
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);