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

Side by Side Diff: ash/wm/workspace/phantom_window_controller.cc

Issue 37733003: Make GetRootWindow() return a Window instead of a RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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/workspace/phantom_window_controller.h" 5 #include "ash/wm/workspace/phantom_window_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/wm/coordinate_conversion.h" 9 #include "ash/wm/coordinate_conversion.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 PhantomWindowController::~PhantomWindowController() { 99 PhantomWindowController::~PhantomWindowController() {
100 Hide(); 100 Hide();
101 } 101 }
102 102
103 void PhantomWindowController::Show(const gfx::Rect& bounds_in_screen) { 103 void PhantomWindowController::Show(const gfx::Rect& bounds_in_screen) {
104 if (bounds_in_screen == bounds_in_screen_) 104 if (bounds_in_screen == bounds_in_screen_)
105 return; 105 return;
106 bounds_in_screen_ = bounds_in_screen; 106 bounds_in_screen_ = bounds_in_screen;
107 aura::RootWindow* target_root = wm::GetRootWindowMatching(bounds_in_screen); 107 aura::Window* target_root = wm::GetRootWindowMatching(bounds_in_screen);
108 // Show the phantom at the current bounds of the window. We'll animate to the 108 // Show the phantom at the current bounds of the window. We'll animate to the
109 // target bounds. If phantom exists, update the start bounds. 109 // target bounds. If phantom exists, update the start bounds.
110 if (!phantom_widget_) 110 if (!phantom_widget_)
111 start_bounds_ = window_->GetBoundsInScreen(); 111 start_bounds_ = window_->GetBoundsInScreen();
112 else 112 else
113 start_bounds_ = phantom_widget_->GetWindowBoundsInScreen(); 113 start_bounds_ = phantom_widget_->GetWindowBoundsInScreen();
114 if (phantom_widget_ && 114 if (phantom_widget_ &&
115 phantom_widget_->GetNativeWindow()->GetRootWindow() != target_root) { 115 phantom_widget_->GetNativeWindow()->GetRootWindow() != target_root) {
116 phantom_widget_->Close(); 116 phantom_widget_->Close();
117 phantom_widget_ = NULL; 117 phantom_widget_ = NULL;
118 } 118 }
119 if (!phantom_widget_) 119 if (!phantom_widget_)
120 phantom_widget_ = CreatePhantomWidget(target_root, start_bounds_); 120 phantom_widget_ = CreatePhantomWidget(target_root, start_bounds_);
121 121
122 // Create a secondary widget in a second screen if start_bounds_ lie at least 122 // Create a secondary widget in a second screen if start_bounds_ lie at least
123 // partially in that other screen. This allows animations to start or restart 123 // partially in that other screen. This allows animations to start or restart
124 // in one root window and progress into another root. 124 // in one root window and progress into another root.
125 aura::RootWindow* start_root = wm::GetRootWindowMatching(start_bounds_); 125 aura::Window* start_root = wm::GetRootWindowMatching(start_bounds_);
126 if (start_root == target_root) { 126 if (start_root == target_root) {
127 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 127 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
128 for (size_t i = 0; i < root_windows.size(); ++i) { 128 for (size_t i = 0; i < root_windows.size(); ++i) {
129 if (root_windows[i] != target_root && 129 if (root_windows[i] != target_root &&
130 root_windows[i]->GetBoundsInScreen().Intersects(start_bounds_)) { 130 root_windows[i]->GetBoundsInScreen().Intersects(start_bounds_)) {
131 start_root = root_windows[i]; 131 start_root = root_windows[i];
132 break; 132 break;
133 } 133 }
134 } 134 }
135 } 135 }
(...skipping 29 matching lines...) Expand all
165 void PhantomWindowController::AnimationProgressed( 165 void PhantomWindowController::AnimationProgressed(
166 const gfx::Animation* animation) { 166 const gfx::Animation* animation) {
167 const gfx::Rect current_bounds = 167 const gfx::Rect current_bounds =
168 animation->CurrentValueBetween(start_bounds_, bounds_in_screen_); 168 animation->CurrentValueBetween(start_bounds_, bounds_in_screen_);
169 if (phantom_widget_start_) 169 if (phantom_widget_start_)
170 phantom_widget_start_->SetBounds(current_bounds); 170 phantom_widget_start_->SetBounds(current_bounds);
171 phantom_widget_->SetBounds(current_bounds); 171 phantom_widget_->SetBounds(current_bounds);
172 } 172 }
173 173
174 views::Widget* PhantomWindowController::CreatePhantomWidget( 174 views::Widget* PhantomWindowController::CreatePhantomWidget(
175 aura::RootWindow* root_window, 175 aura::Window* root_window,
176 const gfx::Rect& bounds_in_screen) { 176 const gfx::Rect& bounds_in_screen) {
177 views::Widget* phantom_widget = new views::Widget; 177 views::Widget* phantom_widget = new views::Widget;
178 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 178 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
179 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 179 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
180 // PhantomWindowController is used by FrameMaximizeButton to highlight the 180 // PhantomWindowController is used by FrameMaximizeButton to highlight the
181 // launcher button. Put the phantom in the same window as the launcher so that 181 // launcher button. Put the phantom in the same window as the launcher so that
182 // the phantom is visible. 182 // the phantom is visible.
183 params.parent = Shell::GetContainer(root_window, 183 params.parent = Shell::GetContainer(root_window,
184 kShellWindowId_ShelfContainer); 184 kShellWindowId_ShelfContainer);
185 params.can_activate = false; 185 params.can_activate = false;
(...skipping 19 matching lines...) Expand all
205 // Fade the window in. 205 // Fade the window in.
206 ui::Layer* widget_layer = phantom_widget->GetNativeWindow()->layer(); 206 ui::Layer* widget_layer = phantom_widget->GetNativeWindow()->layer();
207 widget_layer->SetOpacity(0); 207 widget_layer->SetOpacity(0);
208 ui::ScopedLayerAnimationSettings scoped_setter(widget_layer->GetAnimator()); 208 ui::ScopedLayerAnimationSettings scoped_setter(widget_layer->GetAnimator());
209 widget_layer->SetOpacity(1); 209 widget_layer->SetOpacity(1);
210 return phantom_widget; 210 return phantom_widget;
211 } 211 }
212 212
213 } // namespace internal 213 } // namespace internal
214 } // namespace ash 214 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/phantom_window_controller.h ('k') | ash/wm/workspace/workspace_event_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698