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())->GetTopmostFullscreenWindow(); | |
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 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); | 68 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); |
62 const aura::Window::Windows& windows(viewport_->children()); | 69 const aura::Window::Windows& windows(viewport_->children()); |
63 bool window_overlaps_launcher = false; | 70 bool window_overlaps_launcher = false; |
64 bool has_maximized_window = false; | 71 bool has_maximized_window = false; |
65 for (aura::Window::Windows::const_iterator i = windows.begin(); | 72 for (aura::Window::Windows::const_iterator i = windows.begin(); |
66 i != windows.end(); ++i) { | 73 i != windows.end(); ++i) { |
67 wm::WindowState* window_state = wm::GetWindowState(*i); | 74 wm::WindowState* window_state = wm::GetWindowState(*i); |
68 if (window_state->ignored_by_shelf()) | 75 if (window_state->ignored_by_shelf()) |
69 continue; | 76 continue; |
70 ui::Layer* layer = (*i)->layer(); | 77 ui::Layer* layer = (*i)->layer(); |
71 if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f) | 78 if (!layer->GetTargetVisibility() || layer->GetTargetOpacity() == 0.0f) |
72 continue; | 79 continue; |
73 if (window_state->IsMaximized()) { | 80 if (window_state->IsMaximized()) { |
74 // An untracked window may still be fullscreen so we keep iterating when | 81 // An untracked window may still be fullscreen so we keep iterating when |
75 // we hit a maximized window. | 82 // we hit a maximized window. |
76 has_maximized_window = true; | 83 has_maximized_window = true; |
pkotwicz
2013/12/05 02:46:29
We can return WORKSPACE_WINDOW_STATE_MAXIMIZED imm
flackr
2013/12/05 16:48:54
Nice, the code is getting cleaner and cleaner :-).
| |
77 } else if (window_state->IsFullscreen()) { | |
78 return WORKSPACE_WINDOW_STATE_FULL_SCREEN; | |
79 } | 84 } |
80 if (!window_overlaps_launcher && (*i)->bounds().Intersects(shelf_bounds)) | 85 if (!window_overlaps_launcher && (*i)->bounds().Intersects(shelf_bounds)) |
81 window_overlaps_launcher = true; | 86 window_overlaps_launcher = true; |
82 } | 87 } |
83 if (has_maximized_window) | 88 if (has_maximized_window) |
84 return WORKSPACE_WINDOW_STATE_MAXIMIZED; | 89 return WORKSPACE_WINDOW_STATE_MAXIMIZED; |
85 | 90 |
86 return window_overlaps_launcher ? | 91 return window_overlaps_launcher ? |
87 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : | 92 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : |
88 WORKSPACE_WINDOW_STATE_DEFAULT; | 93 WORKSPACE_WINDOW_STATE_DEFAULT; |
(...skipping 30 matching lines...) Expand all Loading... | |
119 settings.SetTweenType(gfx::Tween::EASE_OUT); | 124 settings.SetTweenType(gfx::Tween::EASE_OUT); |
120 settings.SetTransitionDuration( | 125 settings.SetTransitionDuration( |
121 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); | 126 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); |
122 viewport_->layer()->SetTransform(gfx::Transform()); | 127 viewport_->layer()->SetTransform(gfx::Transform()); |
123 viewport_->layer()->SetOpacity(1.0f); | 128 viewport_->layer()->SetOpacity(1.0f); |
124 } | 129 } |
125 } | 130 } |
126 | 131 |
127 } // namespace internal | 132 } // namespace internal |
128 } // namespace ash | 133 } // namespace ash |
OLD | NEW |