summaryrefslogtreecommitdiffstats
path: root/win8
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-18 20:44:16 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-18 20:44:16 +0000
commit9ed88aedad5c7f9865f783f18de257d5e1185612 (patch)
tree8d527f35600324030076fbe58f8735ae27df4362 /win8
parent33204e20863bca9a9857c338400777be6176537a (diff)
downloadchromium_src-9ed88aedad5c7f9865f783f18de257d5e1185612.zip
chromium_src-9ed88aedad5c7f9865f783f18de257d5e1185612.tar.gz
chromium_src-9ed88aedad5c7f9865f783f18de257d5e1185612.tar.bz2
Add keyboard events to metro aura
This is the first part since there IME are issues that need to be sorted out before this can fully work. In particular, InputMethodEventFilter::PreHandleKeyEvent needs changes not to assume native events. BUG=151718 TEST=none Review URL: https://codereview.chromium.org/11194044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162781 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8')
-rw-r--r--win8/metro_driver/chrome_app_view.cc79
-rw-r--r--win8/metro_driver/chrome_app_view.h8
-rw-r--r--win8/metro_driver/stdafx.h19
3 files changed, 85 insertions, 21 deletions
diff --git a/win8/metro_driver/chrome_app_view.cc b/win8/metro_driver/chrome_app_view.cc
index a8c2213..f6fac76 100644
--- a/win8/metro_driver/chrome_app_view.cc
+++ b/win8/metro_driver/chrome_app_view.cc
@@ -52,6 +52,10 @@ typedef winfoundtn::ITypedEventHandler<
winui::Core::CoreWindow*,
winui::Core::PointerEventArgs*> PointerEventHandler;
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::KeyEventArgs*> KeyEventHandler;
+
struct Globals globals;
// TODO(ananta)
@@ -702,14 +706,9 @@ ChromeAppView::SetWindow(winui::Core::ICoreWindow* window) {
HRESULT hr = url_launch_handler_.Initialize();
CheckHR(hr, "Failed to initialize url launch handler.");
- // Register for size notifications.
- hr = window_->add_SizeChanged(mswr::Callback<SizeChangedHandler>(
- this, &ChromeAppView::OnSizeChanged).Get(),
- &sizechange_token_);
- CheckHR(hr);
-
#if defined(USE_AURA)
- // Register for pointer notifications.
+ // Register for pointer and keyboard notifications. We forward
+ // them to the browser process via IPC.
hr = window_->add_PointerMoved(mswr::Callback<PointerEventHandler>(
this, &ChromeAppView::OnPointerMoved).Get(),
&pointermoved_token_);
@@ -724,7 +723,27 @@ ChromeAppView::SetWindow(winui::Core::ICoreWindow* window) {
this, &ChromeAppView::OnPointerReleased).Get(),
&pointerreleased_token_);
CheckHR(hr);
-#endif
+
+ hr = window_->add_KeyDown(mswr::Callback<KeyEventHandler>(
+ this, &ChromeAppView::OnKeyDown).Get(),
+ &keydown_token_);
+ CheckHR(hr);
+
+ hr = window_->add_KeyUp(mswr::Callback<KeyEventHandler>(
+ this, &ChromeAppView::OnKeyUp).Get(),
+ &keyup_token_);
+ CheckHR(hr);
+
+ // By initializing the direct 3D swap chain with the corewindow
+ // we can now directly blit to it from the browser process.
+ direct3d_helper_.Initialize(window);
+ DVLOG(1) << "Initialized Direct3D.";
+#else
+ // Register for size notifications.
+ hr = window_->add_SizeChanged(mswr::Callback<SizeChangedHandler>(
+ this, &ChromeAppView::OnSizeChanged).Get(),
+ &sizechange_token_);
+ CheckHR(hr);
// Register for edge gesture notifications.
mswr::ComPtr<winui::Input::IEdgeGestureStatics> edge_gesture_statics;
@@ -772,15 +791,13 @@ ChromeAppView::SetWindow(winui::Core::ICoreWindow* window) {
DVLOG(1) << "Created appview instance.";
- direct3d_helper_.Initialize(window);
-
- DVLOG(1) << "Initialized Direct3D.";
-
hr = devices_handler_.Initialize(window);
// Don't check or return the failure here, we need to let the app
// initialization succeed. Even if we won't be able to access devices
// we still want to allow the app to start.
LOG_IF(ERROR, FAILED(hr)) << "Failed to initialize devices handler.";
+#endif
+
return S_OK;
}
@@ -1011,7 +1028,6 @@ HRESULT ChromeAppView::OnActivate(winapp::Core::ICoreApplicationView*,
return E_UNEXPECTED;
}
}
-#endif
if (RegisterHotKey(globals.core_window, kFlipWindowsHotKeyId,
MOD_CONTROL, VK_F12)) {
@@ -1022,6 +1038,9 @@ HRESULT ChromeAppView::OnActivate(winapp::Core::ICoreApplicationView*,
HRESULT hr = settings_handler_.Initialize();
CheckHR(hr,"Failed to initialize settings handler.");
return hr;
+#else
+ return S_OK;
+#endif
}
// We subclass the core window for moving the associated chrome window when the
@@ -1132,6 +1151,40 @@ HRESULT ChromeAppView::OnPointerReleased(winui::Core::ICoreWindow* sender,
return S_OK;
}
+HRESULT ChromeAppView::OnKeyDown(winui::Core::ICoreWindow* sender,
+ winui::Core::IKeyEventArgs* args) {
+ winsys::VirtualKey virtual_key;
+ HRESULT hr = args->get_VirtualKey(&virtual_key);
+ if (FAILED(hr))
+ return hr;
+ winui::Core::CorePhysicalKeyStatus status;
+ hr = args->get_KeyStatus(&status);
+ if (FAILED(hr))
+ return hr;
+
+ ui_channel_->Send(new MetroViewerHostMsg_KeyDown(virtual_key,
+ status.RepeatCount,
+ status.ScanCode));
+ return S_OK;
+}
+
+HRESULT ChromeAppView::OnKeyUp(winui::Core::ICoreWindow* sender,
+ winui::Core::IKeyEventArgs* args) {
+ winsys::VirtualKey virtual_key;
+ HRESULT hr = args->get_VirtualKey(&virtual_key);
+ if (FAILED(hr))
+ return hr;
+ winui::Core::CorePhysicalKeyStatus status;
+ hr = args->get_KeyStatus(&status);
+ if (FAILED(hr))
+ return hr;
+
+ ui_channel_->Send(new MetroViewerHostMsg_KeyUp(virtual_key,
+ status.RepeatCount,
+ status.ScanCode));
+ return S_OK;
+}
+
HRESULT ChromeAppView::OnPositionChanged(int x, int y) {
DVLOG(1) << __FUNCTION__;
diff --git a/win8/metro_driver/chrome_app_view.h b/win8/metro_driver/chrome_app_view.h
index f9d8f90..3ca5e2b 100644
--- a/win8/metro_driver/chrome_app_view.h
+++ b/win8/metro_driver/chrome_app_view.h
@@ -91,6 +91,12 @@ class ChromeAppView
HRESULT OnPointerReleased(winui::Core::ICoreWindow* sender,
winui::Core::IPointerEventArgs* args);
+ HRESULT OnKeyDown(winui::Core::ICoreWindow* sender,
+ winui::Core::IKeyEventArgs* args);
+
+ HRESULT OnKeyUp(winui::Core::ICoreWindow* sender,
+ winui::Core::IKeyEventArgs* args);
+
HRESULT OnEdgeGestureCompleted(winui::Input::IEdgeGesture* gesture,
winui::Input::IEdgeGestureEventArgs* args);
@@ -127,6 +133,8 @@ class ChromeAppView
EventRegistrationToken pointermoved_token_;
EventRegistrationToken pointerpressed_token_;
EventRegistrationToken pointerreleased_token_;
+ EventRegistrationToken keydown_token_;
+ EventRegistrationToken keyup_token_;
ChromeUrlLaunchHandler url_launch_handler_;
metro_driver::DevicesHandler devices_handler_;
diff --git a/win8/metro_driver/stdafx.h b/win8/metro_driver/stdafx.h
index 8373c3c..cf4204d 100644
--- a/win8/metro_driver/stdafx.h
+++ b/win8/metro_driver/stdafx.h
@@ -23,14 +23,17 @@
#include <windows.graphics.printing.h>
#include <windows.ui.notifications.h>
-namespace mswr = Microsoft::WRL;
-namespace mswrw = Microsoft::WRL::Wrappers;
-namespace winapp = ABI::Windows::ApplicationModel;
-namespace windata = ABI::Windows::Data;
-namespace windevs = ABI::Windows::Devices;
+namespace mswr = Microsoft::WRL;
+namespace mswrw = Microsoft::WRL::Wrappers;
+
+namespace winapp = ABI::Windows::ApplicationModel;
+namespace windata = ABI::Windows::Data;
+namespace winxml = ABI::Windows::Data::Xml;
+namespace windevs = ABI::Windows::Devices;
namespace winfoundtn = ABI::Windows::Foundation;
-namespace wingfx = ABI::Windows::Graphics;
-namespace winui = ABI::Windows::UI;
-namespace winxml = windata::Xml;
+namespace wingfx = ABI::Windows::Graphics;
+namespace winui = ABI::Windows::UI;
+namespace winsys = ABI::Windows::System;
+
#endif // CHROME_BROWSER_UI_METRO_DRIVER_STDAFX_H_