If no windows are open, keydown events are sent to the shared context.

This commit is contained in:
Corey Johnson
2012-03-01 12:11:04 -08:00
parent 569bed9ee1
commit bd17d890a1
4 changed files with 17 additions and 14 deletions

View File

@@ -354,7 +354,6 @@
isa = PBXGroup;
children = (
0487C91D14FED5360045E5E3 /* Supporting Files */,
0487D15E14FEE7880045E5E3 /* resources */,
0487C93B14FED6090045E5E3 /* src */,
);
path = Atom;
@@ -363,6 +362,7 @@
0487C91D14FED5360045E5E3 /* Supporting Files */ = {
isa = PBXGroup;
children = (
0487D15E14FEE7880045E5E3 /* resources */,
0487C93314FED5FB0045E5E3 /* Atom.icns */,
0487C93414FED5FB0045E5E3 /* ClientWindow.xib */,
0487C93514FED5FB0045E5E3 /* Info.plist */,

View File

@@ -7,7 +7,7 @@ class ClientHandler;
@class AtomController;
@interface Atom : NSApplication<CefAppProtocol, BrowserDelegate> {
NSView *_hiddenGlobalView;
NSWindow *_hiddenWindow;
BOOL handlingSendEvent_;
CefRefPtr<ClientHandler> _clientHandler;
}

View File

@@ -23,7 +23,7 @@
}
- (void)dealloc {
[_hiddenGlobalView release];
[_hiddenWindow release];
[self dealloc];
}
@@ -37,21 +37,28 @@
- (void)sendEvent:(NSEvent*)event {
CefScopedSendingEvent sendingEventScoper;
[super sendEvent:event];
if (_clientHandler && ![self keyWindow] && [event type] == NSKeyDown) {
[_hiddenWindow makeKeyAndOrderFront:self];
[_hiddenWindow sendEvent:event];
}
else {
[super sendEvent:event];
}
}
- (void)createAtomContext {
_clientHandler = new ClientHandler(self);
CefWindowInfo window_info;
_hiddenGlobalView = [[NSView alloc] init];
window_info.SetAsChild(_hiddenGlobalView, 0, 0, 0, 0);
_hiddenWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 0, 0) styleMask:nil backing:nil defer:YES];
window_info.SetAsChild([_hiddenWindow contentView], 0, 0, 0, 0);
CefBrowserSettings settings;
NSURL *resourceDirURL = [[NSBundle mainBundle] resourceURL];
NSString *indexURLString = [[resourceDirURL URLByAppendingPathComponent:@"index.html"] absoluteString];
CefBrowser::CreateBrowser(window_info, _clientHandler.get(), [indexURLString UTF8String], settings);
}
}
- (void)open:(NSString *)path {
CefRefPtr<CefV8Context> atomContext = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context();
@@ -71,9 +78,7 @@
CefShutdown();
}
- (void)afterCreated {
_clientHandler->GetBrowser()->ShowDevTools();
}
#pragma mark BrowserDelegate
- (void)loadStart {
CefRefPtr<CefV8Context> context = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context();

View File

@@ -55,9 +55,7 @@
CefBrowser::CreateBrowser(window_info, _clientHandler.get(), [indexURLString UTF8String], settings);
}
- (void)afterCreated {
_clientHandler->GetBrowser()->ShowDevTools();
}
#pragma mark BrowserDelegate
- (void)loadStart {
CefRefPtr<CefV8Context> context = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context();