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/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
9 #include "ash/common/wm/wm_event.h" | 9 #include "ash/common/wm/wm_event.h" |
10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
11 #include "ash/common/wm_window.h" | 11 #include "ash/common/wm_window.h" |
12 #include "ash/touch/touch_uma.h" | 12 #include "ash/touch/touch_uma.h" |
13 #include "ash/wm/window_state_aura.h" | 13 #include "ash/wm/window_state_aura.h" |
14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
15 #include "ui/aura/window_delegate.h" | 15 #include "ui/aura/window_delegate.h" |
16 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
17 | 17 |
18 namespace ash { | 18 namespace ash { |
19 | 19 |
20 WorkspaceEventHandler::WorkspaceEventHandler() | 20 WorkspaceEventHandler::WorkspaceEventHandler() : click_component_(HTNOWHERE) {} |
21 : click_component_(HTNOWHERE) { | |
22 } | |
23 | 21 |
24 WorkspaceEventHandler::~WorkspaceEventHandler() { | 22 WorkspaceEventHandler::~WorkspaceEventHandler() {} |
25 } | |
26 | 23 |
27 void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { | 24 void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { |
28 aura::Window* target = static_cast<aura::Window*>(event->target()); | 25 aura::Window* target = static_cast<aura::Window*>(event->target()); |
29 if (event->type() == ui::ET_MOUSE_PRESSED && | 26 if (event->type() == ui::ET_MOUSE_PRESSED && event->IsOnlyLeftMouseButton() && |
30 event->IsOnlyLeftMouseButton() && | 27 ((event->flags() & (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == |
31 ((event->flags() & | 28 0)) { |
32 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0)) { | 29 click_component_ = |
33 click_component_ = target->delegate()-> | 30 target->delegate()->GetNonClientComponent(event->location()); |
34 GetNonClientComponent(event->location()); | |
35 } | 31 } |
36 | 32 |
37 if (event->handled()) | 33 if (event->handled()) |
38 return; | 34 return; |
39 | 35 |
40 switch (event->type()) { | 36 switch (event->type()) { |
41 case ui::ET_MOUSE_MOVED: { | 37 case ui::ET_MOUSE_MOVED: { |
42 int component = | 38 int component = |
43 target->delegate()->GetNonClientComponent(event->location()); | 39 target->delegate()->GetNonClientComponent(event->location()); |
44 multi_window_resize_controller_.Show(WmWindowAura::Get(target), component, | 40 multi_window_resize_controller_.Show(WmWindowAura::Get(target), component, |
45 event->location()); | 41 event->location()); |
46 break; | 42 break; |
47 } | 43 } |
48 case ui::ET_MOUSE_ENTERED: | 44 case ui::ET_MOUSE_ENTERED: |
49 break; | 45 break; |
50 case ui::ET_MOUSE_CAPTURE_CHANGED: | 46 case ui::ET_MOUSE_CAPTURE_CHANGED: |
51 case ui::ET_MOUSE_EXITED: | 47 case ui::ET_MOUSE_EXITED: |
52 break; | 48 break; |
53 case ui::ET_MOUSE_PRESSED: { | 49 case ui::ET_MOUSE_PRESSED: { |
54 wm::WindowState* target_state = wm::GetWindowState(target); | 50 wm::WindowState* target_state = wm::GetWindowState(target); |
55 | 51 |
56 if (event->IsOnlyLeftMouseButton()) { | 52 if (event->IsOnlyLeftMouseButton()) { |
57 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { | 53 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { |
58 int component = target->delegate()-> | 54 int component = |
59 GetNonClientComponent(event->location()); | 55 target->delegate()->GetNonClientComponent(event->location()); |
60 if (component == HTCAPTION && | 56 if (component == HTCAPTION && component == click_component_) { |
61 component == click_component_) { | |
62 WmShell::Get()->RecordUserMetricsAction( | 57 WmShell::Get()->RecordUserMetricsAction( |
63 UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK); | 58 UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK); |
64 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); | 59 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); |
65 target_state->OnWMEvent(&wm_event); | 60 target_state->OnWMEvent(&wm_event); |
66 event->StopPropagation(); | 61 event->StopPropagation(); |
67 } | 62 } |
68 click_component_ = HTNOWHERE; | 63 click_component_ = HTNOWHERE; |
69 } | 64 } |
70 } else { | 65 } else { |
71 click_component_ = HTNOWHERE; | 66 click_component_ = HTNOWHERE; |
72 } | 67 } |
73 | 68 |
74 HandleVerticalResizeDoubleClick(target_state, event); | 69 HandleVerticalResizeDoubleClick(target_state, event); |
75 break; | 70 break; |
76 } | 71 } |
77 default: | 72 default: |
78 break; | 73 break; |
79 } | 74 } |
80 } | 75 } |
81 | 76 |
82 void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { | 77 void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { |
83 if (event->handled() || event->type() != ui::ET_GESTURE_TAP) | 78 if (event->handled() || event->type() != ui::ET_GESTURE_TAP) |
84 return; | 79 return; |
85 | 80 |
86 aura::Window* target = static_cast<aura::Window*>(event->target()); | 81 aura::Window* target = static_cast<aura::Window*>(event->target()); |
87 int previous_target_component = click_component_; | 82 int previous_target_component = click_component_; |
88 click_component_ = target->delegate()-> | 83 click_component_ = |
89 GetNonClientComponent(event->location()); | 84 target->delegate()->GetNonClientComponent(event->location()); |
90 | 85 |
91 if (click_component_ != HTCAPTION) | 86 if (click_component_ != HTCAPTION) |
92 return; | 87 return; |
93 | 88 |
94 if (event->details().tap_count() != 2) { | 89 if (event->details().tap_count() != 2) { |
95 TouchUMA::GetInstance()-> | 90 TouchUMA::GetInstance()->RecordGestureAction( |
96 RecordGestureAction(TouchUMA::GESTURE_FRAMEVIEW_TAP); | 91 TouchUMA::GESTURE_FRAMEVIEW_TAP); |
97 return; | 92 return; |
98 } | 93 } |
99 | 94 |
100 if (click_component_ == previous_target_component) { | 95 if (click_component_ == previous_target_component) { |
101 WmShell::Get()->RecordUserMetricsAction( | 96 WmShell::Get()->RecordUserMetricsAction( |
102 UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE); | 97 UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE); |
103 TouchUMA::GetInstance()->RecordGestureAction( | 98 TouchUMA::GetInstance()->RecordGestureAction( |
104 TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP); | 99 TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP); |
105 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); | 100 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION); |
106 wm::GetWindowState(target)->OnWMEvent(&wm_event); | 101 wm::GetWindowState(target)->OnWMEvent(&wm_event); |
(...skipping 18 matching lines...) Expand all Loading... |
125 WmShell::Get()->RecordUserMetricsAction( | 120 WmShell::Get()->RecordUserMetricsAction( |
126 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); | 121 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); |
127 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE); | 122 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE); |
128 target_state->OnWMEvent(&wm_event); | 123 target_state->OnWMEvent(&wm_event); |
129 event->StopPropagation(); | 124 event->StopPropagation(); |
130 } | 125 } |
131 } | 126 } |
132 } | 127 } |
133 | 128 |
134 } // namespace ash | 129 } // namespace ash |
OLD | NEW |