vcl/qt5/QtTools.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2d33669a535892a9424776e87f928a9321bfbd42
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Sat May 17 00:56:11 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat May 17 10:27:55 2025 +0200

    tdf#130857 qt weld: Report released mouse button in event
    
    As the QSinglePointEvent::buttons doc [1] says:
    
    > For mouse press, double click, or TabletPress events, this includes the
    > button that caused the event.
    >
    > For mouse release or TabletRelease events, this excludes the button that
    > caused the event.
    
    However, LO expects the released mouse button to be set
    in the MouseEvent passed to weld::Widget::signal_mouse_release
    (in QtInstanceWidget::eventFilter).
    
    Therefore, also include QSinglePointEvent::button (without an "s")
    at the end, which "returns the button that caused the event." [2]
    
    Without this commit in place, clicking into the table of available
    characters in the special characters dialog (in a WIP branch
    experimenting with adding support for that dialog for
    SAL_VCL_QT_USE_WELDED_WIDGETS=1) was resulting in the
    mouse getting grabbed, but the mouse kept being grabbed when the
    left mouse button was released, meaning that e.g. clicking on buttons
    in the dialog had no effect.
    
    This is because the `rMEvt.IsLeft()` check in
    SvxShowCharSet::MouseButtonUp returned false:
    
        bool SvxShowCharSet::MouseButtonUp(const MouseEvent& rMEvt)
        {
            if ( bDrag && rMEvt.IsLeft() )
            {
                // released mouse over character map
                if ( tools::Rectangle(Point(), 
GetOutputSizePixel()).Contains(rMEvt.GetPosPixel()))
                    aSelectHdl.Call( this );
                ReleaseMouse();
                bDrag = false;
            }
    
            return true;
        }
    
    [1] https://doc.qt.io/qt-6/qsinglepointevent.html#buttons
    [2] https://doc.qt.io/qt-6/qsinglepointevent.html#button
    
    Change-Id: I88f8314d037a1bcc462a5c4a6cdabd1f70d81bfe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185440
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtTools.cxx b/vcl/qt5/QtTools.cxx
index a6288503e5ad..fa264fe08d7c 100644
--- a/vcl/qt5/QtTools.cxx
+++ b/vcl/qt5/QtTools.cxx
@@ -187,7 +187,7 @@ MouseEvent toVclMouseEvent(QMouseEvent& rEvent)
 {
     const Point aPos = toPoint(rEvent.pos());
     const sal_uInt16 nClicks = rEvent.type() == 
QMouseEvent::MouseButtonDblClick ? 2 : 1;
-    const sal_uInt16 nButtons = toVclMouseButtons(rEvent.buttons());
+    const sal_uInt16 nButtons = toVclMouseButtons(rEvent.button() | 
rEvent.buttons());
     const sal_uInt16 nModifiers = toVclKeyboardModifiers(rEvent.modifiers());
 
     return MouseEvent(aPos, nClicks, MouseEventModifiers::NONE, nButtons, 
nModifiers);

Reply via email to