2016-05-18 04:47:50 +00:00
|
|
|
// Copyright (c) 2016 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "atom/browser/common_web_contents_delegate.h"
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
2016-06-17 17:58:04 +00:00
|
|
|
#include "brightray/browser/mac/event_dispatching_window.h"
|
2016-05-18 04:47:50 +00:00
|
|
|
#include "content/public/browser/native_web_keyboard_event.h"
|
|
|
|
#include "ui/events/keycodes/keyboard_codes.h"
|
|
|
|
|
2016-06-19 11:16:19 +00:00
|
|
|
@interface NSWindow (EventDispatchingWindow)
|
|
|
|
- (void)redispatchKeyEvent:(NSEvent*)event;
|
|
|
|
@end
|
|
|
|
|
2016-05-18 04:47:50 +00:00
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
void CommonWebContentsDelegate::HandleKeyboardEvent(
|
|
|
|
content::WebContents* source,
|
|
|
|
const content::NativeWebKeyboardEvent& event) {
|
|
|
|
if (event.skip_in_browser ||
|
|
|
|
event.type == content::NativeWebKeyboardEvent::Char)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Escape exits tabbed fullscreen mode.
|
|
|
|
if (event.windowsKeyCode == ui::VKEY_ESCAPE && is_html_fullscreen())
|
|
|
|
ExitFullscreenModeForTab(source);
|
|
|
|
|
2016-07-06 17:10:01 +00:00
|
|
|
// Send the event to the menu before sending it to the window
|
|
|
|
if (event.os_event.type == NSKeyDown &&
|
|
|
|
[[NSApp mainMenu] performKeyEquivalent:event.os_event])
|
|
|
|
return;
|
|
|
|
|
2016-06-17 23:23:54 +00:00
|
|
|
if (event.os_event.window)
|
2016-06-19 11:16:19 +00:00
|
|
|
[event.os_event.window redispatchKeyEvent:event.os_event];
|
2016-05-18 04:47:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace atom
|