OLD | NEW |
---|---|
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_properties.h" | 16 #include "ash/wm/window_properties.h" |
17 #include "ash/wm/window_state.h" | |
17 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
18 #include "base/auto_reset.h" | 19 #include "base/auto_reset.h" |
19 #include "base/command_line.h" | 20 #include "base/command_line.h" |
20 #include "third_party/skia/include/core/SkColor.h" | 21 #include "third_party/skia/include/core/SkColor.h" |
21 #include "ui/aura/client/activation_client.h" | 22 #include "ui/aura/client/activation_client.h" |
22 #include "ui/aura/client/aura_constants.h" | 23 #include "ui/aura/client/aura_constants.h" |
23 #include "ui/aura/focus_manager.h" | 24 #include "ui/aura/focus_manager.h" |
24 #include "ui/aura/root_window.h" | 25 #include "ui/aura/root_window.h" |
25 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
26 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 // setting is enabled and hide all windows (immersive mode should hide docked | 471 // setting is enabled and hide all windows (immersive mode should hide docked |
471 // windows). | 472 // windows). |
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 (shelf_hidden_) { | 479 if (shelf_hidden_) { |
479 if (window->IsVisible()) | 480 if (window->IsVisible()) |
480 MinimizeWindow(window); | 481 MinimizeDockedWindow(window); |
481 } else { | 482 } else { |
482 if (!wm::IsWindowMinimized(window)) | 483 if (!wm::GetWindowState(window)->IsMinimized()) |
483 RestoreWindow(window); | 484 RestoreDockedWindow(window); |
484 } | 485 } |
485 } | 486 } |
486 } | 487 } |
487 Relayout(); | 488 Relayout(); |
488 UpdateDockBounds(); | 489 UpdateDockBounds(); |
489 } | 490 } |
490 | 491 |
491 //////////////////////////////////////////////////////////////////////////////// | 492 //////////////////////////////////////////////////////////////////////////////// |
492 // DockLayoutManager private implementation: | 493 // DockLayoutManager private implementation: |
493 | 494 |
494 void DockedWindowLayoutManager::MinimizeWindow(aura::Window* window) { | 495 void DockedWindowLayoutManager::MinimizeDockedWindow(aura::Window* window) { |
James Cook
2013/09/18 20:44:17
Good idea renaming these
| |
495 window->Hide(); | 496 window->Hide(); |
496 if (wm::IsActiveWindow(window)) | 497 if (wm::IsActiveWindow(window)) |
497 wm::DeactivateWindow(window); | 498 wm::DeactivateWindow(window); |
498 } | 499 } |
499 | 500 |
500 void DockedWindowLayoutManager::RestoreWindow(aura::Window* window) { | 501 void DockedWindowLayoutManager::RestoreDockedWindow(aura::Window* window) { |
501 window->Show(); | 502 window->Show(); |
502 } | 503 } |
503 | 504 |
504 void DockedWindowLayoutManager::OnWindowDocked(aura::Window* window) { | 505 void DockedWindowLayoutManager::OnWindowDocked(aura::Window* window) { |
505 DCHECK(!is_dragged_window_docked_); | 506 DCHECK(!is_dragged_window_docked_); |
506 is_dragged_window_docked_ = true; | 507 is_dragged_window_docked_ = true; |
507 | 508 |
508 // If there are no other docked windows update alignment. | 509 // If there are no other docked windows update alignment. |
509 if (!IsAnyWindowDocked()) | 510 if (!IsAnyWindowDocked()) |
510 alignment_ = DOCKED_ALIGNMENT_NONE; | 511 alignment_ = DOCKED_ALIGNMENT_NONE; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
726 | 727 |
727 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 728 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
728 const gfx::Rect& keyboard_bounds) { | 729 const gfx::Rect& keyboard_bounds) { |
729 // This bounds change will have caused a change to the Shelf which does not | 730 // This bounds change will have caused a change to the Shelf which does not |
730 // propagate automatically to this class, so manually recalculate bounds. | 731 // propagate automatically to this class, so manually recalculate bounds. |
731 UpdateDockBounds(); | 732 UpdateDockBounds(); |
732 } | 733 } |
733 | 734 |
734 } // namespace internal | 735 } // namespace internal |
735 } // namespace ash | 736 } // namespace ash |
OLD | NEW |