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

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: fix conflict 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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 } 1142 }
1143 UpdateDockedWidth(new_width); 1143 UpdateDockedWidth(new_width);
1144 // Sort windows by their center positions and fan out overlapping 1144 // Sort windows by their center positions and fan out overlapping
1145 // windows. 1145 // windows.
1146 std::sort(visible_windows->begin(), visible_windows->end(), 1146 std::sort(visible_windows->begin(), visible_windows->end(),
1147 CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : NULL, 1147 CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : NULL,
1148 delta)); 1148 delta));
1149 for (std::vector<WindowWithHeight>::iterator iter = visible_windows->begin(); 1149 for (std::vector<WindowWithHeight>::iterator iter = visible_windows->begin();
1150 iter != visible_windows->end(); ++iter) { 1150 iter != visible_windows->end(); ++iter) {
1151 aura::Window* window = iter->window(); 1151 aura::Window* window = iter->window();
1152 gfx::Rect bounds = ScreenAsh::ConvertRectToScreen( 1152 gfx::Rect bounds = ScreenUtil::ConvertRectToScreen(
1153 window->parent(), window->GetTargetBounds()); 1153 window->parent(), window->GetTargetBounds());
1154 // A window is extended or shrunk to be as close as possible to the ideal 1154 // A window is extended or shrunk to be as close as possible to the ideal
1155 // docked area width. Windows that were resized by a user are kept at their 1155 // docked area width. Windows that were resized by a user are kept at their
1156 // existing size. 1156 // existing size.
1157 // This also enforces the min / max restrictions on the docked area width. 1157 // This also enforces the min / max restrictions on the docked area width.
1158 bounds.set_width(GetWindowWidthCloseTo( 1158 bounds.set_width(GetWindowWidthCloseTo(
1159 window, 1159 window,
1160 wm::GetWindowState(window)->bounds_changed_by_user() ? 1160 wm::GetWindowState(window)->bounds_changed_by_user() ?
1161 bounds.width() : ideal_docked_width)); 1161 bounds.width() : ideal_docked_width));
1162 DCHECK_LE(bounds.width(), ideal_docked_width); 1162 DCHECK_LE(bounds.width(), ideal_docked_width);
(...skipping 26 matching lines...) Expand all
1189 case DOCKED_ALIGNMENT_NONE: 1189 case DOCKED_ALIGNMENT_NONE:
1190 break; 1190 break;
1191 } 1191 }
1192 if (window == dragged_window_) { 1192 if (window == dragged_window_) {
1193 dragged_bounds_ = bounds; 1193 dragged_bounds_ = bounds;
1194 continue; 1194 continue;
1195 } 1195 }
1196 // If the following asserts it is probably because not all the children 1196 // If the following asserts it is probably because not all the children
1197 // have been removed when dock was closed. 1197 // have been removed when dock was closed.
1198 DCHECK_NE(alignment_, DOCKED_ALIGNMENT_NONE); 1198 DCHECK_NE(alignment_, DOCKED_ALIGNMENT_NONE);
1199 bounds = ScreenAsh::ConvertRectFromScreen(dock_container_, bounds); 1199 bounds = ScreenUtil::ConvertRectFromScreen(dock_container_, bounds);
1200 if (bounds != window->GetTargetBounds()) { 1200 if (bounds != window->GetTargetBounds()) {
1201 ui::Layer* layer = window->layer(); 1201 ui::Layer* layer = window->layer();
1202 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); 1202 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator());
1203 slide_settings.SetPreemptionStrategy( 1203 slide_settings.SetPreemptionStrategy(
1204 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 1204 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
1205 slide_settings.SetTransitionDuration( 1205 slide_settings.SetTransitionDuration(
1206 base::TimeDelta::FromMilliseconds(kSlideDurationMs)); 1206 base::TimeDelta::FromMilliseconds(kSlideDurationMs));
1207 SetChildBoundsDirect(window, bounds); 1207 SetChildBoundsDirect(window, bounds);
1208 } 1208 }
1209 } 1209 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1299 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1300 const gfx::Rect& keyboard_bounds) { 1300 const gfx::Rect& keyboard_bounds) {
1301 // This bounds change will have caused a change to the Shelf which does not 1301 // This bounds change will have caused a change to the Shelf which does not
1302 // propagate automatically to this class, so manually recalculate bounds. 1302 // propagate automatically to this class, so manually recalculate bounds.
1303 Relayout(); 1303 Relayout();
1304 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1304 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1305 } 1305 }
1306 1306
1307 } // namespace internal 1307 } // namespace internal
1308 } // namespace ash 1308 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698