Skip to content

Commit 7488790

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
1 parent 22b0f20 commit 7488790

4 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/api/dispatcher_host.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ bool DispatcherHost::Send(IPC::Message* message) {
102102
void DispatcherHost::quit_run_loop() {
103103
if (run_loop_)
104104
run_loop_->Quit();
105+
run_loop_ = NULL;
105106
}
106107

107108
bool DispatcherHost::OnMessageReceived(const IPC::Message& message) {

src/api/dispatcher_host.h

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

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

src/api/menu/menu_delegate_mac.mm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ - (id)initWithMenu:(nwapi::Menu*) menu {
3535
}
3636

3737
- (void)menuNeedsUpdate:(NSMenu*)menu {
38-
if (!nwmenu_->enable_show_event())
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)
3945
return;
4046
base::ListValue args;
4147
base::RunLoop run_loop;

src/nw_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#else
3939
# define NW_VERSION_STRING NW_STRINGIFY(NW_MAJOR_VERSION) "." \
4040
NW_STRINGIFY(NW_MINOR_VERSION) "." \
41-
NW_STRINGIFY(NW_PATCH_VERSION) "-pre2"
41+
NW_STRINGIFY(NW_PATCH_VERSION) "-pre6"
4242
#endif
4343

4444
#define NW_VERSION "v" NW_VERSION_STRING

0 commit comments

Comments
 (0)