include/vcl/svapp.hxx | 3 + vcl/inc/window.h | 5 +++ vcl/source/app/svapp.cxx | 68 ++++++++++++++++++++++++++++++++++++++++++ vcl/source/window/winproc.cxx | 4 +- 4 files changed, 78 insertions(+), 2 deletions(-)
New commits: commit 2f7a0b81f21f7e383808c2e5f5d532cb50b84376 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Wed Jun 23 08:37:34 2021 -0400 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Tue Feb 8 21:40:04 2022 +0100 lok: introduce Application::LOKHandleMouseEvent Entry point to call the ImplLOKHandleMouseEvent function mainly to process mouse events. Change-Id: I17513643733bf5990d41ab8cf47cdc322ed526ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118846 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117711 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index 137177bbfbb0..22164ed78d4c 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -741,6 +741,9 @@ public: */ static ImplSVEvent * PostKeyEvent( VclEventId nEvent, vcl::Window *pWin, KeyEvent const * pKeyEvent ); + + static bool LOKHandleMouseEvent( VclEventId nEvent, vcl::Window *pWin, const MouseEvent* pEvent ); + /** Send mouse event @param nEvent Event ID for mouse event diff --git a/vcl/inc/window.h b/vcl/inc/window.h index 050c0558eb7c..1c3e2e1c41f9 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -31,6 +31,7 @@ #include <o3tl/typed_flags_set.hxx> #include <cppuhelper/weakref.hxx> #include "windowdev.hxx" +#include "salwtype.hxx" #include <optional> #include <list> @@ -93,6 +94,10 @@ bool isEnabledInLayout(const vcl::Window *pWindow); bool ImplWindowFrameProc( vcl::Window* pInst, SalEvent nEvent, const void* pEvent ); +MouseEventModifiers ImplGetMouseMoveMode( SalMouseEvent const * pEvent ); + +MouseEventModifiers ImplGetMouseButtonMode( SalMouseEvent const * pEvent ); + struct ImplWinData { std::optional<OUString> diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index cc046decdad5..d63b8d34bd82 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -925,6 +925,74 @@ ImplSVEvent* Application::PostGestureEvent(VclEventId nEvent, vcl::Window* pWin, return nEventId; } +bool Application::LOKHandleMouseEvent(VclEventId nEvent, vcl::Window* pWindow, const MouseEvent* pEvent) +{ + bool bSuccess = false; + SalMouseEvent aMouseEvent; + + if (!pWindow) + return false; + + if (!pEvent) + return false; + + aMouseEvent.mnTime = tools::Time::GetSystemTicks(); + aMouseEvent.mnX = pEvent->GetPosPixel().X(); + aMouseEvent.mnY = pEvent->GetPosPixel().Y(); + aMouseEvent.mnCode = pEvent->GetButtons() | pEvent->GetModifier(); + + switch (nEvent) + { + case VclEventId::WindowMouseMove: + aMouseEvent.mnButton = 0; + bSuccess = ImplLOKHandleMouseEvent(pWindow, MouseNotifyEvent::MOUSEMOVE, false, + aMouseEvent.mnX, aMouseEvent.mnY, + aMouseEvent.mnTime, aMouseEvent.mnCode, + ImplGetMouseMoveMode(&aMouseEvent), + pEvent->GetClicks()); + break; + + case VclEventId::WindowMouseButtonDown: + aMouseEvent.mnButton = pEvent->GetButtons(); + bSuccess = ImplLOKHandleMouseEvent(pWindow, MouseNotifyEvent::MOUSEBUTTONDOWN, false, + aMouseEvent.mnX, aMouseEvent.mnY, + aMouseEvent.mnTime, +#ifdef MACOSX + aMouseEvent.mnButton | + (aMouseEvent.mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3)), +#else + aMouseEvent.mnButton | + (aMouseEvent.mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)), +#endif + ImplGetMouseButtonMode(&aMouseEvent), + pEvent->GetClicks()); + break; + + case VclEventId::WindowMouseButtonUp: + aMouseEvent.mnButton = pEvent->GetButtons(); + bSuccess = ImplLOKHandleMouseEvent(pWindow, MouseNotifyEvent::MOUSEBUTTONUP, false, + aMouseEvent.mnX, aMouseEvent.mnY, + aMouseEvent.mnTime, +#ifdef MACOSX + aMouseEvent.mnButton | + (aMouseEvent.mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3)), +#else + aMouseEvent.mnButton | + (aMouseEvent.mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)), +#endif + ImplGetMouseButtonMode(&aMouseEvent), + pEvent->GetClicks()); + break; + + default: + SAL_WARN( "vcl.layout", "Application::HandleMouseEvent unknown event (" << static_cast<int>(nEvent) << ")" ); + break; + } + + return bSuccess; +} + + ImplSVEvent* Application::PostMouseEvent( VclEventId nEvent, vcl::Window *pWin, MouseEvent const * pMouseEvent ) { const SolarMutexGuard aGuard; diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index 35a5ce2754d2..b79bc0744729 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -2154,7 +2154,7 @@ static void ImplHandleUserEvent( ImplSVEvent* pSVEvent ) } } -static MouseEventModifiers ImplGetMouseMoveMode( SalMouseEvent const * pEvent ) +MouseEventModifiers ImplGetMouseMoveMode( SalMouseEvent const * pEvent ) { MouseEventModifiers nMode = MouseEventModifiers::NONE; if ( !pEvent->mnCode ) @@ -2166,7 +2166,7 @@ static MouseEventModifiers ImplGetMouseMoveMode( SalMouseEvent const * pEvent ) return nMode; } -static MouseEventModifiers ImplGetMouseButtonMode( SalMouseEvent const * pEvent ) +MouseEventModifiers ImplGetMouseButtonMode( SalMouseEvent const * pEvent ) { MouseEventModifiers nMode = MouseEventModifiers::NONE; if ( pEvent->mnButton == MOUSE_LEFT )