[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - include/vcl vcl/inc vcl/source
Henry Castro (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 7 09:42:24 UTC 2021
include/vcl/window.hxx | 2 +
vcl/inc/window.h | 2 +
vcl/source/window/window.cxx | 2 +
vcl/source/window/window2.cxx | 52 ++++++++++++++++++++++++++++++++----------
vcl/source/window/winproc.cxx | 16 +++++++++++-
5 files changed, 60 insertions(+), 14 deletions(-)
New commits:
commit c816eb597ee7f4d6819da28d3bbb961cb2f7f96c
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Thu Jun 24 07:30:15 2021 -0400
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Oct 7 11:41:50 2021 +0200
lok: introduce local mouse tracking
Add the term local mouse tracking per frame window (per user)
instead of global mouse tracking in the desktop case.
Change-Id: I3f8c55fc770b4ac7dea167385586d8639ac4d93b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118856
Tested-by: Szymon Kłos <szymon.klos at collabora.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 41b35a24063d..220df94e97f2 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1162,6 +1162,8 @@ public:
void SetComponentInterface( css::uno::Reference< css::awt::XWindowPeer > const & xIFace );
+ void SetUseFrameData(bool bUseFrameData);
+
/// Interface to register for dialog / window tunneling.
void SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier, bool bParent = false);
const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() const;
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index aebd513426f9..e6acaa78dbbf 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -139,6 +139,7 @@ struct ImplFrameData
VclPtr<vcl::Window> mpFocusWin; //< focus window (is also set, when frame doesn't have the focus)
VclPtr<vcl::Window> mpMouseMoveWin; //< last window, where MouseMove() called
VclPtr<vcl::Window> mpMouseDownWin; //< last window, where MouseButtonDown() called
+ VclPtr<vcl::Window> mpTrackWin; //< window, that is in tracking mode
std::vector<VclPtr<vcl::Window> > maOwnerDrawList; //< List of system windows with owner draw decoration
std::shared_ptr<PhysicalFontCollection> mxFontCollection; //< Font-List for this frame
std::shared_ptr<ImplFontCache> mxFontCache; //< Font-Cache for this frame
@@ -399,6 +400,7 @@ public:
const vcl::ILibreOfficeKitNotifier* mpLOKNotifier; ///< To emit the LOK callbacks eg. for dialog tunneling.
vcl::LOKWindowId mnLOKWindowId; ///< ID of this specific window.
bool mbLOKParentNotifier;
+ bool mbUseFrameData;
};
namespace vcl
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 3b0e390721e3..e2efee60dce8 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -740,6 +740,7 @@ WindowImpl::WindowImpl( WindowType nType )
mpLOKNotifier = nullptr;
mnLOKWindowId = 0;
mbLOKParentNotifier = false;
+ mbUseFrameData = false;
}
WindowImpl::~WindowImpl()
@@ -774,6 +775,7 @@ ImplFrameData::ImplFrameData( vcl::Window *pWindow )
mpFocusWin = nullptr;
mpMouseMoveWin = nullptr;
mpMouseDownWin = nullptr;
+ mpTrackWin = nullptr;
mxFontCollection = pSVData->maGDIData.mxScreenFontList;
mxFontCache = pSVData->maGDIData.mxScreenFontCache;
mnFocusId = nullptr;
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index b8307db328b1..8b2e145d0aae 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -241,17 +241,30 @@ IMPL_LINK( Window, ImplTrackTimerHdl, Timer*, pTimer, void )
Tracking( aTEvt );
}
+void Window::SetUseFrameData(bool bUseFrameData)
+{
+ if (mpWindowImpl)
+ mpWindowImpl->mbUseFrameData = bUseFrameData;
+}
+
void Window::StartTracking( StartTrackingFlags nFlags )
{
+ if (!mpWindowImpl)
+ return;
+
ImplSVData* pSVData = ImplGetSVData();
+ VclPtr<vcl::Window> pTrackWin = mpWindowImpl->mbUseFrameData ?
+ mpWindowImpl->mpFrameData->mpTrackWin :
+ pSVData->mpWinData->mpTrackWin;
- if ( pSVData->mpWinData->mpTrackWin.get() != this )
+ if ( pTrackWin.get() != this )
{
- if ( pSVData->mpWinData->mpTrackWin )
- pSVData->mpWinData->mpTrackWin->EndTracking( TrackingEventFlags::Cancel );
+ if ( pTrackWin )
+ pTrackWin->EndTracking( TrackingEventFlags::Cancel );
}
- if ( nFlags & (StartTrackingFlags::ScrollRepeat | StartTrackingFlags::ButtonRepeat) )
+ if ( !mpWindowImpl->mbUseFrameData &&
+ (nFlags & (StartTrackingFlags::ScrollRepeat | StartTrackingFlags::ButtonRepeat)) )
{
pSVData->mpWinData->mpTrackTimer = new AutoTimer;
@@ -264,30 +277,43 @@ void Window::StartTracking( StartTrackingFlags nFlags )
pSVData->mpWinData->mpTrackTimer->Start();
}
- pSVData->mpWinData->mpTrackWin = this;
- pSVData->mpWinData->mnTrackFlags = nFlags;
- CaptureMouse();
+ if (mpWindowImpl->mbUseFrameData)
+ {
+ mpWindowImpl->mpFrameData->mpTrackWin = this;
+ }
+ else
+ {
+ pSVData->mpWinData->mpTrackWin = this;
+ pSVData->mpWinData->mnTrackFlags = nFlags;
+ CaptureMouse();
+ }
}
void Window::EndTracking( TrackingEventFlags nFlags )
{
+ if (!mpWindowImpl)
+ return;
+
ImplSVData* pSVData = ImplGetSVData();
+ VclPtr<vcl::Window> pTrackWin = mpWindowImpl->mbUseFrameData ?
+ mpWindowImpl->mpFrameData->mpTrackWin :
+ pSVData->mpWinData->mpTrackWin;
- if ( pSVData->mpWinData->mpTrackWin.get() != this )
+ if ( pTrackWin.get() != this )
return;
- if ( pSVData->mpWinData->mpTrackTimer )
+ if ( !mpWindowImpl->mbUseFrameData && pSVData->mpWinData->mpTrackTimer )
{
delete pSVData->mpWinData->mpTrackTimer;
pSVData->mpWinData->mpTrackTimer = nullptr;
}
- pSVData->mpWinData->mpTrackWin = nullptr;
+ mpWindowImpl->mpFrameData->mpTrackWin = pSVData->mpWinData->mpTrackWin = nullptr;
pSVData->mpWinData->mnTrackFlags = StartTrackingFlags::NONE;
ReleaseMouse();
// call EndTracking if required
- if (mpWindowImpl && mpWindowImpl->mpFrameData)
+ if (mpWindowImpl->mpFrameData)
{
Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
if( ImplIsAntiparallel() )
@@ -312,7 +338,9 @@ void Window::EndTracking( TrackingEventFlags nFlags )
bool Window::IsTracking() const
{
- return (ImplGetSVData()->mpWinData->mpTrackWin == this);
+ return (mpWindowImpl->mbUseFrameData ?
+ mpWindowImpl->mpFrameData->mpTrackWin == this :
+ ImplGetSVData()->mpWinData->mpTrackWin == this);
}
void Window::StartAutoScroll( StartAutoScrollFlags nFlags )
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index fcbf268290a0..36f040ce3a72 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -883,9 +883,16 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven
MouseEvent aMouseEvent(aWinPos, nClicks, nMode, nCode, nCode);
if (nEvent == MouseNotifyEvent::MOUSEMOVE)
{
- xWindow->MouseMove(aMouseEvent);
+ if (pFrameData->mpTrackWin)
+ {
+ TrackingEvent aTrackingEvent(aMouseEvent);
+ pFrameData->mpTrackWin->Tracking(aTrackingEvent);
+ }
+ else
+ xWindow->MouseMove(aMouseEvent);
}
- else if (nEvent == MouseNotifyEvent::MOUSEBUTTONDOWN)
+ else if (nEvent == MouseNotifyEvent::MOUSEBUTTONDOWN &&
+ !pFrameData->mpTrackWin)
{
pFrameData->mpMouseDownWin = xWindow;
pFrameData->mnFirstMouseX = aMousePos.X();
@@ -895,6 +902,11 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven
}
else
{
+ if (pFrameData->mpTrackWin)
+ {
+ pFrameData->mpTrackWin->EndTracking();
+ }
+
pFrameData->mpMouseDownWin = nullptr;
pFrameData->mpMouseMoveWin = nullptr;
pFrameData->mbStartDragCalled = false;
More information about the Libreoffice-commits
mailing list