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 "chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h
" | 5 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h
" |
6 | 6 |
| 7 #include "ash/launcher/launcher_util.h" |
7 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 8 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
8 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" | 9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" |
9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" | 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" |
11 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 12 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
12 #include "chrome/browser/ui/extensions/native_app_window.h" | 13 #include "chrome/browser/ui/extensions/native_app_window.h" |
13 #include "chrome/browser/ui/extensions/shell_window.h" | 14 #include "chrome/browser/ui/extensions/shell_window.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 iter != windows_to_close.end(); ++iter) { | 109 iter != windows_to_close.end(); ++iter) { |
109 (*iter)->GetBaseWindow()->Close(); | 110 (*iter)->GetBaseWindow()->Close(); |
110 } | 111 } |
111 } | 112 } |
112 | 113 |
113 // Behavior for app windows: | 114 // Behavior for app windows: |
114 // * One window: Toggle minimization when clicked. | 115 // * One window: Toggle minimization when clicked. |
115 // * Multiple windows: | 116 // * Multiple windows: |
116 // ** If the first window is not active, activate it. | 117 // ** If the first window is not active, activate it. |
117 // ** Otherwise activate the next window. | 118 // ** Otherwise activate the next window. |
118 void ShellWindowLauncherItemController::Clicked() { | 119 void ShellWindowLauncherItemController::Clicked(const ui::Event& event) { |
119 if (shell_windows_.empty()) | 120 if (shell_windows_.empty()) |
120 return; | 121 return; |
121 ShellWindow* first_window = shell_windows_.front(); | 122 ShellWindow* first_window = shell_windows_.front(); |
122 if (shell_windows_.size() == 1) { | 123 if (shell_windows_.size() == 1) { |
| 124 ash::launcher::MoveToEventRootIfPanel(first_window->GetNativeWindow(), |
| 125 event); |
| 126 // If the window moves, it becomes inactive first then |
| 127 // gets activated in |RestoreOrShow| below. |
123 if (first_window->GetBaseWindow()->IsActive()) | 128 if (first_window->GetBaseWindow()->IsActive()) |
124 first_window->GetBaseWindow()->Minimize(); | 129 first_window->GetBaseWindow()->Minimize(); |
125 else | 130 else |
126 RestoreOrShow(first_window); | 131 RestoreOrShow(first_window); |
127 } else { | 132 } else { |
128 if (!first_window->GetBaseWindow()->IsActive()) { | 133 if (!first_window->GetBaseWindow()->IsActive()) { |
129 RestoreOrShow(first_window); | 134 RestoreOrShow(first_window); |
130 } else { | 135 } else { |
131 shell_windows_.pop_front(); | 136 shell_windows_.pop_front(); |
132 shell_windows_.push_back(first_window); | 137 shell_windows_.push_back(first_window); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 190 |
186 void ShellWindowLauncherItemController::RestoreOrShow( | 191 void ShellWindowLauncherItemController::RestoreOrShow( |
187 ShellWindow* shell_window) { | 192 ShellWindow* shell_window) { |
188 if (shell_window->GetBaseWindow()->IsMinimized()) | 193 if (shell_window->GetBaseWindow()->IsMinimized()) |
189 shell_window->GetBaseWindow()->Restore(); | 194 shell_window->GetBaseWindow()->Restore(); |
190 else | 195 else |
191 shell_window->GetBaseWindow()->Show(); | 196 shell_window->GetBaseWindow()->Show(); |
192 // Always activate windows when shown from the launcher. | 197 // Always activate windows when shown from the launcher. |
193 shell_window->GetBaseWindow()->Activate(); | 198 shell_window->GetBaseWindow()->Activate(); |
194 } | 199 } |
OLD | NEW |