Skip to content

Commit c6dbac8

Browse files
committed
Linux Menu fix
1 parent 07dc32d commit c6dbac8

File tree

6 files changed

+35
-18
lines changed

6 files changed

+35
-18
lines changed

nw.gypi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,12 @@
675675
'src/api/menuitem/menuitem_views.cc',
676676
'src/api/shell/shell.cc',
677677
'src/api/shell/shell.h',
678+
'src/browser/browser_view_layout.cc',
679+
'src/browser/browser_view_layout.h',
680+
'src/browser/menubar_controller.cc',
681+
'src/browser/menubar_controller.h',
682+
'src/browser/menubar_view.cc',
683+
'src/browser/menubar_view.h',
678684
'src/nw_content.cc',
679685
'src/nw_content.h',
680686
'src/nw_custom_bindings.cc',

src/api/base/base.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Base::Base(int id,
2929
const base::WeakPtr<ObjectManager>& object_manager,
3030
const base::DictionaryValue& option,
3131
const std::string& extension_id)
32-
: id_(id),
33-
extension_id_(extension_id),
32+
: extension_id_(extension_id),
33+
id_(id),
3434
object_manager_(object_manager) {
3535
}
3636

src/api/menu/menu.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,13 @@ class Menu : public Base {
118118
#endif
119119

120120
#if defined(OS_MACOSX)
121-
friend class nw::NativeWindowCocoa;
122121
NSMenu* menu_;
123122
NWMenuDelegate* menu_delegate_;
124123
#elif defined(OS_LINUX)
125-
friend class nw::NativeWindowAura;
126124

127125
views::FocusManager *focus_manager_;
128126
std::vector<MenuItem*> menu_items_;
129-
nw::NativeWindowAura* window_;
127+
extensions::AppWindow* window_;
130128
// Flag to indicate the menu has been modified since last show, so we should
131129
// rebuild the menu before next show.
132130
bool is_menu_modified_;

src/api/nw_shell.idl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// nw Shell API
2-
[implemented_in="content/nw/src/api/nw_shell_api.h"]
3-
namespace nw.Shell {
4-
interface Functions {
5-
[nocompile] static void openExternal(DOMString uri);
6-
[nocompile] static void openItem(DOMString filePath);
7-
[nocompile] static void showItemInFolder(DOMString filePath);
8-
};
9-
};
1+
// nw Shell API
2+
[implemented_in="content/nw/src/api/nw_shell_api.h"]
3+
namespace nw.Shell {
4+
interface Functions {
5+
[nocompile] static void openExternal(DOMString uri);
6+
[nocompile] static void openItem(DOMString filePath);
7+
[nocompile] static void showItemInFolder(DOMString filePath);
8+
};
9+
};

src/api/nw_window_api.cc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,18 @@
2424
#include "ui/views/win/hwnd_util.h"
2525
#endif
2626

27+
#if defined(OS_LINUX)
28+
#include "content/nw/src/browser/menubar_view.h"
29+
#include "content/nw/src/browser/browser_view_layout.h"
30+
using nw::BrowserViewLayout;
31+
#endif
32+
2733
using content::RenderWidgetHost;
2834
using content::RenderWidgetHostView;
2935
using content::WebContents;
3036

3137
using nw::Menu;
38+
using nw::MenuBarView;
3239

3340
namespace extensions {
3441
namespace {
@@ -228,12 +235,16 @@ bool NwCurrentWindowInternalSetMenuFunction::RunAsync() {
228235

229236
window->menu_ = menu;
230237
#if defined(OS_LINUX)
238+
native_app_window::NativeAppWindowViews* native_app_window_views =
239+
static_cast<native_app_window::NativeAppWindowViews*>(
240+
window->GetBaseWindow());
241+
231242
MenuBarView* menubar = new MenuBarView();
232-
GetBrowserViewLayout()->set_menu_bar(menubar);
233-
AddChildView(menubar);
243+
static_cast<BrowserViewLayout*>(native_app_window_views->GetLayoutManager())->set_menu_bar(menubar);
244+
native_app_window_views->AddChildView(menubar);
234245
menubar->UpdateMenu(menu->model());
235-
Layout();
236-
SchedulePaint();
246+
native_app_window_views->layout_();
247+
native_app_window_views->SchedulePaint();
237248
#endif
238249
// The menu is lazily built.
239250
#if defined(OS_WIN) //FIXME

src/nw_content.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,9 @@ bool ExecuteAppCommandHook(int command_id, extensions::AppWindow* app_window) {
663663
if (!menu)
664664
return false;
665665
menu->menu_delegate_->ExecuteCommand(command_id, 0);
666+
#if defined(OS_WIN)
666667
menu->menu_->UpdateStates();
668+
#endif
667669
return true;
668670
}
669671

0 commit comments

Comments
 (0)