Handle keyboard events with AtomEventProcessingWindow.
Some system events like cmd+` will be handled by it automatically.
This commit is contained in:
parent
f62b00eaac
commit
26d6df7852
5 changed files with 24 additions and 5 deletions
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
#include "brightray/browser/browser_context.h"
|
#include "brightray/browser/browser_context.h"
|
||||||
#include "brightray/browser/default_web_contents_delegate.h"
|
|
||||||
#include "brightray/browser/inspectable_web_contents.h"
|
#include "brightray/browser/inspectable_web_contents.h"
|
||||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||||
#include "common/options_switches.h"
|
#include "common/options_switches.h"
|
||||||
|
@ -22,7 +21,7 @@ NativeWindow::NativeWindow(content::BrowserContext* browser_context,
|
||||||
base::DictionaryValue* options)
|
base::DictionaryValue* options)
|
||||||
: inspectable_web_contents_(brightray::InspectableWebContents::Create(
|
: inspectable_web_contents_(brightray::InspectableWebContents::Create(
|
||||||
content::WebContents::CreateParams(browser_context))) {
|
content::WebContents::CreateParams(browser_context))) {
|
||||||
GetWebContents()->SetDelegate(new brightray::DefaultWebContentsDelegate());
|
GetWebContents()->SetDelegate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeWindow::~NativeWindow() {
|
NativeWindow::~NativeWindow() {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
|
#include "content/public/browser/web_contents_delegate.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
class DictionaryValue;
|
class DictionaryValue;
|
||||||
|
@ -32,7 +33,7 @@ class Size;
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class NativeWindow {
|
class NativeWindow : public content::WebContentsDelegate {
|
||||||
public:
|
public:
|
||||||
virtual ~NativeWindow();
|
virtual ~NativeWindow();
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,11 @@ class NativeWindowMac : public NativeWindow {
|
||||||
protected:
|
protected:
|
||||||
void SetNonLionFullscreen(bool fullscreen);
|
void SetNonLionFullscreen(bool fullscreen);
|
||||||
|
|
||||||
|
// Implementations of content::WebContentsDelegate.
|
||||||
|
virtual void HandleKeyboardEvent(
|
||||||
|
content::WebContents*,
|
||||||
|
const content::NativeWebKeyboardEvent&) OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InstallView();
|
void InstallView();
|
||||||
void UninstallView();
|
void UninstallView();
|
||||||
|
|
|
@ -11,10 +11,11 @@
|
||||||
#include "base/mac/mac_util.h"
|
#include "base/mac/mac_util.h"
|
||||||
#include "base/sys_string_conversions.h"
|
#include "base/sys_string_conversions.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
#include "browser/atom_event_processing_window.h"
|
#import "browser/atom_event_processing_window.h"
|
||||||
#include "brightray/browser/inspectable_web_contents.h"
|
#include "brightray/browser/inspectable_web_contents.h"
|
||||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||||
#include "common/options_switches.h"
|
#include "common/options_switches.h"
|
||||||
|
#include "content/public/browser/native_web_keyboard_event.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "content/public/browser/web_contents_view.h"
|
#include "content/public/browser/web_contents_view.h"
|
||||||
|
|
||||||
|
@ -293,6 +294,19 @@ bool NativeWindowMac::IsKiosk() {
|
||||||
return is_kiosk_;
|
return is_kiosk_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::HandleKeyboardEvent(
|
||||||
|
content::WebContents*,
|
||||||
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
|
if (event.skip_in_browser ||
|
||||||
|
event.type == content::NativeWebKeyboardEvent::Char)
|
||||||
|
return;
|
||||||
|
|
||||||
|
AtomEventProcessingWindow* event_window =
|
||||||
|
static_cast<AtomEventProcessingWindow*>(window());
|
||||||
|
DCHECK([event_window isKindOfClass:[AtomEventProcessingWindow class]]);
|
||||||
|
[event_window redispatchKeyEvent:event.os_event];
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindowMac::InstallView() {
|
void NativeWindowMac::InstallView() {
|
||||||
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
|
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
|
||||||
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
|
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 57770d517efe09b0b74e891f5baed0cbb2cad2c1
|
Subproject commit 5a1c81d204ef308cb747ad3b2e4535f6dd456704
|
Loading…
Reference in a new issue