Skip to content

Commit 72f5808

Browse files
committed
[OSX] stop nesting loop for menuNeedsUpdate; fix key stroke skipping
nesting loop and doneMenuShow() will lost key stokes; and 'show' event was sent on every key stroke, which is part of hotkey Conflicts: src/api/menu/menu_delegate_mac.mm src/nw_version.h
1 parent 20fbe5f commit 72f5808

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/api/dispatcher_host.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ bool DispatcherHost::Send(IPC::Message* message) {
108108
void DispatcherHost::quit_run_loop() {
109109
if (run_loop_)
110110
run_loop_->Quit();
111+
run_loop_ = NULL;
111112
}
112113

113114
bool DispatcherHost::OnMessageReceived(

src/api/dispatcher_host.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class DispatcherHost : public content::WebContentsObserver {
7979

8080
void set_run_loop(base::RunLoop* run_loop) { run_loop_ = run_loop; }
8181
void quit_run_loop();
82+
base::RunLoop* run_loop() { return run_loop_; }
83+
8284
private:
8385
content::RenderViewHost* render_view_host_;
8486
friend class content::Shell;

src/api/menu/menu_delegate_mac.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ - (id)initWithMenu:(nwapi::Menu*) menu {
3535
}
3636

3737
- (void)menuNeedsUpdate:(NSMenu*)menu {
38+
if (!nwmenu_->enable_show_event() || nwmenu_->dispatcher_host()->run_loop())
39+
return;
40+
NSEvent* event = [NSApp currentEvent];
41+
// NSLog (@"%@\n", event);
42+
// Cocoa will try to populate menu on every keystoke of the key equivlants,
43+
// which is slow. The following bypassed it
44+
if ([event type] != NSSystemDefined || [event subtype] == 8)
45+
return;
46+
3847
base::ListValue args;
3948
base::RunLoop run_loop;
4049
nwmenu_->dispatcher_host()->set_run_loop(&run_loop);

0 commit comments

Comments
 (0)