Bind meta-~ to focus previous window

Closes #212
This commit is contained in:
Kevin Sawicki
2013-01-30 18:32:08 -08:00
parent 9a2db26393
commit 983f1ab18b
3 changed files with 21 additions and 0 deletions

View File

@@ -141,6 +141,8 @@ bool AtomCefClient::OnKeyEvent(CefRefPtr<CefBrowser> browser,
ToggleDevTools(browser);
} else if (event.modifiers == EVENTFLAG_COMMAND_DOWN && event.unmodified_character == '`') {
FocusNextWindow();
} else if (event.modifiers == (EVENTFLAG_COMMAND_DOWN | EVENTFLAG_SHIFT_DOWN) && event.unmodified_character == '~') {
FocusPreviousWindow();
}
else {
return false;

View File

@@ -105,6 +105,7 @@ class AtomCefClient : public CefClient,
bool m_HandlePasteboardCommands = false;
void FocusNextWindow();
void FocusPreviousWindow();
void Open(std::string path);
void Open();
void OpenUnstable(std::string path);

View File

@@ -23,6 +23,24 @@ void AtomCefClient::FocusNextWindow() {
}
}
void AtomCefClient::FocusPreviousWindow() {
NSArray *windows = [NSApp windows];
int count = [windows count];
int start = [windows indexOfObject:[NSApp keyWindow]];
int i = start;
while (true) {
i = i - 1;
if (i == 0) i = count -1;
if (i == start) break;
NSWindow *window = [windows objectAtIndex:i];
if ([window isVisible] && ![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];