include/vcl/window.hxx | 1 + sfx2/source/view/lokhelper.cxx | 25 +++++++++++++++---------- vcl/source/window/window.cxx | 8 ++++++++ 3 files changed, 24 insertions(+), 10 deletions(-)
New commits: commit 6385067924a5d80bd261ddce2d70f003353dccc2 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Thu Jul 18 20:46:36 2019 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Fri Oct 11 20:20:21 2019 +0200 lok: ensure that dialog windows are focused before emitting events. Otherwise, we can emit events on a different view's window, causing problems, and cross-user interference. Also emit the key-event on the focused sub-window so event bubbling works. Change-Id: I9dd16c2a256bae58d754f94c6d94a1f3fcdb800b Reviewed-on: https://gerrit.libreoffice.org/80661 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 72bf36ec21e3..9f97f915b11c 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1112,6 +1112,7 @@ public: bool HasActiveChildFrame(); GetFocusFlags GetGetFocusFlags() const; void GrabFocusToDocument(); + VclPtr<vcl::Window> GetFocusedWindow() const; /** * Set this when you need to act as if the window has focus even if it diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index c44d4c94d37d..3b05bd1dd696 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -314,24 +314,29 @@ namespace SfxLokHelper::setView(pLOKEv->mnView); } + if (!pLOKEv->mpWindow->HasChildPathFocus(true)) + { + SAL_INFO("sfx.view", "LOK - focus mismatch, switching focus"); + pLOKEv->mpWindow->GrabFocus(); + } + + VclPtr<vcl::Window> pFocusWindow = pLOKEv->mpWindow->GetFocusedWindow(); + if (!pFocusWindow) + pFocusWindow = pLOKEv->mpWindow; + switch (pLOKEv->mnEvent) { case VclEventId::WindowKeyInput: { sal_uInt16 nRepeat = pLOKEv->maKeyEvent.GetRepeat(); - if (nRepeat > 0) - { - KeyEvent singlePress(pLOKEv->maKeyEvent.GetCharCode(), - pLOKEv->maKeyEvent.GetKeyCode()); - for (sal_uInt16 i = 0; i <= nRepeat; ++i) - pLOKEv->mpWindow->KeyInput(singlePress); - } - else - pLOKEv->mpWindow->KeyInput(pLOKEv->maKeyEvent); + KeyEvent singlePress(pLOKEv->maKeyEvent.GetCharCode(), + pLOKEv->maKeyEvent.GetKeyCode()); + for (sal_uInt16 i = 0; i <= nRepeat; ++i) + pFocusWindow->KeyInput(singlePress); break; } case VclEventId::WindowKeyUp: - pLOKEv->mpWindow->KeyUp(pLOKEv->maKeyEvent); + pFocusWindow->KeyUp(pLOKEv->maKeyEvent); break; case VclEventId::WindowMouseButtonDown: pLOKEv->mpWindow->LogicMouseButtonDown(pLOKEv->maMouseEvent); diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 24724e6c8ada..a6b7bfc026f8 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -3008,6 +3008,14 @@ void Window::GrabFocusToDocument() ImplGrabFocusToDocument(GetFocusFlags::NONE); } +VclPtr<vcl::Window> Window::GetFocusedWindow() const +{ + if (mpWindowImpl && mpWindowImpl->mpFrameData) + return mpWindowImpl->mpFrameData->mpFocusWin; + else + return VclPtr<vcl::Window>(); +} + void Window::SetFakeFocus( bool bFocus ) { ImplGetWindowImpl()->mbFakeFocusSet = bFocus; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits