[Libreoffice-commits] core.git: vcl/inc vcl/source
Armin Le Grand (Allotropia) (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 18 16:49:57 UTC 2021
vcl/inc/svimpbox.hxx | 9 +++++++++
vcl/source/treelist/treelistbox.cxx | 24 ++++++++++++++++++------
2 files changed, 27 insertions(+), 6 deletions(-)
New commits:
commit eaac26c886a793dfb6c619a32a9fdeef98af3f79
Author: Armin Le Grand (Allotropia) <Armin.Le.Grand at me.com>
AuthorDate: Tue Aug 17 14:37:24 2021 +0200
Commit: Armin Le Grand <Armin.Le.Grand at me.com>
CommitDate: Wed Aug 18 18:49:19 2021 +0200
tdf#143114 Avoid StartDrag on TreeListBox when CaptureOnButton
The original method SvTreeListBox::StartDrag always triggers
a MouseButtonUp event and tries to initiate a Drag of a Line of
a TreeListBox (on MouseMove, btw).
This is not wanted if the last MouseButtonDown started a
ButtonActive mode and activated CaptureMouse, prepared to
trigger Action on that Button on MouseButtonUp. It leads to
unwanted/strange behaviour of Buttons/CheckBoxes when used in
TreeListBoxes.
The behaviour is also dependent on the UI implementation used
under Linux (gen/gtk3_kde5/gtk3/qt5/kf5) which are all
(unfortunately) behaving differently, but a first suggestion/
step to enhance the situation.
Found now for gen/qt5/kf5 that when on the LineEntry, but
not on the CheckBox, on MouseButtonUp the other line gets
switched. Corrected that.
Also moved call to base class method MouseButtonDown in
SvTreeListBox to the end of function due to that call may
lead to current incarnation getting disposed. That was
the reason for the crash described in tdf#143749
Note: for gtk3_kde5/gtk3 there remains the problem that the
CheckBoxes get switched on MouseButtonDown, butt these are
generic widgets and this needs to be solved differently.
Change-Id: I9b73d9a7230469664dd6041f81b399e7d933852b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120593
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand at me.com>
diff --git a/vcl/inc/svimpbox.hxx b/vcl/inc/svimpbox.hxx
index 554c5a8070ae..c46003c35dd4 100644
--- a/vcl/inc/svimpbox.hxx
+++ b/vcl/inc/svimpbox.hxx
@@ -310,8 +310,17 @@ public:
bool IsSelectable( const SvTreeListEntry* pEntry );
void SetForceMakeVisible(bool bEnable) { mbForceMakeVisible = bEnable; }
+
+ // tdf#143114 allow to ask if CaptureOnButton is active
+ // (MouseButtonDown hit on SvLBoxButton, CaptureMouse() active)
+ bool IsCaptureOnButtonActive() const;
};
+inline bool SvImpLBox::IsCaptureOnButtonActive() const
+{
+ return nullptr != m_pActiveButton && nullptr != m_pActiveEntry;
+}
+
inline Image& SvImpLBox::implGetImageLocation( const ImageType _eType )
{
return m_aNodeAndEntryImages[_eType];
diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx
index 660294dd36c4..79bd0768f939 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -1108,9 +1108,13 @@ void SvTreeListBox::SetupDragOrigin()
void SvTreeListBox::StartDrag( sal_Int8, const Point& rPosPixel )
{
- Point aEventPos( rPosPixel );
- MouseEvent aMouseEvt( aEventPos, 1, MouseEventModifiers::SELECT, MOUSE_LEFT );
- MouseButtonUp( aMouseEvt );
+ if(!isDisposed())
+ {
+ // tdf#143114 do not start drag when a Button/Checkbox is in
+ // drag-before-ButtonUp mode (CaptureMouse() active)
+ if(pImpl->IsCaptureOnButtonActive())
+ return;
+ }
nOldDragMode = GetDragDropMode();
if ( nOldDragMode == DragDropMode::NONE )
@@ -2282,18 +2286,26 @@ void SvTreeListBox::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
void SvTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
{
- pImpl->m_pCursorOld = pImpl->m_pCursor;
+ // tdf#143114 remember the *correct* starting entry
+ pImpl->m_pCursorOld = (rMEvt.IsLeft() && (nTreeFlags & SvTreeFlags::CHKBTN) && mnClicksToToggle > 0)
+ ? GetEntry(rMEvt.GetPosPixel())
+ : nullptr;
+
pImpl->MouseButtonDown( rMEvt );
}
void SvTreeListBox::MouseButtonUp( const MouseEvent& rMEvt )
{
// tdf#116675 clicking on an entry should toggle its checkbox
- if (rMEvt.IsLeft() && (nTreeFlags & SvTreeFlags::CHKBTN) && mnClicksToToggle > 0)
+ // tdf#143114 use the already created starting entry and if it exists
+ if (nullptr != pImpl->m_pCursorOld)
{
const Point aPnt = rMEvt.GetPosPixel();
SvTreeListEntry* pEntry = GetEntry(aPnt);
- if (pEntry && pEntry->m_Items.size() > 0 && (mnClicksToToggle == 1 || pEntry == pImpl->m_pCursorOld))
+
+ // compare if MouseButtonUp *is* on the same entry, regardless of scrolling
+ // or other things
+ if (pEntry && pEntry->m_Items.size() > 0 && 1 == mnClicksToToggle && pEntry == pImpl->m_pCursorOld)
{
SvLBoxItem* pItem = GetItem(pEntry, aPnt.X());
// if the checkbox button was clicked, that will be toggled later, do not toggle here
More information about the Libreoffice-commits
mailing list