[Libreoffice-commits] core.git: vcl/source
Maxim Monastirsky
momonasmon at gmail.com
Fri Jun 8 10:43:01 UTC 2018
vcl/source/window/menubarwindow.cxx | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
New commits:
commit bff36583c7be2eb4112adfb778d19a308b458ca8
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Wed May 9 23:52:00 2018 +0300
tdf#117440 Can't move focus to disposed window
xSaveFocusId is the already disposed comments floating window,
so it can't accept focus anymore. Moreover, if closing the
menu by clicking its title, the focus results nowhere, and no
keyboard interaction works at all (including e.g. F6 or F10).
This patch makes the focus switch back to the document, like
it was in earlier LO versions. And does it in a way that
doesn't break tdf#115227.
Change-Id: I1d473557c10faf65b5b1fa917f5a5d66d0de8656
Reviewed-on: https://gerrit.libreoffice.org/55457
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index c264e89fba0a..e2d6660dd7af 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -514,20 +514,25 @@ void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool b
ImplGetSVData()->maWinData.mbNoDeactivate = false;
if( !ImplGetSVData()->maWinData.mbNoSaveFocus )
{
- VclPtr<vcl::Window> xTempFocusId = xSaveFocusId;
+ VclPtr<vcl::Window> xTempFocusId;
+ if (xSaveFocusId && !xSaveFocusId->isDisposed())
+ xTempFocusId = xSaveFocusId;
xSaveFocusId = nullptr;
+
if (bAllowRestoreFocus)
{
// tdf#115227 the popup is already killed, so temporarily set us as the
// focus window, so we could avoid sending superfluous activate events
// to top window listeners.
- ImplGetSVData()->maWinData.mpFocusWin = this;
- Window::EndSaveFocus(xTempFocusId);
- assert(xTempFocusId == nullptr || ImplGetSVData()->maWinData.mpFocusWin != this);
+ if (xTempFocusId || bDefaultToDocument)
+ ImplGetSVData()->maWinData.mpFocusWin = this;
+
+ // #105406# restore focus to document if we could not save focus before
+ if (!xTempFocusId && bDefaultToDocument)
+ GrabFocusToDocument();
+ else
+ Window::EndSaveFocus(xTempFocusId);
}
- // #105406# restore focus to document if we could not save focus before
- if (bDefaultToDocument && xTempFocusId == nullptr && bAllowRestoreFocus)
- GrabFocusToDocument();
}
}
More information about the Libreoffice-commits
mailing list