OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ash_touch_exploration_manager_chromeos.h" | 5 #include "ash/ash_touch_exploration_manager_chromeos.h" |
6 | 6 |
7 #include "ash/common/accessibility_delegate.h" | 7 #include "ash/common/accessibility_delegate.h" |
8 #include "ash/common/system/tray/system_tray_notifier.h" | 8 #include "ash/common/system/tray/system_tray_notifier.h" |
9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 10 #include "ash/display/display_manager.h" |
10 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 12 #include "ash/root_window_settings.h" |
11 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/wm/window_state_aura.h" |
12 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
13 #include "base/command_line.h" | 16 #include "base/command_line.h" |
14 #include "chromeos/audio/chromeos_sounds.h" | 17 #include "chromeos/audio/chromeos_sounds.h" |
15 #include "chromeos/audio/cras_audio_handler.h" | 18 #include "chromeos/audio/cras_audio_handler.h" |
16 #include "chromeos/chromeos_switches.h" | 19 #include "chromeos/chromeos_switches.h" |
17 #include "ui/chromeos/touch_exploration_controller.h" | 20 #include "ui/chromeos/touch_exploration_controller.h" |
18 #include "ui/wm/public/activation_client.h" | 21 #include "ui/wm/public/activation_client.h" |
19 | 22 |
20 namespace ash { | 23 namespace ash { |
21 | 24 |
22 AshTouchExplorationManager::AshTouchExplorationManager( | 25 AshTouchExplorationManager::AshTouchExplorationManager( |
23 RootWindowController* root_window_controller) | 26 RootWindowController* root_window_controller) |
24 : root_window_controller_(root_window_controller), | 27 : root_window_controller_(root_window_controller), |
25 audio_handler_(chromeos::CrasAudioHandler::Get()) { | 28 audio_handler_(chromeos::CrasAudioHandler::Get()) { |
26 WmShell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); | 29 WmShell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); |
27 Shell::GetInstance()->activation_client()->AddObserver(this); | 30 Shell::GetInstance()->activation_client()->AddObserver(this); |
| 31 WmShell::Get()->AddDisplayObserver(this); |
28 UpdateTouchExplorationState(); | 32 UpdateTouchExplorationState(); |
29 } | 33 } |
30 | 34 |
31 AshTouchExplorationManager::~AshTouchExplorationManager() { | 35 AshTouchExplorationManager::~AshTouchExplorationManager() { |
32 SystemTrayNotifier* system_tray_notifier = | 36 SystemTrayNotifier* system_tray_notifier = |
33 WmShell::Get()->system_tray_notifier(); | 37 WmShell::Get()->system_tray_notifier(); |
34 if (system_tray_notifier) | 38 if (system_tray_notifier) |
35 system_tray_notifier->RemoveAccessibilityObserver(this); | 39 system_tray_notifier->RemoveAccessibilityObserver(this); |
36 Shell::GetInstance()->activation_client()->RemoveObserver(this); | 40 Shell::GetInstance()->activation_client()->RemoveObserver(this); |
| 41 WmShell::Get()->RemoveDisplayObserver(this); |
37 } | 42 } |
38 | 43 |
39 void AshTouchExplorationManager::OnAccessibilityModeChanged( | 44 void AshTouchExplorationManager::OnAccessibilityModeChanged( |
40 AccessibilityNotificationVisibility notify) { | 45 AccessibilityNotificationVisibility notify) { |
41 UpdateTouchExplorationState(); | 46 UpdateTouchExplorationState(); |
42 } | 47 } |
43 | 48 |
44 void AshTouchExplorationManager::SetOutputLevel(int volume) { | 49 void AshTouchExplorationManager::SetOutputLevel(int volume) { |
45 if (volume > 0) { | 50 if (volume > 0) { |
46 if (audio_handler_->IsOutputMuted()) { | 51 if (audio_handler_->IsOutputMuted()) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void AshTouchExplorationManager::PlayEnterScreenEarcon() { | 86 void AshTouchExplorationManager::PlayEnterScreenEarcon() { |
82 WmShell::Get()->accessibility_delegate()->PlayEarcon( | 87 WmShell::Get()->accessibility_delegate()->PlayEarcon( |
83 chromeos::SOUND_ENTER_SCREEN); | 88 chromeos::SOUND_ENTER_SCREEN); |
84 } | 89 } |
85 | 90 |
86 void AshTouchExplorationManager::HandleAccessibilityGesture( | 91 void AshTouchExplorationManager::HandleAccessibilityGesture( |
87 ui::AXGesture gesture) { | 92 ui::AXGesture gesture) { |
88 WmShell::Get()->accessibility_delegate()->HandleAccessibilityGesture(gesture); | 93 WmShell::Get()->accessibility_delegate()->HandleAccessibilityGesture(gesture); |
89 } | 94 } |
90 | 95 |
| 96 void AshTouchExplorationManager::OnDisplayConfigurationChanged() { |
| 97 UpdateTouchExplorationState(); |
| 98 } |
| 99 |
91 void AshTouchExplorationManager::OnWindowActivated( | 100 void AshTouchExplorationManager::OnWindowActivated( |
92 aura::client::ActivationChangeObserver::ActivationReason reason, | 101 aura::client::ActivationChangeObserver::ActivationReason reason, |
93 aura::Window* gained_active, | 102 aura::Window* gained_active, |
94 aura::Window* lost_active) { | 103 aura::Window* lost_active) { |
95 UpdateTouchExplorationState(); | 104 UpdateTouchExplorationState(); |
96 } | 105 } |
97 | 106 |
98 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint( | 107 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint( |
99 const gfx::Point& anchor_point) { | 108 const gfx::Point& anchor_point) { |
100 if (touch_exploration_controller_) { | 109 if (touch_exploration_controller_) { |
101 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint( | 110 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint( |
102 anchor_point); | 111 anchor_point); |
103 } | 112 } |
104 } | 113 } |
105 | 114 |
106 void AshTouchExplorationManager::UpdateTouchExplorationState() { | 115 void AshTouchExplorationManager::UpdateTouchExplorationState() { |
107 // Comes from components/exo/shell_surface.cc. | 116 // Comes from components/exo/shell_surface.cc. |
108 const char kExoShellSurfaceWindowName[] = "ExoShellSurface"; | 117 const char kExoShellSurfaceWindowName[] = "ExoShellSurface"; |
109 | 118 |
110 // See crbug.com/603745 for more details. | 119 // See crbug.com/603745 for more details. |
111 const bool pass_through_surface = | 120 const bool pass_through_surface = |
112 wm::GetActiveWindow() && | 121 wm::GetActiveWindow() && |
113 wm::GetActiveWindow()->name() == kExoShellSurfaceWindowName; | 122 wm::GetActiveWindow()->name() == kExoShellSurfaceWindowName; |
114 | 123 |
115 const bool spoken_feedback_enabled = | 124 const bool spoken_feedback_enabled = |
116 WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); | 125 WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); |
117 | 126 |
118 if (!pass_through_surface && spoken_feedback_enabled && | 127 if (spoken_feedback_enabled) { |
119 !touch_exploration_controller_.get()) { | 128 if (!touch_exploration_controller_.get()) { |
120 touch_exploration_controller_.reset(new ui::TouchExplorationController( | 129 touch_exploration_controller_ = |
121 root_window_controller_->GetRootWindow(), this)); | 130 base::MakeUnique<ui::TouchExplorationController>( |
122 } else if (!spoken_feedback_enabled || pass_through_surface) { | 131 root_window_controller_->GetRootWindow(), this); |
| 132 } |
| 133 if (pass_through_surface) { |
| 134 aura::Window* root_window = root_window_controller_->GetRootWindow(); |
| 135 int64_t display_id = ash::GetRootWindowSettings(root_window)->display_id; |
| 136 const gfx::Rect& work_area = ash::Shell::GetInstance() |
| 137 ->display_manager() |
| 138 ->GetDisplayForId(display_id) |
| 139 .work_area(); |
| 140 touch_exploration_controller_->SetExcludeBounds(work_area); |
| 141 } else { |
| 142 touch_exploration_controller_->SetExcludeBounds(gfx::Rect()); |
| 143 } |
| 144 } else { |
123 touch_exploration_controller_.reset(); | 145 touch_exploration_controller_.reset(); |
124 } | 146 } |
125 } | 147 } |
126 | 148 |
127 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { | 149 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { |
128 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 150 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
129 chromeos::switches::kDisableVolumeAdjustSound); | 151 chromeos::switches::kDisableVolumeAdjustSound); |
130 } | 152 } |
131 | 153 |
132 } // namespace ash | 154 } // namespace ash |
OLD | NEW |