Commit fbdbb023 authored by Bret Sepulveda's avatar Bret Sepulveda Committed by Commit Bot

Add support for WM_NCPOINTER* messages.

A recent change caused the caption buttons to stop responding to touch.
When I investigated, the change caused Windows to send WM_NCPOINTERDOWN
and WM_NCPOINTERUP in that area (which we don't handle), where
previously it was sending WM_POINTERDOWN and WM_POINTERUP.

Since the change in question is fixing a different critical issue, this
patch implements handling for WM_NCPOINTERDOWN, WM_NCPOINTERUP, and
WM_NCPOINTERUPDATE, by delegating to the existing touch event handler.

This patch also modifies the workaround frin crrev.com/c/1260507, since
the type of messages being translated into ui::ET_TOUCH_RELEASED events
is now different.

Bug: 897662
Change-Id: I6fd052211b91a9a78834573deac830883972092b
Reviewed-on: https://chromium-review.googlesource.com/c/1330838Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Bret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608108}
parent 28d90591
......@@ -2950,7 +2950,7 @@ LRESULT HWNDMessageHandler::HandlePointerEventTypeTouch(UINT message,
// Increment |touch_down_contexts_| on a pointer down. This variable
// is used to debounce the WM_MOUSEACTIVATE events.
if (message == WM_POINTERDOWN) {
if (message == WM_POINTERDOWN || message == WM_NCPOINTERDOWN) {
touch_down_contexts_++;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
......@@ -3004,10 +3004,24 @@ LRESULT HWNDMessageHandler::HandlePointerEventTypeTouch(UINT message,
if (event_type == ui::ET_TOUCH_RELEASED)
id_generator_.ReleaseNumber(pointer_id);
// Mark all touch released events handled. These will usually turn into tap
// Mark touch released events handled. These will usually turn into tap
// gestures, and doing this avoids propagating the event to other windows.
const bool always_mark_handled = event_type == ui::ET_TOUCH_RELEASED;
SetMsgHandled(always_mark_handled || event.handled());
if (delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN) {
// WM_NCPOINTERUP must be DefWindowProc'ed in order for the system caption
// buttons to work correctly.
if (message == WM_POINTERUP)
event.SetHandled();
} else {
// Messages on HTCAPTION should be DefWindowProc'ed, as we let Windows
// take care of dragging the window and double-tapping to maximize.
const bool on_titlebar =
SendMessage(hwnd(), WM_NCHITTEST, 0, l_param) == HTCAPTION;
// Unlike above, we must mark both WM_POINTERUP and WM_NCPOINTERUP as
// handled, in order for the custom caption buttons to work correctly.
if (event_type == ui::ET_TOUCH_RELEASED && !on_titlebar)
event.SetHandled();
}
SetMsgHandled(event.handled());
}
return 0;
}
......
......@@ -355,6 +355,9 @@ class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl,
CR_MESSAGE_HANDLER_EX(WM_POINTERUPDATE, OnPointerEvent)
CR_MESSAGE_HANDLER_EX(WM_POINTERENTER, OnPointerEvent)
CR_MESSAGE_HANDLER_EX(WM_POINTERLEAVE, OnPointerEvent)
CR_MESSAGE_HANDLER_EX(WM_NCPOINTERDOWN, OnPointerEvent)
CR_MESSAGE_HANDLER_EX(WM_NCPOINTERUP, OnPointerEvent)
CR_MESSAGE_HANDLER_EX(WM_NCPOINTERUPDATE, OnPointerEvent)
// Key events.
CR_MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyEvent)
......
......@@ -48,7 +48,7 @@ std::unique_ptr<ui::Event> PenEventProcessor::GenerateEvent(
DCHECK(!eraser_pointer_id_ || *eraser_pointer_id_ == mapped_pointer_id);
eraser_pointer_id_ = mapped_pointer_id;
} else if (eraser_pointer_id_ && *eraser_pointer_id_ == mapped_pointer_id &&
message == WM_POINTERUP) {
(message == WM_POINTERUP || message == WM_NCPOINTERUP)) {
input_type = ui::EventPointerType::POINTER_TYPE_ERASER;
eraser_pointer_id_.reset();
}
......@@ -113,6 +113,7 @@ std::unique_ptr<ui::Event> PenEventProcessor::GenerateMouseEvent(
int click_count = 0;
switch (message) {
case WM_POINTERDOWN:
case WM_NCPOINTERDOWN:
event_type = ui::ET_MOUSE_PRESSED;
if (pointer_info.ButtonChangeType == POINTER_CHANGE_FIRSTBUTTON_DOWN)
changed_flag = ui::EF_LEFT_MOUSE_BUTTON;
......@@ -122,6 +123,7 @@ std::unique_ptr<ui::Event> PenEventProcessor::GenerateMouseEvent(
sent_mouse_down_ = true;
break;
case WM_POINTERUP:
case WM_NCPOINTERUP:
event_type = ui::ET_MOUSE_RELEASED;
if (pointer_info.ButtonChangeType == POINTER_CHANGE_FIRSTBUTTON_UP) {
flag |= ui::EF_LEFT_MOUSE_BUTTON;
......@@ -137,6 +139,7 @@ std::unique_ptr<ui::Event> PenEventProcessor::GenerateMouseEvent(
sent_mouse_down_ = false;
break;
case WM_POINTERUPDATE:
case WM_NCPOINTERUPDATE:
event_type = ui::ET_MOUSE_DRAGGED;
if (flag == ui::EF_NONE)
event_type = ui::ET_MOUSE_MOVED;
......@@ -169,10 +172,12 @@ std::unique_ptr<ui::Event> PenEventProcessor::GenerateTouchEvent(
ui::EventType event_type = ui::ET_TOUCH_MOVED;
switch (message) {
case WM_POINTERDOWN:
case WM_NCPOINTERDOWN:
event_type = ui::ET_TOUCH_PRESSED;
sent_touch_start_ = true;
break;
case WM_POINTERUP:
case WM_NCPOINTERUP:
event_type = ui::ET_TOUCH_RELEASED;
id_generator_->ReleaseNumber(pointer_id);
if (!sent_touch_start_)
......@@ -180,6 +185,7 @@ std::unique_ptr<ui::Event> PenEventProcessor::GenerateTouchEvent(
sent_touch_start_ = false;
break;
case WM_POINTERUPDATE:
case WM_NCPOINTERUPDATE:
event_type = ui::ET_TOUCH_MOVED;
break;
default:
......
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