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

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

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/common/wm/workspace/workspace_event_handler.h"
6
7 #include "ash/common/wm/window_state.h"
8 #include "ash/common/wm/wm_event.h"
9 #include "ash/common/wm_shell.h"
10 #include "ash/common/wm_window.h"
11 #include "ui/base/hit_test.h"
12 #include "ui/events/event.h"
13
14 namespace ash {
15
16 WorkspaceEventHandler::WorkspaceEventHandler() : click_component_(HTNOWHERE) {}
17
18 WorkspaceEventHandler::~WorkspaceEventHandler() {}
19
20 void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event,
21 WmWindow* target) {
22 if (event->type() == ui::ET_MOUSE_PRESSED && event->IsOnlyLeftMouseButton() &&
23 ((event->flags() & (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) ==
24 0)) {
25 click_component_ = target->GetNonClientComponent(event->location());
26 }
27
28 if (event->handled())
29 return;
30
31 switch (event->type()) {
32 case ui::ET_MOUSE_MOVED: {
33 int component = target->GetNonClientComponent(event->location());
34 multi_window_resize_controller_.Show(target, component,
35 event->location());
36 break;
37 }
38 case ui::ET_MOUSE_ENTERED:
39 break;
40 case ui::ET_MOUSE_CAPTURE_CHANGED:
41 case ui::ET_MOUSE_EXITED:
42 break;
43 case ui::ET_MOUSE_PRESSED: {
44 wm::WindowState* target_state = target->GetWindowState();
45
46 if (event->IsOnlyLeftMouseButton()) {
47 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) {
48 int component = target->GetNonClientComponent(event->location());
49 if (component == HTCAPTION && component == click_component_) {
50 WmShell::Get()->RecordUserMetricsAction(
51 UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK);
52 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION);
53 target_state->OnWMEvent(&wm_event);
54 event->StopPropagation();
55 }
56 click_component_ = HTNOWHERE;
57 }
58 } else {
59 click_component_ = HTNOWHERE;
60 }
61
62 HandleVerticalResizeDoubleClick(target_state, event);
63 break;
64 }
65 default:
66 break;
67 }
68 }
69
70 void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event,
71 WmWindow* target) {
72 if (event->handled() || event->type() != ui::ET_GESTURE_TAP)
73 return;
74
75 int previous_target_component = click_component_;
76 click_component_ = target->GetNonClientComponent(event->location());
77
78 if (click_component_ != HTCAPTION)
79 return;
80
81 if (event->details().tap_count() != 2) {
82 WmShell::Get()->RecordGestureAction(GESTURE_FRAMEVIEW_TAP);
83 return;
84 }
85
86 if (click_component_ == previous_target_component) {
87 WmShell::Get()->RecordUserMetricsAction(
88 UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE);
89 WmShell::Get()->RecordGestureAction(GESTURE_MAXIMIZE_DOUBLETAP);
90 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION);
91 target->GetWindowState()->OnWMEvent(&wm_event);
92 event->StopPropagation();
93 }
94 click_component_ = HTNOWHERE;
95 }
96
97 void WorkspaceEventHandler::HandleVerticalResizeDoubleClick(
98 wm::WindowState* target_state,
99 ui::MouseEvent* event) {
100 WmWindow* target = target_state->window();
101 if (event->flags() & ui::EF_IS_DOUBLE_CLICK) {
102 int component = target->GetNonClientComponent(event->location());
103 if (component == HTBOTTOM || component == HTTOP) {
104 WmShell::Get()->RecordUserMetricsAction(
105 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK);
106 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE);
107 target_state->OnWMEvent(&wm_event);
108 event->StopPropagation();
109 } else if (component == HTLEFT || component == HTRIGHT) {
110 WmShell::Get()->RecordUserMetricsAction(
111 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK);
112 const wm::WMEvent wm_event(wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE);
113 target_state->OnWMEvent(&wm_event);
114 event->StopPropagation();
115 }
116 }
117 }
118
119 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/workspace/workspace_event_handler.h ('k') | ash/common/wm/workspace/workspace_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698