| 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/shell_port.h" | 7 #include "ash/shell_port.h" |
| 8 #include "ash/wm/window_state.h" | 8 #include "ash/wm/window_state.h" |
| 9 #include "ash/wm/window_util.h" |
| 9 #include "ash/wm/wm_event.h" | 10 #include "ash/wm/wm_event.h" |
| 10 #include "ash/wm_window.h" | |
| 11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 12 #include "ui/aura/window_delegate.h" | 12 #include "ui/aura/window_delegate.h" |
| 13 #include "ui/base/hit_test.h" | 13 #include "ui/base/hit_test.h" |
| 14 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
| 15 | 15 |
| 16 namespace ash { | 16 namespace ash { |
| 17 | 17 |
| 18 WorkspaceEventHandler::WorkspaceEventHandler() : click_component_(HTNOWHERE) {} | 18 WorkspaceEventHandler::WorkspaceEventHandler() : click_component_(HTNOWHERE) {} |
| 19 | 19 |
| 20 WorkspaceEventHandler::~WorkspaceEventHandler() {} | 20 WorkspaceEventHandler::~WorkspaceEventHandler() {} |
| 21 | 21 |
| 22 void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event, | 22 void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event, |
| 23 WmWindow* target) { | 23 aura::Window* target) { |
| 24 if (event->type() == ui::ET_MOUSE_PRESSED && event->IsOnlyLeftMouseButton() && | 24 if (event->type() == ui::ET_MOUSE_PRESSED && event->IsOnlyLeftMouseButton() && |
| 25 ((event->flags() & (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == | 25 ((event->flags() & (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == |
| 26 0)) { | 26 0)) { |
| 27 click_component_ = target->GetNonClientComponent(event->location()); | 27 click_component_ = wm::GetNonClientComponent(target, event->location()); |
| 28 } | 28 } |
| 29 | 29 |
| 30 if (event->handled()) | 30 if (event->handled()) |
| 31 return; | 31 return; |
| 32 | 32 |
| 33 switch (event->type()) { | 33 switch (event->type()) { |
| 34 case ui::ET_MOUSE_MOVED: { | 34 case ui::ET_MOUSE_MOVED: { |
| 35 int component = target->GetNonClientComponent(event->location()); | 35 int component = wm::GetNonClientComponent(target, event->location()); |
| 36 multi_window_resize_controller_.Show(target->aura_window(), component, | 36 multi_window_resize_controller_.Show(target, component, |
| 37 event->location()); | 37 event->location()); |
| 38 break; | 38 break; |
| 39 } | 39 } |
| 40 case ui::ET_MOUSE_ENTERED: | 40 case ui::ET_MOUSE_ENTERED: |
| 41 break; | 41 break; |
| 42 case ui::ET_MOUSE_CAPTURE_CHANGED: | 42 case ui::ET_MOUSE_CAPTURE_CHANGED: |
| 43 case ui::ET_MOUSE_EXITED: | 43 case ui::ET_MOUSE_EXITED: |
| 44 break; | 44 break; |
| 45 case ui::ET_MOUSE_PRESSED: { | 45 case ui::ET_MOUSE_PRESSED: { |
| 46 wm::WindowState* target_state = target->GetWindowState(); | 46 wm::WindowState* target_state = wm::GetWindowState(target); |
| 47 | 47 |
| 48 if (event->IsOnlyLeftMouseButton()) { | 48 if (event->IsOnlyLeftMouseButton()) { |
| 49 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { | 49 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { |
| 50 int component = target->GetNonClientComponent(event->location()); | 50 int component = wm::GetNonClientComponent(target, event->location()); |
| 51 if (component == HTCAPTION && component == click_component_) { | 51 if (component == HTCAPTION && component == click_component_) { |
| 52 ShellPort::Get()->RecordUserMetricsAction( | 52 ShellPort::Get()->RecordUserMetricsAction( |
| 53 UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK); | 53 UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK); |
| 54 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); | 54 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); |
| 55 target_state->OnWMEvent(&wm_event); | 55 target_state->OnWMEvent(&wm_event); |
| 56 event->StopPropagation(); | 56 event->StopPropagation(); |
| 57 } | 57 } |
| 58 click_component_ = HTNOWHERE; | 58 click_component_ = HTNOWHERE; |
| 59 } | 59 } |
| 60 } else { | 60 } else { |
| 61 click_component_ = HTNOWHERE; | 61 click_component_ = HTNOWHERE; |
| 62 } | 62 } |
| 63 | 63 |
| 64 HandleVerticalResizeDoubleClick(target_state, event); | 64 HandleVerticalResizeDoubleClick(target_state, event); |
| 65 break; | 65 break; |
| 66 } | 66 } |
| 67 default: | 67 default: |
| 68 break; | 68 break; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event, | 72 void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event, |
| 73 WmWindow* target) { | 73 aura::Window* target) { |
| 74 if (event->handled() || event->type() != ui::ET_GESTURE_TAP) | 74 if (event->handled() || event->type() != ui::ET_GESTURE_TAP) |
| 75 return; | 75 return; |
| 76 | 76 |
| 77 int previous_target_component = click_component_; | 77 int previous_target_component = click_component_; |
| 78 click_component_ = target->GetNonClientComponent(event->location()); | 78 click_component_ = wm::GetNonClientComponent(target, event->location()); |
| 79 | 79 |
| 80 if (click_component_ != HTCAPTION) | 80 if (click_component_ != HTCAPTION) |
| 81 return; | 81 return; |
| 82 | 82 |
| 83 if (event->details().tap_count() != 2) { | 83 if (event->details().tap_count() != 2) { |
| 84 ShellPort::Get()->RecordGestureAction(GESTURE_FRAMEVIEW_TAP); | 84 ShellPort::Get()->RecordGestureAction(GESTURE_FRAMEVIEW_TAP); |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 | 87 |
| 88 if (click_component_ == previous_target_component) { | 88 if (click_component_ == previous_target_component) { |
| 89 ShellPort::Get()->RecordUserMetricsAction( | 89 ShellPort::Get()->RecordUserMetricsAction( |
| 90 UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE); | 90 UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE); |
| 91 ShellPort::Get()->RecordGestureAction(GESTURE_MAXIMIZE_DOUBLETAP); | 91 ShellPort::Get()->RecordGestureAction(GESTURE_MAXIMIZE_DOUBLETAP); |
| 92 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); | 92 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); |
| 93 target->GetWindowState()->OnWMEvent(&wm_event); | 93 wm::GetWindowState(target)->OnWMEvent(&wm_event); |
| 94 event->StopPropagation(); | 94 event->StopPropagation(); |
| 95 } | 95 } |
| 96 click_component_ = HTNOWHERE; | 96 click_component_ = HTNOWHERE; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void WorkspaceEventHandler::HandleVerticalResizeDoubleClick( | 99 void WorkspaceEventHandler::HandleVerticalResizeDoubleClick( |
| 100 wm::WindowState* target_state, | 100 wm::WindowState* target_state, |
| 101 ui::MouseEvent* event) { | 101 ui::MouseEvent* event) { |
| 102 aura::Window* target = target_state->window(); | 102 aura::Window* target = target_state->window(); |
| 103 if ((event->flags() & ui::EF_IS_DOUBLE_CLICK) != 0 && target->delegate()) { | 103 if ((event->flags() & ui::EF_IS_DOUBLE_CLICK) != 0 && target->delegate()) { |
| 104 const int component = | 104 const int component = wm::GetNonClientComponent(target, event->location()); |
| 105 target->delegate()->GetNonClientComponent(event->location()); | |
| 106 if (component == HTBOTTOM || component == HTTOP) { | 105 if (component == HTBOTTOM || component == HTTOP) { |
| 107 ShellPort::Get()->RecordUserMetricsAction( | 106 ShellPort::Get()->RecordUserMetricsAction( |
| 108 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); | 107 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); |
| 109 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE); | 108 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE); |
| 110 target_state->OnWMEvent(&wm_event); | 109 target_state->OnWMEvent(&wm_event); |
| 111 event->StopPropagation(); | 110 event->StopPropagation(); |
| 112 } else if (component == HTLEFT || component == HTRIGHT) { | 111 } else if (component == HTLEFT || component == HTRIGHT) { |
| 113 ShellPort::Get()->RecordUserMetricsAction( | 112 ShellPort::Get()->RecordUserMetricsAction( |
| 114 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); | 113 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); |
| 115 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE); | 114 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE); |
| 116 target_state->OnWMEvent(&wm_event); | 115 target_state->OnWMEvent(&wm_event); |
| 117 event->StopPropagation(); | 116 event->StopPropagation(); |
| 118 } | 117 } |
| 119 } | 118 } |
| 120 } | 119 } |
| 121 | 120 |
| 122 } // namespace ash | 121 } // namespace ash |
| OLD | NEW |