diff options
author | Henry Castro <hcastro@collabora.com> | 2021-06-23 08:37:34 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2022-02-08 21:40:04 +0100 |
commit | 2f7a0b81f21f7e383808c2e5f5d532cb50b84376 (patch) | |
tree | d46bf60c7329d7f45ae49bf650f157d0b3386d9c /vcl/source | |
parent | d8538d7fd693a24c7698ac9dd5447134c0c0f210 (diff) |
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.klos@collabora.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117711
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/app/svapp.cxx | 68 | ||||
-rw-r--r-- | vcl/source/window/winproc.cxx | 4 |
2 files changed, 70 insertions, 2 deletions
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 ) |