gtk is the only case auto-accel is true, and the menubar is native gtk there

so this special case handling can go now

Change-Id: I98675b084fbef463d7ee4ee452eb57d1d4ff20c8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120074
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2021-08-05 17:37:18 +02:00
parent 746d95bb40
commit 3fbae5dc7e
6 changed files with 3 additions and 104 deletions
-2
View File
@@ -46,7 +46,6 @@ class MenuItemList;
class Image;
class PopupMenu;
class KeyEvent;
class CommandEvent;
class MenuFloatingWindow;
class SalMenu;
class MenuBarWindow;
@@ -427,7 +426,6 @@ class VCL_DLLPUBLIC MenuBar final : public Menu
SAL_DLLPRIVATE static VclPtr<vcl::Window> ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, MenuBar* pMenu);
SAL_DLLPRIVATE static void ImplDestroy(MenuBar* pMenu, bool bDelete);
SAL_DLLPRIVATE bool ImplHandleKeyEvent(const KeyEvent& rKEvent);
SAL_DLLPRIVATE bool ImplHandleCmdEvent(const CommandEvent& rCEvent);
/// Return the MenuBarWindow.
MenuBarWindow* getMenuBarWindow();
-41
View File
@@ -1956,12 +1956,6 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize,
aTmpPos.AdjustY(nTextOffsetY );
DrawTextFlags nStyle = nTextStyle | DrawTextFlags::Mnemonic;
const Menu *pMenu = this;
while (!pMenu->IsMenuBar() && pMenu->pStartedFrom)
pMenu = pMenu->pStartedFrom;
if (pMenu->IsMenuBar() && static_cast<MenuBarWindow*>(pMenu->pWindow.get())->GetMBWHideAccel())
nStyle |= DrawTextFlags::HideMnemonic;
if (pData->bIsTemporary)
nStyle |= DrawTextFlags::Disable;
std::vector< tools::Rectangle >* pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : nullptr;
@@ -2557,34 +2551,6 @@ bool MenuBar::ImplHandleKeyEvent( const KeyEvent& rKEvent )
return bDone;
}
bool MenuBar::ImplHandleCmdEvent( const CommandEvent& rCEvent )
{
// No keyboard processing when system handles the menu or our menubar is invisible
if( !IsDisplayable() ||
( ImplGetSalMenu() && ImplGetSalMenu()->VisibleMenuBar() ) )
return false;
// check for enabled, if this method is called from another window...
MenuBarWindow* pWin = static_cast<MenuBarWindow*>(ImplGetWindow());
if ( pWin && pWin->IsEnabled() && pWin->IsInputEnabled() && ! pWin->IsInModalMode() )
{
if (rCEvent.GetCommand() == CommandEventId::ModKeyChange && ImplGetSVData()->maNWFData.mbAutoAccel)
{
const CommandModKeyData* pCData = rCEvent.GetModKeyData ();
if (pWin->m_nHighlightedItem == ITEMPOS_INVALID)
{
if (pCData && pCData->IsMod2() && pCData->IsDown())
pWin->SetMBWHideAccel(false);
else
pWin->SetMBWHideAccel(true);
pWin->Invalidate(InvalidateFlags::Update);
}
return true;
}
}
return false;
}
void MenuBar::SelectItem(sal_uInt16 nId)
{
if (!pWindow)
@@ -2861,13 +2827,6 @@ sal_uInt16 PopupMenu::ImplExecute( const VclPtr<vcl::Window>& pW, const tools::R
if ( !pSFrom && ( PopupMenu::IsInExecute() || !GetItemCount() ) )
return 0;
// set the flag to hide or show accelerators in the menu depending on whether the menu was launched by mouse or keyboard shortcut
if( pSFrom && pSFrom->IsMenuBar())
{
auto pMenuBarWindow = static_cast<MenuBarWindow*>(pSFrom->pWindow.get());
pMenuBarWindow->SetMBWHideAccel( !(pMenuBarWindow->GetMBWMenuKey()) );
}
mpLayoutData.reset();
ImplSVData* pSVData = ImplGetSVData();
+1 -29
View File
@@ -123,8 +123,6 @@ MenuBarWindow::MenuBarWindow( vcl::Window* pParent ) :
m_nRolloveredItem = ITEMPOS_INVALID;
mbAutoPopup = true;
m_bIgnoreFirstMove = true;
SetMBWHideAccel(true);
SetMBWMenuKey(false);
m_aCloseBtn->maImage = Image(StockImage::Yes, SV_RESID_BITMAP_CLOSEDOC);
@@ -390,7 +388,6 @@ void MenuBarWindow::PopupClosed( Menu const * pPopup )
void MenuBarWindow::MouseButtonDown( const MouseEvent& rMEvt )
{
mbAutoPopup = true;
SetMBWMenuKey(false);
sal_uInt16 nEntry = ImplFindEntry( rMEvt.GetPosPixel() );
if ( ( nEntry != ITEMPOS_INVALID ) && !m_pActivePopup )
{
@@ -415,18 +412,7 @@ void MenuBarWindow::MouseMove( const MouseEvent& rMEvt )
if ( rMEvt.IsLeaveWindow() )
{
if ( m_nRolloveredItem != ITEMPOS_INVALID && m_nRolloveredItem != m_nHighlightedItem )
{
// there is a spurious MouseMove generated after a menu is launched from the keyboard, hence this...
if (m_nHighlightedItem != ITEMPOS_INVALID)
{
bool hide = GetMBWHideAccel();
SetMBWHideAccel(true);
Invalidate(); //HighlightItem( nRolloveredItem, false );
SetMBWHideAccel(hide);
}
else
Invalidate(); //HighlightItem( nRolloveredItem, false );
}
Invalidate(); //HighlightItem( nRolloveredItem, false );
m_nRolloveredItem = ITEMPOS_INVALID;
return;
@@ -463,9 +449,6 @@ void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool b
if( ! m_pMenu )
return;
// always hide accelerators when updating the menu bar...
SetMBWHideAccel(true);
// #57934# close active popup if applicable, as TH's background storage works.
MenuItemData* pNextData = m_pMenu->pItemList->GetDataFromPos( n );
if ( m_pActivePopup && m_pActivePopup->ImplGetWindow() && ( !pNextData || ( m_pActivePopup != pNextData->pSubMenu ) ) )
@@ -849,8 +832,6 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
}
}
bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel;
if ( !bDone && ( bFromMenu || rKEvent.GetKeyCode().IsMod2() ) )
{
sal_Unicode nCharCode = rKEvent.GetCharCode();
@@ -867,15 +848,6 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
}
}
const bool bShowAccels = nCode != KEY_ESCAPE;
if (GetMBWMenuKey() != bShowAccels)
{
SetMBWMenuKey(bShowAccels);
SetMBWHideAccel(!bShowAccels);
if (autoacc)
Invalidate(InvalidateFlags::Update);
}
return bDone;
}
-6
View File
@@ -76,8 +76,6 @@ private:
VclPtr<vcl::Window> m_xSaveFocusId;
bool mbAutoPopup;
bool m_bIgnoreFirstMove;
bool mbHideAccel;
bool mbMenuKey;
VclPtr<DecoToolBox> m_aCloseBtn;
VclPtr<PushButton> m_aFloatBtn;
@@ -138,10 +136,6 @@ public:
tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId);
void RemoveMenuBarButton(sal_uInt16 nId);
bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId);
void SetMBWHideAccel(bool val) { mbHideAccel = val; }
bool GetMBWHideAccel() const { return mbHideAccel; }
void SetMBWMenuKey(bool val) { mbMenuKey = val; }
bool GetMBWMenuKey() const { return mbMenuKey; }
bool CanGetFocus() const;
};
-15
View File
@@ -19,7 +19,6 @@
#include "menufloatingwindow.hxx"
#include "menuitemlist.hxx"
#include "menubarwindow.hxx"
#include "bufferdevice.hxx"
#include <sal/log.hxx>
@@ -1032,7 +1031,6 @@ void MenuFloatingWindow::KeyInput( const KeyEvent& rKEvent )
{
VclPtr<vcl::Window> xWindow = this;
bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel;
sal_uInt16 nCode = rKEvent.GetKeyCode().GetCode();
bKeyInput = true;
switch ( nCode )
@@ -1179,19 +1177,6 @@ void MenuFloatingWindow::KeyInput( const KeyEvent& rKEvent )
}
}
if (pMenu && pMenu->pStartedFrom && pMenu->pStartedFrom->IsMenuBar())
{
MenuBar *pMenuBar = static_cast<MenuBar*>(pMenu->pStartedFrom.get());
const bool bShowAccels = nCode != KEY_ESCAPE;
if (pMenuBar->getMenuBarWindow()->GetMBWMenuKey() != bShowAccels)
{
pMenuBar->getMenuBarWindow()->SetMBWMenuKey(bShowAccels);
pMenuBar->getMenuBarWindow()->SetMBWHideAccel(!bShowAccels);
if (autoacc)
Invalidate(InvalidateFlags::Update);
}
}
// #105474# check if menu window was not destroyed
if ( !xWindow->isDisposed() )
{
+2 -11
View File
@@ -177,8 +177,7 @@ bool SystemWindow::EventNotify( NotifyEvent& rNEvt )
ToggleMnemonicsOnHierarchy(*rNEvt.GetCommandEvent(), this);
// capture KeyEvents for menu handling
if (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ||
rNEvt.GetType() == MouseNotifyEvent::COMMAND)
if (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT)
{
MenuBar* pMBar = mpMenuBar;
if ( !pMBar && ( GetType() == WindowType::FLOATINGWINDOW ) )
@@ -187,15 +186,7 @@ bool SystemWindow::EventNotify( NotifyEvent& rNEvt )
if( pWin && pWin->IsSystemWindow() )
pMBar = static_cast<SystemWindow*>(pWin)->GetMenuBar();
}
bool bDone(false);
if (pMBar)
{
if (rNEvt.GetType() == MouseNotifyEvent::COMMAND)
bDone = pMBar->ImplHandleCmdEvent(*rNEvt.GetCommandEvent());
else
bDone = pMBar->ImplHandleKeyEvent(*rNEvt.GetKeyEvent());
}
if (bDone)
if (pMBar && pMBar->ImplHandleKeyEvent(*rNEvt.GetKeyEvent()))
return true;
}