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/shelf_layout_manager.h" | 5 #include "ash/wm/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/launcher/launcher.h" | 9 #include "ash/launcher/launcher.h" |
10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 bool ShelfLayoutManager::IsVisible() const { | 150 bool ShelfLayoutManager::IsVisible() const { |
151 return status_->IsVisible() && (state_.visibility_state == VISIBLE || | 151 return status_->IsVisible() && (state_.visibility_state == VISIBLE || |
152 (state_.visibility_state == AUTO_HIDE && | 152 (state_.visibility_state == AUTO_HIDE && |
153 state_.auto_hide_state == AUTO_HIDE_SHOWN)); | 153 state_.auto_hide_state == AUTO_HIDE_SHOWN)); |
154 } | 154 } |
155 | 155 |
156 gfx::Rect ShelfLayoutManager::GetMaximizedWindowBounds( | 156 gfx::Rect ShelfLayoutManager::GetMaximizedWindowBounds( |
157 aura::Window* window) { | 157 aura::Window* window) { |
158 // TODO: needs to be multi-mon aware. | 158 // TODO: needs to be multi-mon aware. |
159 gfx::Rect bounds(gfx::Screen::GetMonitorNearestWindow(window).bounds()); | 159 gfx::Rect bounds(gfx::Screen::GetDisplayNearestWindow(window).bounds()); |
160 if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT || | 160 if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT || |
161 auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) { | 161 auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) { |
162 AdjustBoundsBasedOnAlignment(kAutoHideSize, &bounds); | 162 AdjustBoundsBasedOnAlignment(kAutoHideSize, &bounds); |
163 return bounds; | 163 return bounds; |
164 } | 164 } |
165 // SHELF_AUTO_HIDE_BEHAVIOR_NEVER maximized windows don't get any taller. | 165 // SHELF_AUTO_HIDE_BEHAVIOR_NEVER maximized windows don't get any taller. |
166 return GetUnmaximizedWorkAreaBounds(window); | 166 return GetUnmaximizedWorkAreaBounds(window); |
167 } | 167 } |
168 | 168 |
169 gfx::Rect ShelfLayoutManager::GetUnmaximizedWorkAreaBounds( | 169 gfx::Rect ShelfLayoutManager::GetUnmaximizedWorkAreaBounds( |
170 aura::Window* window) { | 170 aura::Window* window) { |
171 // TODO: needs to be multi-mon aware. | 171 // TODO: needs to be multi-mon aware. |
172 gfx::Rect bounds(gfx::Screen::GetMonitorNearestWindow(window).bounds()); | 172 gfx::Rect bounds(gfx::Screen::GetDisplayNearestWindow(window).bounds()); |
173 int size; | 173 int size; |
174 if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) { | 174 if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) { |
175 size = kAutoHideSize; | 175 size = kAutoHideSize; |
176 } else { | 176 } else { |
177 int width, height; | 177 int width, height; |
178 GetShelfSize(&width, &height); | 178 GetShelfSize(&width, &height); |
179 size = std::max(width, height); | 179 size = std::max(width, height); |
180 } | 180 } |
181 AdjustBoundsBasedOnAlignment(size, &bounds); | 181 AdjustBoundsBasedOnAlignment(size, &bounds); |
182 return bounds; | 182 return bounds; |
(...skipping 19 matching lines...) Expand all Loading... |
202 if (status_area_widget) | 202 if (status_area_widget) |
203 Shell::GetInstance()->status_area_widget()->SetShelfAlignment(alignment); | 203 Shell::GetInstance()->status_area_widget()->SetShelfAlignment(alignment); |
204 LayoutShelf(); | 204 LayoutShelf(); |
205 return true; | 205 return true; |
206 } | 206 } |
207 | 207 |
208 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 208 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
209 // TODO: this is wrong. Figure out what monitor shelf is on and everything | 209 // TODO: this is wrong. Figure out what monitor shelf is on and everything |
210 // should be based on it. | 210 // should be based on it. |
211 gfx::Rect bounds( | 211 gfx::Rect bounds( |
212 gfx::Screen::GetMonitorNearestWindow(status_->GetNativeView()).bounds()); | 212 gfx::Screen::GetDisplayNearestWindow(status_->GetNativeView()).bounds()); |
213 int width = 0, height = 0; | 213 int width = 0, height = 0; |
214 GetShelfSize(&width, &height); | 214 GetShelfSize(&width, &height); |
215 switch (alignment_) { | 215 switch (alignment_) { |
216 case SHELF_ALIGNMENT_BOTTOM: | 216 case SHELF_ALIGNMENT_BOTTOM: |
217 return gfx::Rect(bounds.x(), bounds.bottom() - height, | 217 return gfx::Rect(bounds.x(), bounds.bottom() - height, |
218 bounds.width(), height); | 218 bounds.width(), height); |
219 case SHELF_ALIGNMENT_LEFT: | 219 case SHELF_ALIGNMENT_LEFT: |
220 return gfx::Rect(bounds.x(), bounds.y(), width, bounds.height()); | 220 return gfx::Rect(bounds.x(), bounds.y(), width, bounds.height()); |
221 case SHELF_ALIGNMENT_RIGHT: | 221 case SHELF_ALIGNMENT_RIGHT: |
222 return gfx::Rect(bounds.right() - width, bounds.y(), width, | 222 return gfx::Rect(bounds.right() - width, bounds.y(), width, |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 574 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
575 if (state.visibility_state == VISIBLE) | 575 if (state.visibility_state == VISIBLE) |
576 return size; | 576 return size; |
577 if (state.visibility_state == AUTO_HIDE) | 577 if (state.visibility_state == AUTO_HIDE) |
578 return kAutoHideSize; | 578 return kAutoHideSize; |
579 return 0; | 579 return 0; |
580 } | 580 } |
581 | 581 |
582 } // namespace internal | 582 } // namespace internal |
583 } // namespace ash | 583 } // namespace ash |
OLD | NEW |