[Libreoffice-commits] core.git: include/vcl sfx2/source vcl/source
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Fri Oct 11 19:37:19 UTC 2019
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 f016af33cc1b6e5f1a617ccaa37c2e3d6c81678f
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Thu Jul 18 20:46:36 2019 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Oct 11 21:36:08 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/80659
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 965bc79f65c7..58dad46aeef2 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1088,6 +1088,7 @@ public:
bool HasActiveChildFrame() const;
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 b7a4b238f18b..4224c54a3df7 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -317,24 +317,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 05fe9b8ff9e3..b09158b9b16c 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -2992,6 +2992,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;
More information about the Libreoffice-commits
mailing list