OLD | NEW |
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_controller.h" | 5 #include "ash/wm/workspace_controller.h" |
6 | 6 |
| 7 #include "ash/root_window_controller.h" |
7 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
8 #include "ash/shell.h" | 9 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/base_layout_manager.h" | 11 #include "ash/wm/base_layout_manager.h" |
11 #include "ash/wm/window_animations.h" | 12 #include "ash/wm/window_animations.h" |
12 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
13 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
14 #include "ash/wm/workspace/workspace_event_handler.h" | 15 #include "ash/wm/workspace/workspace_event_handler.h" |
15 #include "ash/wm/workspace/workspace_layout_manager.h" | 16 #include "ash/wm/workspace/workspace_layout_manager.h" |
16 #include "ui/aura/client/activation_client.h" | 17 #include "ui/aura/client/activation_client.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 WorkspaceController::~WorkspaceController() { | 51 WorkspaceController::~WorkspaceController() { |
51 viewport_->SetLayoutManager(NULL); | 52 viewport_->SetLayoutManager(NULL); |
52 viewport_->SetEventFilter(NULL); | 53 viewport_->SetEventFilter(NULL); |
53 viewport_->RemovePreTargetHandler(event_handler_.get()); | 54 viewport_->RemovePreTargetHandler(event_handler_.get()); |
54 viewport_->RemovePostTargetHandler(event_handler_.get()); | 55 viewport_->RemovePostTargetHandler(event_handler_.get()); |
55 } | 56 } |
56 | 57 |
57 WorkspaceWindowState WorkspaceController::GetWindowState() const { | 58 WorkspaceWindowState WorkspaceController::GetWindowState() const { |
58 if (!shelf_) | 59 if (!shelf_) |
59 return WORKSPACE_WINDOW_STATE_DEFAULT; | 60 return WORKSPACE_WINDOW_STATE_DEFAULT; |
| 61 const aura::Window* topmost_fullscreen_window = GetRootWindowController( |
| 62 viewport_->GetRootWindow())->GetWindowForFullscreenMode(); |
| 63 if (topmost_fullscreen_window && |
| 64 !wm::GetWindowState(topmost_fullscreen_window)->ignored_by_shelf()) { |
| 65 return WORKSPACE_WINDOW_STATE_FULL_SCREEN; |
| 66 } |
60 | 67 |
61 // These are the container ids of containers which may contain windows that | 68 // These are the container ids of containers which may contain windows that |
62 // may overlap the launcher shelf and affect its transparency. | 69 // may overlap the launcher shelf and affect its transparency. |
63 const int kWindowContainerIds[] = { | 70 const int kWindowContainerIds[] = { |
64 internal::kShellWindowId_DefaultContainer, | 71 internal::kShellWindowId_DefaultContainer, |
65 internal::kShellWindowId_DockedContainer, | 72 internal::kShellWindowId_DockedContainer, |
66 }; | 73 }; |
67 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); | 74 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); |
68 bool window_overlaps_launcher = false; | 75 bool window_overlaps_launcher = false; |
69 bool has_maximized_window = false; | |
70 for (size_t idx = 0; idx < arraysize(kWindowContainerIds); idx++) { | 76 for (size_t idx = 0; idx < arraysize(kWindowContainerIds); idx++) { |
71 const aura::Window* container = Shell::GetContainer( | 77 const aura::Window* container = Shell::GetContainer( |
72 viewport_->GetRootWindow(), kWindowContainerIds[idx]); | 78 viewport_->GetRootWindow(), kWindowContainerIds[idx]); |
73 const aura::Window::Windows& windows(container->children()); | 79 const aura::Window::Windows& windows(container->children()); |
74 for (aura::Window::Windows::const_iterator i = windows.begin(); | 80 for (aura::Window::Windows::const_iterator i = windows.begin(); |
75 i != windows.end(); ++i) { | 81 i != windows.end(); ++i) { |
76 wm::WindowState* window_state = wm::GetWindowState(*i); | 82 wm::WindowState* window_state = wm::GetWindowState(*i); |
77 if (window_state->ignored_by_shelf()) | 83 if (window_state->ignored_by_shelf()) |
78 continue; | 84 continue; |
79 ui::Layer* layer = (*i)->layer(); | 85 ui::Layer* layer = (*i)->layer(); |
80 if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f) | 86 if (!layer->GetTargetVisibility()) |
81 continue; | 87 continue; |
82 if (window_state->IsMaximized()) { | 88 if (window_state->IsMaximized()) |
83 // An untracked window may still be fullscreen so we keep iterating when | 89 return WORKSPACE_WINDOW_STATE_MAXIMIZED; |
84 // we hit a maximized window. | |
85 has_maximized_window = true; | |
86 } else if (window_state->IsFullscreen()) { | |
87 return WORKSPACE_WINDOW_STATE_FULL_SCREEN; | |
88 } | |
89 if (!window_overlaps_launcher && (*i)->bounds().Intersects(shelf_bounds)) | 90 if (!window_overlaps_launcher && (*i)->bounds().Intersects(shelf_bounds)) |
90 window_overlaps_launcher = true; | 91 window_overlaps_launcher = true; |
91 } | 92 } |
92 } | 93 } |
93 if (has_maximized_window) | |
94 return WORKSPACE_WINDOW_STATE_MAXIMIZED; | |
95 | 94 |
96 return window_overlaps_launcher ? | 95 return window_overlaps_launcher ? |
97 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : | 96 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : |
98 WORKSPACE_WINDOW_STATE_DEFAULT; | 97 WORKSPACE_WINDOW_STATE_DEFAULT; |
99 } | 98 } |
100 | 99 |
101 void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) { | 100 void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) { |
102 shelf_ = shelf; | 101 shelf_ = shelf; |
103 layout_manager_->SetShelf(shelf); | 102 layout_manager_->SetShelf(shelf); |
104 } | 103 } |
(...skipping 24 matching lines...) Expand all Loading... |
129 settings.SetTweenType(gfx::Tween::EASE_OUT); | 128 settings.SetTweenType(gfx::Tween::EASE_OUT); |
130 settings.SetTransitionDuration( | 129 settings.SetTransitionDuration( |
131 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); | 130 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); |
132 viewport_->layer()->SetTransform(gfx::Transform()); | 131 viewport_->layer()->SetTransform(gfx::Transform()); |
133 viewport_->layer()->SetOpacity(1.0f); | 132 viewport_->layer()->SetOpacity(1.0f); |
134 } | 133 } |
135 } | 134 } |
136 | 135 |
137 } // namespace internal | 136 } // namespace internal |
138 } // namespace ash | 137 } // namespace ash |
OLD | NEW |