Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: ash/wm/workspace/workspace_event_handler.cc

Issue 239213003: Revert of Prevents double-clicks on a tab close button from aslo maximizing the browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "ash/wm/wm_event.h" 11 #include "ash/wm/wm_event.h"
12 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/aura/window_delegate.h" 13 #include "ui/aura/window_delegate.h"
14 #include "ui/base/hit_test.h" 14 #include "ui/base/hit_test.h"
15 15
16 namespace ash { 16 namespace ash {
17 17
18 WorkspaceEventHandler::WorkspaceEventHandler() 18 WorkspaceEventHandler::WorkspaceEventHandler() {
19 : click_component_(HTNOWHERE) {
20 } 19 }
21 20
22 WorkspaceEventHandler::~WorkspaceEventHandler() { 21 WorkspaceEventHandler::~WorkspaceEventHandler() {
23 } 22 }
24 23
25 void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { 24 void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) {
26 aura::Window* target = static_cast<aura::Window*>(event->target());
27 if (event->type() == ui::ET_MOUSE_PRESSED &&
28 event->IsOnlyLeftMouseButton() &&
29 ((event->flags() &
30 (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0)) {
31 click_component_ = target->delegate()->
32 GetNonClientComponent(event->location());
33 }
34
35 if (event->handled()) 25 if (event->handled())
36 return; 26 return;
37 27 aura::Window* target = static_cast<aura::Window*>(event->target());
38 switch (event->type()) { 28 switch (event->type()) {
39 case ui::ET_MOUSE_MOVED: { 29 case ui::ET_MOUSE_MOVED: {
40 int component = 30 int component =
41 target->delegate()->GetNonClientComponent(event->location()); 31 target->delegate()->GetNonClientComponent(event->location());
42 multi_window_resize_controller_.Show(target, component, 32 multi_window_resize_controller_.Show(target, component,
43 event->location()); 33 event->location());
44 break; 34 break;
45 } 35 }
46 case ui::ET_MOUSE_ENTERED: 36 case ui::ET_MOUSE_ENTERED:
47 break; 37 break;
48 case ui::ET_MOUSE_CAPTURE_CHANGED: 38 case ui::ET_MOUSE_CAPTURE_CHANGED:
49 case ui::ET_MOUSE_EXITED: 39 case ui::ET_MOUSE_EXITED:
50 break; 40 break;
51 case ui::ET_MOUSE_PRESSED: { 41 case ui::ET_MOUSE_PRESSED: {
52 wm::WindowState* target_state = wm::GetWindowState(target); 42 wm::WindowState* target_state = wm::GetWindowState(target);
53 43 if (event->flags() & ui::EF_IS_DOUBLE_CLICK &&
54 if (event->IsOnlyLeftMouseButton()) { 44 event->IsOnlyLeftMouseButton() &&
55 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { 45 target->delegate()->GetNonClientComponent(event->location()) ==
56 int component = target->delegate()-> 46 HTCAPTION) {
57 GetNonClientComponent(event->location()); 47 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(
58 if (component == HTCAPTION && 48 ash::UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK);
59 component == click_component_) { 49 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION);
60 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( 50 target_state->OnWMEvent(&wm_event);
61 ash::UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK); 51 event->StopPropagation();
62 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION);
63 target_state->OnWMEvent(&wm_event);
64 event->StopPropagation();
65 }
66 // WindowEventHandler can receive each event up to two times. Once a
67 // double-click has been received clear the target. Otherwise a
68 // duplicate of the event will be checking target history against
69 // itself.
70 click_component_ = HTNOWHERE;
71 }
72 } else {
73 click_component_ = HTNOWHERE;
74 } 52 }
75
76 multi_window_resize_controller_.Hide(); 53 multi_window_resize_controller_.Hide();
77 HandleVerticalResizeDoubleClick(target_state, event); 54 HandleVerticalResizeDoubleClick(target_state, event);
78 break; 55 break;
79 } 56 }
80 default: 57 default:
81 break; 58 break;
82 } 59 }
83 } 60 }
84 61
85 void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { 62 void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) {
86 if (event->handled() || event->type() != ui::ET_GESTURE_TAP) 63 if (event->handled())
87 return; 64 return;
88
89 aura::Window* target = static_cast<aura::Window*>(event->target()); 65 aura::Window* target = static_cast<aura::Window*>(event->target());
90 int previous_target_component = click_component_; 66 if (event->type() == ui::ET_GESTURE_TAP &&
91 click_component_ = target->delegate()-> 67 target->delegate()->GetNonClientComponent(event->location()) ==
92 GetNonClientComponent(event->location()); 68 HTCAPTION) {
93 69 if (event->details().tap_count() == 2) {
94 if (click_component_ != HTCAPTION) 70 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(
95 return; 71 ash::UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE);
96 72 // Note: TouchUMA::GESTURE_FRAMEVIEW_TAP is counted twice each time
97 if (event->details().tap_count() != 2) { 73 // TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP is counted once.
98 // Note: TouchUMA::GESTURE_FRAMEVIEW_TAP is counted twice for each tap. 74 TouchUMA::GetInstance()->RecordGestureAction(
99 TouchUMA::GetInstance()-> 75 TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP);
100 RecordGestureAction(TouchUMA::GESTURE_FRAMEVIEW_TAP); 76 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION);
101 return; 77 wm::GetWindowState(target)->OnWMEvent(&wm_event);
78 event->StopPropagation();
79 return;
80 } else {
81 // Note: TouchUMA::GESTURE_FRAMEVIEW_TAP is counted twice for each tap.
82 TouchUMA::GetInstance()->RecordGestureAction(
83 TouchUMA::GESTURE_FRAMEVIEW_TAP);
84 }
102 } 85 }
103
104 if (click_component_ == previous_target_component) {
105 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(
106 ash::UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE);
107 // Note: TouchUMA::GESTURE_FRAMEVIEW_TAP is counted twice each time
108 // TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP is counted once.
109 TouchUMA::GetInstance()->RecordGestureAction(
110 TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP);
111 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION);
112 wm::GetWindowState(target)->OnWMEvent(&wm_event);
113 event->StopPropagation();
114 }
115 click_component_ = HTNOWHERE;
116 } 86 }
117 87
118 void WorkspaceEventHandler::HandleVerticalResizeDoubleClick( 88 void WorkspaceEventHandler::HandleVerticalResizeDoubleClick(
119 wm::WindowState* target_state, 89 wm::WindowState* target_state,
120 ui::MouseEvent* event) { 90 ui::MouseEvent* event) {
121 aura::Window* target = target_state->window(); 91 aura::Window* target = target_state->window();
122 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { 92 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) {
123 int component = 93 int component =
124 target->delegate()->GetNonClientComponent(event->location()); 94 target->delegate()->GetNonClientComponent(event->location());
125 if (component == HTBOTTOM || component == HTTOP) { 95 if (component == HTBOTTOM || component == HTTOP) {
126 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 96 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
127 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); 97 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK);
128 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE); 98 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE);
129 target_state->OnWMEvent(&wm_event); 99 target_state->OnWMEvent(&wm_event);
130 event->StopPropagation(); 100 event->StopPropagation();
131 } else if (component == HTLEFT || component == HTRIGHT) { 101 } else if (component == HTLEFT || component == HTRIGHT) {
132 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 102 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
133 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK); 103 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK);
134 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE); 104 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE);
135 target_state->OnWMEvent(&wm_event); 105 target_state->OnWMEvent(&wm_event);
136 event->StopPropagation(); 106 event->StopPropagation();
137 } 107 }
138 } 108 }
139 } 109 }
140 110
141 } // namespace ash 111 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_event_handler.h ('k') | ash/wm/workspace/workspace_event_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698