Skip to content

Commit

Permalink
Support multi touch on Windows 8 AURA and ASH.
Browse files Browse the repository at this point in the history
The touch events coming in from desktop chrome AURA and ASH have hardcoded touch ids
which breaks the gesture recognizer as it is unable to figure out that multiple touch points
are involved.

Fix on desktop Chrome AURA is to use the OS generated touch id mapped to the gesture recognizer range.
For ASH Windows 8 we pass in the mapped touch ids from the metro driver in the touch IPC messages.

Fixes bug https://code.google.com/p/chromium/issues/detail?id=179977

BUG=179977
R=cpu,sky
Review URL: https://codereview.chromium.org/13003004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191015 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ananta@chromium.org committed Mar 27, 2013
1 parent de894b0 commit d5bdab6
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 28 deletions.
5 changes: 5 additions & 0 deletions content/browser/renderer_host/render_widget_host_view_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "ui/gfx/skia_util.h"

#if defined(OS_WIN)
#include "base/win/windows_version.h"
#include "content/browser/accessibility/browser_accessibility_manager_win.h"
#include "content/browser/accessibility/browser_accessibility_win.h"
#include "ui/base/win/hidden_window.h"
Expand Down Expand Up @@ -265,6 +266,10 @@ void GetScreenInfoForWindow(WebScreenInfo* results, aura::Window* window) {
}

bool ShouldSendPinchGesture() {
#if defined(OS_WIN)
if (base::win::GetVersion() >= base::win::VERSION_WIN8)
return true;
#endif
static bool pinch_allowed =
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableViewport) ||
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch);
Expand Down
22 changes: 13 additions & 9 deletions ui/aura/remote_root_window_host_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ namespace {

const char* kRootWindowHostWinKey = "__AURA_REMOTE_ROOT_WINDOW_HOST_WIN__";

// The touch id to be used for touch events coming in from Windows Ash.
const int kRemoteWindowTouchId = 10;

// Sets the keystate for the virtual key passed in to down or up.
void SetKeyState(uint8* key_states, bool key_down, uint32 virtual_key_code) {
DCHECK(key_states);
Expand Down Expand Up @@ -373,28 +370,35 @@ void RemoteRootWindowHostWin::OnVisibilityChanged(bool visible) {
delegate_->OnHostActivated();
}

void RemoteRootWindowHostWin::OnTouchDown(int32 x, int32 y, uint64 timestamp) {
void RemoteRootWindowHostWin::OnTouchDown(int32 x,
int32 y,
uint64 timestamp,
uint32 pointer_id) {
ui::TouchEvent event(ui::ET_TOUCH_PRESSED,
gfx::Point(x, y),
kRemoteWindowTouchId,
pointer_id,
base::TimeDelta::FromMicroseconds(timestamp));
delegate_->OnHostTouchEvent(&event);
}

void RemoteRootWindowHostWin::OnTouchUp(int32 x, int32 y, uint64 timestamp) {
void RemoteRootWindowHostWin::OnTouchUp(int32 x,
int32 y,
uint64 timestamp,
uint32 pointer_id) {
ui::TouchEvent event(ui::ET_TOUCH_RELEASED,
gfx::Point(x, y),
kRemoteWindowTouchId,
pointer_id,
base::TimeDelta::FromMicroseconds(timestamp));
delegate_->OnHostTouchEvent(&event);
}

void RemoteRootWindowHostWin::OnTouchMoved(int32 x,
int32 y,
uint64 timestamp) {
uint64 timestamp,
uint32 pointer_id) {
ui::TouchEvent event(ui::ET_TOUCH_MOVED,
gfx::Point(x, y),
kRemoteWindowTouchId,
pointer_id,
base::TimeDelta::FromMicroseconds(timestamp));
delegate_->OnHostTouchEvent(&event);
}
Expand Down
6 changes: 3 additions & 3 deletions ui/aura/remote_root_window_host_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost {
uint32 scan_code,
uint32 flags);
void OnVisibilityChanged(bool visible);
void OnTouchDown(int32 x, int32 y, uint64 timestamp);
void OnTouchUp(int32 x, int32 y, uint64 timestamp);
void OnTouchMoved(int32 x, int32 y, uint64 timestamp);
void OnTouchDown(int32 x, int32 y, uint64 timestamp, uint32 pointer_id);
void OnTouchUp(int32 x, int32 y, uint64 timestamp, uint32 pointer_id);
void OnTouchMoved(int32 x, int32 y, uint64 timestamp, uint32 pointer_id);
void OnFileSaveAsDone(bool success,
string16 filename,
int filter_index);
Expand Down
15 changes: 9 additions & 6 deletions ui/metro_viewer/metro_viewer_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,21 @@ IPC_MESSAGE_CONTROL4(MetroViewerHostMsg_Character,
IPC_MESSAGE_CONTROL1(MetroViewerHostMsg_VisibilityChanged,
bool /* visible */);

IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_TouchDown,
IPC_MESSAGE_CONTROL4(MetroViewerHostMsg_TouchDown,
int32, /* x-coordinate */
int32, /* y-coordinate */
uint64) /* timestamp */
IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_TouchUp,
uint64, /* timestamp */
uint32) /* pointer_id */
IPC_MESSAGE_CONTROL4(MetroViewerHostMsg_TouchUp,
int32, /* x-coordinate */
int32, /* y-coordinate */
uint64) /* timestamp */
IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_TouchMoved,
uint64, /* timestamp */
uint32) /* pointer_id */
IPC_MESSAGE_CONTROL4(MetroViewerHostMsg_TouchMoved,
int32, /* x-coordinate */
int32, /* y-coordinate */
uint64) /* timestamp */
uint64, /* timestamp */
uint32) /* pointer_id */

// Informs the browser of the result of a file save as operation.
IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_FileSaveAsDone,
Expand Down
7 changes: 2 additions & 5 deletions ui/views/win/hwnd_message_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/win/windows_version.h"
#include "ui/base/events/event.h"
#include "ui/base/events/event_utils.h"
#include "ui/base/gestures/gesture_sequence.h"
#include "ui/base/keycodes/keyboard_code_conversion_win.h"
#include "ui/base/win/hwnd_util.h"
#include "ui/base/win/mouse_wheel_util.h"
Expand Down Expand Up @@ -292,10 +293,6 @@ bool ProcessChildWindowMessage(UINT message,
// The thickness of an auto-hide taskbar in pixels.
const int kAutoHideTaskbarThicknessPx = 2;

// The touch id to be used for touch events coming in from Windows Aura
// Desktop.
const int kDesktopChromeAuraTouchId = 9;

// For windows with the standard frame removed, the client area needs to be
// different from the window area to avoid a "feature" in Windows's handling of
// WM_NCCALCSIZE data. See the comment near the bottom of GetClientAreaInsets
Expand Down Expand Up @@ -2003,7 +2000,7 @@ LRESULT HWNDMessageHandler::OnTouchEvent(UINT message,
ui::TouchEvent event(
touch_event_type,
gfx::Point(point.x, point.y),
kDesktopChromeAuraTouchId,
input[i].dwID % ui::GestureSequence::kMaxGesturePoints,
base::TimeDelta::FromMilliseconds(input[i].dwTime));
delegate_->HandleTouchEvent(event);
}
Expand Down
23 changes: 18 additions & 5 deletions win8/metro_driver/chrome_app_view_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_sender.h"
#include "ui/base/gestures/gesture_sequence.h"
#include "ui/metro_viewer/metro_viewer_messages.h"
#include "win8/metro_driver/file_picker_ash.h"
#include "win8/metro_driver/metro_driver.h"
Expand Down Expand Up @@ -145,7 +146,8 @@ class PointerInfoHandler {
y_(0),
wheel_delta_(0),
update_kind_(winui::Input::PointerUpdateKind_Other),
timestamp_(0) {}
timestamp_(0),
pointer_id_(0) {}

HRESULT Init(winui::Core::IPointerEventArgs* args) {
HRESULT hr = args->get_CurrentPoint(&pointer_point_);
Expand All @@ -169,10 +171,13 @@ class PointerInfoHandler {
hr = properties->get_MouseWheelDelta(&wheel_delta_);
if (FAILED(hr))
return hr;

x_ = point.X;
y_ = point.Y;
pointer_point_->get_Timestamp(&timestamp_);
pointer_point_->get_PointerId(&pointer_id_);
// Map the OS touch event id to a range allowed by the gesture recognizer.
if (IsTouch())
pointer_id_ %= ui::GestureSequence::kMaxGesturePoints;
return S_OK;
}

Expand Down Expand Up @@ -218,12 +223,17 @@ class PointerInfoHandler {
int x() const { return x_; }
int y() const { return y_; }

uint32 pointer_id() const {
return pointer_id_;
}

uint64 timestamp() const { return timestamp_; }

private:
int x_;
int y_;
int wheel_delta_;
uint32 pointer_id_;
winui::Input::PointerUpdateKind update_kind_;
mswr::ComPtr<winui::Input::IPointerPoint> pointer_point_;
uint64 timestamp_;
Expand Down Expand Up @@ -548,7 +558,8 @@ HRESULT ChromeAppViewAsh::OnPointerMoved(winui::Core::ICoreWindow* sender,
DCHECK(pointer.IsTouch());
ui_channel_->Send(new MetroViewerHostMsg_TouchMoved(pointer.x(),
pointer.y(),
pointer.timestamp()));
pointer.timestamp(),
pointer.pointer_id()));
}
return S_OK;
}
Expand Down Expand Up @@ -577,7 +588,8 @@ HRESULT ChromeAppViewAsh::OnPointerPressed(
DCHECK(pointer.IsTouch());
ui_channel_->Send(new MetroViewerHostMsg_TouchDown(pointer.x(),
pointer.y(),
pointer.timestamp()));
pointer.timestamp(),
pointer.pointer_id()));
}
return S_OK;
}
Expand All @@ -601,7 +613,8 @@ HRESULT ChromeAppViewAsh::OnPointerReleased(
DCHECK(pointer.IsTouch());
ui_channel_->Send(new MetroViewerHostMsg_TouchUp(pointer.x(),
pointer.y(),
pointer.timestamp()));
pointer.timestamp(),
pointer.pointer_id()));
}
return S_OK;
}
Expand Down

0 comments on commit d5bdab6

Please sign in to comment.