mirror of
https://github.com/atom/atom.git
synced 2026-02-12 15:45:23 -05:00
If no windows are open, keydown events are sent to the shared context.
This commit is contained in:
@@ -7,7 +7,7 @@ class ClientHandler;
|
||||
@class AtomController;
|
||||
|
||||
@interface Atom : NSApplication<CefAppProtocol, BrowserDelegate> {
|
||||
NSView *_hiddenGlobalView;
|
||||
NSWindow *_hiddenWindow;
|
||||
BOOL handlingSendEvent_;
|
||||
CefRefPtr<ClientHandler> _clientHandler;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user