Chromium Code Reviews| Index: ash/wm/workspace/workspace_event_handler.cc |
| diff --git a/ash/wm/workspace/workspace_event_handler.cc b/ash/wm/workspace/workspace_event_handler.cc |
| index 65a8841b46b68701908da3ddcb3dda49446dbb58..501f409645794d2ddcbd35590855333d23916e8c 100644 |
| --- a/ash/wm/workspace/workspace_event_handler.cc |
| +++ b/ash/wm/workspace/workspace_event_handler.cc |
| @@ -16,7 +16,8 @@ |
| namespace ash { |
| namespace internal { |
| -WorkspaceEventHandler::WorkspaceEventHandler() { |
| +WorkspaceEventHandler::WorkspaceEventHandler() |
| + : double_click_component_(HTNOWHERE) { |
| } |
| WorkspaceEventHandler::~WorkspaceEventHandler() { |
| @@ -25,6 +26,7 @@ WorkspaceEventHandler::~WorkspaceEventHandler() { |
| void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { |
| if (event->handled()) |
| return; |
| + |
| aura::Window* target = static_cast<aura::Window*>(event->target()); |
| switch (event->type()) { |
| case ui::ET_MOUSE_MOVED: { |
| @@ -39,18 +41,43 @@ void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { |
| case ui::ET_MOUSE_CAPTURE_CHANGED: |
| case ui::ET_MOUSE_EXITED: |
| break; |
| + case ui::ET_MOUSE_RELEASED: |
| + // WindowEventHandler is not guaranteed to get paired ET_MOUSE_PRESSED |
| + // and ET_MOUSE_RELEASED events. |
| + if (event->IsOnlyLeftMouseButton()) { |
| + double_click_component_ = target->delegate()-> |
| + GetNonClientComponent(event->location()); |
| + } else { |
| + double_click_component_ = HTNOWHERE; |
| + } |
| + break; |
| case ui::ET_MOUSE_PRESSED: { |
| wm::WindowState* target_state = wm::GetWindowState(target); |
| - if (event->flags() & ui::EF_IS_DOUBLE_CLICK && |
| - event->IsOnlyLeftMouseButton() && |
| - target->delegate()->GetNonClientComponent(event->location()) == |
| - HTCAPTION) { |
| - ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| - ash::UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK); |
| - const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); |
| - target_state->OnWMEvent(&wm_event); |
| - event->StopPropagation(); |
| + int component = target->delegate()-> |
| + GetNonClientComponent(event->location()); |
| + |
| + if (event->IsOnlyLeftMouseButton()) { |
| + int previous_target_component = double_click_component_; |
| + double_click_component_ = component; |
|
flackr
2014/04/08 14:08:00
why not only change the double click component if
jonross
2014/04/08 15:34:36
A nice cleanup vs caching the last one. Will make
|
| + if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { |
| + if (double_click_component_ == HTCAPTION && |
| + double_click_component_ == previous_target_component) { |
|
flackr
2014/04/08 14:08:00
i.e. compare component to double click component h
jonross
2014/04/08 15:34:36
Done.
|
| + ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| + ash::UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK); |
| + const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); |
| + target_state->OnWMEvent(&wm_event); |
| + event->StopPropagation(); |
| + } |
| + // WindowEventHandler can receive each event up to two times. Once a |
| + // double-click has been received clear the target. Otherwise a |
| + // duplicate of the event will be checking target history against |
| + // itself. |
| + double_click_component_ = HTNOWHERE; |
| + } |
| + } else { |
| + double_click_component_ = HTNOWHERE; |
| } |
| + |
| multi_window_resize_controller_.Hide(); |
| HandleVerticalResizeDoubleClick(target_state, event); |
| break; |
| @@ -61,13 +88,19 @@ void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { |
| } |
| void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { |
| - if (event->handled()) |
| + if (event->handled() || event->type() != ui::ET_GESTURE_TAP) |
| return; |
| + |
| aura::Window* target = static_cast<aura::Window*>(event->target()); |
| - if (event->type() == ui::ET_GESTURE_TAP && |
| - target->delegate()->GetNonClientComponent(event->location()) == |
| - HTCAPTION) { |
| - if (event->details().tap_count() == 2) { |
| + int previous_target_component = double_click_component_; |
| + double_click_component_ = target->delegate()-> |
| + GetNonClientComponent(event->location()); |
| + |
| + if (double_click_component_ != HTCAPTION) |
| + return; |
| + |
| + if (event->details().tap_count() == 2) { |
| + if (double_click_component_ == previous_target_component) { |
| ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| ash::UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE); |
| // Note: TouchUMA::GESTURE_FRAMEVIEW_TAP is counted twice each time |
| @@ -77,13 +110,12 @@ void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { |
| const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); |
| wm::GetWindowState(target)->OnWMEvent(&wm_event); |
| event->StopPropagation(); |
| - return; |
| - } else { |
| - // Note: TouchUMA::GESTURE_FRAMEVIEW_TAP is counted twice for each tap. |
| - TouchUMA::GetInstance()->RecordGestureAction( |
| - TouchUMA::GESTURE_FRAMEVIEW_TAP); |
| } |
| + double_click_component_ = HTNOWHERE; |
| + return; |
| } |
| + // Note: TouchUMA::GESTURE_FRAMEVIEW_TAP is counted twice for each tap. |
| + TouchUMA::GetInstance()->RecordGestureAction(TouchUMA::GESTURE_FRAMEVIEW_TAP); |
| } |
| void WorkspaceEventHandler::HandleVerticalResizeDoubleClick( |