diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2019-07-18 20:46:36 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-10-11 20:20:21 +0200 |
commit | 6385067924a5d80bd261ddce2d70f003353dccc2 (patch) | |
tree | 995ff96c60372e2f30614774bf7c10181c0c7045 /sfx2 | |
parent | 4dfba2861424693455818f8ae16537b2d62961eb (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/80661
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 25 |
1 files changed, 15 insertions, 10 deletions
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); |