Commit 934b9d43 authored by cpu@chromium.org's avatar cpu@chromium.org

Wiring mouse messages to aura metro viewer.

Missed the actual mouse sending in the previous CL. 
https://codereview.chromium.org/11047012/

Note that to view the aura-in-metro you need
0) chrome as default browser
1) start chrome with --open-ash
2) hold shift-f11 while clicking on the chrome metro tile

BUG=151718
TEST=see bug
Review URL: https://codereview.chromium.org/11088083

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161387 0039d316-1c4b-4281-b951-d872f2087c98
parent 8a8cebfb
...@@ -48,6 +48,10 @@ typedef winfoundtn::ITypedEventHandler< ...@@ -48,6 +48,10 @@ typedef winfoundtn::ITypedEventHandler<
winui::ViewManagement::InputPaneVisibilityEventArgs*> winui::ViewManagement::InputPaneVisibilityEventArgs*>
InputPaneEventHandler; InputPaneEventHandler;
typedef winfoundtn::ITypedEventHandler<
winui::Core::CoreWindow*,
winui::Core::PointerEventArgs*> PointerEventHandler;
struct Globals globals; struct Globals globals;
// TODO(ananta) // TODO(ananta)
...@@ -666,7 +670,9 @@ DWORD WINAPI HostMainThreadProc(void*) { ...@@ -666,7 +670,9 @@ DWORD WINAPI HostMainThreadProc(void*) {
ChromeAppView::ChromeAppView() ChromeAppView::ChromeAppView()
: osk_visible_notification_received_(false), : osk_visible_notification_received_(false),
osk_offset_adjustment_(0) { osk_offset_adjustment_(0),
ui_channel_(nullptr),
ui_channel_listener_(nullptr) {
globals.previous_state = globals.previous_state =
winapp::Activation::ApplicationExecutionState_NotRunning; winapp::Activation::ApplicationExecutionState_NotRunning;
} }
...@@ -702,6 +708,24 @@ ChromeAppView::SetWindow(winui::Core::ICoreWindow* window) { ...@@ -702,6 +708,24 @@ ChromeAppView::SetWindow(winui::Core::ICoreWindow* window) {
&sizechange_token_); &sizechange_token_);
CheckHR(hr); CheckHR(hr);
#if defined(USE_AURA)
// Register for pointer notifications.
hr = window_->add_PointerMoved(mswr::Callback<PointerEventHandler>(
this, &ChromeAppView::OnPointerMoved).Get(),
&pointermoved_token_);
CheckHR(hr);
hr = window_->add_PointerPressed(mswr::Callback<PointerEventHandler>(
this, &ChromeAppView::OnPointerPressed).Get(),
&pointerpressed_token_);
CheckHR(hr);
hr = window_->add_PointerReleased(mswr::Callback<PointerEventHandler>(
this, &ChromeAppView::OnPointerReleased).Get(),
&pointerreleased_token_);
CheckHR(hr);
#endif
// Register for edge gesture notifications. // Register for edge gesture notifications.
mswr::ComPtr<winui::Input::IEdgeGestureStatics> edge_gesture_statics; mswr::ComPtr<winui::Input::IEdgeGestureStatics> edge_gesture_statics;
hr = winrt_utils::CreateActivationFactory( hr = winrt_utils::CreateActivationFactory(
...@@ -847,15 +871,22 @@ ChromeAppView::Run() { ...@@ -847,15 +871,22 @@ ChromeAppView::Run() {
options.message_loop_type = MessageLoop::TYPE_IO; options.message_loop_type = MessageLoop::TYPE_IO;
thread.StartWithOptions(options); thread.StartWithOptions(options);
// The viewer channel opened below only applies when we are launched as an
// AURA viewer process.
#if defined(USE_AURA) #if defined(USE_AURA)
ChromeChannelListener channel_listener; // In Aura mode we create an IPC channel to the browser which should
IPC::ChannelProxy chan("viewer", IPC::Channel::MODE_NAMED_CLIENT, // be already running.
&channel_listener, thread.message_loop_proxy()); ChromeChannelListener ui_channel_listener;
channel_listener.Init(&chan); IPC::ChannelProxy ui_channel("viewer",
chan.Send(new MetroViewerHostMsg_SetTargetSurface( IPC::Channel::MODE_NAMED_CLIENT,
gfx::NativeViewId(globals.core_window))); &ui_channel_listener,
thread.message_loop_proxy());
ui_channel_listener.Init(&ui_channel);
ui_channel_listener_ = &ui_channel_listener;
ui_channel_ = &ui_channel;
ui_channel_->Send(new MetroViewerHostMsg_SetTargetSurface(
gfx::NativeViewId(globals.core_window)));
DVLOG(1) << "ICoreWindow sent " << globals.core_window; DVLOG(1) << "ICoreWindow sent " << globals.core_window;
#endif #endif
...@@ -1056,6 +1087,51 @@ HRESULT ChromeAppView::OnSizeChanged(winui::Core::ICoreWindow* sender, ...@@ -1056,6 +1087,51 @@ HRESULT ChromeAppView::OnSizeChanged(winui::Core::ICoreWindow* sender,
return S_OK; return S_OK;
} }
HRESULT ChromeAppView::OnPointerMoved(winui::Core::ICoreWindow* sender,
winui::Core::IPointerEventArgs* args) {
metro_driver::PointerEventHandler pointer;
HRESULT hr = pointer.Init(args);
if (FAILED(hr))
return hr;
if (!pointer.is_mouse())
return S_OK;
ui_channel_->Send(new MetroViewerHostMsg_MouseMoved(pointer.x(),
pointer.y(),
0));
return S_OK;
}
HRESULT ChromeAppView::OnPointerPressed(winui::Core::ICoreWindow* sender,
winui::Core::IPointerEventArgs* args) {
metro_driver::PointerEventHandler pointer;
HRESULT hr = pointer.Init(args);
if (FAILED(hr))
return hr;
if (!pointer.is_mouse())
return S_OK;
ui_channel_->Send(new MetroViewerHostMsg_MouseButton(pointer.x(),
pointer.y(),
1));
return S_OK;
}
HRESULT ChromeAppView::OnPointerReleased(winui::Core::ICoreWindow* sender,
winui::Core::IPointerEventArgs* args) {
metro_driver::PointerEventHandler pointer;
HRESULT hr = pointer.Init(args);
if (FAILED(hr))
return hr;
if (!pointer.is_mouse())
return S_OK;
ui_channel_->Send(new MetroViewerHostMsg_MouseButton(pointer.x(),
pointer.y(),
0));
return S_OK;
}
HRESULT ChromeAppView::OnPositionChanged(int x, int y) { HRESULT ChromeAppView::OnPositionChanged(int x, int y) {
DVLOG(1) << __FUNCTION__; DVLOG(1) << __FUNCTION__;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment