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

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

Issue 24108003: [Cleanup] Rename WindowSettings to WindowState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase fix Created 7 years, 3 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/launcher/launcher.h" 8 #include "ash/launcher/launcher.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
11 #include "ash/shelf/shelf_types.h" 11 #include "ash/shelf/shelf_types.h"
12 #include "ash/shelf/shelf_widget.h" 12 #include "ash/shelf/shelf_widget.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/shell_window_ids.h" 14 #include "ash/shell_window_ids.h"
15 #include "ash/wm/coordinate_conversion.h" 15 #include "ash/wm/coordinate_conversion.h"
16 #include "ash/wm/window_animations.h" 16 #include "ash/wm/window_animations.h"
17 #include "ash/wm/window_properties.h" 17 #include "ash/wm/window_properties.h"
18 #include "ash/wm/window_state.h"
18 #include "ash/wm/window_util.h" 19 #include "ash/wm/window_util.h"
19 #include "base/auto_reset.h" 20 #include "base/auto_reset.h"
20 #include "base/command_line.h" 21 #include "base/command_line.h"
21 #include "third_party/skia/include/core/SkColor.h" 22 #include "third_party/skia/include/core/SkColor.h"
22 #include "ui/aura/client/activation_client.h" 23 #include "ui/aura/client/activation_client.h"
23 #include "ui/aura/client/aura_constants.h" 24 #include "ui/aura/client/aura_constants.h"
24 #include "ui/aura/focus_manager.h" 25 #include "ui/aura/focus_manager.h"
25 #include "ui/aura/root_window.h" 26 #include "ui/aura/root_window.h"
26 #include "ui/aura/window.h" 27 #include "ui/aura/window.h"
27 #include "ui/gfx/rect.h" 28 #include "ui/gfx/rect.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 aura::Window* dock = Shell::GetContainer( 78 aura::Window* dock = Shell::GetContainer(
78 wm::GetRootWindowMatching(near_location), 79 wm::GetRootWindowMatching(near_location),
79 kShellWindowId_DockedContainer); 80 kShellWindowId_DockedContainer);
80 return static_cast<internal::DockedWindowLayoutManager*>( 81 return static_cast<internal::DockedWindowLayoutManager*>(
81 dock->layout_manager()); 82 dock->layout_manager());
82 } 83 }
83 84
84 // Certain windows (minimized, hidden or popups) do not matter to docking. 85 // Certain windows (minimized, hidden or popups) do not matter to docking.
85 bool IsUsedByLayout(aura::Window* window) { 86 bool IsUsedByLayout(aura::Window* window) {
86 return (window->IsVisible() && 87 return (window->IsVisible() &&
87 !wm::IsWindowMinimized(window) && 88 !wm::GetWindowState(window)->IsMinimized() &&
88 window->type() != aura::client::WINDOW_TYPE_POPUP); 89 window->type() != aura::client::WINDOW_TYPE_POPUP);
89 } 90 }
90 91
91 // A functor used to sort the windows in order of their center Y position. 92 // A functor used to sort the windows in order of their center Y position.
92 // |delta| is a pre-calculated distance from the bottom of one window to the top 93 // |delta| is a pre-calculated distance from the bottom of one window to the top
93 // of the next. Its value can be positive (gap) or negative (overlap). 94 // of the next. Its value can be positive (gap) or negative (overlap).
94 // Half of |delta| is used as a transition point at which windows could ideally 95 // Half of |delta| is used as a transition point at which windows could ideally
95 // swap positions. 96 // swap positions.
96 struct CompareWindowPos { 97 struct CompareWindowPos {
97 CompareWindowPos(aura::Window* dragged_window, float delta) 98 CompareWindowPos(aura::Window* dragged_window, float delta)
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 405
405 void DockedWindowLayoutManager::OnWindowPropertyChanged(aura::Window* window, 406 void DockedWindowLayoutManager::OnWindowPropertyChanged(aura::Window* window,
406 const void* key, 407 const void* key,
407 intptr_t old) { 408 intptr_t old) {
408 if (key != aura::client::kShowStateKey) 409 if (key != aura::client::kShowStateKey)
409 return; 410 return;
410 // The window property will still be set, but no actual change will occur 411 // The window property will still be set, but no actual change will occur
411 // until WillChangeVisibilityState is called when the shelf is visible again 412 // until WillChangeVisibilityState is called when the shelf is visible again
412 if (shelf_hidden_) 413 if (shelf_hidden_)
413 return; 414 return;
414 if (wm::IsWindowMinimized(window)) 415 if (wm::GetWindowState(window)->IsMinimized())
415 MinimizeWindow(window); 416 MinimizeDockedWindow(window);
416 else 417 else
417 RestoreWindow(window); 418 RestoreDockedWindow(window);
418 } 419 }
419 420
420 void DockedWindowLayoutManager::OnWindowBoundsChanged( 421 void DockedWindowLayoutManager::OnWindowBoundsChanged(
421 aura::Window* window, 422 aura::Window* window,
422 const gfx::Rect& old_bounds, 423 const gfx::Rect& old_bounds,
423 const gfx::Rect& new_bounds) { 424 const gfx::Rect& new_bounds) {
424 // Only relayout if the dragged window would get docked. 425 // Only relayout if the dragged window would get docked.
425 if (window == dragged_window_ && is_dragged_window_docked_) 426 if (window == dragged_window_ && is_dragged_window_docked_)
426 Relayout(); 427 Relayout();
427 } 428 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 shelf_hidden_ = new_state == ash::SHELF_HIDDEN; 473 shelf_hidden_ = new_state == ash::SHELF_HIDDEN;
473 { 474 {
474 // prevent Relayout from getting called multiple times during this 475 // prevent Relayout from getting called multiple times during this
475 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 476 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
476 for (size_t i = 0; i < dock_container_->children().size(); ++i) { 477 for (size_t i = 0; i < dock_container_->children().size(); ++i) {
477 aura::Window* window = dock_container_->children()[i]; 478 aura::Window* window = dock_container_->children()[i];
478 if (window->type() == aura::client::WINDOW_TYPE_POPUP) 479 if (window->type() == aura::client::WINDOW_TYPE_POPUP)
479 continue; 480 continue;
480 if (shelf_hidden_) { 481 if (shelf_hidden_) {
481 if (window->IsVisible()) 482 if (window->IsVisible())
482 MinimizeWindow(window); 483 MinimizeDockedWindow(window);
483 } else { 484 } else {
484 if (!wm::IsWindowMinimized(window)) 485 if (!wm::GetWindowState(window)->IsMinimized())
485 RestoreWindow(window); 486 RestoreDockedWindow(window);
486 } 487 }
487 } 488 }
488 } 489 }
489 Relayout(); 490 Relayout();
490 UpdateDockBounds(); 491 UpdateDockBounds();
491 } 492 }
492 493
493 //////////////////////////////////////////////////////////////////////////////// 494 ////////////////////////////////////////////////////////////////////////////////
494 // DockLayoutManager private implementation: 495 // DockLayoutManager private implementation:
495 496
496 void DockedWindowLayoutManager::MinimizeWindow(aura::Window* window) { 497 void DockedWindowLayoutManager::MinimizeDockedWindow(aura::Window* window) {
497 DCHECK_NE(window->type(), aura::client::WINDOW_TYPE_POPUP); 498 DCHECK_NE(window->type(), aura::client::WINDOW_TYPE_POPUP);
498 views::corewm::SetWindowVisibilityAnimationType( 499 views::corewm::SetWindowVisibilityAnimationType(
499 window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); 500 window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
500 window->Hide(); 501 window->Hide();
501 if (wm::IsActiveWindow(window)) 502 wm::WindowState* window_state = wm::GetWindowState(window);
502 wm::DeactivateWindow(window); 503 if (window_state->IsActive())
504 window_state->Deactivate();
503 } 505 }
504 506
505 void DockedWindowLayoutManager::RestoreWindow(aura::Window* window) { 507 void DockedWindowLayoutManager::RestoreDockedWindow(aura::Window* window) {
506 DCHECK_NE(window->type(), aura::client::WINDOW_TYPE_POPUP); 508 DCHECK_NE(window->type(), aura::client::WINDOW_TYPE_POPUP);
507 window->Show(); 509 window->Show();
508 } 510 }
509 511
510 void DockedWindowLayoutManager::OnWindowDocked(aura::Window* window) { 512 void DockedWindowLayoutManager::OnWindowDocked(aura::Window* window) {
511 DCHECK(!is_dragged_window_docked_); 513 DCHECK(!is_dragged_window_docked_);
512 is_dragged_window_docked_ = true; 514 is_dragged_window_docked_ = true;
513 515
514 // If there are no other docked windows update alignment. 516 // If there are no other docked windows update alignment.
515 if (!IsAnyWindowDocked()) 517 if (!IsAnyWindowDocked())
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 737
736 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 738 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
737 const gfx::Rect& keyboard_bounds) { 739 const gfx::Rect& keyboard_bounds) {
738 // This bounds change will have caused a change to the Shelf which does not 740 // This bounds change will have caused a change to the Shelf which does not
739 // propagate automatically to this class, so manually recalculate bounds. 741 // propagate automatically to this class, so manually recalculate bounds.
740 UpdateDockBounds(); 742 UpdateDockBounds();
741 } 743 }
742 744
743 } // namespace internal 745 } // namespace internal
744 } // namespace ash 746 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/dock/docked_window_layout_manager.h ('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