summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/metro_viewer/metro_viewer_process_host_win.cc24
-rw-r--r--chrome/browser/metro_viewer/metro_viewer_process_host_win.h8
-rw-r--r--ui/aura/remote_root_window_host_win.cc23
-rw-r--r--ui/aura/remote_root_window_host_win.h6
-rw-r--r--ui/metro_viewer/metro_viewer_messages.h24
-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
8 files changed, 151 insertions, 40 deletions
diff --git a/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc b/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
index db26ed4..d84886c 100644
--- a/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
+++ b/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
@@ -37,6 +37,8 @@ bool MetroViewerProcessHost::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetTargetSurface, OnSetTargetSurface)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseMoved, OnMouseMoved)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseButton, OnMouseButton)
+ IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyDown, OnKeyDown)
+ IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyUp, OnKeyUp)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -59,12 +61,26 @@ void MetroViewerProcessHost::OnSetTargetSurface(
any_window->SetNewTargetWindow(hwnd);
}
-void MetroViewerProcessHost::OnMouseMoved(int x, int y, int modifiers) {
- // TODO(cpu): Find a decent way to get to the root window host.
+// TODO(cpu): Find a decent way to get to the root window host in the
+// next four methods.
+void MetroViewerProcessHost::OnMouseMoved(int32 x, int32 y, int32 modifiers) {
aura::RemoteRootWindowHostWin::Instance()->OnMouseMoved(x, y, modifiers);
}
-void MetroViewerProcessHost::OnMouseButton(int x, int y, int modifiers) {
- // TODO(cpu): Find a decent way to get to the root window host.
+void MetroViewerProcessHost::OnMouseButton(int32 x, int32 y, int32 modifiers) {
aura::RemoteRootWindowHostWin::Instance()->OnMouseClick(x, y, modifiers);
}
+
+void MetroViewerProcessHost::OnKeyDown(uint32 vkey,
+ uint32 repeat_count,
+ uint32 scan_code) {
+ aura::RemoteRootWindowHostWin::Instance()->OnKeyDown(
+ vkey, repeat_count, scan_code);
+}
+
+void MetroViewerProcessHost::OnKeyUp(uint32 vkey,
+ uint32 repeat_count,
+ uint32 scan_code) {
+ aura::RemoteRootWindowHostWin::Instance()->OnKeyUp(
+ vkey, repeat_count, scan_code);
+}
diff --git a/chrome/browser/metro_viewer/metro_viewer_process_host_win.h b/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
index 51207ec..e38a54e 100644
--- a/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
+++ b/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
@@ -32,9 +32,11 @@ class MetroViewerProcessHost : public IPC::Listener,
private:
void OnSetTargetSurface(gfx::NativeViewId target_surface);
- void OnMouseEvent(int msg, WPARAM w_param, LPARAM l_param);
- void OnMouseMoved(int x, int y, int modifiers);
- void OnMouseButton(int x, int y, int modifiers);
+ void OnMouseEvent(int32 msg, WPARAM w_param, LPARAM l_param);
+ void OnMouseMoved(int32 x, int32 y, int32 modifiers);
+ void OnMouseButton(int32 x, int32 y, int32 modifiers);
+ void OnKeyDown(uint32 vkey, uint32 repeat_count, uint32 scan_code);
+ void OnKeyUp(uint32 vkey, uint32 repeat_count, uint32 scan_code);
scoped_ptr<IPC::ChannelProxy> channel_;
diff --git a/ui/aura/remote_root_window_host_win.cc b/ui/aura/remote_root_window_host_win.cc
index 619b783..71411b0 100644
--- a/ui/aura/remote_root_window_host_win.cc
+++ b/ui/aura/remote_root_window_host_win.cc
@@ -14,6 +14,7 @@
#include "ui/aura/root_window.h"
#include "ui/base/cursor/cursor_loader_win.h"
#include "ui/base/events/event.h"
+#include "ui/base/keycodes/keyboard_code_conversion_win.h"
#include "ui/base/view_prop.h"
using std::max;
@@ -136,13 +137,13 @@ void RemoteRootWindowHostWin::PrepareForShutdown() {
NOTIMPLEMENTED();
}
-void RemoteRootWindowHostWin::OnMouseMoved(int x, int y, int extra) {
+void RemoteRootWindowHostWin::OnMouseMoved(int32 x, int32 y, int32 extra) {
gfx::Point location(x, y);
ui::MouseEvent event(ui::ET_MOUSE_MOVED, location, location, 0);
delegate_->OnHostMouseEvent(&event);
}
-void RemoteRootWindowHostWin::OnMouseClick(int x, int y, int extra) {
+void RemoteRootWindowHostWin::OnMouseClick(int32 x, int32 y, int32 extra) {
gfx::Point location(x, y);
ui::EventType type = (extra == 1) ?
ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED;
@@ -152,4 +153,22 @@ void RemoteRootWindowHostWin::OnMouseClick(int x, int y, int extra) {
delegate_->OnHostMouseEvent(&event);
}
+void RemoteRootWindowHostWin::OnKeyDown(uint32 vkey,
+ uint32 repeat_count,
+ uint32 scan_code) {
+ ui::KeyEvent event(ui::ET_KEY_PRESSED,
+ ui::KeyboardCodeForWindowsKeyCode(vkey),
+ 0);
+ delegate_->OnHostKeyEvent(&event);
+}
+
+void RemoteRootWindowHostWin::OnKeyUp(uint32 vkey,
+ uint32 repeat_count,
+ uint32 scan_code) {
+ ui::KeyEvent event(ui::ET_KEY_RELEASED,
+ ui::KeyboardCodeForWindowsKeyCode(vkey),
+ 0);
+ delegate_->OnHostKeyEvent(&event);
+}
+
} // namespace aura
diff --git a/ui/aura/remote_root_window_host_win.h b/ui/aura/remote_root_window_host_win.h
index 795af0f..c45af18 100644
--- a/ui/aura/remote_root_window_host_win.h
+++ b/ui/aura/remote_root_window_host_win.h
@@ -22,8 +22,10 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost {
static RemoteRootWindowHostWin* Instance();
static RemoteRootWindowHostWin* Create(const gfx::Rect& bounds);
- void OnMouseMoved(int x, int y, int extra);
- void OnMouseClick(int x, int y, int extra);
+ void OnMouseMoved(int32 x, int32 y, int32 extra);
+ void OnMouseClick(int32 x, int32 y, int32 extra);
+ void OnKeyDown(uint32 vkey, uint32 repeat_count, uint32 scan_code);
+ void OnKeyUp(uint32 vkey, uint32 repeat_count, uint32 scan_code);
private:
RemoteRootWindowHostWin(const gfx::Rect& bounds);
diff --git a/ui/metro_viewer/metro_viewer_messages.h b/ui/metro_viewer/metro_viewer_messages.h
index 66d482c..b94a561 100644
--- a/ui/metro_viewer/metro_viewer_messages.h
+++ b/ui/metro_viewer/metro_viewer_messages.h
@@ -17,13 +17,21 @@ IPC_MESSAGE_CONTROL1(MetroViewerHostMsg_SetTargetSurface,
gfx::NativeViewId /* target hwnd */)
// Informs the browser that the mouse moved.
IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_MouseMoved,
- int, /* x-coordinate */
- int, /* y-coordinate */
- int /* modifiers */)
+ int32, /* x-coordinate */
+ int32, /* y-coordinate */
+ int32 /* modifiers */)
// Inforoms the brower that a mouse button was pressed.
IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_MouseButton,
- int, /* x-coordinate */
- int, /* y-coordinate */
- int /* modifiers */)
-
-
+ int32, /* x-coordinate */
+ int32, /* y-coordinate */
+ int32 /* modifiers */)
+// Informs the browser that a key was pressed.
+IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_KeyDown,
+ uint32, /* virtual key */
+ uint32, /* repeat count */
+ uint32 /* scan code*/);
+// Informs the browser that a key was released.
+IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_KeyUp,
+ uint32, /* virtual key */
+ uint32, /* repeat count */
+ uint32 /* scan code*/);
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_