vcl/source/control/listbox.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
New commits: commit 22250df05830700b2555348b8ac46ee1007d0e5d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Dec 8 11:50:40 2023 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Dec 12 06:22:11 2023 +0100 tdf#158548 vcl: Require mouse over listbox to mouse-wheel through entries As described in tdf#158548, it's unexpected that listbox/ combobox entries change when using the mouse wheel while the listbox/combobox has keyboard focus, but the mouse cursor is positioned somewhere else Therefore, only do that for the VCL ListBox when the mouse cursor is currently positioned above it, which also matches what e.g. native Qt applications do. (When using the gtk3 VCL plugin that uses a native GtkComboBox, nothing changes on scroll independent of the position.) Change-Id: I8a69628471c1cd4258194627b95145d6b8fb686a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160459 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx index 7e87ae390185..e189c8480f05 100644 --- a/vcl/source/control/listbox.cxx +++ b/vcl/source/control/listbox.cxx @@ -867,12 +867,14 @@ bool ListBox::PreNotify( NotifyEvent& rNEvt ) (rNEvt.GetCommandEvent()->GetCommand() == CommandEventId::Wheel) && (rNEvt.GetWindow() == mpImplWin) ) { + const Point& rMousePos = rNEvt.GetCommandEvent()->GetMousePosPixel(); + const tools::Rectangle aWinRect(mpImplWin->GetPosPixel(), mpImplWin->GetSizePixel()); + const bool bMousePositionedOverWin = aWinRect.Contains(rMousePos); + MouseWheelBehaviour nWheelBehavior( GetSettings().GetMouseSettings().GetWheelBehavior() ); - if ( ( nWheelBehavior == MouseWheelBehaviour::ALWAYS ) - || ( ( nWheelBehavior == MouseWheelBehaviour::FocusOnly ) - && HasChildPathFocus() - ) - ) + if (bMousePositionedOverWin + && ((nWheelBehavior == MouseWheelBehaviour::ALWAYS) + || ((nWheelBehavior == MouseWheelBehaviour::FocusOnly) && HasChildPathFocus()))) { bDone = mpImplLB->HandleWheelAsCursorTravel(*rNEvt.GetCommandEvent(), *this); }