[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx
Maxim Monastirsky
momonasmon at gmail.com
Thu Mar 9 00:00:41 UTC 2017
include/vcl/menu.hxx | 1 +
vcl/source/window/menu.cxx | 11 ++++++++---
vcl/unx/gtk/gtksalmenu.cxx | 23 ++++++++++++++++-------
3 files changed, 25 insertions(+), 10 deletions(-)
New commits:
commit 3daa6c66eb9a4c334d6f72a8fd4bb09d7360a913
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Wed Mar 8 11:46:04 2017 +0200
Don't use SetDisplayable when enabling Unity mode
because now it tracks the global menu too, but all we need
here is to hide the in-window menubar widget.
Change-Id: Ic3c8c20b88d37430e80b682333ca384bccc3f697
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index f2202d1..3f57ae2 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -474,6 +474,7 @@ public:
// if the menubar is unattached an empty rectangle is returned
Rectangle GetMenuBarButtonRectPixel( sal_uInt16 nId );
void RemoveMenuBarButton( sal_uInt16 nId );
+ void LayoutChanged();
};
inline MenuBar& MenuBar::operator=( const MenuBar& rMenu )
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index e76662b..76a6432 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2477,6 +2477,13 @@ void MenuBar::ShowButtons( bool bClose, bool bFloat, bool bHide )
}
}
+void MenuBar::LayoutChanged()
+{
+ MenuBarWindow* pMenuWin = getMenuBarWindow();
+ if (pMenuWin)
+ pMenuWin->LayoutChanged();
+}
+
void MenuBar::SetDisplayable( bool bDisplayable )
{
if( bDisplayable != mbDisplayable )
@@ -2485,9 +2492,7 @@ void MenuBar::SetDisplayable( bool bDisplayable )
ImplGetSalMenu()->ShowMenuBar( bDisplayable );
mbDisplayable = bDisplayable;
- MenuBarWindow* pMenuWin = getMenuBarWindow();
- if (pMenuWin)
- pMenuWin->LayoutChanged();
+ LayoutChanged();
}
}
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index 1b5481b..e4d2eba 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -766,6 +766,9 @@ static gboolean MenuBarSignalKey(GtkWidget*, GdkEventKey* pEvent, gpointer menu)
void GtkSalMenu::CreateMenuBarWidget()
{
#if GTK_CHECK_VERSION(3,0,0)
+ if (mpMenuBarContainerWidget)
+ return;
+
GtkGrid* pGrid = mpFrame->getTopLevelGridWidget();
mpMenuBarContainerWidget = gtk_grid_new();
@@ -1153,14 +1156,20 @@ void GtkSalMenu::Deactivate(const gchar* pCommand)
void GtkSalMenu::EnableUnity(bool bEnable)
{
- if (bUnityMode != bEnable)
- {
- static_cast<MenuBar*>(mpVCLMenu.get())->SetDisplayable(!bEnable);
- bUnityMode = bEnable;
+ bUnityMode = bEnable;
+
+ MenuBar* pMenuBar(static_cast<MenuBar*>(mpVCLMenu.get()));
- if (!bEnable)
- ShowMenuBar(true);
+ if (bEnable)
+ DestroyMenuBarWidget();
+ else
+ {
+ Update();
+ if (pMenuBar->IsDisplayable())
+ CreateMenuBarWidget();
}
+
+ pMenuBar->LayoutChanged();
}
void GtkSalMenu::ShowMenuBar( bool bVisible )
@@ -1173,7 +1182,7 @@ void GtkSalMenu::ShowMenuBar( bool bVisible )
else if (mpMenuModel && g_menu_model_get_n_items(G_MENU_MODEL(mpMenuModel)) > 0)
g_lo_menu_remove(G_LO_MENU(mpMenuModel), 0);
}
- else if (bVisible && !mpMenuBarContainerWidget)
+ else if (bVisible)
CreateMenuBarWidget();
else
DestroyMenuBarWidget();
More information about the Libreoffice-commits
mailing list