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

Side by Side Diff: ash/shelf/shelf_layout_manager.cc

Issue 1812013003: Pass shelf instances, not root windows, for ash context menus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call OnShelfAlignmentChanged after LayoutShelf. Created 4 years, 9 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
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <cstring> 9 #include <cstring>
10 #include <string> 10 #include <string>
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 240
241 bool ShelfLayoutManager::IsVisible() const { 241 bool ShelfLayoutManager::IsVisible() const {
242 // status_area_widget() may be NULL during the shutdown. 242 // status_area_widget() may be NULL during the shutdown.
243 return shelf_->status_area_widget() && 243 return shelf_->status_area_widget() &&
244 shelf_->status_area_widget()->IsVisible() && 244 shelf_->status_area_widget()->IsVisible() &&
245 (state_.visibility_state == SHELF_VISIBLE || 245 (state_.visibility_state == SHELF_VISIBLE ||
246 (state_.visibility_state == SHELF_AUTO_HIDE && 246 (state_.visibility_state == SHELF_AUTO_HIDE &&
247 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); 247 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN));
248 } 248 }
249 249
250 bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { 250 void ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) {
251 if (alignment_ == alignment) 251 if (alignment_ == alignment)
252 return false; 252 return;
253 253
254 alignment_ = alignment; 254 alignment_ = alignment;
255 // The shelf will itself move to the bottom while locked or obscured by user 255 // The shelf will itself move to the bottom while locked or obscured by user
256 // login. If a request is sent to move while being obscured, we postpone the 256 // login. If a request is sent to move while being obscured, we postpone the
257 // move until the user session is resumed. 257 // move until the user session is resumed.
258 if (IsAlignmentLocked()) 258 if (!IsAlignmentLocked()) {
259 return false; 259 shelf_->SetAlignment(alignment);
260 260 LayoutShelf();
261 // This should not be called during the lock screen transitions. 261 Shell::GetInstance()->OnShelfAlignmentChanged(
262 shelf_->SetAlignment(alignment); 262 shelf_->GetNativeWindow()->GetRootWindow());
263 LayoutShelf(); 263 }
264 return true;
265 } 264 }
266 265
267 ShelfAlignment ShelfLayoutManager::GetAlignment() const { 266 ShelfAlignment ShelfLayoutManager::GetAlignment() const {
268 // When the screen is locked or a user gets added, the shelf is forced into 267 // When the screen is locked or a user gets added, the shelf is forced into
269 // bottom alignment. 268 // bottom alignment.
270 if (IsAlignmentLocked()) 269 if (IsAlignmentLocked())
271 return SHELF_ALIGNMENT_BOTTOM; 270 return SHELF_ALIGNMENT_BOTTOM;
272 return alignment_; 271 return alignment_;
273 } 272 }
274 273
(...skipping 14 matching lines...) Expand all
289 if (shelf_->shelf()) { 288 if (shelf_->shelf()) {
290 // Update insets in ShelfWindowTargeter when shelf bounds change. 289 // Update insets in ShelfWindowTargeter when shelf bounds change.
291 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, 290 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
292 WillChangeVisibilityState(visibility_state())); 291 WillChangeVisibilityState(visibility_state()));
293 } 292 }
294 } 293 }
295 294
296 ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() { 295 ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() {
297 switch(auto_hide_behavior_) { 296 switch(auto_hide_behavior_) {
298 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: 297 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
299 #if defined(OS_WIN)
300 // Disable shelf auto-hide behavior on screen sides in Metro mode.
301 if (GetAlignment() != SHELF_ALIGNMENT_BOTTOM)
302 return SHELF_VISIBLE;
303 #endif
304 return SHELF_AUTO_HIDE; 298 return SHELF_AUTO_HIDE;
305 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: 299 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
306 return SHELF_VISIBLE; 300 return SHELF_VISIBLE;
307 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: 301 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN:
308 return SHELF_HIDDEN; 302 return SHELF_HIDDEN;
309 } 303 }
310 return SHELF_VISIBLE; 304 return SHELF_VISIBLE;
311 } 305 }
312 306
313 void ShelfLayoutManager::UpdateVisibilityState() { 307 void ShelfLayoutManager::UpdateVisibilityState() {
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 TargetBounds target_bounds; 1136 TargetBounds target_bounds;
1143 CalculateTargetBounds(state_, &target_bounds); 1137 CalculateTargetBounds(state_, &target_bounds);
1144 UpdateBoundsAndOpacity(target_bounds, true, NULL); 1138 UpdateBoundsAndOpacity(target_bounds, true, NULL);
1145 UpdateVisibilityState(); 1139 UpdateVisibilityState();
1146 } 1140 }
1147 1141
1148 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { 1142 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() {
1149 shelf_->SetAlignment(GetAlignment()); 1143 shelf_->SetAlignment(GetAlignment());
1150 UpdateVisibilityState(); 1144 UpdateVisibilityState();
1151 LayoutShelf(); 1145 LayoutShelf();
1146 Shell::GetInstance()->OnShelfAlignmentChanged(
1147 shelf_->GetNativeWindow()->GetRootWindow());
1152 } 1148 }
1153 1149
1154 bool ShelfLayoutManager::IsAlignmentLocked() const { 1150 bool ShelfLayoutManager::IsAlignmentLocked() const {
1155 if (state_.is_screen_locked) 1151 if (state_.is_screen_locked)
1156 return true; 1152 return true;
1157 // The session state becomes active at the start of transitioning to a user 1153 // The session state becomes active at the start of transitioning to a user
1158 // session, however the session is considered blocked until the full UI is 1154 // session, however the session is considered blocked until the full UI is
1159 // ready. Exit early to allow for proper layout. 1155 // ready. Exit early to allow for proper layout.
1160 SessionStateDelegate* session_state_delegate = 1156 SessionStateDelegate* session_state_delegate =
1161 Shell::GetInstance()->session_state_delegate(); 1157 Shell::GetInstance()->session_state_delegate();
1162 if (session_state_delegate->GetSessionState() == 1158 if (session_state_delegate->GetSessionState() ==
1163 SessionStateDelegate::SESSION_STATE_ACTIVE) { 1159 SessionStateDelegate::SESSION_STATE_ACTIVE) {
1164 return false; 1160 return false;
1165 } 1161 }
1166 if (session_state_delegate->IsUserSessionBlocked() || 1162 if (session_state_delegate->IsUserSessionBlocked() ||
1167 state_.is_adding_user_screen) { 1163 state_.is_adding_user_screen) {
1168 return true; 1164 return true;
1169 } 1165 }
1170 return false; 1166 return false;
1171 } 1167 }
1172 1168
1173 } // namespace ash 1169 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698