sc/source/ui/cctrl/checklistmenu.cxx | 26 +++++++++++++++++++++++++- sc/source/ui/inc/checklistmenu.hxx | 6 ++++++ sc/uiconfig/scalc/ui/filterdropdown.ui | 1 - 3 files changed, 31 insertions(+), 2 deletions(-)
New commits: commit 66e4ffd27fae894ae67ee7337a490aab18e56562 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Dec 1 20:24:00 2021 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Dec 2 23:06:07 2021 +0100 Related: tdf#144410 submenu indicator misplaced under x11 gtk so drop the GtkTreeViewColumn expand and go back to setting the size via the size-allocate, but for wayland launch it in a callback because setting the column widths during the size-allocate callback doesn't work as hoped for and the indicator is misplaced. Change-Id: I58a7a11cb1a1c065cee364f932cebddfb9ea453c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126203 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index b12868ea2f2a..f4caff97e8ad 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -144,14 +144,32 @@ void ScCheckListMenuControl::addSeparator() } IMPL_LINK(ScCheckListMenuControl, TreeSizeAllocHdl, const Size&, rSize, void) +{ + maAllocatedSize = rSize; + SetDropdownPos(); + if (!mnAsyncSetDropdownPosId && Application::GetToolkitName().startsWith("gtk")) + { + // for gtk retry again later in case it didn't work (wayland) + mnAsyncSetDropdownPosId = Application::PostUserEvent(LINK(this, ScCheckListMenuControl, SetDropdownPosHdl)); + } +} + +void ScCheckListMenuControl::SetDropdownPos() { std::vector<int> aWidths { - o3tl::narrowing<int>(rSize.Width() - (mxMenu->get_text_height() * 3) / 4 - 6) + o3tl::narrowing<int>(maAllocatedSize.Width() - (mxMenu->get_text_height() * 3) / 4 - 6) }; mxMenu->set_column_fixed_widths(aWidths); } +IMPL_LINK_NOARG(ScCheckListMenuControl, SetDropdownPosHdl, void*, void) +{ + mnAsyncSetDropdownPosId = nullptr; + SetDropdownPos(); + mxMenu->queue_resize(); +} + void ScCheckListMenuControl::CreateDropDown() { int nWidth = (mxMenu->get_text_height() * 3) / 4; @@ -458,6 +476,7 @@ ScCheckListMenuControl::ScCheckListMenuControl(weld::Widget* pParent, ScDocument , mnSelectedMenu(MENU_NOT_SELECTED) , mpDoc(pDoc) , mnAsyncPostPopdownId(nullptr) + , mnAsyncSetDropdownPosId(nullptr) , mpNotifier(pNotifier) , mbHasDates(bHasDates) , mbIsPoppedUp(false) @@ -560,6 +579,11 @@ ScCheckListMenuControl::~ScCheckListMenuControl() Application::RemoveUserEvent(mnAsyncPostPopdownId); mnAsyncPostPopdownId = nullptr; } + if (mnAsyncSetDropdownPosId) + { + Application::RemoveUserEvent(mnAsyncSetDropdownPosId); + mnAsyncSetDropdownPosId = nullptr; + } } void ScCheckListMenuControl::prepWindow() diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx index 2e6041270b5b..6a5dbceb1966 100644 --- a/sc/source/ui/inc/checklistmenu.hxx +++ b/sc/source/ui/inc/checklistmenu.hxx @@ -249,6 +249,10 @@ private: DECL_LINK(PostPopdownHdl, void*, void); + void SetDropdownPos(); + + DECL_LINK(SetDropdownPosHdl, void*, void); + private: std::unique_ptr<weld::Builder> mxBuilder; std::unique_ptr<weld::Popover> mxPopover; @@ -281,6 +285,7 @@ private: std::unique_ptr<Action> mxPopupEndAction; Config maConfig; + Size maAllocatedSize; int mnCheckWidthReq; /// matching width request for mxChecks int mnWndWidth; /// whole window width. TriState mePrevToggleAllState; @@ -290,6 +295,7 @@ private: ScDocument* mpDoc; ImplSVEvent* mnAsyncPostPopdownId; + ImplSVEvent* mnAsyncSetDropdownPosId; vcl::ILibreOfficeKitNotifier* mpNotifier; bool mbHasDates; diff --git a/sc/uiconfig/scalc/ui/filterdropdown.ui b/sc/uiconfig/scalc/ui/filterdropdown.ui index 3a38b0e8104f..caa4506aa453 100644 --- a/sc/uiconfig/scalc/ui/filterdropdown.ui +++ b/sc/uiconfig/scalc/ui/filterdropdown.ui @@ -86,7 +86,6 @@ </child> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn1"> - <property name="expand">True</property> <child> <object class="GtkCellRendererText" id="cellrenderertext1"/> <attributes>