Commit fed11438 authored by lanwei's avatar lanwei Committed by Commit Bot

Send PointerUp event when using stylus on Windows

After we changed to use ui::TouchEvent to represent stylus input instead
of ui::MouseEvent, we should not set its flag to left button or right
button when we press or release the pen on the tablet or any button on
the pen.


Bug: 850011
Change-Id: I2c2dc11e2cc625691aee11c14f28e632e0c15df3
Reviewed-on: https://chromium-review.googlesource.com/1099876Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarElla Ge <eirage@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568461}
parent c4be4f60
......@@ -18,12 +18,6 @@ int GetFlagsFromPointerMessage(UINT message, const POINTER_INFO& pointer_info) {
if (pointer_info.pointerFlags & POINTER_FLAG_SECONDBUTTON)
flags |= ui::EF_RIGHT_MOUSE_BUTTON;
if (message == WM_POINTERUP) {
if (pointer_info.ButtonChangeType == POINTER_CHANGE_SECONDBUTTON_UP)
flags |= ui::EF_RIGHT_MOUSE_BUTTON;
else
flags |= ui::EF_LEFT_MOUSE_BUTTON;
}
return flags;
}
......@@ -121,10 +115,13 @@ std::unique_ptr<ui::Event> PenEventProcessor::GenerateMouseEvent(
break;
case WM_POINTERUP:
event_type = ui::ET_MOUSE_RELEASED;
if (pointer_info.ButtonChangeType == POINTER_CHANGE_FIRSTBUTTON_UP)
if (pointer_info.ButtonChangeType == POINTER_CHANGE_FIRSTBUTTON_UP) {
flag |= ui::EF_LEFT_MOUSE_BUTTON;
changed_flag = ui::EF_LEFT_MOUSE_BUTTON;
else
} else {
flag |= ui::EF_RIGHT_MOUSE_BUTTON;
changed_flag = ui::EF_RIGHT_MOUSE_BUTTON;
}
id_generator_->ReleaseNumber(pointer_id);
click_count = 1;
if (!sent_mouse_down_)
......
......@@ -164,4 +164,67 @@ TEST(PenProcessorTest, UnpairedPointerDownMouseDMEnabled) {
EXPECT_EQ(nullptr, event.get());
}
TEST(PenProcessorTest, TouchFlagDMEnabled) {
ui::SequentialIDGenerator id_generator(0);
PenEventProcessor processor(&id_generator,
/*direct_manipulation_enabled*/ true);
POINTER_PEN_INFO pen_info;
memset(&pen_info, 0, sizeof(POINTER_PEN_INFO));
gfx::Point point(100, 100);
pen_info.pointerInfo.pointerFlags =
POINTER_FLAG_INCONTACT | POINTER_FLAG_FIRSTBUTTON;
pen_info.pointerInfo.ButtonChangeType = POINTER_CHANGE_FIRSTBUTTON_DOWN;
std::unique_ptr<ui::Event> event =
processor.GenerateEvent(WM_POINTERDOWN, 0, pen_info, point);
ASSERT_TRUE(event);
ASSERT_TRUE(event->IsTouchEvent());
EXPECT_EQ(ui::ET_TOUCH_PRESSED, event->AsTouchEvent()->type());
EXPECT_TRUE(event->flags() & ui::EF_LEFT_MOUSE_BUTTON);
pen_info.pointerInfo.pointerFlags = POINTER_FLAG_UP;
pen_info.pointerInfo.ButtonChangeType = POINTER_CHANGE_FIRSTBUTTON_UP;
event = processor.GenerateEvent(WM_POINTERUP, 0, pen_info, point);
ASSERT_TRUE(event);
ASSERT_TRUE(event->IsTouchEvent());
EXPECT_EQ(ui::ET_TOUCH_RELEASED, event->AsTouchEvent()->type());
EXPECT_FALSE(event->flags() & ui::EF_LEFT_MOUSE_BUTTON);
}
TEST(PenProcessorTest, MouseFlagDMEnabled) {
ui::SequentialIDGenerator id_generator(0);
PenEventProcessor processor(&id_generator,
/*direct_manipulation_enabled*/ true);
POINTER_PEN_INFO pen_info;
memset(&pen_info, 0, sizeof(POINTER_PEN_INFO));
gfx::Point point(100, 100);
pen_info.pointerInfo.pointerFlags = POINTER_FLAG_FIRSTBUTTON;
pen_info.pointerInfo.ButtonChangeType = POINTER_CHANGE_FIRSTBUTTON_DOWN;
std::unique_ptr<ui::Event> event =
processor.GenerateEvent(WM_POINTERDOWN, 0, pen_info, point);
ASSERT_TRUE(event);
ASSERT_TRUE(event->IsMouseEvent());
EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->AsMouseEvent()->type());
EXPECT_TRUE(event->flags() & ui::EF_LEFT_MOUSE_BUTTON);
EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON,
event->AsMouseEvent()->changed_button_flags());
pen_info.pointerInfo.pointerFlags = POINTER_FLAG_NONE;
pen_info.pointerInfo.ButtonChangeType = POINTER_CHANGE_FIRSTBUTTON_UP;
event = processor.GenerateEvent(WM_POINTERUP, 0, pen_info, point);
ASSERT_TRUE(event);
ASSERT_TRUE(event->IsMouseEvent());
EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->AsMouseEvent()->type());
EXPECT_TRUE(event->flags() & ui::EF_LEFT_MOUSE_BUTTON);
EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON,
event->AsMouseEvent()->changed_button_flags());
}
} // namespace views
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