| 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/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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "ash/accelerators/accelerator_commands.h" | 13 #include "ash/accelerators/accelerator_commands.h" |
| 14 #include "ash/ash_switches.h" | 14 #include "ash/ash_switches.h" |
| 15 #include "ash/root_window_controller.h" | 15 #include "ash/root_window_controller.h" |
| 16 #include "ash/screen_util.h" | 16 #include "ash/screen_util.h" |
| 17 #include "ash/session/session_state_delegate.h" | 17 #include "ash/session/session_state_delegate.h" |
| 18 #include "ash/shelf/shelf.h" | 18 #include "ash/shelf/shelf.h" |
| 19 #include "ash/shelf/shelf_bezel_event_filter.h" | 19 #include "ash/shelf/shelf_bezel_event_filter.h" |
| 20 #include "ash/shelf/shelf_constants.h" | 20 #include "ash/shelf/shelf_constants.h" |
| 21 #include "ash/shelf/shelf_delegate.h" |
| 21 #include "ash/shelf/shelf_layout_manager_observer.h" | 22 #include "ash/shelf/shelf_layout_manager_observer.h" |
| 22 #include "ash/shelf/shelf_util.h" | 23 #include "ash/shelf/shelf_util.h" |
| 23 #include "ash/shelf/shelf_widget.h" | 24 #include "ash/shelf/shelf_widget.h" |
| 24 #include "ash/shell.h" | 25 #include "ash/shell.h" |
| 25 #include "ash/shell_window_ids.h" | 26 #include "ash/shell_window_ids.h" |
| 26 #include "ash/system/status_area_widget.h" | 27 #include "ash/system/status_area_widget.h" |
| 27 #include "ash/wm/aura/wm_window_aura.h" | 28 #include "ash/wm/aura/wm_window_aura.h" |
| 28 #include "ash/wm/common/shelf/wm_shelf_util.h" | 29 #include "ash/wm/common/shelf/wm_shelf_util.h" |
| 29 #include "ash/wm/common/window_state.h" | 30 #include "ash/wm/common/window_state.h" |
| 30 #include "ash/wm/common/wm_root_window_controller.h" | 31 #include "ash/wm/common/wm_root_window_controller.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 const int ShelfLayoutManager::kWorkspaceAreaAutoHideInset = 5; | 94 const int ShelfLayoutManager::kWorkspaceAreaAutoHideInset = 5; |
| 94 | 95 |
| 95 // static | 96 // static |
| 96 const int ShelfLayoutManager::kAutoHideSize = 3; | 97 const int ShelfLayoutManager::kAutoHideSize = 3; |
| 97 | 98 |
| 98 // static | 99 // static |
| 99 const int ShelfLayoutManager::kShelfItemInset = 3; | 100 const int ShelfLayoutManager::kShelfItemInset = 3; |
| 100 | 101 |
| 101 // ShelfLayoutManager::AutoHideEventFilter ------------------------------------- | 102 // ShelfLayoutManager::AutoHideEventFilter ------------------------------------- |
| 102 | 103 |
| 103 // Notifies ShelfLayoutManager any time the mouse moves. | 104 // Notifies ShelfLayoutManager any time the mouse moves. Not used on mash. |
| 105 // TODO(jamescook): Delete this once the mash implementation handles drags on |
| 106 // and off the shelf. |
| 104 class ShelfLayoutManager::AutoHideEventFilter : public ui::EventHandler { | 107 class ShelfLayoutManager::AutoHideEventFilter : public ui::EventHandler { |
| 105 public: | 108 public: |
| 106 explicit AutoHideEventFilter(ShelfLayoutManager* shelf); | 109 explicit AutoHideEventFilter(ShelfLayoutManager* shelf); |
| 107 ~AutoHideEventFilter() override; | 110 ~AutoHideEventFilter() override; |
| 108 | 111 |
| 109 // Returns true if the last mouse event was a mouse drag. | 112 // Returns true if the last mouse event was a mouse drag. |
| 110 bool in_mouse_drag() const { return in_mouse_drag_; } | 113 bool in_mouse_drag() const { return in_mouse_drag_; } |
| 111 | 114 |
| 112 // Overridden from ui::EventHandler: | 115 // Overridden from ui::EventHandler: |
| 113 void OnMouseEvent(ui::MouseEvent* event) override; | 116 void OnMouseEvent(ui::MouseEvent* event) override; |
| 114 void OnGestureEvent(ui::GestureEvent* event) override; | 117 void OnGestureEvent(ui::GestureEvent* event) override; |
| 115 | 118 |
| 116 private: | 119 private: |
| 117 ShelfLayoutManager* shelf_; | 120 ShelfLayoutManager* shelf_; |
| 118 bool in_mouse_drag_; | 121 bool in_mouse_drag_; |
| 119 ShelfGestureHandler gesture_handler_; | |
| 120 DISALLOW_COPY_AND_ASSIGN(AutoHideEventFilter); | 122 DISALLOW_COPY_AND_ASSIGN(AutoHideEventFilter); |
| 121 }; | 123 }; |
| 122 | 124 |
| 123 ShelfLayoutManager::AutoHideEventFilter::AutoHideEventFilter( | 125 ShelfLayoutManager::AutoHideEventFilter::AutoHideEventFilter( |
| 124 ShelfLayoutManager* shelf) | 126 ShelfLayoutManager* shelf) |
| 125 : shelf_(shelf), | 127 : shelf_(shelf), |
| 126 in_mouse_drag_(false) { | 128 in_mouse_drag_(false) { |
| 127 Shell::GetInstance()->AddPreTargetHandler(this); | 129 Shell::GetInstance()->AddPreTargetHandler(this); |
| 128 } | 130 } |
| 129 | 131 |
| 130 ShelfLayoutManager::AutoHideEventFilter::~AutoHideEventFilter() { | 132 ShelfLayoutManager::AutoHideEventFilter::~AutoHideEventFilter() { |
| 131 Shell::GetInstance()->RemovePreTargetHandler(this); | 133 Shell::GetInstance()->RemovePreTargetHandler(this); |
| 132 } | 134 } |
| 133 | 135 |
| 134 void ShelfLayoutManager::AutoHideEventFilter::OnMouseEvent( | 136 void ShelfLayoutManager::AutoHideEventFilter::OnMouseEvent( |
| 135 ui::MouseEvent* event) { | 137 ui::MouseEvent* event) { |
| 136 // This also checks IsShelfWindow() to make sure we don't attempt to hide the | 138 // This also checks IsShelfWindow() to make sure we don't attempt to hide the |
| 137 // shelf if the mouse down occurs on the shelf. | 139 // shelf if the mouse down occurs on the shelf. |
| 138 in_mouse_drag_ = (event->type() == ui::ET_MOUSE_DRAGGED || | 140 in_mouse_drag_ = (event->type() == ui::ET_MOUSE_DRAGGED || |
| 139 (in_mouse_drag_ && event->type() != ui::ET_MOUSE_RELEASED && | 141 (in_mouse_drag_ && event->type() != ui::ET_MOUSE_RELEASED && |
| 140 event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)) && | 142 event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)) && |
| 141 !shelf_->IsShelfWindow(static_cast<aura::Window*>(event->target())); | 143 !shelf_->IsShelfWindow(static_cast<aura::Window*>(event->target())); |
| 142 if (event->type() == ui::ET_MOUSE_MOVED) | 144 shelf_->UpdateAutoHideForMouseEvent(event); |
| 143 shelf_->UpdateAutoHideState(); | |
| 144 return; | |
| 145 } | 145 } |
| 146 | 146 |
| 147 void ShelfLayoutManager::AutoHideEventFilter::OnGestureEvent( | 147 void ShelfLayoutManager::AutoHideEventFilter::OnGestureEvent( |
| 148 ui::GestureEvent* event) { | 148 ui::GestureEvent* event) { |
| 149 aura::Window* target_window = static_cast<aura::Window*>(event->target()); | 149 shelf_->UpdateAutoHideForGestureEvent(event); |
| 150 if (shelf_->IsShelfWindow(target_window)) { | |
| 151 if (gesture_handler_.ProcessGestureEvent(*event, target_window)) | |
| 152 event->StopPropagation(); | |
| 153 } | |
| 154 } | 150 } |
| 155 | 151 |
| 156 // ShelfLayoutManager:UpdateShelfObserver -------------------------------------- | 152 // ShelfLayoutManager:UpdateShelfObserver -------------------------------------- |
| 157 | 153 |
| 158 // UpdateShelfObserver is used to delay updating the background until the | 154 // UpdateShelfObserver is used to delay updating the background until the |
| 159 // animation completes. | 155 // animation completes. |
| 160 class ShelfLayoutManager::UpdateShelfObserver | 156 class ShelfLayoutManager::UpdateShelfObserver |
| 161 : public ui::ImplicitAnimationObserver { | 157 : public ui::ImplicitAnimationObserver { |
| 162 public: | 158 public: |
| 163 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) { | 159 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 Shell::GetInstance()-> | 251 Shell::GetInstance()-> |
| 256 session_state_delegate()->RemoveSessionStateObserver(this); | 252 session_state_delegate()->RemoveSessionStateObserver(this); |
| 257 if (root_window_controller_observer_) { | 253 if (root_window_controller_observer_) { |
| 258 wm::WmWindowAura::Get(root_window_) | 254 wm::WmWindowAura::Get(root_window_) |
| 259 ->GetRootWindowController() | 255 ->GetRootWindowController() |
| 260 ->RemoveObserver(root_window_controller_observer_.get()); | 256 ->RemoveObserver(root_window_controller_observer_.get()); |
| 261 } | 257 } |
| 262 } | 258 } |
| 263 | 259 |
| 264 void ShelfLayoutManager::PrepareForShutdown() { | 260 void ShelfLayoutManager::PrepareForShutdown() { |
| 261 in_shutdown_ = true; |
| 265 // Clear all event filters, otherwise sometimes those filters may catch | 262 // Clear all event filters, otherwise sometimes those filters may catch |
| 266 // synthesized mouse event and cause crashes during the shutdown. | 263 // synthesized mouse event and cause crashes during the shutdown. |
| 267 set_workspace_controller(NULL); | 264 set_workspace_controller(NULL); |
| 268 auto_hide_event_filter_.reset(); | 265 auto_hide_event_filter_.reset(); |
| 269 bezel_event_filter_.reset(); | 266 bezel_event_filter_.reset(); |
| 270 // Stop observing window change, otherwise we can attempt to update a | 267 // Stop observing window change, otherwise we can attempt to update a |
| 271 // partially destructed shelf. | 268 // partially destructed shelf. |
| 272 aura::client::GetActivationClient(root_window_)->RemoveObserver(this); | 269 aura::client::GetActivationClient(root_window_)->RemoveObserver(this); |
| 273 } | 270 } |
| 274 | 271 |
| 275 bool ShelfLayoutManager::IsVisible() const { | 272 bool ShelfLayoutManager::IsVisible() const { |
| 276 // status_area_widget() may be NULL during the shutdown. | 273 // status_area_widget() may be NULL during the shutdown. |
| 277 return shelf_->status_area_widget() && | 274 return shelf_->status_area_widget() && |
| 278 shelf_->status_area_widget()->IsVisible() && | 275 shelf_->status_area_widget()->IsVisible() && |
| 279 (state_.visibility_state == SHELF_VISIBLE || | 276 (state_.visibility_state == SHELF_VISIBLE || |
| 280 (state_.visibility_state == SHELF_AUTO_HIDE && | 277 (state_.visibility_state == SHELF_AUTO_HIDE && |
| 281 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); | 278 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); |
| 282 } | 279 } |
| 283 | 280 |
| 284 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 281 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
| 285 gfx::Rect rect(ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView())); | 282 gfx::Rect rect(ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView())); |
| 286 return SelectValueForShelfAlignment( | 283 return SelectValueForShelfAlignment( |
| 287 gfx::Rect(rect.x(), rect.bottom() - kShelfSize, rect.width(), kShelfSize), | 284 gfx::Rect(rect.x(), rect.bottom() - kShelfSize, rect.width(), kShelfSize), |
| 288 gfx::Rect(rect.x(), rect.y(), kShelfSize, rect.height()), | 285 gfx::Rect(rect.x(), rect.y(), kShelfSize, rect.height()), |
| 289 gfx::Rect(rect.right() - kShelfSize, rect.y(), kShelfSize, | 286 gfx::Rect(rect.right() - kShelfSize, rect.y(), kShelfSize, |
| 290 rect.height())); | 287 rect.height())); |
| 291 } | 288 } |
| 292 | 289 |
| 290 gfx::Size ShelfLayoutManager::GetPreferredSize() { |
| 291 TargetBounds target_bounds; |
| 292 CalculateTargetBounds(state_, &target_bounds); |
| 293 return target_bounds.shelf_bounds_in_root.size(); |
| 294 } |
| 295 |
| 293 void ShelfLayoutManager::LayoutShelf() { | 296 void ShelfLayoutManager::LayoutShelf() { |
| 294 TargetBounds target_bounds; | 297 TargetBounds target_bounds; |
| 295 CalculateTargetBounds(state_, &target_bounds); | 298 CalculateTargetBounds(state_, &target_bounds); |
| 296 UpdateBoundsAndOpacity(target_bounds, false, NULL); | 299 UpdateBoundsAndOpacity(target_bounds, false, NULL); |
| 297 | 300 |
| 298 // Update insets in ShelfWindowTargeter when shelf bounds change. | 301 // Update insets in ShelfWindowTargeter when shelf bounds change. |
| 299 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 302 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
| 300 WillChangeVisibilityState(visibility_state())); | 303 WillChangeVisibilityState(visibility_state())); |
| 301 } | 304 } |
| 302 | 305 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 auto_hide_timer_.Start( | 373 auto_hide_timer_.Start( |
| 371 FROM_HERE, | 374 FROM_HERE, |
| 372 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS), | 375 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS), |
| 373 this, &ShelfLayoutManager::UpdateAutoHideStateNow); | 376 this, &ShelfLayoutManager::UpdateAutoHideStateNow); |
| 374 } | 377 } |
| 375 } else { | 378 } else { |
| 376 StopAutoHideTimer(); | 379 StopAutoHideTimer(); |
| 377 } | 380 } |
| 378 } | 381 } |
| 379 | 382 |
| 383 void ShelfLayoutManager::UpdateAutoHideForMouseEvent(ui::MouseEvent* event) { |
| 384 // Don't update during shutdown because synthetic mouse events (e.g. mouse |
| 385 // exit) may be generated during status area widget teardown. |
| 386 if (visibility_state() != SHELF_AUTO_HIDE || in_shutdown_) |
| 387 return; |
| 388 |
| 389 if (event->type() == ui::ET_MOUSE_MOVED || |
| 390 event->type() == ui::ET_MOUSE_ENTERED || |
| 391 event->type() == ui::ET_MOUSE_EXITED) { |
| 392 UpdateAutoHideState(); |
| 393 } |
| 394 } |
| 395 |
| 396 void ShelfLayoutManager::UpdateAutoHideForGestureEvent( |
| 397 ui::GestureEvent* event) { |
| 398 if (visibility_state() != SHELF_AUTO_HIDE || in_shutdown_) |
| 399 return; |
| 400 |
| 401 aura::Window* target_window = static_cast<aura::Window*>(event->target()); |
| 402 if (IsShelfWindow(target_window)) { |
| 403 if (gesture_handler_.ProcessGestureEvent(*event, target_window)) |
| 404 event->StopPropagation(); |
| 405 } |
| 406 } |
| 407 |
| 380 void ShelfLayoutManager::SetWindowOverlapsShelf(bool value) { | 408 void ShelfLayoutManager::SetWindowOverlapsShelf(bool value) { |
| 381 window_overlaps_shelf_ = value; | 409 window_overlaps_shelf_ = value; |
| 382 UpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE); | 410 UpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE); |
| 383 } | 411 } |
| 384 | 412 |
| 385 void ShelfLayoutManager::AddObserver(ShelfLayoutManagerObserver* observer) { | 413 void ShelfLayoutManager::AddObserver(ShelfLayoutManagerObserver* observer) { |
| 386 observers_.AddObserver(observer); | 414 observers_.AddObserver(observer); |
| 387 } | 415 } |
| 388 | 416 |
| 389 void ShelfLayoutManager::RemoveObserver(ShelfLayoutManagerObserver* observer) { | 417 void ShelfLayoutManager::RemoveObserver(ShelfLayoutManagerObserver* observer) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 bool force_update = | 602 bool force_update = |
| 575 (gesture_drag_status_ == GESTURE_DRAG_CANCEL_IN_PROGRESS || | 603 (gesture_drag_status_ == GESTURE_DRAG_CANCEL_IN_PROGRESS || |
| 576 gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS); | 604 gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS); |
| 577 | 605 |
| 578 if (!force_update && state_.Equals(state)) | 606 if (!force_update && state_.Equals(state)) |
| 579 return; // Nothing changed. | 607 return; // Nothing changed. |
| 580 | 608 |
| 581 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 609 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
| 582 WillChangeVisibilityState(visibility_state)); | 610 WillChangeVisibilityState(visibility_state)); |
| 583 | 611 |
| 584 if (state.visibility_state == SHELF_AUTO_HIDE) { | 612 // mash does not support global event handlers. It uses events on the shelf |
| 585 // When state is SHELF_AUTO_HIDE we need to track when the mouse is over the | 613 // and status area widgets to update auto-hide. |
| 586 // shelf to unhide it. AutoHideEventFilter does that for us. | 614 if (!Shell::GetInstance()->in_mus()) { |
| 587 if (!auto_hide_event_filter_) | 615 if (state.visibility_state == SHELF_AUTO_HIDE) { |
| 588 auto_hide_event_filter_.reset(new AutoHideEventFilter(this)); | 616 // When state is SHELF_AUTO_HIDE we need to track when the mouse is over |
| 589 } else { | 617 // the shelf to unhide it. AutoHideEventFilter does that for us. |
| 590 auto_hide_event_filter_.reset(NULL); | 618 if (!auto_hide_event_filter_) |
| 619 auto_hide_event_filter_.reset(new AutoHideEventFilter(this)); |
| 620 } else { |
| 621 auto_hide_event_filter_.reset(NULL); |
| 622 } |
| 591 } | 623 } |
| 592 | 624 |
| 593 StopAutoHideTimer(); | 625 StopAutoHideTimer(); |
| 594 | 626 |
| 595 State old_state = state_; | 627 State old_state = state_; |
| 596 state_ = state; | 628 state_ = state; |
| 597 | 629 |
| 598 BackgroundAnimatorChangeType change_type = BACKGROUND_CHANGE_ANIMATE; | 630 BackgroundAnimatorChangeType change_type = BACKGROUND_CHANGE_ANIMATE; |
| 599 bool delay_background_change = false; | 631 bool delay_background_change = false; |
| 600 | 632 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 628 | 660 |
| 629 shelf_->SetDimsShelf(state.visibility_state == SHELF_VISIBLE && | 661 shelf_->SetDimsShelf(state.visibility_state == SHELF_VISIBLE && |
| 630 state.window_state == | 662 state.window_state == |
| 631 wm::WORKSPACE_WINDOW_STATE_MAXIMIZED); | 663 wm::WORKSPACE_WINDOW_STATE_MAXIMIZED); |
| 632 | 664 |
| 633 TargetBounds target_bounds; | 665 TargetBounds target_bounds; |
| 634 CalculateTargetBounds(state_, &target_bounds); | 666 CalculateTargetBounds(state_, &target_bounds); |
| 635 UpdateBoundsAndOpacity(target_bounds, true, | 667 UpdateBoundsAndOpacity(target_bounds, true, |
| 636 delay_background_change ? update_shelf_observer_ : NULL); | 668 delay_background_change ? update_shelf_observer_ : NULL); |
| 637 | 669 |
| 670 // The delegate must be notified after |state_| is updated so that it can |
| 671 // query the new target bounds. |
| 672 ShelfDelegate* shelf_delegate = Shell::GetInstance()->GetShelfDelegate(); |
| 673 if (old_state.visibility_state != state_.visibility_state) |
| 674 shelf_delegate->OnShelfVisibilityStateChanged(shelf_->shelf()); |
| 675 |
| 638 // OnAutoHideStateChanged Should be emitted when: | 676 // OnAutoHideStateChanged Should be emitted when: |
| 639 // - firstly state changed to auto-hide from other state | 677 // - firstly state changed to auto-hide from other state |
| 640 // - or, auto_hide_state has changed | 678 // - or, auto_hide_state has changed |
| 641 if ((old_state.visibility_state != state_.visibility_state && | 679 if ((old_state.visibility_state != state_.visibility_state && |
| 642 state_.visibility_state == SHELF_AUTO_HIDE) || | 680 state_.visibility_state == SHELF_AUTO_HIDE) || |
| 643 old_state.auto_hide_state != state_.auto_hide_state) { | 681 old_state.auto_hide_state != state_.auto_hide_state) { |
| 682 shelf_delegate->OnShelfAutoHideStateChanged(shelf_->shelf()); |
| 644 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 683 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
| 645 OnAutoHideStateChanged(state_.auto_hide_state)); | 684 OnAutoHideStateChanged(state_.auto_hide_state)); |
| 646 } | 685 } |
| 647 } | 686 } |
| 648 | 687 |
| 649 void ShelfLayoutManager::UpdateBoundsAndOpacity( | 688 void ShelfLayoutManager::UpdateBoundsAndOpacity( |
| 650 const TargetBounds& target_bounds, | 689 const TargetBounds& target_bounds, |
| 651 bool animate, | 690 bool animate, |
| 652 ui::ImplicitAnimationObserver* observer) { | 691 ui::ImplicitAnimationObserver* observer) { |
| 653 base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true); | 692 base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 return SHELF_AUTO_HIDE_SHOWN; | 1031 return SHELF_AUTO_HIDE_SHOWN; |
| 993 | 1032 |
| 994 if (shelf_->shelf() && shelf_->shelf()->IsShowingOverflowBubble()) | 1033 if (shelf_->shelf() && shelf_->shelf()->IsShowingOverflowBubble()) |
| 995 return SHELF_AUTO_HIDE_SHOWN; | 1034 return SHELF_AUTO_HIDE_SHOWN; |
| 996 | 1035 |
| 997 if (shelf_->IsActive() || | 1036 if (shelf_->IsActive() || |
| 998 (shelf_->status_area_widget() && | 1037 (shelf_->status_area_widget() && |
| 999 shelf_->status_area_widget()->IsActive())) | 1038 shelf_->status_area_widget()->IsActive())) |
| 1000 return SHELF_AUTO_HIDE_SHOWN; | 1039 return SHELF_AUTO_HIDE_SHOWN; |
| 1001 | 1040 |
| 1002 const std::vector<aura::Window*> windows = | 1041 // TODO(jamescook): Track visible windows on mash via ShelfDelegate. |
| 1003 shell->mru_window_tracker()->BuildWindowListIgnoreModal(); | 1042 if (!Shell::GetInstance()->in_mus()) { |
| 1043 const std::vector<aura::Window*> windows = |
| 1044 shell->mru_window_tracker()->BuildWindowListIgnoreModal(); |
| 1004 | 1045 |
| 1005 // Process the window list and check if there are any visible windows. | 1046 // Process the window list and check if there are any visible windows. |
| 1006 bool visible_window = false; | 1047 bool visible_window = false; |
| 1007 for (size_t i = 0; i < windows.size(); ++i) { | 1048 for (size_t i = 0; i < windows.size(); ++i) { |
| 1008 if (windows[i] && windows[i]->IsVisible() && | 1049 if (windows[i] && windows[i]->IsVisible() && |
| 1009 !wm::GetWindowState(windows[i])->IsMinimized() && | 1050 !wm::GetWindowState(windows[i])->IsMinimized() && |
| 1010 root_window_ == windows[i]->GetRootWindow()) { | 1051 root_window_ == windows[i]->GetRootWindow()) { |
| 1011 visible_window = true; | 1052 visible_window = true; |
| 1012 break; | 1053 break; |
| 1054 } |
| 1013 } | 1055 } |
| 1056 // If there are no visible windows do not hide the shelf. |
| 1057 if (!visible_window) |
| 1058 return SHELF_AUTO_HIDE_SHOWN; |
| 1014 } | 1059 } |
| 1015 // If there are no visible windows do not hide the shelf. | |
| 1016 if (!visible_window) | |
| 1017 return SHELF_AUTO_HIDE_SHOWN; | |
| 1018 | 1060 |
| 1019 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) | 1061 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) |
| 1020 return gesture_drag_auto_hide_state_; | 1062 return gesture_drag_auto_hide_state_; |
| 1021 | 1063 |
| 1022 // Don't show if the user is dragging the mouse. | 1064 // Don't show if the user is dragging the mouse. |
| 1023 if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag()) | 1065 if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag()) |
| 1024 return SHELF_AUTO_HIDE_HIDDEN; | 1066 return SHELF_AUTO_HIDE_HIDDEN; |
| 1025 | 1067 |
| 1026 // Ignore the mouse position if mouse events are disabled. | 1068 // Ignore the mouse position if mouse events are disabled. |
| 1027 aura::client::CursorClient* cursor_client = aura::client::GetCursorClient( | 1069 aura::client::CursorClient* cursor_client = aura::client::GetCursorClient( |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 UpdateBoundsAndOpacity(target_bounds, true, NULL); | 1188 UpdateBoundsAndOpacity(target_bounds, true, NULL); |
| 1147 UpdateVisibilityState(); | 1189 UpdateVisibilityState(); |
| 1148 } | 1190 } |
| 1149 | 1191 |
| 1150 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { | 1192 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { |
| 1151 UpdateVisibilityState(); | 1193 UpdateVisibilityState(); |
| 1152 LayoutShelf(); | 1194 LayoutShelf(); |
| 1153 } | 1195 } |
| 1154 | 1196 |
| 1155 } // namespace ash | 1197 } // namespace ash |
| OLD | NEW |