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

Side by Side Diff: ash/wm/dock/docked_window_layout_manager.cc

Issue 138003007: [Cleanup] Screen cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make sure screen_for_shutdown is reset everytime Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/wm/dock/docked_window_layout_manager.h" 5 #include "ash/wm/dock/docked_window_layout_manager.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_util.h"
9 #include "ash/shelf/shelf.h" 9 #include "ash/shelf/shelf.h"
10 #include "ash/shelf/shelf_constants.h" 10 #include "ash/shelf/shelf_constants.h"
11 #include "ash/shelf/shelf_layout_manager.h" 11 #include "ash/shelf/shelf_layout_manager.h"
12 #include "ash/shelf/shelf_types.h" 12 #include "ash/shelf/shelf_types.h"
13 #include "ash/shelf/shelf_widget.h" 13 #include "ash/shelf/shelf_widget.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/shell_window_ids.h" 15 #include "ash/shell_window_ids.h"
16 #include "ash/wm/coordinate_conversion.h" 16 #include "ash/wm/coordinate_conversion.h"
17 #include "ash/wm/window_animations.h" 17 #include "ash/wm/window_animations.h"
18 #include "ash/wm/window_properties.h" 18 #include "ash/wm/window_properties.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 CompareWindowPos(aura::Window* dragged_window, float delta) 304 CompareWindowPos(aura::Window* dragged_window, float delta)
305 : dragged_window_(dragged_window), 305 : dragged_window_(dragged_window),
306 delta_(delta / 2) {} 306 delta_(delta / 2) {}
307 307
308 bool operator()(WindowWithHeight window_with_height1, 308 bool operator()(WindowWithHeight window_with_height1,
309 WindowWithHeight window_with_height2) { 309 WindowWithHeight window_with_height2) {
310 // Use target coordinates since animations may be active when windows are 310 // Use target coordinates since animations may be active when windows are
311 // reordered. 311 // reordered.
312 aura::Window* win1(window_with_height1.window()); 312 aura::Window* win1(window_with_height1.window());
313 aura::Window* win2(window_with_height2.window()); 313 aura::Window* win2(window_with_height2.window());
314 gfx::Rect win1_bounds = ScreenAsh::ConvertRectToScreen( 314 gfx::Rect win1_bounds = ScreenUtil::ConvertRectToScreen(
315 win1->parent(), win1->GetTargetBounds()); 315 win1->parent(), win1->GetTargetBounds());
316 gfx::Rect win2_bounds = ScreenAsh::ConvertRectToScreen( 316 gfx::Rect win2_bounds = ScreenUtil::ConvertRectToScreen(
317 win2->parent(), win2->GetTargetBounds()); 317 win2->parent(), win2->GetTargetBounds());
318 win1_bounds.set_height(window_with_height1.height_); 318 win1_bounds.set_height(window_with_height1.height_);
319 win2_bounds.set_height(window_with_height2.height_); 319 win2_bounds.set_height(window_with_height2.height_);
320 // If one of the windows is the |dragged_window_| attempt to make an 320 // If one of the windows is the |dragged_window_| attempt to make an
321 // earlier swap between the windows than just based on their centers. 321 // earlier swap between the windows than just based on their centers.
322 // This is possible if the dragged window is at least as tall as the other 322 // This is possible if the dragged window is at least as tall as the other
323 // window. 323 // window.
324 if (win1 == dragged_window_) 324 if (win1 == dragged_window_)
325 return compare_two_windows(win1_bounds, win2_bounds); 325 return compare_two_windows(win1_bounds, win2_bounds);
326 if (win2 == dragged_window_) 326 if (win2 == dragged_window_)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 if (docked_layout_manager_->shelf() && 375 if (docked_layout_manager_->shelf() &&
376 docked_layout_manager_->shelf()->shelf_widget()) 376 docked_layout_manager_->shelf()->shelf_widget())
377 docked_layout_manager_->shelf()->shelf_widget()->GetNativeView() 377 docked_layout_manager_->shelf()->shelf_widget()->GetNativeView()
378 ->RemoveObserver(this); 378 ->RemoveObserver(this);
379 } 379 }
380 380
381 // aura::WindowObserver: 381 // aura::WindowObserver:
382 virtual void OnWindowBoundsChanged(aura::Window* window, 382 virtual void OnWindowBoundsChanged(aura::Window* window,
383 const gfx::Rect& old_bounds, 383 const gfx::Rect& old_bounds,
384 const gfx::Rect& new_bounds) OVERRIDE { 384 const gfx::Rect& new_bounds) OVERRIDE {
385 shelf_bounds_in_screen_ = ScreenAsh::ConvertRectToScreen( 385 shelf_bounds_in_screen_ = ScreenUtil::ConvertRectToScreen(
386 window->parent(), new_bounds); 386 window->parent(), new_bounds);
387 docked_layout_manager_->OnShelfBoundsChanged(); 387 docked_layout_manager_->OnShelfBoundsChanged();
388 } 388 }
389 389
390 const gfx::Rect& shelf_bounds_in_screen() const { 390 const gfx::Rect& shelf_bounds_in_screen() const {
391 return shelf_bounds_in_screen_; 391 return shelf_bounds_in_screen_;
392 } 392 }
393 393
394 private: 394 private:
395 DockedWindowLayoutManager* docked_layout_manager_; 395 DockedWindowLayoutManager* docked_layout_manager_;
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 } 1148 }
1149 UpdateDockedWidth(new_width); 1149 UpdateDockedWidth(new_width);
1150 // Sort windows by their center positions and fan out overlapping 1150 // Sort windows by their center positions and fan out overlapping
1151 // windows. 1151 // windows.
1152 std::sort(visible_windows->begin(), visible_windows->end(), 1152 std::sort(visible_windows->begin(), visible_windows->end(),
1153 CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : NULL, 1153 CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : NULL,
1154 delta)); 1154 delta));
1155 for (std::vector<WindowWithHeight>::iterator iter = visible_windows->begin(); 1155 for (std::vector<WindowWithHeight>::iterator iter = visible_windows->begin();
1156 iter != visible_windows->end(); ++iter) { 1156 iter != visible_windows->end(); ++iter) {
1157 aura::Window* window = iter->window(); 1157 aura::Window* window = iter->window();
1158 gfx::Rect bounds = ScreenAsh::ConvertRectToScreen( 1158 gfx::Rect bounds = ScreenUtil::ConvertRectToScreen(
1159 window->parent(), window->GetTargetBounds()); 1159 window->parent(), window->GetTargetBounds());
1160 // A window is extended or shrunk to be as close as possible to the ideal 1160 // A window is extended or shrunk to be as close as possible to the ideal
1161 // docked area width. Windows that were resized by a user are kept at their 1161 // docked area width. Windows that were resized by a user are kept at their
1162 // existing size. 1162 // existing size.
1163 // This also enforces the min / max restrictions on the docked area width. 1163 // This also enforces the min / max restrictions on the docked area width.
1164 bounds.set_width(GetWindowWidthCloseTo( 1164 bounds.set_width(GetWindowWidthCloseTo(
1165 window, 1165 window,
1166 wm::GetWindowState(window)->bounds_changed_by_user() ? 1166 wm::GetWindowState(window)->bounds_changed_by_user() ?
1167 bounds.width() : ideal_docked_width)); 1167 bounds.width() : ideal_docked_width));
1168 DCHECK_LE(bounds.width(), ideal_docked_width); 1168 DCHECK_LE(bounds.width(), ideal_docked_width);
(...skipping 26 matching lines...) Expand all
1195 case DOCKED_ALIGNMENT_NONE: 1195 case DOCKED_ALIGNMENT_NONE:
1196 break; 1196 break;
1197 } 1197 }
1198 if (window == dragged_window_) { 1198 if (window == dragged_window_) {
1199 dragged_bounds_ = bounds; 1199 dragged_bounds_ = bounds;
1200 continue; 1200 continue;
1201 } 1201 }
1202 // If the following asserts it is probably because not all the children 1202 // If the following asserts it is probably because not all the children
1203 // have been removed when dock was closed. 1203 // have been removed when dock was closed.
1204 DCHECK_NE(alignment_, DOCKED_ALIGNMENT_NONE); 1204 DCHECK_NE(alignment_, DOCKED_ALIGNMENT_NONE);
1205 bounds = ScreenAsh::ConvertRectFromScreen(dock_container_, bounds); 1205 bounds = ScreenUtil::ConvertRectFromScreen(dock_container_, bounds);
1206 if (bounds != window->GetTargetBounds()) { 1206 if (bounds != window->GetTargetBounds()) {
1207 ui::Layer* layer = window->layer(); 1207 ui::Layer* layer = window->layer();
1208 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); 1208 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator());
1209 slide_settings.SetPreemptionStrategy( 1209 slide_settings.SetPreemptionStrategy(
1210 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 1210 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
1211 slide_settings.SetTransitionDuration( 1211 slide_settings.SetTransitionDuration(
1212 base::TimeDelta::FromMilliseconds(kSlideDurationMs)); 1212 base::TimeDelta::FromMilliseconds(kSlideDurationMs));
1213 SetChildBoundsDirect(window, bounds); 1213 SetChildBoundsDirect(window, bounds);
1214 } 1214 }
1215 } 1215 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1305 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1306 const gfx::Rect& keyboard_bounds) { 1306 const gfx::Rect& keyboard_bounds) {
1307 // This bounds change will have caused a change to the Shelf which does not 1307 // This bounds change will have caused a change to the Shelf which does not
1308 // propagate automatically to this class, so manually recalculate bounds. 1308 // propagate automatically to this class, so manually recalculate bounds.
1309 Relayout(); 1309 Relayout();
1310 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1310 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1311 } 1311 }
1312 1312
1313 } // namespace internal 1313 } // namespace internal
1314 } // namespace ash 1314 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/caption_buttons/frame_maximize_button.cc ('k') | ash/wm/dock/docked_window_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698