summaryrefslogtreecommitdiff
path: root/sfx2/source/view
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2019-07-18 20:46:36 +0100
committerMichael Meeks <michael.meeks@collabora.com>2019-10-11 21:36:08 +0200
commitf016af33cc1b6e5f1a617ccaa37c2e3d6c81678f (patch)
treed9f66662888f266ff60d42b9f4bbc2fc7df2252c /sfx2/source/view
parente04fb52e8cdc8811c90f7c3492caa87c03ea6c67 (diff)
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@collabora.com>
Diffstat (limited to 'sfx2/source/view')
-rw-r--r--sfx2/source/view/lokhelper.cxx25
1 files changed, 15 insertions, 10 deletions
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);