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

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

Issue 2726823003: Remove WmLookup. (Closed)
Patch Set: Clean up include and modify comment. Created 3 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/common/shelf/shelf_controller.cc ('k') | ash/common/shelf/shelf_tooltip_manager.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/common/shelf/shelf_layout_manager.h" 5 #include "ash/common/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/animation/animation_change_type.h" 11 #include "ash/animation/animation_change_type.h"
12 #include "ash/common/session/session_controller.h" 12 #include "ash/common/session/session_controller.h"
13 #include "ash/common/session/session_state_delegate.h" 13 #include "ash/common/session/session_state_delegate.h"
14 #include "ash/common/shelf/shelf_constants.h" 14 #include "ash/common/shelf/shelf_constants.h"
15 #include "ash/common/shelf/shelf_layout_manager_observer.h" 15 #include "ash/common/shelf/shelf_layout_manager_observer.h"
16 #include "ash/common/shelf/shelf_widget.h" 16 #include "ash/common/shelf/shelf_widget.h"
17 #include "ash/common/shelf/wm_shelf.h" 17 #include "ash/common/shelf/wm_shelf.h"
18 #include "ash/common/system/status_area_widget.h" 18 #include "ash/common/system/status_area_widget.h"
19 #include "ash/common/wm/fullscreen_window_finder.h" 19 #include "ash/common/wm/fullscreen_window_finder.h"
20 #include "ash/common/wm/mru_window_tracker.h" 20 #include "ash/common/wm/mru_window_tracker.h"
21 #include "ash/common/wm/window_state.h" 21 #include "ash/common/wm/window_state.h"
22 #include "ash/common/wm/wm_screen_util.h" 22 #include "ash/common/wm/wm_screen_util.h"
23 #include "ash/common/wm_lookup.h"
24 #include "ash/common/wm_shell.h" 23 #include "ash/common/wm_shell.h"
25 #include "ash/common/wm_window.h" 24 #include "ash/common/wm_window.h"
26 #include "ash/public/cpp/shell_window_ids.h" 25 #include "ash/public/cpp/shell_window_ids.h"
27 #include "ash/root_window_controller.h" 26 #include "ash/root_window_controller.h"
28 #include "base/auto_reset.h" 27 #include "base/auto_reset.h"
29 #include "base/command_line.h" 28 #include "base/command_line.h"
30 #include "base/i18n/rtl.h" 29 #include "base/i18n/rtl.h"
31 #include "ui/base/ui_base_switches.h" 30 #include "ui/base/ui_base_switches.h"
32 #include "ui/compositor/layer.h" 31 #include "ui/compositor/layer.h"
33 #include "ui/compositor/layer_animation_observer.h" 32 #include "ui/compositor/layer_animation_observer.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // status_area_widget() may be NULL during the shutdown. 183 // status_area_widget() may be NULL during the shutdown.
185 return shelf_widget_->status_area_widget() && 184 return shelf_widget_->status_area_widget() &&
186 shelf_widget_->status_area_widget()->IsVisible() && 185 shelf_widget_->status_area_widget()->IsVisible() &&
187 (state_.visibility_state == SHELF_VISIBLE || 186 (state_.visibility_state == SHELF_VISIBLE ||
188 (state_.visibility_state == SHELF_AUTO_HIDE && 187 (state_.visibility_state == SHELF_AUTO_HIDE &&
189 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); 188 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN));
190 } 189 }
191 190
192 gfx::Rect ShelfLayoutManager::GetIdealBounds() { 191 gfx::Rect ShelfLayoutManager::GetIdealBounds() {
193 const int shelf_size = GetShelfConstant(SHELF_SIZE); 192 const int shelf_size = GetShelfConstant(SHELF_SIZE);
194 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); 193 WmWindow* shelf_window = WmWindow::Get(shelf_widget_->GetNativeWindow());
195 gfx::Rect rect(wm::GetDisplayBoundsInParent(shelf_window)); 194 gfx::Rect rect(wm::GetDisplayBoundsInParent(shelf_window));
196 return SelectValueForShelfAlignment( 195 return SelectValueForShelfAlignment(
197 gfx::Rect(rect.x(), rect.bottom() - shelf_size, rect.width(), shelf_size), 196 gfx::Rect(rect.x(), rect.bottom() - shelf_size, rect.width(), shelf_size),
198 gfx::Rect(rect.x(), rect.y(), shelf_size, rect.height()), 197 gfx::Rect(rect.x(), rect.y(), shelf_size, rect.height()),
199 gfx::Rect(rect.right() - shelf_size, rect.y(), shelf_size, 198 gfx::Rect(rect.right() - shelf_size, rect.y(), shelf_size,
200 rect.height())); 199 rect.height()));
201 } 200 }
202 201
203 gfx::Size ShelfLayoutManager::GetPreferredSize() { 202 gfx::Size ShelfLayoutManager::GetPreferredSize() {
204 TargetBounds target_bounds; 203 TargetBounds target_bounds;
(...skipping 22 matching lines...) Expand all
227 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: 226 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
228 return SHELF_VISIBLE; 227 return SHELF_VISIBLE;
229 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: 228 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN:
230 return SHELF_HIDDEN; 229 return SHELF_HIDDEN;
231 } 230 }
232 return SHELF_VISIBLE; 231 return SHELF_VISIBLE;
233 } 232 }
234 233
235 void ShelfLayoutManager::UpdateVisibilityState() { 234 void ShelfLayoutManager::UpdateVisibilityState() {
236 // Bail out early before the shelf is initialized or after it is destroyed. 235 // Bail out early before the shelf is initialized or after it is destroyed.
237 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); 236 WmWindow* shelf_window = WmWindow::Get(shelf_widget_->GetNativeWindow());
238 if (in_shutdown_ || !wm_shelf_->IsShelfInitialized() || !shelf_window) 237 if (in_shutdown_ || !wm_shelf_->IsShelfInitialized() || !shelf_window)
239 return; 238 return;
240 if (state_.IsScreenLocked() || state_.IsAddingSecondaryUser()) { 239 if (state_.IsScreenLocked() || state_.IsAddingSecondaryUser()) {
241 SetState(SHELF_VISIBLE); 240 SetState(SHELF_VISIBLE);
242 } else if (WmShell::Get()->IsPinned()) { 241 } else if (WmShell::Get()->IsPinned()) {
243 SetState(SHELF_HIDDEN); 242 SetState(SHELF_HIDDEN);
244 } else { 243 } else {
245 // TODO(zelidrag): Verify shelf drag animation still shows on the device 244 // TODO(zelidrag): Verify shelf drag animation still shows on the device
246 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. 245 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN.
247 wm::WorkspaceWindowState window_state( 246 wm::WorkspaceWindowState window_state(
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 void ShelfLayoutManager::OnWindowResized() { 379 void ShelfLayoutManager::OnWindowResized() {
381 LayoutShelf(); 380 LayoutShelf();
382 } 381 }
383 382
384 void ShelfLayoutManager::SetChildBounds(WmWindow* child, 383 void ShelfLayoutManager::SetChildBounds(WmWindow* child,
385 const gfx::Rect& requested_bounds) { 384 const gfx::Rect& requested_bounds) {
386 wm::WmSnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); 385 wm::WmSnapToPixelLayoutManager::SetChildBounds(child, requested_bounds);
387 // We may contain other widgets (such as frame maximize bubble) but they don't 386 // We may contain other widgets (such as frame maximize bubble) but they don't
388 // effect the layout in anyway. 387 // effect the layout in anyway.
389 if (!updating_bounds_ && 388 if (!updating_bounds_ &&
390 ((WmLookup::Get()->GetWindowForWidget(shelf_widget_) == child) || 389 ((WmWindow::Get(shelf_widget_->GetNativeWindow()) == child) ||
391 (WmLookup::Get()->GetWindowForWidget( 390 (WmWindow::Get(shelf_widget_->status_area_widget()->GetNativeWindow()) ==
392 shelf_widget_->status_area_widget()) == child))) { 391 child))) {
393 LayoutShelf(); 392 LayoutShelf();
394 } 393 }
395 } 394 }
396 395
397 void ShelfLayoutManager::OnShelfAutoHideBehaviorChanged(WmWindow* root_window) { 396 void ShelfLayoutManager::OnShelfAutoHideBehaviorChanged(WmWindow* root_window) {
398 UpdateVisibilityState(); 397 UpdateVisibilityState();
399 } 398 }
400 399
401 void ShelfLayoutManager::OnPinnedStateChanged(WmWindow* pinned_window) { 400 void ShelfLayoutManager::OnPinnedStateChanged(WmWindow* pinned_window) {
402 // Shelf needs to be hidden on entering to pinned mode, or restored 401 // Shelf needs to be hidden on entering to pinned mode, or restored
(...skipping 18 matching lines...) Expand all
421 keyboard::KeyboardController::GetInstance()->keyboard_locked()); 420 keyboard::KeyboardController::GetInstance()->keyboard_locked());
422 421
423 keyboard_bounds_ = new_bounds; 422 keyboard_bounds_ = new_bounds;
424 LayoutShelfAndUpdateBounds(change_work_area); 423 LayoutShelfAndUpdateBounds(change_work_area);
425 424
426 // On login screen if keyboard has been just hidden, update bounds just once 425 // On login screen if keyboard has been just hidden, update bounds just once
427 // but ignore target_bounds.work_area_insets since shelf overlaps with login 426 // but ignore target_bounds.work_area_insets since shelf overlaps with login
428 // window. 427 // window.
429 if (WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked() && 428 if (WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked() &&
430 keyboard_is_about_to_hide) { 429 keyboard_is_about_to_hide) {
431 WmWindow* window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); 430 WmWindow* window = WmWindow::Get(shelf_widget_->GetNativeWindow());
432 WmShell::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets()); 431 WmShell::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets());
433 } 432 }
434 } 433 }
435 434
436 void ShelfLayoutManager::OnKeyboardClosed() {} 435 void ShelfLayoutManager::OnKeyboardClosed() {}
437 436
438 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { 437 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
439 if (state_.pre_lock_screen_animation_active) 438 if (state_.pre_lock_screen_animation_active)
440 return SHELF_BACKGROUND_DEFAULT; 439 return SHELF_BACKGROUND_DEFAULT;
441 440
(...skipping 25 matching lines...) Expand all
467 ShelfLayoutManager::TargetBounds::TargetBounds() 466 ShelfLayoutManager::TargetBounds::TargetBounds()
468 : opacity(0.0f), status_opacity(0.0f) {} 467 : opacity(0.0f), status_opacity(0.0f) {}
469 468
470 ShelfLayoutManager::TargetBounds::~TargetBounds() {} 469 ShelfLayoutManager::TargetBounds::~TargetBounds() {}
471 470
472 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { 471 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
473 State state; 472 State state;
474 state.visibility_state = visibility_state; 473 state.visibility_state = visibility_state;
475 state.auto_hide_state = CalculateAutoHideState(visibility_state); 474 state.auto_hide_state = CalculateAutoHideState(visibility_state);
476 475
477 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); 476 WmWindow* shelf_window = WmWindow::Get(shelf_widget_->GetNativeWindow());
478 RootWindowController* controller = shelf_window->GetRootWindowController(); 477 RootWindowController* controller = shelf_window->GetRootWindowController();
479 state.window_state = controller ? controller->GetWorkspaceWindowState() 478 state.window_state = controller ? controller->GetWorkspaceWindowState()
480 : wm::WORKSPACE_WINDOW_STATE_DEFAULT; 479 : wm::WORKSPACE_WINDOW_STATE_DEFAULT;
481 // Preserve the log in screen states. 480 // Preserve the log in screen states.
482 state.session_state = state_.session_state; 481 state.session_state = state_.session_state;
483 state.pre_lock_screen_animation_active = 482 state.pre_lock_screen_animation_active =
484 state_.pre_lock_screen_animation_active; 483 state_.pre_lock_screen_animation_active;
485 484
486 // Force an update because gesture drags affect the shelf bounds and we 485 // Force an update because gesture drags affect the shelf bounds and we
487 // should animate back to the normal bounds at the end of a gesture. 486 // should animate back to the normal bounds at the end of a gesture.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 573 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
575 } else { 574 } else {
576 StopAnimating(); 575 StopAnimating();
577 shelf_animation_setter.SetTransitionDuration(base::TimeDelta()); 576 shelf_animation_setter.SetTransitionDuration(base::TimeDelta());
578 status_animation_setter.SetTransitionDuration(base::TimeDelta()); 577 status_animation_setter.SetTransitionDuration(base::TimeDelta());
579 } 578 }
580 if (observer) 579 if (observer)
581 status_animation_setter.AddObserver(observer); 580 status_animation_setter.AddObserver(observer);
582 581
583 GetLayer(shelf_widget_)->SetOpacity(target_bounds.opacity); 582 GetLayer(shelf_widget_)->SetOpacity(target_bounds.opacity);
584 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); 583 WmWindow* shelf_window = WmWindow::Get(shelf_widget_->GetNativeWindow());
585 shelf_widget_->SetBounds(shelf_window->GetParent()->ConvertRectToScreen( 584 shelf_widget_->SetBounds(shelf_window->GetParent()->ConvertRectToScreen(
586 target_bounds.shelf_bounds_in_root)); 585 target_bounds.shelf_bounds_in_root));
587 586
588 GetLayer(shelf_widget_->status_area_widget()) 587 GetLayer(shelf_widget_->status_area_widget())
589 ->SetOpacity(target_bounds.status_opacity); 588 ->SetOpacity(target_bounds.status_opacity);
590 589
591 // Having a window which is visible but does not have an opacity is an 590 // Having a window which is visible but does not have an opacity is an
592 // illegal state. We therefore hide the shelf here if required. 591 // illegal state. We therefore hide the shelf here if required.
593 if (!target_bounds.status_opacity) 592 if (!target_bounds.status_opacity)
594 shelf_widget_->status_area_widget()->Hide(); 593 shelf_widget_->status_area_widget()->Hide();
595 // Setting visibility during an animation causes the visibility property to 594 // Setting visibility during an animation causes the visibility property to
596 // animate. Override the animation settings to immediately set the 595 // animate. Override the animation settings to immediately set the
597 // visibility property. Opacity will still animate. 596 // visibility property. Opacity will still animate.
598 597
599 // TODO(harrym): Once status area widget is a child view of shelf 598 // TODO(harrym): Once status area widget is a child view of shelf
600 // this can be simplified. 599 // this can be simplified.
601 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; 600 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf;
602 status_bounds.Offset(target_bounds.shelf_bounds_in_root.OffsetFromOrigin()); 601 status_bounds.Offset(target_bounds.shelf_bounds_in_root.OffsetFromOrigin());
603 WmWindow* status_window = WmLookup::Get()->GetWindowForWidget( 602 WmWindow* status_window =
604 shelf_widget_->status_area_widget()); 603 WmWindow::Get(shelf_widget_->status_area_widget()->GetNativeWindow());
605 shelf_widget_->status_area_widget()->SetBounds( 604 shelf_widget_->status_area_widget()->SetBounds(
606 status_window->GetParent()->ConvertRectToScreen(status_bounds)); 605 status_window->GetParent()->ConvertRectToScreen(status_bounds));
607 606
608 // For crbug.com/622431, when the shelf alignment is BOTTOM_LOCKED, we 607 // For crbug.com/622431, when the shelf alignment is BOTTOM_LOCKED, we
609 // don't set display work area, as it is not real user-set alignment. 608 // don't set display work area, as it is not real user-set alignment.
610 if (!state_.IsScreenLocked() && 609 if (!state_.IsScreenLocked() &&
611 wm_shelf_->GetAlignment() != SHELF_ALIGNMENT_BOTTOM_LOCKED && 610 wm_shelf_->GetAlignment() != SHELF_ALIGNMENT_BOTTOM_LOCKED &&
612 change_work_area) { 611 change_work_area) {
613 gfx::Insets insets; 612 gfx::Insets insets;
614 // If user session is blocked (login to new user session or add user to 613 // If user session is blocked (login to new user session or add user to
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 // Auto-hidden shelf always starts with the default size. If a gesture-drag 645 // Auto-hidden shelf always starts with the default size. If a gesture-drag
647 // is in progress, then the call to UpdateTargetBoundsForGesture() below 646 // is in progress, then the call to UpdateTargetBoundsForGesture() below
648 // takes care of setting the height properly. 647 // takes care of setting the height properly.
649 shelf_size = kShelfAutoHideSize; 648 shelf_size = kShelfAutoHideSize;
650 } else if (state.visibility_state == SHELF_HIDDEN || 649 } else if (state.visibility_state == SHELF_HIDDEN ||
651 (!keyboard_bounds_.IsEmpty() && 650 (!keyboard_bounds_.IsEmpty() &&
652 !keyboard::IsKeyboardOverscrollEnabled())) { 651 !keyboard::IsKeyboardOverscrollEnabled())) {
653 shelf_size = 0; 652 shelf_size = 0;
654 } 653 }
655 654
656 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); 655 WmWindow* shelf_window = WmWindow::Get(shelf_widget_->GetNativeWindow());
657 gfx::Rect available_bounds = wm::GetDisplayBoundsWithShelf(shelf_window); 656 gfx::Rect available_bounds = wm::GetDisplayBoundsWithShelf(shelf_window);
658 available_bounds.Inset(0, chromevox_panel_height_, 0, 0); 657 available_bounds.Inset(0, chromevox_panel_height_, 0, 0);
659 int shelf_width = PrimaryAxisValue(available_bounds.width(), shelf_size); 658 int shelf_width = PrimaryAxisValue(available_bounds.width(), shelf_size);
660 int shelf_height = PrimaryAxisValue(shelf_size, available_bounds.height()); 659 int shelf_height = PrimaryAxisValue(shelf_size, available_bounds.height());
661 int bottom_shelf_vertical_offset = available_bounds.bottom(); 660 int bottom_shelf_vertical_offset = available_bounds.bottom();
662 if (keyboard_bounds_.IsEmpty()) 661 if (keyboard_bounds_.IsEmpty())
663 bottom_shelf_vertical_offset -= shelf_height; 662 bottom_shelf_vertical_offset -= shelf_height;
664 else 663 else
665 bottom_shelf_vertical_offset -= keyboard_bounds_.height(); 664 bottom_shelf_vertical_offset -= keyboard_bounds_.height();
666 665
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 available_bounds.Subtract(keyboard_bounds_); 739 available_bounds.Subtract(keyboard_bounds_);
741 740
742 WmWindow* root = shelf_window->GetRootWindow(); 741 WmWindow* root = shelf_window->GetRootWindow();
743 user_work_area_bounds_ = root->ConvertRectToScreen(available_bounds); 742 user_work_area_bounds_ = root->ConvertRectToScreen(available_bounds);
744 } 743 }
745 744
746 void ShelfLayoutManager::UpdateTargetBoundsForGesture( 745 void ShelfLayoutManager::UpdateTargetBoundsForGesture(
747 TargetBounds* target_bounds) const { 746 TargetBounds* target_bounds) const {
748 CHECK_EQ(GESTURE_DRAG_IN_PROGRESS, gesture_drag_status_); 747 CHECK_EQ(GESTURE_DRAG_IN_PROGRESS, gesture_drag_status_);
749 bool horizontal = wm_shelf_->IsHorizontalAlignment(); 748 bool horizontal = wm_shelf_->IsHorizontalAlignment();
750 WmWindow* window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); 749 WmWindow* window = WmWindow::Get(shelf_widget_->GetNativeWindow());
751 gfx::Rect available_bounds = wm::GetDisplayBoundsWithShelf(window); 750 gfx::Rect available_bounds = wm::GetDisplayBoundsWithShelf(window);
752 int resistance_free_region = 0; 751 int resistance_free_region = 0;
753 752
754 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN && 753 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN &&
755 visibility_state() == SHELF_AUTO_HIDE && 754 visibility_state() == SHELF_AUTO_HIDE &&
756 auto_hide_state() != SHELF_AUTO_HIDE_SHOWN) { 755 auto_hide_state() != SHELF_AUTO_HIDE_SHOWN) {
757 // If the shelf was hidden when the drag started (and the state hasn't 756 // If the shelf was hidden when the drag started (and the state hasn't
758 // changed since then, e.g. because the tray-menu was shown because of the 757 // changed since then, e.g. because the tray-menu was shown because of the
759 // drag), then allow the drag some resistance-free region at first to make 758 // drag), then allow the drag some resistance-free region at first to make
760 // sure the shelf sticks with the finger until the shelf is visible. 759 // sure the shelf sticks with the finger until the shelf is visible.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 return SHELF_AUTO_HIDE_SHOWN; 871 return SHELF_AUTO_HIDE_SHOWN;
873 872
874 if (shelf_widget_->IsShowingOverflowBubble()) 873 if (shelf_widget_->IsShowingOverflowBubble())
875 return SHELF_AUTO_HIDE_SHOWN; 874 return SHELF_AUTO_HIDE_SHOWN;
876 875
877 if (shelf_widget_->IsActive() || 876 if (shelf_widget_->IsActive() ||
878 (shelf_widget_->status_area_widget() && 877 (shelf_widget_->status_area_widget() &&
879 shelf_widget_->status_area_widget()->IsActive())) 878 shelf_widget_->status_area_widget()->IsActive()))
880 return SHELF_AUTO_HIDE_SHOWN; 879 return SHELF_AUTO_HIDE_SHOWN;
881 880
882 const int64_t shelf_display_id = WmLookup::Get() 881 const int64_t shelf_display_id =
883 ->GetWindowForWidget(shelf_widget_) 882 WmWindow::Get(shelf_widget_->GetNativeWindow())
884 ->GetDisplayNearestWindow() 883 ->GetDisplayNearestWindow()
885 .id(); 884 .id();
886 const std::vector<WmWindow*> windows = 885 const std::vector<WmWindow*> windows =
887 WmShell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal(); 886 WmShell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal();
888 // Process the window list and check if there are any visible windows. 887 // Process the window list and check if there are any visible windows.
889 // Ignore app list windows that may be animating to hide after dismissal. 888 // Ignore app list windows that may be animating to hide after dismissal.
890 bool visible_window = false; 889 bool visible_window = false;
891 for (size_t i = 0; i < windows.size(); ++i) { 890 for (size_t i = 0; i < windows.size(); ++i) {
892 if (windows[i] && windows[i]->IsVisible() && !IsAppListWindow(windows[i]) && 891 if (windows[i] && windows[i]->IsVisible() && !IsAppListWindow(windows[i]) &&
893 !windows[i]->GetWindowState()->IsMinimized() && 892 !windows[i]->GetWindowState()->IsMinimized() &&
894 windows[i]->GetDisplayNearestWindow().id() == shelf_display_id) { 893 windows[i]->GetDisplayNearestWindow().id() == shelf_display_id) {
895 visible_window = true; 894 visible_window = true;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 cursor_position_in_screen)) { 947 cursor_position_in_screen)) {
949 return SHELF_AUTO_HIDE_SHOWN; 948 return SHELF_AUTO_HIDE_SHOWN;
950 } 949 }
951 950
952 return SHELF_AUTO_HIDE_HIDDEN; 951 return SHELF_AUTO_HIDE_HIDDEN;
953 } 952 }
954 953
955 bool ShelfLayoutManager::IsShelfWindow(WmWindow* window) { 954 bool ShelfLayoutManager::IsShelfWindow(WmWindow* window) {
956 if (!window) 955 if (!window)
957 return false; 956 return false;
958 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); 957 WmWindow* shelf_window = WmWindow::Get(shelf_widget_->GetNativeWindow());
959 WmWindow* status_window = 958 WmWindow* status_window =
960 WmLookup::Get()->GetWindowForWidget(shelf_widget_->status_area_widget()); 959 WmWindow::Get(shelf_widget_->status_area_widget()->GetNativeWindow());
961 return (shelf_window && shelf_window->Contains(window)) || 960 return (shelf_window && shelf_window->Contains(window)) ||
962 (status_window && status_window->Contains(window)); 961 (status_window && status_window->Contains(window));
963 } 962 }
964 963
965 int ShelfLayoutManager::GetWorkAreaInsets(const State& state, int size) const { 964 int ShelfLayoutManager::GetWorkAreaInsets(const State& state, int size) const {
966 if (state.visibility_state == SHELF_VISIBLE) 965 if (state.visibility_state == SHELF_VISIBLE)
967 return size; 966 return size;
968 if (state.visibility_state == SHELF_AUTO_HIDE) 967 if (state.visibility_state == SHELF_AUTO_HIDE)
969 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); 968 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE);
970 return 0; 969 return 0;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 // target bounds are also hidden. So the window can extend to the edge of 1034 // target bounds are also hidden. So the window can extend to the edge of
1036 // screen. 1035 // screen.
1037 return (state.visibility_state == SHELF_AUTO_HIDE && 1036 return (state.visibility_state == SHELF_AUTO_HIDE &&
1038 state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN) 1037 state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)
1039 ? 1.0f 1038 ? 1.0f
1040 : 0.0f; 1039 : 0.0f;
1041 } 1040 }
1042 1041
1043 bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const { 1042 bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const {
1044 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode( 1043 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode(
1045 WmLookup::Get()->GetWindowForWidget(shelf_widget_)); 1044 WmWindow::Get(shelf_widget_->GetNativeWindow()));
1046 return fullscreen_window && 1045 return fullscreen_window &&
1047 fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen(); 1046 fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen();
1048 } 1047 }
1049 1048
1050 //////////////////////////////////////////////////////////////////////////////// 1049 ////////////////////////////////////////////////////////////////////////////////
1051 // ShelfLayoutManager, Gesture functions: 1050 // ShelfLayoutManager, Gesture functions:
1052 1051
1053 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { 1052 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) {
1054 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; 1053 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS;
1055 gesture_drag_amount_ = 0.f; 1054 gesture_drag_amount_ = 0.f;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 gesture_drag_status_ = GESTURE_DRAG_NONE; 1134 gesture_drag_status_ = GESTURE_DRAG_NONE;
1136 } 1135 }
1137 1136
1138 void ShelfLayoutManager::CancelGestureDrag() { 1137 void ShelfLayoutManager::CancelGestureDrag() {
1139 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; 1138 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS;
1140 UpdateVisibilityState(); 1139 UpdateVisibilityState();
1141 gesture_drag_status_ = GESTURE_DRAG_NONE; 1140 gesture_drag_status_ = GESTURE_DRAG_NONE;
1142 } 1141 }
1143 1142
1144 } // namespace ash 1143 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_controller.cc ('k') | ash/common/shelf/shelf_tooltip_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698