Hack in a workaround to cycle windows with meta-`

There's something wrong with CEF 3 right now where meta-` events aren't being forwarded to cocoa correctly. I just added some code to intercept meta-` and manually cycle the windows. I ignore any windows for which `excludeFromWindowsMenu` is true. That means we don't ever cycle to the hidden menu.
This commit is contained in:
Nathan Sobo 2012-09-24 16:27:42 -06:00
parent ae0be397de
commit df0c19482c
4 changed files with 23 additions and 0 deletions

View File

@ -107,6 +107,8 @@ bool AtomCefClient::OnKeyEvent(CefRefPtr<CefBrowser> browser,
}
else if (event.modifiers == (KEY_META | KEY_ALT) && event.unmodified_character == 'i') {
ToggleDevTools(browser);
} else if (event.modifiers == KEY_META && event.unmodified_character == '`') {
FocusNextWindow();
}
else {
return false;

View File

@ -98,6 +98,7 @@ class AtomCefClient : public CefClient,
protected:
CefRefPtr<CefBrowser> m_Browser;
void FocusNextWindow();
void Open(std::string path);
void Open();
void NewWindow();

View File

@ -5,6 +5,25 @@
#import "atom_application.h"
#import "atom_window_controller.h"
void AtomCefClient::FocusNextWindow() {
NSArray *windows = [NSApp windows];
int count = [windows count];
int start = [windows indexOfObject:[NSApp mainWindow]];
int i = start;
while (true) {
i = (i + 1) % count;
if (i == start) break;
NSWindow *window = [windows objectAtIndex:i];
if (![window isExcludedFromWindowsMenu]) {
[window makeKeyAndOrderFront:nil];
break;
}
}
}
void AtomCefClient::Open(std::string path) {
NSString *pathString = [NSString stringWithCString:path.c_str() encoding:NSUTF8StringEncoding];
[(AtomApplication *)[AtomApplication sharedApplication] open:pathString];

View File

@ -44,6 +44,7 @@
- (id)initInBackground {
[self initWithBootstrapScript:@"window-bootstrap" background:YES];
[self.window setFrame:NSMakeRect(0, 0, 0, 0) display:NO];
[self.window setExcludedFromWindowsMenu:YES];
return self;
}