diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2018-05-09 23:52:00 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2018-06-08 12:42:27 +0200 |
commit | bff36583c7be2eb4112adfb778d19a308b458ca8 (patch) | |
tree | 929c43987d9e85ca2e81d7ddc3687368804f3150 /vcl/source | |
parent | 11d542352e1088a2c870b0e73e14e10266276483 (diff) |
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@libreoffice.org>
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/window/menubarwindow.cxx | 19 |
1 files changed, 12 insertions, 7 deletions
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(); } } |