Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: win8/metro_driver/chrome_app_view.cc

Issue 11088083: Wiring mouse messages to aura metro viewer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: win8/metro_driver/chrome_app_view.cc
===================================================================
--- win8/metro_driver/chrome_app_view.cc (revision 161376)
+++ win8/metro_driver/chrome_app_view.cc (working copy)
@@ -48,6 +48,10 @@
winui::ViewManagement::InputPaneVisibilityEventArgs*>
InputPaneEventHandler;
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::PointerEventArgs*> PointerEventHandler;
+
struct Globals globals;
// TODO(ananta)
@@ -666,7 +670,9 @@
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 @@
&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,16 +871,23 @@
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
// And post the task that'll do the inner Metro message pumping to it.
@@ -1056,6 +1087,51 @@
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__;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698