vcl/inc/listbox.hxx | 1 - vcl/qt5/QtGraphics_Controls.cxx | 4 +++- vcl/source/control/imp_listbox.cxx | 36 ++++++++++-------------------------- vcl/source/control/listbox.cxx | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 28 deletions(-)
New commits: commit b845ba1900387b8ea44a27a1f7d045ca0091adf2 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Feb 14 17:20:49 2023 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Feb 20 06:11:05 2023 +0000 tdf#153614 qt: Set keyboard focus state when focused, too For example the Breeze theme only draws a light blue focus rectangle for list boxes when the `QStyle::State_KeyboardFocusChange` state is set in addition to `QStyle::State_HasFocus`. Therefore, set that state in addition to ensure that the focused control actually gets a focus indicator when moving there using the keyboard. Change-Id: Ib4b85f9140629e6b69c80b85e85913392a6c000f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147019 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtGraphics_Controls.cxx b/vcl/qt5/QtGraphics_Controls.cxx index 0c5b85d28a11..4bb4df1e6e66 100644 --- a/vcl/qt5/QtGraphics_Controls.cxx +++ b/vcl/qt5/QtGraphics_Controls.cxx @@ -40,7 +40,9 @@ static QStyle::State vclStateValue2StateFlag(ControlState nControlState, { QStyle::State nState = ((nControlState & ControlState::ENABLED) ? QStyle::State_Enabled : QStyle::State_None) - | ((nControlState & ControlState::FOCUSED) ? QStyle::State_HasFocus : QStyle::State_None) + | ((nControlState & ControlState::FOCUSED) + ? QStyle::State_HasFocus | QStyle::State_KeyboardFocusChange + : QStyle::State_None) | ((nControlState & ControlState::PRESSED) ? QStyle::State_Sunken : QStyle::State_None) | ((nControlState & ControlState::SELECTED) ? QStyle::State_Selected : QStyle::State_None) | ((nControlState & ControlState::ROLLOVER) ? QStyle::State_MouseOver commit d5ace6bf0f1e48ee02e5eb22ce0f9f8953517f60 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Feb 14 16:16:30 2023 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Feb 20 06:10:58 2023 +0000 tdf#153520 vcl: Align listbox invalidation with mouseover check Before commit 4cb11d8a6682fecd661b926a417ae7f26f76e7db Date: Fri Oct 7 16:40:23 2022 +0100 Related: tdf#98067 do RollOver for Edit as well as SpinButton , the check whether the mouse is over a control was only checking the control's child windows. The above commit introduced a check for the control's window as well in `ImplSmallBorderWindowView::DrawWindow`. When moving the mouse inside or outside a `ListBox` control, the invalidation of the corresponding border window happened when the mouse cursor would enter or leave the `ListBox`'s `ImplWin` child (in `ImplWin::PreNotify`). The `ImplWin` only covers a part of the `ListBox` area. As a consequence, when moving the mouse out of the `ImplWin` area, the mouse would still be over the parent `ListBox` area, so the `ControlState::ROLLOVER` state would still be set in `ImplSmallBorderWindowView::DrawWindow` from the above commit on. Since there was no additional invalidation when the mouse moved out of the `ListBox` area, the `ROLLOVER` state would remain set even when the mouse left the `ListBox` area as well. Move the invalidation from `ImplWin` to `ListBox` so this gets processed when the mouse cursor actually enters or leaves the `ListBox`, not just the `ImplWin` child. Also align the mouse over check in `ImplWin::ImplDraw` with the one in `ImplSmallBorderWindowView::DrawWindow` again. (Take the parent into account there as well.) Change-Id: I8974e370819719489e3d9f091d96b3353888d26b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147018 Tested-by: Jenkins Reviewed-by: Rafael Lima <rafael.palma.l...@gmail.com> diff --git a/vcl/inc/listbox.hxx b/vcl/inc/listbox.hxx index 8aa23e90cff8..e9bd4f53b843 100644 --- a/vcl/inc/listbox.hxx +++ b/vcl/inc/listbox.hxx @@ -559,7 +559,6 @@ public: virtual void Resize() override; virtual void GetFocus() override; virtual void LoseFocus() override; - virtual bool PreNotify( NotifyEvent& rNEvt ) override; sal_Int32 GetItemPos() const { return mnItemPos; } void SetItemPos( sal_Int32 n ) { mnItemPos = n; } diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index 75bc1fd622e2..1b18498c68fc 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -2537,25 +2537,6 @@ void ImplWin::FillLayoutData() const pThis->ImplDraw(*pThis->GetOutDev(), true); } -bool ImplWin::PreNotify( NotifyEvent& rNEvt ) -{ - if( rNEvt.GetType() == NotifyEventType::MOUSEMOVE ) - { - const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent(); - if( pMouseEvt && (pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow()) ) - { - // trigger redraw as mouse over state has changed - if ( IsNativeControlSupported(ControlType::Listbox, ControlPart::Entire) - && ! IsNativeControlSupported(ControlType::Listbox, ControlPart::ButtonDown) ) - { - GetParent()->GetWindow( GetWindowType::Border )->Invalidate( InvalidateFlags::NoErase ); - } - } - } - - return Control::PreNotify(rNEvt); -} - void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout) { const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); @@ -2591,14 +2572,17 @@ void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout) Point aPoint( -nLeft, -nTop ); tools::Rectangle aCtrlRegion( aPoint - GetPosPixel(), pWin->GetSizePixel() ); - bool bMouseOver = false; - vcl::Window *pChild = pWin->GetWindow( GetWindowType::FirstChild ); - while( pChild ) + bool bMouseOver = pWin->IsMouseOver(); + if (!bMouseOver) { - bMouseOver = pChild->IsMouseOver(); - if (bMouseOver) - break; - pChild = pChild->GetWindow( GetWindowType::Next ); + vcl::Window *pChild = pWin->GetWindow( GetWindowType::FirstChild ); + while( pChild ) + { + bMouseOver = pChild->IsMouseOver(); + if (bMouseOver) + break; + pChild = pChild->GetWindow( GetWindowType::Next ); + } } if( bMouseOver ) nState |= ControlState::ROLLOVER; diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx index ce3cbba69aec..405919bc3565 100644 --- a/vcl/source/control/listbox.cxx +++ b/vcl/source/control/listbox.cxx @@ -883,6 +883,20 @@ bool ListBox::PreNotify( NotifyEvent& rNEvt ) } } + if (rNEvt.GetType() == NotifyEventType::MOUSEMOVE) + { + const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent(); + if (pMouseEvt && (pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow())) + { + // trigger redraw as mouse over state has changed + if (IsNativeControlSupported(ControlType::Listbox, ControlPart::Entire) + && !IsNativeControlSupported(ControlType::Listbox, ControlPart::ButtonDown)) + { + GetWindow(GetWindowType::Border)->Invalidate(InvalidateFlags::NoErase); + } + } + } + return bDone || Control::PreNotify( rNEvt ); }