| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/workspace/workspace_event_handler.h" | 5 #include "ash/wm/workspace/workspace_event_handler.h" |
| 6 | 6 |
| 7 #include "ash/metrics/user_metrics_recorder.h" | 7 #include "ash/metrics/user_metrics_recorder.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/touch/touch_uma.h" | 9 #include "ash/touch/touch_uma.h" |
| 10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 WorkspaceEventHandler::~WorkspaceEventHandler() { | 22 WorkspaceEventHandler::~WorkspaceEventHandler() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { | 25 void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { |
| 26 aura::Window* target = static_cast<aura::Window*>(event->target()); | 26 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 27 if (event->type() == ui::ET_MOUSE_PRESSED && | 27 if (event->type() == ui::ET_MOUSE_PRESSED && |
| 28 event->IsOnlyLeftMouseButton() && | 28 event->IsOnlyLeftMouseButton() && |
| 29 ((event->flags() & | 29 ((event->flags() & |
| 30 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0)) { | 30 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0)) { |
| 31 click_component_ = target->delegate()-> | 31 click_component_ = target->delegate()->GetNonClientComponent( |
| 32 GetNonClientComponent(event->location()); | 32 gfx::ToFlooredPoint(event->location())); |
| 33 } | 33 } |
| 34 | 34 |
| 35 if (event->handled()) | 35 if (event->handled()) |
| 36 return; | 36 return; |
| 37 | 37 |
| 38 switch (event->type()) { | 38 switch (event->type()) { |
| 39 case ui::ET_MOUSE_MOVED: { | 39 case ui::ET_MOUSE_MOVED: { |
| 40 int component = | 40 int component = target->delegate()->GetNonClientComponent( |
| 41 target->delegate()->GetNonClientComponent(event->location()); | 41 gfx::ToFlooredPoint(event->location())); |
| 42 multi_window_resize_controller_.Show(target, component, | 42 multi_window_resize_controller_.Show( |
| 43 event->location()); | 43 target, component, gfx::ToFlooredPoint(event->location())); |
| 44 break; | 44 break; |
| 45 } | 45 } |
| 46 case ui::ET_MOUSE_ENTERED: | 46 case ui::ET_MOUSE_ENTERED: |
| 47 break; | 47 break; |
| 48 case ui::ET_MOUSE_CAPTURE_CHANGED: | 48 case ui::ET_MOUSE_CAPTURE_CHANGED: |
| 49 case ui::ET_MOUSE_EXITED: | 49 case ui::ET_MOUSE_EXITED: |
| 50 break; | 50 break; |
| 51 case ui::ET_MOUSE_PRESSED: { | 51 case ui::ET_MOUSE_PRESSED: { |
| 52 wm::WindowState* target_state = wm::GetWindowState(target); | 52 wm::WindowState* target_state = wm::GetWindowState(target); |
| 53 | 53 |
| 54 if (event->IsOnlyLeftMouseButton()) { | 54 if (event->IsOnlyLeftMouseButton()) { |
| 55 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { | 55 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { |
| 56 int component = target->delegate()-> | 56 int component = target->delegate()->GetNonClientComponent( |
| 57 GetNonClientComponent(event->location()); | 57 gfx::ToFlooredPoint(event->location())); |
| 58 if (component == HTCAPTION && | 58 if (component == HTCAPTION && |
| 59 component == click_component_) { | 59 component == click_component_) { |
| 60 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 60 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 61 ash::UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK); | 61 ash::UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK); |
| 62 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); | 62 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); |
| 63 target_state->OnWMEvent(&wm_event); | 63 target_state->OnWMEvent(&wm_event); |
| 64 event->StopPropagation(); | 64 event->StopPropagation(); |
| 65 } | 65 } |
| 66 // WindowEventHandler can receive each event up to two times. Once a | 66 // WindowEventHandler can receive each event up to two times. Once a |
| 67 // double-click has been received clear the target. Otherwise a | 67 // double-click has been received clear the target. Otherwise a |
| (...skipping 13 matching lines...) Expand all Loading... |
| 81 break; | 81 break; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { | 85 void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { |
| 86 if (event->handled() || event->type() != ui::ET_GESTURE_TAP) | 86 if (event->handled() || event->type() != ui::ET_GESTURE_TAP) |
| 87 return; | 87 return; |
| 88 | 88 |
| 89 aura::Window* target = static_cast<aura::Window*>(event->target()); | 89 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 90 int previous_target_component = click_component_; | 90 int previous_target_component = click_component_; |
| 91 click_component_ = target->delegate()-> | 91 click_component_ = target->delegate()->GetNonClientComponent( |
| 92 GetNonClientComponent(event->location()); | 92 gfx::ToFlooredPoint(event->location())); |
| 93 | 93 |
| 94 if (click_component_ != HTCAPTION) | 94 if (click_component_ != HTCAPTION) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 if (event->details().tap_count() != 2) { | 97 if (event->details().tap_count() != 2) { |
| 98 // Note: TouchUMA::GESTURE_FRAMEVIEW_TAP is counted twice for each tap. | 98 // Note: TouchUMA::GESTURE_FRAMEVIEW_TAP is counted twice for each tap. |
| 99 TouchUMA::GetInstance()-> | 99 TouchUMA::GetInstance()-> |
| 100 RecordGestureAction(TouchUMA::GESTURE_FRAMEVIEW_TAP); | 100 RecordGestureAction(TouchUMA::GESTURE_FRAMEVIEW_TAP); |
| 101 return; | 101 return; |
| 102 } | 102 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 113 event->StopPropagation(); | 113 event->StopPropagation(); |
| 114 } | 114 } |
| 115 click_component_ = HTNOWHERE; | 115 click_component_ = HTNOWHERE; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void WorkspaceEventHandler::HandleVerticalResizeDoubleClick( | 118 void WorkspaceEventHandler::HandleVerticalResizeDoubleClick( |
| 119 wm::WindowState* target_state, | 119 wm::WindowState* target_state, |
| 120 ui::MouseEvent* event) { | 120 ui::MouseEvent* event) { |
| 121 aura::Window* target = target_state->window(); | 121 aura::Window* target = target_state->window(); |
| 122 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { | 122 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { |
| 123 int component = | 123 int component = target->delegate()->GetNonClientComponent( |
| 124 target->delegate()->GetNonClientComponent(event->location()); | 124 gfx::ToFlooredPoint(event->location())); |
| 125 if (component == HTBOTTOM || component == HTTOP) { | 125 if (component == HTBOTTOM || component == HTTOP) { |
| 126 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 126 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 127 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); | 127 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); |
| 128 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE); | 128 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE); |
| 129 target_state->OnWMEvent(&wm_event); | 129 target_state->OnWMEvent(&wm_event); |
| 130 event->StopPropagation(); | 130 event->StopPropagation(); |
| 131 } else if (component == HTLEFT || component == HTRIGHT) { | 131 } else if (component == HTLEFT || component == HTRIGHT) { |
| 132 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 132 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 133 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); | 133 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); |
| 134 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE); | 134 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE); |
| 135 target_state->OnWMEvent(&wm_event); | 135 target_state->OnWMEvent(&wm_event); |
| 136 event->StopPropagation(); | 136 event->StopPropagation(); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace ash | 141 } // namespace ash |
| OLD | NEW |