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

Side by Side Diff: ash/wm/drag_window_resizer.cc

Issue 115453004: Moves management of transients out of Window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix MRUWindowTracker and MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest Created 7 years 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 | Annotate | Revision Log
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/drag_window_resizer.h" 5 #include "ash/wm/drag_window_resizer.h"
6 6
7 #include "ash/display/mouse_cursor_event_filter.h" 7 #include "ash/display/mouse_cursor_event_filter.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/system/tray/system_tray.h" 11 #include "ash/system/tray/system_tray.h"
12 #include "ash/system/user/tray_user.h" 12 #include "ash/system/user/tray_user.h"
13 #include "ash/wm/coordinate_conversion.h" 13 #include "ash/wm/coordinate_conversion.h"
14 #include "ash/wm/drag_window_controller.h" 14 #include "ash/wm/drag_window_controller.h"
15 #include "ash/wm/window_state.h" 15 #include "ash/wm/window_state.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "ui/aura/client/aura_constants.h" 17 #include "ui/aura/client/aura_constants.h"
18 #include "ui/aura/env.h" 18 #include "ui/aura/env.h"
19 #include "ui/aura/root_window.h" 19 #include "ui/aura/root_window.h"
20 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
21 #include "ui/aura/window_delegate.h" 21 #include "ui/aura/window_delegate.h"
22 #include "ui/base/hit_test.h" 22 #include "ui/base/hit_test.h"
23 #include "ui/base/ui_base_types.h" 23 #include "ui/base/ui_base_types.h"
24 #include "ui/gfx/screen.h" 24 #include "ui/gfx/screen.h"
25 #include "ui/views/corewm/transient_window_manager.h"
25 26
26 namespace ash { 27 namespace ash {
27 namespace internal { 28 namespace internal {
28 29
29 namespace { 30 namespace {
30 31
31 // The maximum opacity of the drag phantom window. 32 // The maximum opacity of the drag phantom window.
32 const float kMaxOpacity = 0.8f; 33 const float kMaxOpacity = 0.8f;
33 34
34 // The opacity of the window when dragging it over a user item in the tray. 35 // The opacity of the window when dragging it over a user item in the tray.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 drag_window_controller_->SetOpacity(phantom_opacity); 206 drag_window_controller_->SetOpacity(phantom_opacity);
206 GetTarget()->layer()->SetOpacity(window_opacity); 207 GetTarget()->layer()->SetOpacity(window_opacity);
207 } else { 208 } else {
208 drag_window_controller_.reset(); 209 drag_window_controller_.reset();
209 GetTarget()->layer()->SetOpacity(1.0f); 210 GetTarget()->layer()->SetOpacity(1.0f);
210 } 211 }
211 } 212 }
212 213
213 bool DragWindowResizer::ShouldAllowMouseWarp() { 214 bool DragWindowResizer::ShouldAllowMouseWarp() {
214 return (details_.window_component == HTCAPTION) && 215 return (details_.window_component == HTCAPTION) &&
215 !GetTarget()->transient_parent() && 216 !views::corewm::GetTransientParent(GetTarget()) &&
216 (GetTarget()->type() == aura::client::WINDOW_TYPE_NORMAL || 217 (GetTarget()->type() == aura::client::WINDOW_TYPE_NORMAL ||
217 GetTarget()->type() == aura::client::WINDOW_TYPE_PANEL); 218 GetTarget()->type() == aura::client::WINDOW_TYPE_PANEL);
218 } 219 }
219 220
220 TrayUser* DragWindowResizer::GetTrayUserItemAtPoint( 221 TrayUser* DragWindowResizer::GetTrayUserItemAtPoint(
221 const gfx::Point& point_in_screen) { 222 const gfx::Point& point_in_screen) {
222 // Unit tests might not have an ash shell. 223 // Unit tests might not have an ash shell.
223 if (!ash::Shell::GetInstance()) 224 if (!ash::Shell::GetInstance())
224 return NULL; 225 return NULL;
225 226
226 // Check that this is a drag move operation from a suitable window. 227 // Check that this is a drag move operation from a suitable window.
227 if (details_.window_component != HTCAPTION || 228 if (details_.window_component != HTCAPTION ||
228 GetTarget()->transient_parent() || 229 views::corewm::GetTransientParent(GetTarget()) ||
229 (GetTarget()->type() != aura::client::WINDOW_TYPE_NORMAL && 230 (GetTarget()->type() != aura::client::WINDOW_TYPE_NORMAL &&
230 GetTarget()->type() != aura::client::WINDOW_TYPE_PANEL && 231 GetTarget()->type() != aura::client::WINDOW_TYPE_PANEL &&
231 GetTarget()->type() != aura::client::WINDOW_TYPE_POPUP)) 232 GetTarget()->type() != aura::client::WINDOW_TYPE_POPUP))
232 return NULL; 233 return NULL;
233 234
234 // We only allow to drag the window onto a tray of it's own RootWindow. 235 // We only allow to drag the window onto a tray of it's own RootWindow.
235 SystemTray* tray = internal::GetRootWindowController( 236 SystemTray* tray = internal::GetRootWindowController(
236 details_.window->GetRootWindow())->GetSystemTray(); 237 details_.window->GetRootWindow())->GetSystemTray();
237 238
238 // Again - unit tests might not have a tray. 239 // Again - unit tests might not have a tray.
(...skipping 29 matching lines...) Expand all
268 if (!tray_user->TransferWindowToUser(details_.window)) { 269 if (!tray_user->TransferWindowToUser(details_.window)) {
269 GetTarget()->layer()->SetOpacity(old_opacity); 270 GetTarget()->layer()->SetOpacity(old_opacity);
270 return false; 271 return false;
271 } 272 }
272 RevertDrag(); 273 RevertDrag();
273 return true; 274 return true;
274 } 275 }
275 276
276 } // namespace internal 277 } // namespace internal
277 } // namespace ash 278 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698