Skip to content

Commit

Permalink
Wiring mouse messages to aura metro viewer.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cpu@chromium.org committed Oct 11, 2012
1 parent 8a8cebf commit 934b9d4
Showing 1 changed file with 85 additions and 9 deletions.
94 changes: 85 additions & 9 deletions win8/metro_driver/chrome_app_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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__;

Expand Down

0 comments on commit 934b9d4

Please sign in to comment.