Commit 16ac979e authored by lanwei's avatar lanwei Committed by Commit bot

We hard coded the pointer type as mouse in ui::GetMousePointerDetailsFromNative

for events sending from Windows. Now we use a mouse message from GetMessageExtraInfo to decide
the actual input device type.

GetMessageExtraInfo needs to be mask-checked against 0xFFFFFF00, and then compared
with 0xFF515700. True when this mouse message was generated by a Tablet PC pen or touch
screen. Otherwise it is from a mouse device. Additionally, in Windows Vista or later,
the eighth bit, masked by 0x80, is used to differentiate
touch input from pen input
(0 = pen, 1 = touch).

Reference:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms703320(v=vs.85).aspx

BUG=614820

Review-Url: https://codereview.chromium.org/2020143003
Cr-Commit-Position: refs/heads/master@{#398025}
parent e34f3291
...@@ -19,9 +19,12 @@ namespace ui { ...@@ -19,9 +19,12 @@ namespace ui {
namespace { namespace {
// From MSDN: "Mouse" events are flagged with 0xFF515700 if they come // From MSDN: "Mouse" events are flagged with 0xFF515700 if they come
// from a touch or stylus device. In Vista or later, they are also flagged // from a touch or stylus device. In Vista or later, the eighth bit,
// with 0x80 if they come from touch. // masked by 0x80, is used to differentiate touch input from pen input
#define MOUSEEVENTF_FROMTOUCH (0xFF515700 | 0x80) // (0 = pen, 1 = touch).
#define MOUSEEVENTF_FROMTOUCHPEN 0xFF515700
#define MOUSEEVENTF_FROMTOUCH (MOUSEEVENTF_FROMTOUCHPEN | 0x80)
#define SIGNATURE_MASK 0xFFFFFF00
// Get the native mouse key state from the native event message type. // Get the native mouse key state from the native event message type.
int GetNativeMouseKey(const base::NativeEvent& native_event) { int GetNativeMouseKey(const base::NativeEvent& native_event) {
...@@ -292,7 +295,12 @@ int GetChangedMouseButtonFlagsFromNative( ...@@ -292,7 +295,12 @@ int GetChangedMouseButtonFlagsFromNative(
PointerDetails GetMousePointerDetailsFromNative( PointerDetails GetMousePointerDetailsFromNative(
const base::NativeEvent& native_event) { const base::NativeEvent& native_event) {
return PointerDetails(EventPointerType::POINTER_TYPE_MOUSE); // We should filter out all the mouse events Synthesized from touch events.
// TODO(lanwei): Will set the pointer ID, see https://crbug.com/616771.
if ((GetMessageExtraInfo() & SIGNATURE_MASK) != MOUSEEVENTF_FROMTOUCHPEN)
return PointerDetails(EventPointerType::POINTER_TYPE_MOUSE);
return PointerDetails(EventPointerType::POINTER_TYPE_PEN);
} }
gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) { gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) {
......
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