diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-11 20:18:39 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-11 20:18:39 +0000 |
commit | 934b9d43c37d789878789375e959231f17ff23ef (patch) | |
tree | 5031160476b260d14bbd3ff51171d3b10f72a466 /win8/metro_driver | |
parent | 8a8cebfba1bb54804e2082b8904b3c47b6ab6996 (diff) | |
download | chromium_src-934b9d43c37d789878789375e959231f17ff23ef.zip chromium_src-934b9d43c37d789878789375e959231f17ff23ef.tar.gz chromium_src-934b9d43c37d789878789375e959231f17ff23ef.tar.bz2 |
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
Diffstat (limited to 'win8/metro_driver')
-rw-r--r-- | win8/metro_driver/chrome_app_view.cc | 94 |
1 files changed, 85 insertions, 9 deletions
diff --git a/win8/metro_driver/chrome_app_view.cc b/win8/metro_driver/chrome_app_view.cc index 28e9e76..a8c2213 100644 --- a/win8/metro_driver/chrome_app_view.cc +++ b/win8/metro_driver/chrome_app_view.cc @@ -48,6 +48,10 @@ typedef winfoundtn::ITypedEventHandler< winui::ViewManagement::InputPaneVisibilityEventArgs*> InputPaneEventHandler; +typedef winfoundtn::ITypedEventHandler< + winui::Core::CoreWindow*, + winui::Core::PointerEventArgs*> PointerEventHandler; + struct Globals globals; // TODO(ananta) @@ -666,7 +670,9 @@ DWORD WINAPI HostMainThreadProc(void*) { ChromeAppView::ChromeAppView() : osk_visible_notification_received_(false), - osk_offset_adjustment_(0) { + osk_offset_adjustment_(0), + ui_channel_(nullptr), + ui_channel_listener_(nullptr) { globals.previous_state = winapp::Activation::ApplicationExecutionState_NotRunning; } @@ -702,6 +708,24 @@ ChromeAppView::SetWindow(winui::Core::ICoreWindow* window) { &sizechange_token_); 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. mswr::ComPtr<winui::Input::IEdgeGestureStatics> edge_gesture_statics; hr = winrt_utils::CreateActivationFactory( @@ -847,15 +871,22 @@ ChromeAppView::Run() { options.message_loop_type = MessageLoop::TYPE_IO; thread.StartWithOptions(options); - // The viewer channel opened below only applies when we are launched as an - // AURA viewer process. + #if defined(USE_AURA) - ChromeChannelListener channel_listener; - IPC::ChannelProxy chan("viewer", IPC::Channel::MODE_NAMED_CLIENT, - &channel_listener, thread.message_loop_proxy()); - channel_listener.Init(&chan); - chan.Send(new MetroViewerHostMsg_SetTargetSurface( - gfx::NativeViewId(globals.core_window))); + // In Aura mode we create an IPC channel to the browser which should + // be already running. + ChromeChannelListener ui_channel_listener; + IPC::ChannelProxy ui_channel("viewer", + IPC::Channel::MODE_NAMED_CLIENT, + &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; #endif @@ -1056,6 +1087,51 @@ HRESULT ChromeAppView::OnSizeChanged(winui::Core::ICoreWindow* sender, 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) { DVLOG(1) << __FUNCTION__; |