diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-02-23 14:42:29 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-02-23 14:45:18 +0000 |
commit | 3cb62eacae001df546c2a8f39ae4d37c33791d0b (patch) | |
tree | badbfeff7b97c17eb68b69f225401403540b622c | |
parent | b4d3a0d6744b8c6e5861b8198b31a434a5c2a6f6 (diff) |
gtk3: vcl popups flush any unexecuted Select events on popdown
so if the gtksalmenu integration wants to drive popups by setting a selection
on the vcl popup, then the same flush is needed after ShowNativePopupMenu
Change-Id: I59be60de5742d1e382cabefcbf0d8cdd5fc30b00
-rw-r--r-- | include/vcl/menu.hxx | 1 | ||||
-rw-r--r-- | vcl/source/window/menu.cxx | 24 |
2 files changed, 16 insertions, 9 deletions
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index 7ad334ea40c6..2ce8ba4ad610 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -509,6 +509,7 @@ private: protected: SAL_DLLPRIVATE sal_uInt16 ImplExecute( const VclPtr<vcl::Window>& xWindow, const Rectangle& rRect, FloatWinPopupFlags nPopupFlags, Menu* pStaredFrom, bool bPreSelectFirst ); + SAL_DLLPRIVATE void ImplFlushPendingSelect(); SAL_DLLPRIVATE long ImplCalcHeight( sal_uInt16 nEntries ) const; SAL_DLLPRIVATE sal_uInt16 ImplCalcVisEntries( long nMaxHeight, sal_uInt16 nStartEntry = 0, sal_uInt16* pLastVisible = nullptr ) const; diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 701779cfe9af..baa40292afef 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2921,6 +2921,19 @@ sal_uInt16 PopupMenu::Execute( vcl::Window* pExecWindow, const Rectangle& rRect, return ImplExecute( pExecWindow, rRect, nPopupModeFlags, nullptr, false ); } +void PopupMenu::ImplFlushPendingSelect() +{ + // is there still Select? + Menu* pSelect = ImplFindSelectMenu(); + if (pSelect) + { + // Select should be called prior to leaving execute in a popup menu! + Application::RemoveUserEvent( pSelect->nEventId ); + pSelect->nEventId = nullptr; + pSelect->Select(); + } +} + sal_uInt16 PopupMenu::ImplExecute( const VclPtr<vcl::Window>& pW, const Rectangle& rRect, FloatWinPopupFlags nPopupModeFlags, Menu* pSFrom, bool bPreSelectFirst ) { if ( !pSFrom && ( PopupMenu::IsInExecute() || !GetItemCount() ) ) @@ -3081,6 +3094,7 @@ sal_uInt16 PopupMenu::ImplExecute( const VclPtr<vcl::Window>& pW, const Rectangl SalMenu* pMenu = ImplGetSalMenu(); if( pMenu && bRealExecute && pMenu->ShowNativePopupMenu( pWin, aRect, nPopupModeFlags | FloatWinPopupFlags::GrabFocus ) ) { + ImplFlushPendingSelect(); pWin->StopExecute(); pWin->doShutdown(); pWindow->doLazyDelete(); @@ -3158,15 +3172,7 @@ sal_uInt16 PopupMenu::ImplExecute( const VclPtr<vcl::Window>& pW, const Rectangl pWindow->doLazyDelete(); pWindow = nullptr; - // is there still Select? - Menu* pSelect = ImplFindSelectMenu(); - if ( pSelect ) - { - // Select should be called prior to leaving execute in a popup menu! - Application::RemoveUserEvent( pSelect->nEventId ); - pSelect->nEventId = nullptr; - pSelect->Select(); - } + ImplFlushPendingSelect(); } return bRealExecute ? nSelectedId : 0; |