From 49f995925c8981f4d90809d49839e05f349a9b0a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 23 Feb 2016 15:43:32 +0800 Subject: [PATCH] Notify the global menu bar when window is mapped --- atom/browser/native_window_views.cc | 15 +++++++++++++++ atom/browser/ui/views/global_menu_bar_x11.cc | 8 ++++++++ atom/browser/ui/views/global_menu_bar_x11.h | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 44df87d..97a2ee0 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -300,14 +300,29 @@ bool NativeWindowViews::IsFocused() { void NativeWindowViews::Show() { window_->native_widget_private()->ShowWithWindowState(GetRestoredState()); + +#if defined(USE_X11) + if (global_menu_bar_) + global_menu_bar_->OnWindowMapped(); +#endif } void NativeWindowViews::ShowInactive() { window_->ShowInactive(); + +#if defined(USE_X11) + if (global_menu_bar_) + global_menu_bar_->OnWindowMapped(); +#endif } void NativeWindowViews::Hide() { window_->Hide(); + +#if defined(USE_X11) + if (global_menu_bar_) + global_menu_bar_->OnWindowUnmapped(); +#endif } bool NativeWindowViews::IsVisible() { diff --git a/atom/browser/ui/views/global_menu_bar_x11.cc b/atom/browser/ui/views/global_menu_bar_x11.cc index 26279ec..b393e3f 100644 --- a/atom/browser/ui/views/global_menu_bar_x11.cc +++ b/atom/browser/ui/views/global_menu_bar_x11.cc @@ -210,6 +210,14 @@ void GlobalMenuBarX11::InitServer(gfx::AcceleratedWidget xid) { server_ = server_new(path.c_str()); } +void GlobalMenuBarX11::OnWindowMapped() { + GlobalMenuBarRegistrarX11::GetInstance()->OnWindowMapped(xid_); +} + +void GlobalMenuBarX11::OnWindowUnmapped() { + GlobalMenuBarRegistrarX11::GetInstance()->OnWindowUnmapped(xid_); +} + void GlobalMenuBarX11::BuildMenuFromModel(ui::MenuModel* model, DbusmenuMenuitem* parent) { for (int i = 0; i < model->GetItemCount(); ++i) { diff --git a/atom/browser/ui/views/global_menu_bar_x11.h b/atom/browser/ui/views/global_menu_bar_x11.h index 51147a2..d9e818c 100644 --- a/atom/browser/ui/views/global_menu_bar_x11.h +++ b/atom/browser/ui/views/global_menu_bar_x11.h @@ -46,6 +46,10 @@ class GlobalMenuBarX11 { void SetMenu(ui::MenuModel* menu_model); bool IsServerStarted() const; + // Called by NativeWindow when it show/hides. + void OnWindowMapped(); + void OnWindowUnmapped(); + private: // Creates a DbusmenuServer. void InitServer(gfx::AcceleratedWidget xid); -- 2.7.4