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

Side by Side Diff: ash/autoclick/autoclick_controller.cc

Issue 2316553003: mash: Add autoclick app. (Closed)
Patch Set: MouseEvent; if etc. Created 4 years, 3 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
« no previous file with comments | « no previous file | ash/autoclick/common/autoclick_controller_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/autoclick/autoclick_controller.h" 5 #include "ash/autoclick/autoclick_controller.h"
6 6
7 #include "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/autoclick/common/autoclick_controller_common.h" 8 #include "ash/autoclick/common/autoclick_controller_common.h"
9 #include "ash/autoclick/common/autoclick_controller_common_delegate.h" 9 #include "ash/autoclick/common/autoclick_controller_common_delegate.h"
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 void SetAutoclickDelay(base::TimeDelta delay) override; 46 void SetAutoclickDelay(base::TimeDelta delay) override;
47 47
48 // ui::EventHandler overrides: 48 // ui::EventHandler overrides:
49 void OnMouseEvent(ui::MouseEvent* event) override; 49 void OnMouseEvent(ui::MouseEvent* event) override;
50 void OnKeyEvent(ui::KeyEvent* event) override; 50 void OnKeyEvent(ui::KeyEvent* event) override;
51 void OnTouchEvent(ui::TouchEvent* event) override; 51 void OnTouchEvent(ui::TouchEvent* event) override;
52 void OnGestureEvent(ui::GestureEvent* event) override; 52 void OnGestureEvent(ui::GestureEvent* event) override;
53 void OnScrollEvent(ui::ScrollEvent* event) override; 53 void OnScrollEvent(ui::ScrollEvent* event) override;
54 54
55 // AutoclickControllerCommonDelegate overrides: 55 // AutoclickControllerCommonDelegate overrides:
56 std::unique_ptr<views::Widget> CreateAutoclickRingWidget( 56 views::Widget* CreateAutoclickRingWidget(
57 const gfx::Point& event_location) override; 57 const gfx::Point& event_location) override;
58 void UpdateAutoclickRingWidget(views::Widget* widget, 58 void UpdateAutoclickRingWidget(views::Widget* widget,
59 const gfx::Point& event_location) override; 59 const gfx::Point& event_location) override;
60 void DoAutoclick(const gfx::Point& event_location, 60 void DoAutoclick(const gfx::Point& event_location,
61 const int mouse_event_flags) override; 61 const int mouse_event_flags) override;
62 void OnAutoclickCanceled() override; 62 void OnAutoclickCanceled() override;
63 63
64 // aura::WindowObserver overrides: 64 // aura::WindowObserver overrides:
65 void OnWindowDestroying(aura::Window* window) override; 65 void OnWindowDestroying(aura::Window* window) override;
66 66
67 bool enabled_; 67 bool enabled_;
68 // The target window is observed by AutoclickControllerImpl for the duration 68 // The target window is observed by AutoclickControllerImpl for the duration
69 // of a autoclick gesture. 69 // of a autoclick gesture.
70 aura::Window* tap_down_target_; 70 aura::Window* tap_down_target_;
71 std::unique_ptr<views::Widget> widget_;
71 std::unique_ptr<AutoclickControllerCommon> autoclick_controller_common_; 72 std::unique_ptr<AutoclickControllerCommon> autoclick_controller_common_;
72 73
73 DISALLOW_COPY_AND_ASSIGN(AutoclickControllerImpl); 74 DISALLOW_COPY_AND_ASSIGN(AutoclickControllerImpl);
74 }; 75 };
75 76
76 AutoclickControllerImpl::AutoclickControllerImpl() 77 AutoclickControllerImpl::AutoclickControllerImpl()
77 : enabled_(false), 78 : enabled_(false),
78 tap_down_target_(nullptr), 79 tap_down_target_(nullptr),
79 autoclick_controller_common_( 80 autoclick_controller_common_(
80 new AutoclickControllerCommon(GetDefaultAutoclickDelay(), this)) {} 81 new AutoclickControllerCommon(GetDefaultAutoclickDelay(), this)) {}
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 129 }
129 130
130 void AutoclickControllerImpl::OnGestureEvent(ui::GestureEvent* event) { 131 void AutoclickControllerImpl::OnGestureEvent(ui::GestureEvent* event) {
131 autoclick_controller_common_->CancelAutoclick(); 132 autoclick_controller_common_->CancelAutoclick();
132 } 133 }
133 134
134 void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) { 135 void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) {
135 autoclick_controller_common_->CancelAutoclick(); 136 autoclick_controller_common_->CancelAutoclick();
136 } 137 }
137 138
138 std::unique_ptr<views::Widget> 139 views::Widget* AutoclickControllerImpl::CreateAutoclickRingWidget(
139 AutoclickControllerImpl::CreateAutoclickRingWidget(
140 const gfx::Point& event_location) { 140 const gfx::Point& event_location) {
141 aura::Window* target = 141 aura::Window* target =
142 WmWindowAura::GetAuraWindow(ash::wm::GetRootWindowAt(event_location)); 142 WmWindowAura::GetAuraWindow(ash::wm::GetRootWindowAt(event_location));
143 SetTapDownTarget(target); 143 SetTapDownTarget(target);
144 aura::Window* root_window = target->GetRootWindow(); 144 aura::Window* root_window = target->GetRootWindow();
145 std::unique_ptr<views::Widget> widget(new views::Widget); 145 widget_.reset(new views::Widget);
146 views::Widget::InitParams params; 146 views::Widget::InitParams params;
147 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; 147 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
148 params.accept_events = false; 148 params.accept_events = false;
149 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; 149 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
150 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 150 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
151 params.context = root_window; 151 params.context = root_window;
152 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 152 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
153 params.parent = 153 params.parent =
154 Shell::GetContainer(root_window, kShellWindowId_OverlayContainer); 154 Shell::GetContainer(root_window, kShellWindowId_OverlayContainer);
155 widget->Init(params); 155 widget_->Init(params);
156 widget->SetOpacity(1.f); 156 widget_->SetOpacity(1.f);
157 return widget; 157 return widget_.get();
158 } 158 }
159 159
160 void AutoclickControllerImpl::UpdateAutoclickRingWidget( 160 void AutoclickControllerImpl::UpdateAutoclickRingWidget(
161 views::Widget* widget, 161 views::Widget* widget,
162 const gfx::Point& event_location) { 162 const gfx::Point& event_location) {
163 aura::Window* target = 163 aura::Window* target =
164 WmWindowAura::GetAuraWindow(ash::wm::GetRootWindowAt(event_location)); 164 WmWindowAura::GetAuraWindow(ash::wm::GetRootWindowAt(event_location));
165 SetTapDownTarget(target); 165 SetTapDownTarget(target);
166 aura::Window* root_window = target->GetRootWindow(); 166 aura::Window* root_window = target->GetRootWindow();
167 if (widget->GetNativeView()->GetRootWindow() != root_window) { 167 if (widget->GetNativeView()->GetRootWindow() != root_window) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 DCHECK_EQ(tap_down_target_, window); 207 DCHECK_EQ(tap_down_target_, window);
208 autoclick_controller_common_->CancelAutoclick(); 208 autoclick_controller_common_->CancelAutoclick();
209 } 209 }
210 210
211 // static. 211 // static.
212 AutoclickController* AutoclickController::CreateInstance() { 212 AutoclickController* AutoclickController::CreateInstance() {
213 return new AutoclickControllerImpl(); 213 return new AutoclickControllerImpl();
214 } 214 }
215 215
216 } // namespace ash 216 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/autoclick/common/autoclick_controller_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698