[Libreoffice-commits] core.git: include/vcl vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 5 15:37:54 UTC 2021


 include/vcl/menu.hxx                     |    2 -
 vcl/source/window/menu.cxx               |   41 -------------------------------
 vcl/source/window/menubarwindow.cxx      |   30 ----------------------
 vcl/source/window/menubarwindow.hxx      |    6 ----
 vcl/source/window/menufloatingwindow.cxx |   15 -----------
 vcl/source/window/syswin.cxx             |   13 +--------
 6 files changed, 3 insertions(+), 104 deletions(-)

New commits:
commit 3fbae5dc7e7b200776bbc8a7c2a43e1e04f15a2b
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Aug 5 14:57:59 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Aug 5 17:37:18 2021 +0200

    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 at redhat.com>

diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index faf002d9a4d7..c0a627a30f88 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -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();
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index d9555da15de5..8f0b0fe23d30 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -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();
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 09dd1d569edf..5879eed8926c 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -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;
 }
 
diff --git a/vcl/source/window/menubarwindow.hxx b/vcl/source/window/menubarwindow.hxx
index 570ffc5d20ca..469c141cae92 100644
--- a/vcl/source/window/menubarwindow.hxx
+++ b/vcl/source/window/menubarwindow.hxx
@@ -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;
 };
 
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 1737e80da843..a5509f2109f3 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -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() )
     {
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index c1a946d04007..d6991ab11636 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -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;
     }
 


More information about the Libreoffice-commits mailing list