aboutsummaryrefslogtreecommitdiff
path: root/module/topmenumenubarimpl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'module/topmenumenubarimpl.cc')
-rw-r--r--module/topmenumenubarimpl.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/module/topmenumenubarimpl.cc b/module/topmenumenubarimpl.cc
index 64934c1..641d748 100644
--- a/module/topmenumenubarimpl.cc
+++ b/module/topmenumenubarimpl.cc
@@ -69,6 +69,14 @@ static inline void set_menubarimpl_for_widget(QWidget *widget, TopMenuMenuBarImp
}
}
+static void handle_monitor_availability_changed(GObject *object, GParamSpec *pspec, gpointer user_data)
+{
+ TopMenuMenuBarImpl* self = static_cast<TopMenuMenuBarImpl*>(user_data);
+ Q_UNUSED(object);
+ Q_UNUSED(pspec);
+ self->updateServerAvailability();
+}
+
TopMenuMenuBarImpl::TopMenuMenuBarImpl(QObject *parent) :
MenuProxy(parent),
m_window(0), m_menubar(0), m_appmenubar(0), m_appmenu(0),
@@ -86,7 +94,8 @@ TopMenuMenuBarImpl::TopMenuMenuBarImpl(QObject *parent) :
}
m_monitor_connection_id = g_signal_connect(menuMonitor, "notify::available",
- G_CALLBACK(handleMonitorAvailabilityChanged), this);
+ G_CALLBACK(handle_monitor_availability_changed),
+ static_cast<void*>(this));
}
TopMenuMenuBarImpl::~TopMenuMenuBarImpl()
@@ -94,7 +103,6 @@ TopMenuMenuBarImpl::~TopMenuMenuBarImpl()
if (m_appmenubar) {
gtk_widget_destroy(GTK_WIDGET(m_appmenubar));
g_object_unref(m_appmenubar);
- m_appmenubar = 0;
}
if (m_window) {
if (get_menubarimpl_for_widget(m_window) == this) {
@@ -229,6 +237,14 @@ bool TopMenuMenuBarImpl::menuBarEventFilter(QObject *src, QEvent *event)
return false;
}
+void TopMenuMenuBarImpl::updateServerAvailability()
+{
+ if (m_menubar) {
+ // Hopefully the following causes Qt to "ask" isNativeMenuBar() again.
+ m_menubar->updateGeometry();
+ }
+}
+
GtkMenuItem * TopMenuMenuBarImpl::addAction(QAction* action, QAction* before, QMenu* parent)
{
if (!parent) {
@@ -296,13 +312,6 @@ QShortcut * TopMenuMenuBarImpl::createMnemonicShortcut(QAction *action, QWidget
return shortcut;
}
-void TopMenuMenuBarImpl::handleMonitorAvailabilityChanged(TopMenuMenuBarImpl *self)
-{
- if (self->m_menubar) {
- self->m_menubar->updateGeometry();
- }
-}
-
void TopMenuMenuBarImpl::handleShortcutActivated()
{
QShortcut *shortcut = static_cast<QShortcut*>(sender());