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> |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 private: | 206 private: |
207 ShelfLayoutManager* shelf_layout_manager_; | 207 ShelfLayoutManager* shelf_layout_manager_; |
208 | 208 |
209 DISALLOW_COPY_AND_ASSIGN(RootWindowControllerObserverImpl); | 209 DISALLOW_COPY_AND_ASSIGN(RootWindowControllerObserverImpl); |
210 }; | 210 }; |
211 | 211 |
212 // ShelfLayoutManager ---------------------------------------------------------- | 212 // ShelfLayoutManager ---------------------------------------------------------- |
213 | 213 |
214 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf) | 214 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf_widget) |
215 : SnapToPixelLayoutManager(shelf->GetNativeView()->parent()), | 215 : SnapToPixelLayoutManager(shelf_widget->GetNativeView()->parent()), |
216 root_window_(shelf->GetNativeView()->GetRootWindow()), | 216 root_window_(shelf_widget->GetNativeView()->GetRootWindow()), |
217 updating_bounds_(false), | 217 updating_bounds_(false), |
218 shelf_(shelf), | 218 shelf_widget_(shelf_widget), |
219 workspace_controller_(NULL), | 219 workspace_controller_(NULL), |
220 window_overlaps_shelf_(false), | 220 window_overlaps_shelf_(false), |
221 mouse_over_shelf_when_auto_hide_timer_started_(false), | 221 mouse_over_shelf_when_auto_hide_timer_started_(false), |
222 bezel_event_filter_(new ShelfBezelEventFilter(this)), | 222 bezel_event_filter_(new ShelfBezelEventFilter(this)), |
223 gesture_drag_status_(GESTURE_DRAG_NONE), | 223 gesture_drag_status_(GESTURE_DRAG_NONE), |
224 gesture_drag_amount_(0.f), | 224 gesture_drag_amount_(0.f), |
225 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), | 225 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), |
226 update_shelf_observer_(NULL), | 226 update_shelf_observer_(NULL), |
227 chromevox_panel_height_(0), | 227 chromevox_panel_height_(0), |
228 duration_override_in_ms_(0) { | 228 duration_override_in_ms_(0) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 set_workspace_controller(NULL); | 264 set_workspace_controller(NULL); |
265 auto_hide_event_filter_.reset(); | 265 auto_hide_event_filter_.reset(); |
266 bezel_event_filter_.reset(); | 266 bezel_event_filter_.reset(); |
267 // Stop observing window change, otherwise we can attempt to update a | 267 // Stop observing window change, otherwise we can attempt to update a |
268 // partially destructed shelf. | 268 // partially destructed shelf. |
269 aura::client::GetActivationClient(root_window_)->RemoveObserver(this); | 269 aura::client::GetActivationClient(root_window_)->RemoveObserver(this); |
270 } | 270 } |
271 | 271 |
272 bool ShelfLayoutManager::IsVisible() const { | 272 bool ShelfLayoutManager::IsVisible() const { |
273 // status_area_widget() may be NULL during the shutdown. | 273 // status_area_widget() may be NULL during the shutdown. |
274 return shelf_->status_area_widget() && | 274 return shelf_widget_->status_area_widget() && |
275 shelf_->status_area_widget()->IsVisible() && | 275 shelf_widget_->status_area_widget()->IsVisible() && |
276 (state_.visibility_state == SHELF_VISIBLE || | 276 (state_.visibility_state == SHELF_VISIBLE || |
277 (state_.visibility_state == SHELF_AUTO_HIDE && | 277 (state_.visibility_state == SHELF_AUTO_HIDE && |
278 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); | 278 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); |
279 } | 279 } |
280 | 280 |
281 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 281 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
282 gfx::Rect rect(ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView())); | 282 gfx::Rect rect( |
| 283 ScreenUtil::GetDisplayBoundsInParent(shelf_widget_->GetNativeView())); |
283 return SelectValueForShelfAlignment( | 284 return SelectValueForShelfAlignment( |
284 gfx::Rect(rect.x(), rect.bottom() - kShelfSize, rect.width(), kShelfSize), | 285 gfx::Rect(rect.x(), rect.bottom() - kShelfSize, rect.width(), kShelfSize), |
285 gfx::Rect(rect.x(), rect.y(), kShelfSize, rect.height()), | 286 gfx::Rect(rect.x(), rect.y(), kShelfSize, rect.height()), |
286 gfx::Rect(rect.right() - kShelfSize, rect.y(), kShelfSize, | 287 gfx::Rect(rect.right() - kShelfSize, rect.y(), kShelfSize, |
287 rect.height())); | 288 rect.height())); |
288 } | 289 } |
289 | 290 |
290 gfx::Size ShelfLayoutManager::GetPreferredSize() { | 291 gfx::Size ShelfLayoutManager::GetPreferredSize() { |
291 TargetBounds target_bounds; | 292 TargetBounds target_bounds; |
292 CalculateTargetBounds(state_, &target_bounds); | 293 CalculateTargetBounds(state_, &target_bounds); |
293 return target_bounds.shelf_bounds_in_root.size(); | 294 return target_bounds.shelf_bounds_in_root.size(); |
294 } | 295 } |
295 | 296 |
296 void ShelfLayoutManager::LayoutShelf() { | 297 void ShelfLayoutManager::LayoutShelf() { |
297 TargetBounds target_bounds; | 298 TargetBounds target_bounds; |
298 CalculateTargetBounds(state_, &target_bounds); | 299 CalculateTargetBounds(state_, &target_bounds); |
299 UpdateBoundsAndOpacity(target_bounds, false, NULL); | 300 UpdateBoundsAndOpacity(target_bounds, false, NULL); |
300 | 301 |
301 // Update insets in ShelfWindowTargeter when shelf bounds change. | 302 // Update insets in ShelfWindowTargeter when shelf bounds change. |
302 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 303 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
303 WillChangeVisibilityState(visibility_state())); | 304 WillChangeVisibilityState(visibility_state())); |
304 } | 305 } |
305 | 306 |
306 ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() { | 307 ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() { |
307 switch (auto_hide_behavior()) { | 308 switch (shelf_widget_->shelf()->auto_hide_behavior()) { |
308 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: | 309 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: |
309 return SHELF_AUTO_HIDE; | 310 return SHELF_AUTO_HIDE; |
310 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: | 311 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: |
311 return SHELF_VISIBLE; | 312 return SHELF_VISIBLE; |
312 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: | 313 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: |
313 return SHELF_HIDDEN; | 314 return SHELF_HIDDEN; |
314 } | 315 } |
315 return SHELF_VISIBLE; | 316 return SHELF_VISIBLE; |
316 } | 317 } |
317 | 318 |
318 void ShelfLayoutManager::UpdateVisibilityState() { | 319 void ShelfLayoutManager::UpdateVisibilityState() { |
319 // Bail out early when there is no |workspace_controller_|, which happens | 320 // Bail out early when there is no |workspace_controller_|, which happens |
320 // during shutdown after PrepareForShutdown. Also bail before a shelf exists. | 321 // during shutdown after PrepareForShutdown. Also bail before a shelf exists. |
321 if (!workspace_controller_ || !shelf_->shelf()) | 322 if (!workspace_controller_ || !shelf_widget_->shelf()) |
322 return; | 323 return; |
323 | 324 |
324 if (state_.is_screen_locked || state_.is_adding_user_screen) { | 325 if (state_.is_screen_locked || state_.is_adding_user_screen) { |
325 SetState(SHELF_VISIBLE); | 326 SetState(SHELF_VISIBLE); |
326 } else { | 327 } else { |
327 // TODO(zelidrag): Verify shelf drag animation still shows on the device | 328 // TODO(zelidrag): Verify shelf drag animation still shows on the device |
328 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. | 329 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. |
329 wm::WorkspaceWindowState window_state( | 330 wm::WorkspaceWindowState window_state( |
330 workspace_controller_->GetWindowState()); | 331 workspace_controller_->GetWindowState()); |
331 switch (window_state) { | 332 switch (window_state) { |
(...skipping 28 matching lines...) Expand all Loading... |
360 void ShelfLayoutManager::UpdateAutoHideState() { | 361 void ShelfLayoutManager::UpdateAutoHideState() { |
361 ShelfAutoHideState auto_hide_state = | 362 ShelfAutoHideState auto_hide_state = |
362 CalculateAutoHideState(state_.visibility_state); | 363 CalculateAutoHideState(state_.visibility_state); |
363 if (auto_hide_state != state_.auto_hide_state) { | 364 if (auto_hide_state != state_.auto_hide_state) { |
364 if (auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { | 365 if (auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { |
365 // Hides happen immediately. | 366 // Hides happen immediately. |
366 SetState(state_.visibility_state); | 367 SetState(state_.visibility_state); |
367 } else { | 368 } else { |
368 if (!auto_hide_timer_.IsRunning()) { | 369 if (!auto_hide_timer_.IsRunning()) { |
369 mouse_over_shelf_when_auto_hide_timer_started_ = | 370 mouse_over_shelf_when_auto_hide_timer_started_ = |
370 shelf_->GetWindowBoundsInScreen().Contains( | 371 shelf_widget_->GetWindowBoundsInScreen().Contains( |
371 display::Screen::GetScreen()->GetCursorScreenPoint()); | 372 display::Screen::GetScreen()->GetCursorScreenPoint()); |
372 } | 373 } |
373 auto_hide_timer_.Start( | 374 auto_hide_timer_.Start( |
374 FROM_HERE, | 375 FROM_HERE, |
375 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS), | 376 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS), |
376 this, &ShelfLayoutManager::UpdateAutoHideStateNow); | 377 this, &ShelfLayoutManager::UpdateAutoHideStateNow); |
377 } | 378 } |
378 } else { | 379 } else { |
379 StopAutoHideTimer(); | 380 StopAutoHideTimer(); |
380 } | 381 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 gesture.details().velocity_x() < 0); | 483 gesture.details().velocity_x() < 0); |
483 } | 484 } |
484 } else { | 485 } else { |
485 NOTREACHED(); | 486 NOTREACHED(); |
486 } | 487 } |
487 | 488 |
488 if (!should_change) { | 489 if (!should_change) { |
489 CancelGestureDrag(); | 490 CancelGestureDrag(); |
490 return; | 491 return; |
491 } | 492 } |
492 if (shelf_) { | 493 if (shelf_widget_) { |
493 shelf_->Deactivate(); | 494 shelf_widget_->Deactivate(); |
494 shelf_->status_area_widget()->Deactivate(); | 495 shelf_widget_->status_area_widget()->Deactivate(); |
495 } | 496 } |
496 gesture_drag_auto_hide_state_ = | 497 gesture_drag_auto_hide_state_ = |
497 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN ? | 498 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN ? |
498 SHELF_AUTO_HIDE_HIDDEN : SHELF_AUTO_HIDE_SHOWN; | 499 SHELF_AUTO_HIDE_HIDDEN : SHELF_AUTO_HIDE_SHOWN; |
499 ShelfAutoHideBehavior new_auto_hide_behavior = | 500 ShelfAutoHideBehavior new_auto_hide_behavior = |
500 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN ? | 501 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN ? |
501 SHELF_AUTO_HIDE_BEHAVIOR_NEVER : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | 502 SHELF_AUTO_HIDE_BEHAVIOR_NEVER : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; |
502 | 503 |
503 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide | 504 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide |
504 // behavior affects neither the visibility state nor the auto hide state. Set | 505 // behavior affects neither the visibility state nor the auto hide state. Set |
505 // |gesture_drag_status_| to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto | 506 // |gesture_drag_status_| to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto |
506 // hide state to |gesture_drag_auto_hide_state_|. | 507 // hide state to |gesture_drag_auto_hide_state_|. |
507 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; | 508 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; |
508 if (auto_hide_behavior() != new_auto_hide_behavior) | 509 Shelf* shelf = shelf_widget_->shelf(); |
509 SetAutoHideBehavior(new_auto_hide_behavior); | 510 if (shelf->auto_hide_behavior() != new_auto_hide_behavior) |
| 511 shelf->SetAutoHideBehavior(new_auto_hide_behavior); |
510 else | 512 else |
511 UpdateVisibilityState(); | 513 UpdateVisibilityState(); |
512 gesture_drag_status_ = GESTURE_DRAG_NONE; | 514 gesture_drag_status_ = GESTURE_DRAG_NONE; |
513 } | 515 } |
514 | 516 |
515 void ShelfLayoutManager::CancelGestureDrag() { | 517 void ShelfLayoutManager::CancelGestureDrag() { |
516 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; | 518 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; |
517 UpdateVisibilityState(); | 519 UpdateVisibilityState(); |
518 gesture_drag_status_ = GESTURE_DRAG_NONE; | 520 gesture_drag_status_ = GESTURE_DRAG_NONE; |
519 } | 521 } |
520 | 522 |
521 void ShelfLayoutManager::SetAnimationDurationOverride( | 523 void ShelfLayoutManager::SetAnimationDurationOverride( |
522 int duration_override_in_ms) { | 524 int duration_override_in_ms) { |
523 duration_override_in_ms_ = duration_override_in_ms; | 525 duration_override_in_ms_ = duration_override_in_ms; |
524 } | 526 } |
525 | 527 |
526 //////////////////////////////////////////////////////////////////////////////// | 528 //////////////////////////////////////////////////////////////////////////////// |
527 // ShelfLayoutManager, aura::LayoutManager implementation: | 529 // ShelfLayoutManager, aura::LayoutManager implementation: |
528 | 530 |
529 void ShelfLayoutManager::OnWindowResized() { | 531 void ShelfLayoutManager::OnWindowResized() { |
530 LayoutShelf(); | 532 LayoutShelf(); |
531 } | 533 } |
532 | 534 |
533 void ShelfLayoutManager::SetChildBounds(aura::Window* child, | 535 void ShelfLayoutManager::SetChildBounds(aura::Window* child, |
534 const gfx::Rect& requested_bounds) { | 536 const gfx::Rect& requested_bounds) { |
535 SnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); | 537 SnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); |
536 // We may contain other widgets (such as frame maximize bubble) but they don't | 538 // We may contain other widgets (such as frame maximize bubble) but they don't |
537 // effect the layout in anyway. | 539 // effect the layout in anyway. |
538 if (!updating_bounds_ && | 540 if (!updating_bounds_ && |
539 ((shelf_->GetNativeView() == child) || | 541 ((shelf_widget_->GetNativeView() == child) || |
540 (shelf_->status_area_widget()->GetNativeView() == child))) { | 542 (shelf_widget_->status_area_widget()->GetNativeView() == child))) { |
541 LayoutShelf(); | 543 LayoutShelf(); |
542 } | 544 } |
543 } | 545 } |
544 | 546 |
545 void ShelfLayoutManager::OnLockStateChanged(bool locked) { | 547 void ShelfLayoutManager::OnLockStateChanged(bool locked) { |
546 // Force the shelf to layout for alignment (bottom if locked, restore | 548 // Force the shelf to layout for alignment (bottom if locked, restore |
547 // the previous alignment otherwise). | 549 // the previous alignment otherwise). |
548 state_.is_screen_locked = locked; | 550 state_.is_screen_locked = locked; |
549 UpdateShelfVisibilityAfterLoginUIChange(); | 551 UpdateShelfVisibilityAfterLoginUIChange(); |
550 } | 552 } |
(...skipping 26 matching lines...) Expand all Loading... |
577 | 579 |
578 //////////////////////////////////////////////////////////////////////////////// | 580 //////////////////////////////////////////////////////////////////////////////// |
579 // ShelfLayoutManager, private: | 581 // ShelfLayoutManager, private: |
580 | 582 |
581 ShelfLayoutManager::TargetBounds::TargetBounds() | 583 ShelfLayoutManager::TargetBounds::TargetBounds() |
582 : opacity(0.0f), status_opacity(0.0f) {} | 584 : opacity(0.0f), status_opacity(0.0f) {} |
583 | 585 |
584 ShelfLayoutManager::TargetBounds::~TargetBounds() {} | 586 ShelfLayoutManager::TargetBounds::~TargetBounds() {} |
585 | 587 |
586 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { | 588 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { |
587 if (!shelf_->GetNativeView()) | 589 if (!shelf_widget_->GetNativeView()) |
588 return; | 590 return; |
589 | 591 |
590 State state; | 592 State state; |
591 state.visibility_state = visibility_state; | 593 state.visibility_state = visibility_state; |
592 state.auto_hide_state = CalculateAutoHideState(visibility_state); | 594 state.auto_hide_state = CalculateAutoHideState(visibility_state); |
593 state.window_state = workspace_controller_ | 595 state.window_state = workspace_controller_ |
594 ? workspace_controller_->GetWindowState() | 596 ? workspace_controller_->GetWindowState() |
595 : wm::WORKSPACE_WINDOW_STATE_DEFAULT; | 597 : wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
596 // Preserve the log in screen states. | 598 // Preserve the log in screen states. |
597 state.is_adding_user_screen = state_.is_adding_user_screen; | 599 state.is_adding_user_screen = state_.is_adding_user_screen; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 | 653 |
652 if (delay_background_change) { | 654 if (delay_background_change) { |
653 if (update_shelf_observer_) | 655 if (update_shelf_observer_) |
654 update_shelf_observer_->Detach(); | 656 update_shelf_observer_->Detach(); |
655 // UpdateShelfBackground deletes itself when the animation is done. | 657 // UpdateShelfBackground deletes itself when the animation is done. |
656 update_shelf_observer_ = new UpdateShelfObserver(this); | 658 update_shelf_observer_ = new UpdateShelfObserver(this); |
657 } else { | 659 } else { |
658 UpdateShelfBackground(change_type); | 660 UpdateShelfBackground(change_type); |
659 } | 661 } |
660 | 662 |
661 shelf_->SetDimsShelf(state.visibility_state == SHELF_VISIBLE && | 663 shelf_widget_->SetDimsShelf(state.visibility_state == SHELF_VISIBLE && |
662 state.window_state == | 664 state.window_state == |
663 wm::WORKSPACE_WINDOW_STATE_MAXIMIZED); | 665 wm::WORKSPACE_WINDOW_STATE_MAXIMIZED); |
664 | 666 |
665 TargetBounds target_bounds; | 667 TargetBounds target_bounds; |
666 CalculateTargetBounds(state_, &target_bounds); | 668 CalculateTargetBounds(state_, &target_bounds); |
667 UpdateBoundsAndOpacity(target_bounds, true, | 669 UpdateBoundsAndOpacity(target_bounds, true, |
668 delay_background_change ? update_shelf_observer_ : NULL); | 670 delay_background_change ? update_shelf_observer_ : NULL); |
669 | 671 |
670 // The delegate must be notified after |state_| is updated so that it can | 672 // The delegate must be notified after |state_| is updated so that it can |
671 // query the new target bounds. | 673 // query the new target bounds. |
672 ShelfDelegate* shelf_delegate = Shell::GetInstance()->GetShelfDelegate(); | 674 ShelfDelegate* shelf_delegate = Shell::GetInstance()->GetShelfDelegate(); |
673 if (old_state.visibility_state != state_.visibility_state) | 675 if (old_state.visibility_state != state_.visibility_state) |
674 shelf_delegate->OnShelfVisibilityStateChanged(shelf_->shelf()); | 676 shelf_delegate->OnShelfVisibilityStateChanged(shelf_widget_->shelf()); |
675 | 677 |
676 // OnAutoHideStateChanged Should be emitted when: | 678 // OnAutoHideStateChanged Should be emitted when: |
677 // - firstly state changed to auto-hide from other state | 679 // - firstly state changed to auto-hide from other state |
678 // - or, auto_hide_state has changed | 680 // - or, auto_hide_state has changed |
679 if ((old_state.visibility_state != state_.visibility_state && | 681 if ((old_state.visibility_state != state_.visibility_state && |
680 state_.visibility_state == SHELF_AUTO_HIDE) || | 682 state_.visibility_state == SHELF_AUTO_HIDE) || |
681 old_state.auto_hide_state != state_.auto_hide_state) { | 683 old_state.auto_hide_state != state_.auto_hide_state) { |
682 shelf_delegate->OnShelfAutoHideStateChanged(shelf_->shelf()); | 684 shelf_delegate->OnShelfAutoHideStateChanged(shelf_widget_->shelf()); |
683 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 685 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
684 OnAutoHideStateChanged(state_.auto_hide_state)); | 686 OnAutoHideStateChanged(state_.auto_hide_state)); |
685 } | 687 } |
686 } | 688 } |
687 | 689 |
688 void ShelfLayoutManager::UpdateBoundsAndOpacity( | 690 void ShelfLayoutManager::UpdateBoundsAndOpacity( |
689 const TargetBounds& target_bounds, | 691 const TargetBounds& target_bounds, |
690 bool animate, | 692 bool animate, |
691 ui::ImplicitAnimationObserver* observer) { | 693 ui::ImplicitAnimationObserver* observer) { |
692 base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true); | 694 base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true); |
693 { | 695 { |
694 ui::ScopedLayerAnimationSettings shelf_animation_setter( | 696 ui::ScopedLayerAnimationSettings shelf_animation_setter( |
695 GetLayer(shelf_)->GetAnimator()); | 697 GetLayer(shelf_widget_)->GetAnimator()); |
696 ui::ScopedLayerAnimationSettings status_animation_setter( | 698 ui::ScopedLayerAnimationSettings status_animation_setter( |
697 GetLayer(shelf_->status_area_widget())->GetAnimator()); | 699 GetLayer(shelf_widget_->status_area_widget())->GetAnimator()); |
698 if (animate) { | 700 if (animate) { |
699 int duration = duration_override_in_ms_ ? duration_override_in_ms_ : | 701 int duration = duration_override_in_ms_ ? duration_override_in_ms_ : |
700 kCrossFadeDurationMS; | 702 kCrossFadeDurationMS; |
701 shelf_animation_setter.SetTransitionDuration( | 703 shelf_animation_setter.SetTransitionDuration( |
702 base::TimeDelta::FromMilliseconds(duration)); | 704 base::TimeDelta::FromMilliseconds(duration)); |
703 shelf_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); | 705 shelf_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); |
704 shelf_animation_setter.SetPreemptionStrategy( | 706 shelf_animation_setter.SetPreemptionStrategy( |
705 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 707 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
706 status_animation_setter.SetTransitionDuration( | 708 status_animation_setter.SetTransitionDuration( |
707 base::TimeDelta::FromMilliseconds(duration)); | 709 base::TimeDelta::FromMilliseconds(duration)); |
708 status_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); | 710 status_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); |
709 status_animation_setter.SetPreemptionStrategy( | 711 status_animation_setter.SetPreemptionStrategy( |
710 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 712 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
711 } else { | 713 } else { |
712 StopAnimating(); | 714 StopAnimating(); |
713 shelf_animation_setter.SetTransitionDuration(base::TimeDelta()); | 715 shelf_animation_setter.SetTransitionDuration(base::TimeDelta()); |
714 status_animation_setter.SetTransitionDuration(base::TimeDelta()); | 716 status_animation_setter.SetTransitionDuration(base::TimeDelta()); |
715 } | 717 } |
716 if (observer) | 718 if (observer) |
717 status_animation_setter.AddObserver(observer); | 719 status_animation_setter.AddObserver(observer); |
718 | 720 |
719 GetLayer(shelf_)->SetOpacity(target_bounds.opacity); | 721 GetLayer(shelf_widget_)->SetOpacity(target_bounds.opacity); |
720 // mash::wm::ShelfLayout manages window bounds when running in mash. | 722 // mash::wm::ShelfLayout manages window bounds when running in mash. |
721 if (!Shell::GetInstance()->in_mus()) { | 723 if (!Shell::GetInstance()->in_mus()) { |
722 shelf_->SetBounds(ScreenUtil::ConvertRectToScreen( | 724 shelf_widget_->SetBounds(ScreenUtil::ConvertRectToScreen( |
723 shelf_->GetNativeView()->parent(), | 725 shelf_widget_->GetNativeView()->parent(), |
724 target_bounds.shelf_bounds_in_root)); | 726 target_bounds.shelf_bounds_in_root)); |
725 } | 727 } |
726 | 728 |
727 GetLayer(shelf_->status_area_widget())->SetOpacity( | 729 GetLayer(shelf_widget_->status_area_widget()) |
728 target_bounds.status_opacity); | 730 ->SetOpacity(target_bounds.status_opacity); |
729 | 731 |
730 // Having a window which is visible but does not have an opacity is an | 732 // Having a window which is visible but does not have an opacity is an |
731 // illegal state. We therefore hide the shelf here if required. | 733 // illegal state. We therefore hide the shelf here if required. |
732 if (!target_bounds.status_opacity) | 734 if (!target_bounds.status_opacity) |
733 shelf_->status_area_widget()->Hide(); | 735 shelf_widget_->status_area_widget()->Hide(); |
734 // Setting visibility during an animation causes the visibility property to | 736 // Setting visibility during an animation causes the visibility property to |
735 // animate. Override the animation settings to immediately set the | 737 // animate. Override the animation settings to immediately set the |
736 // visibility property. Opacity will still animate. | 738 // visibility property. Opacity will still animate. |
737 | 739 |
738 // TODO(harrym): Once status area widget is a child view of shelf | 740 // TODO(harrym): Once status area widget is a child view of shelf |
739 // this can be simplified. | 741 // this can be simplified. |
740 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; | 742 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; |
741 status_bounds.Offset(target_bounds.shelf_bounds_in_root.OffsetFromOrigin()); | 743 status_bounds.Offset(target_bounds.shelf_bounds_in_root.OffsetFromOrigin()); |
742 // mash::wm::ShelfLayout manages window bounds when running mash. | 744 // mash::wm::ShelfLayout manages window bounds when running mash. |
743 if (!Shell::GetInstance()->in_mus()) { | 745 if (!Shell::GetInstance()->in_mus()) { |
744 shelf_->status_area_widget()->SetBounds( | 746 shelf_widget_->status_area_widget()->SetBounds( |
745 ScreenUtil::ConvertRectToScreen( | 747 ScreenUtil::ConvertRectToScreen( |
746 shelf_->status_area_widget()->GetNativeView()->parent(), | 748 shelf_widget_->status_area_widget()->GetNativeView()->parent(), |
747 status_bounds)); | 749 status_bounds)); |
748 } | 750 } |
749 if (!state_.is_screen_locked) { | 751 if (!state_.is_screen_locked) { |
750 gfx::Insets insets; | 752 gfx::Insets insets; |
751 // If user session is blocked (login to new user session or add user to | 753 // If user session is blocked (login to new user session or add user to |
752 // the existing session - multi-profile) then give 100% of work area only | 754 // the existing session - multi-profile) then give 100% of work area only |
753 // if keyboard is not shown. | 755 // if keyboard is not shown. |
754 if (!state_.is_adding_user_screen || !keyboard_bounds_.IsEmpty()) | 756 if (!state_.is_adding_user_screen || !keyboard_bounds_.IsEmpty()) |
755 insets = target_bounds.work_area_insets; | 757 insets = target_bounds.work_area_insets; |
756 Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets); | 758 Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets); |
757 } | 759 } |
758 } | 760 } |
759 | 761 |
760 // Set an empty border to avoid the shelf view and status area overlapping. | 762 // Set an empty border to avoid the shelf view and status area overlapping. |
761 // TODO(msw): Avoid setting bounds of views within the shelf widget here. | 763 // TODO(msw): Avoid setting bounds of views within the shelf widget here. |
762 gfx::Rect shelf_bounds = gfx::Rect(target_bounds.shelf_bounds_in_root.size()); | 764 gfx::Rect shelf_bounds = gfx::Rect(target_bounds.shelf_bounds_in_root.size()); |
763 shelf_->GetContentsView()->SetBorder(views::Border::CreateEmptyBorder( | 765 shelf_widget_->GetContentsView()->SetBorder(views::Border::CreateEmptyBorder( |
764 shelf_bounds.InsetsFrom(target_bounds.shelf_bounds_in_shelf))); | 766 shelf_bounds.InsetsFrom(target_bounds.shelf_bounds_in_shelf))); |
765 shelf_->GetContentsView()->Layout(); | 767 shelf_widget_->GetContentsView()->Layout(); |
766 | 768 |
767 // Setting visibility during an animation causes the visibility property to | 769 // Setting visibility during an animation causes the visibility property to |
768 // animate. Set the visibility property without an animation. | 770 // animate. Set the visibility property without an animation. |
769 if (target_bounds.status_opacity) | 771 if (target_bounds.status_opacity) |
770 shelf_->status_area_widget()->Show(); | 772 shelf_widget_->status_area_widget()->Show(); |
771 } | 773 } |
772 | 774 |
773 void ShelfLayoutManager::StopAnimating() { | 775 void ShelfLayoutManager::StopAnimating() { |
774 GetLayer(shelf_)->GetAnimator()->StopAnimating(); | 776 GetLayer(shelf_widget_)->GetAnimator()->StopAnimating(); |
775 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); | 777 GetLayer(shelf_widget_->status_area_widget())->GetAnimator()->StopAnimating(); |
776 } | 778 } |
777 | 779 |
778 void ShelfLayoutManager::CalculateTargetBounds(const State& state, | 780 void ShelfLayoutManager::CalculateTargetBounds(const State& state, |
779 TargetBounds* target_bounds) { | 781 TargetBounds* target_bounds) { |
780 int shelf_size = kShelfSize; | 782 int shelf_size = kShelfSize; |
781 if (state.visibility_state == SHELF_AUTO_HIDE && | 783 if (state.visibility_state == SHELF_AUTO_HIDE && |
782 state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { | 784 state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { |
783 // Auto-hidden shelf always starts with the default size. If a gesture-drag | 785 // Auto-hidden shelf always starts with the default size. If a gesture-drag |
784 // is in progress, then the call to UpdateTargetBoundsForGesture() below | 786 // is in progress, then the call to UpdateTargetBoundsForGesture() below |
785 // takes care of setting the height properly. | 787 // takes care of setting the height properly. |
(...skipping 15 matching lines...) Expand all Loading... |
801 bottom_shelf_vertical_offset -= keyboard_bounds_.height(); | 803 bottom_shelf_vertical_offset -= keyboard_bounds_.height(); |
802 | 804 |
803 gfx::Point shelf_origin = SelectValueForShelfAlignment( | 805 gfx::Point shelf_origin = SelectValueForShelfAlignment( |
804 gfx::Point(available_bounds.x(), bottom_shelf_vertical_offset), | 806 gfx::Point(available_bounds.x(), bottom_shelf_vertical_offset), |
805 gfx::Point(available_bounds.x(), available_bounds.y()), | 807 gfx::Point(available_bounds.x(), available_bounds.y()), |
806 gfx::Point(available_bounds.right() - shelf_width, available_bounds.y())); | 808 gfx::Point(available_bounds.right() - shelf_width, available_bounds.y())); |
807 target_bounds->shelf_bounds_in_root = | 809 target_bounds->shelf_bounds_in_root = |
808 gfx::Rect(shelf_origin.x(), shelf_origin.y(), shelf_width, shelf_height); | 810 gfx::Rect(shelf_origin.x(), shelf_origin.y(), shelf_width, shelf_height); |
809 | 811 |
810 gfx::Size status_size( | 812 gfx::Size status_size( |
811 shelf_->status_area_widget()->GetWindowBoundsInScreen().size()); | 813 shelf_widget_->status_area_widget()->GetWindowBoundsInScreen().size()); |
812 if (IsHorizontalAlignment()) | 814 if (IsHorizontalAlignment()) |
813 status_size.set_height(kShelfSize); | 815 status_size.set_height(kShelfSize); |
814 else | 816 else |
815 status_size.set_width(kShelfSize); | 817 status_size.set_width(kShelfSize); |
816 | 818 |
817 gfx::Point status_origin = SelectValueForShelfAlignment( | 819 gfx::Point status_origin = SelectValueForShelfAlignment( |
818 gfx::Point(0, 0), | 820 gfx::Point(0, 0), |
819 gfx::Point(shelf_width - status_size.width(), | 821 gfx::Point(shelf_width - status_size.width(), |
820 shelf_height - status_size.height()), | 822 shelf_height - status_size.height()), |
821 gfx::Point(0, shelf_height - status_size.height())); | 823 gfx::Point(0, shelf_height - status_size.height())); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 else | 949 else |
948 target_bounds->status_bounds_in_shelf.set_x( | 950 target_bounds->status_bounds_in_shelf.set_x( |
949 target_bounds->shelf_bounds_in_root.width() - | 951 target_bounds->shelf_bounds_in_root.width() - |
950 kShelfSize); | 952 kShelfSize); |
951 } | 953 } |
952 } | 954 } |
953 | 955 |
954 void ShelfLayoutManager::UpdateShelfBackground( | 956 void ShelfLayoutManager::UpdateShelfBackground( |
955 BackgroundAnimatorChangeType type) { | 957 BackgroundAnimatorChangeType type) { |
956 const wm::ShelfBackgroundType background_type(GetShelfBackgroundType()); | 958 const wm::ShelfBackgroundType background_type(GetShelfBackgroundType()); |
957 shelf_->SetPaintsBackground(background_type, type); | 959 shelf_widget_->SetPaintsBackground(background_type, type); |
958 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 960 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
959 OnBackgroundUpdated(background_type, type)); | 961 OnBackgroundUpdated(background_type, type)); |
960 } | 962 } |
961 | 963 |
962 wm::ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { | 964 wm::ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { |
963 if (state_.visibility_state != SHELF_AUTO_HIDE && | 965 if (state_.visibility_state != SHELF_AUTO_HIDE && |
964 state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) { | 966 state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) { |
965 return wm::SHELF_BACKGROUND_MAXIMIZED; | 967 return wm::SHELF_BACKGROUND_MAXIMIZED; |
966 } | 968 } |
967 | 969 |
(...skipping 13 matching lines...) Expand all Loading... |
981 // If the state did not change, the auto hide timer may still be running. | 983 // If the state did not change, the auto hide timer may still be running. |
982 StopAutoHideTimer(); | 984 StopAutoHideTimer(); |
983 } | 985 } |
984 | 986 |
985 void ShelfLayoutManager::StopAutoHideTimer() { | 987 void ShelfLayoutManager::StopAutoHideTimer() { |
986 auto_hide_timer_.Stop(); | 988 auto_hide_timer_.Stop(); |
987 mouse_over_shelf_when_auto_hide_timer_started_ = false; | 989 mouse_over_shelf_when_auto_hide_timer_started_ = false; |
988 } | 990 } |
989 | 991 |
990 gfx::Rect ShelfLayoutManager::GetAutoHideShowShelfRegionInScreen() const { | 992 gfx::Rect ShelfLayoutManager::GetAutoHideShowShelfRegionInScreen() const { |
991 gfx::Rect shelf_bounds_in_screen = shelf_->GetWindowBoundsInScreen(); | 993 gfx::Rect shelf_bounds_in_screen = shelf_widget_->GetWindowBoundsInScreen(); |
992 gfx::Vector2d offset = SelectValueForShelfAlignment( | 994 gfx::Vector2d offset = SelectValueForShelfAlignment( |
993 gfx::Vector2d(0, shelf_bounds_in_screen.height()), | 995 gfx::Vector2d(0, shelf_bounds_in_screen.height()), |
994 gfx::Vector2d(-kMaxAutoHideShowShelfRegionSize, 0), | 996 gfx::Vector2d(-kMaxAutoHideShowShelfRegionSize, 0), |
995 gfx::Vector2d(shelf_bounds_in_screen.width(), 0)); | 997 gfx::Vector2d(shelf_bounds_in_screen.width(), 0)); |
996 | 998 |
997 gfx::Rect show_shelf_region_in_screen = shelf_bounds_in_screen; | 999 gfx::Rect show_shelf_region_in_screen = shelf_bounds_in_screen; |
998 show_shelf_region_in_screen += offset; | 1000 show_shelf_region_in_screen += offset; |
999 if (IsHorizontalAlignment()) | 1001 if (IsHorizontalAlignment()) |
1000 show_shelf_region_in_screen.set_height(kMaxAutoHideShowShelfRegionSize); | 1002 show_shelf_region_in_screen.set_height(kMaxAutoHideShowShelfRegionSize); |
1001 else | 1003 else |
1002 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize); | 1004 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize); |
1003 | 1005 |
1004 // TODO: Figure out if we need any special handling when the keyboard is | 1006 // TODO: Figure out if we need any special handling when the keyboard is |
1005 // visible. | 1007 // visible. |
1006 return show_shelf_region_in_screen; | 1008 return show_shelf_region_in_screen; |
1007 } | 1009 } |
1008 | 1010 |
1009 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( | 1011 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( |
1010 ShelfVisibilityState visibility_state) const { | 1012 ShelfVisibilityState visibility_state) const { |
1011 if (visibility_state != SHELF_AUTO_HIDE || !shelf_ || !shelf_->shelf()) | 1013 if (visibility_state != SHELF_AUTO_HIDE || !shelf_widget_ || |
| 1014 !shelf_widget_->shelf()) |
1012 return SHELF_AUTO_HIDE_HIDDEN; | 1015 return SHELF_AUTO_HIDE_HIDDEN; |
1013 | 1016 |
1014 Shell* shell = Shell::GetInstance(); | 1017 Shell* shell = Shell::GetInstance(); |
1015 // Unhide the shelf only on the active screen when the AppList is shown | 1018 // Unhide the shelf only on the active screen when the AppList is shown |
1016 // (crbug.com/312445). | 1019 // (crbug.com/312445). |
1017 if (shell->GetAppListTargetVisibility()) { | 1020 if (shell->GetAppListTargetVisibility()) { |
1018 aura::Window* active_window = wm::GetActiveWindow(); | 1021 aura::Window* active_window = wm::GetActiveWindow(); |
1019 aura::Window* shelf_window = shelf_->GetNativeWindow(); | 1022 aura::Window* shelf_window = shelf_widget_->GetNativeWindow(); |
1020 if (active_window && shelf_window && | 1023 if (active_window && shelf_window && |
1021 active_window->GetRootWindow() == shelf_window->GetRootWindow()) { | 1024 active_window->GetRootWindow() == shelf_window->GetRootWindow()) { |
1022 return SHELF_AUTO_HIDE_SHOWN; | 1025 return SHELF_AUTO_HIDE_SHOWN; |
1023 } | 1026 } |
1024 } | 1027 } |
1025 | 1028 |
1026 if (shelf_->status_area_widget() && | 1029 if (shelf_widget_->status_area_widget() && |
1027 shelf_->status_area_widget()->ShouldShowShelf()) | 1030 shelf_widget_->status_area_widget()->ShouldShowShelf()) |
1028 return SHELF_AUTO_HIDE_SHOWN; | 1031 return SHELF_AUTO_HIDE_SHOWN; |
1029 | 1032 |
1030 if (shelf_->shelf() && shelf_->shelf()->IsShowingMenu()) | 1033 if (shelf_widget_->shelf() && shelf_widget_->shelf()->IsShowingMenu()) |
1031 return SHELF_AUTO_HIDE_SHOWN; | 1034 return SHELF_AUTO_HIDE_SHOWN; |
1032 | 1035 |
1033 if (shelf_->shelf() && shelf_->shelf()->IsShowingOverflowBubble()) | 1036 if (shelf_widget_->shelf() && |
| 1037 shelf_widget_->shelf()->IsShowingOverflowBubble()) |
1034 return SHELF_AUTO_HIDE_SHOWN; | 1038 return SHELF_AUTO_HIDE_SHOWN; |
1035 | 1039 |
1036 if (shelf_->IsActive() || | 1040 if (shelf_widget_->IsActive() || |
1037 (shelf_->status_area_widget() && | 1041 (shelf_widget_->status_area_widget() && |
1038 shelf_->status_area_widget()->IsActive())) | 1042 shelf_widget_->status_area_widget()->IsActive())) |
1039 return SHELF_AUTO_HIDE_SHOWN; | 1043 return SHELF_AUTO_HIDE_SHOWN; |
1040 | 1044 |
1041 // TODO(jamescook): Track visible windows on mash via ShelfDelegate. | 1045 // TODO(jamescook): Track visible windows on mash via ShelfDelegate. |
1042 if (!Shell::GetInstance()->in_mus()) { | 1046 if (!Shell::GetInstance()->in_mus()) { |
1043 const std::vector<aura::Window*> windows = | 1047 const std::vector<aura::Window*> windows = |
1044 shell->mru_window_tracker()->BuildWindowListIgnoreModal(); | 1048 shell->mru_window_tracker()->BuildWindowListIgnoreModal(); |
1045 | 1049 |
1046 // Process the window list and check if there are any visible windows. | 1050 // Process the window list and check if there are any visible windows. |
1047 bool visible_window = false; | 1051 bool visible_window = false; |
1048 for (size_t i = 0; i < windows.size(); ++i) { | 1052 for (size_t i = 0; i < windows.size(); ++i) { |
(...skipping 11 matching lines...) Expand all Loading... |
1060 | 1064 |
1061 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) | 1065 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) |
1062 return gesture_drag_auto_hide_state_; | 1066 return gesture_drag_auto_hide_state_; |
1063 | 1067 |
1064 // Don't show if the user is dragging the mouse. | 1068 // Don't show if the user is dragging the mouse. |
1065 if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag()) | 1069 if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag()) |
1066 return SHELF_AUTO_HIDE_HIDDEN; | 1070 return SHELF_AUTO_HIDE_HIDDEN; |
1067 | 1071 |
1068 // Ignore the mouse position if mouse events are disabled. | 1072 // Ignore the mouse position if mouse events are disabled. |
1069 aura::client::CursorClient* cursor_client = aura::client::GetCursorClient( | 1073 aura::client::CursorClient* cursor_client = aura::client::GetCursorClient( |
1070 shelf_->GetNativeWindow()->GetRootWindow()); | 1074 shelf_widget_->GetNativeWindow()->GetRootWindow()); |
1071 if (!cursor_client->IsMouseEventsEnabled()) | 1075 if (!cursor_client->IsMouseEventsEnabled()) |
1072 return SHELF_AUTO_HIDE_HIDDEN; | 1076 return SHELF_AUTO_HIDE_HIDDEN; |
1073 | 1077 |
1074 gfx::Rect shelf_region = shelf_->GetWindowBoundsInScreen(); | 1078 gfx::Rect shelf_region = shelf_widget_->GetWindowBoundsInScreen(); |
1075 if (shelf_->status_area_widget() && | 1079 if (shelf_widget_->status_area_widget() && |
1076 shelf_->status_area_widget()->IsMessageBubbleShown() && | 1080 shelf_widget_->status_area_widget()->IsMessageBubbleShown() && |
1077 IsVisible()) { | 1081 IsVisible()) { |
1078 // Increase the the hit test area to prevent the shelf from disappearing | 1082 // Increase the the hit test area to prevent the shelf from disappearing |
1079 // when the mouse is over the bubble gap. | 1083 // when the mouse is over the bubble gap. |
1080 wm::ShelfAlignment alignment = GetAlignment(); | 1084 wm::ShelfAlignment alignment = GetAlignment(); |
1081 shelf_region.Inset( | 1085 shelf_region.Inset( |
1082 alignment == wm::SHELF_ALIGNMENT_RIGHT ? -kNotificationBubbleGapHeight | 1086 alignment == wm::SHELF_ALIGNMENT_RIGHT ? -kNotificationBubbleGapHeight |
1083 : 0, | 1087 : 0, |
1084 IsHorizontalAlignment() ? -kNotificationBubbleGapHeight : 0, | 1088 IsHorizontalAlignment() ? -kNotificationBubbleGapHeight : 0, |
1085 alignment == wm::SHELF_ALIGNMENT_LEFT ? -kNotificationBubbleGapHeight | 1089 alignment == wm::SHELF_ALIGNMENT_LEFT ? -kNotificationBubbleGapHeight |
1086 : 0, | 1090 : 0, |
(...skipping 23 matching lines...) Expand all Loading... |
1110 cursor_position_in_screen)) { | 1114 cursor_position_in_screen)) { |
1111 return SHELF_AUTO_HIDE_SHOWN; | 1115 return SHELF_AUTO_HIDE_SHOWN; |
1112 } | 1116 } |
1113 | 1117 |
1114 return SHELF_AUTO_HIDE_HIDDEN; | 1118 return SHELF_AUTO_HIDE_HIDDEN; |
1115 } | 1119 } |
1116 | 1120 |
1117 bool ShelfLayoutManager::IsShelfWindow(aura::Window* window) { | 1121 bool ShelfLayoutManager::IsShelfWindow(aura::Window* window) { |
1118 if (!window) | 1122 if (!window) |
1119 return false; | 1123 return false; |
1120 return (shelf_ && shelf_->GetNativeWindow()->Contains(window)) || | 1124 return (shelf_widget_ && |
1121 (shelf_->status_area_widget() && | 1125 shelf_widget_->GetNativeWindow()->Contains(window)) || |
1122 shelf_->status_area_widget()->GetNativeWindow()->Contains(window)); | 1126 (shelf_widget_->status_area_widget() && |
| 1127 shelf_widget_->status_area_widget()->GetNativeWindow()->Contains( |
| 1128 window)); |
1123 } | 1129 } |
1124 | 1130 |
1125 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 1131 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
1126 if (state.visibility_state == SHELF_VISIBLE) | 1132 if (state.visibility_state == SHELF_VISIBLE) |
1127 return size; | 1133 return size; |
1128 if (state.visibility_state == SHELF_AUTO_HIDE) | 1134 if (state.visibility_state == SHELF_AUTO_HIDE) |
1129 return kAutoHideSize; | 1135 return kAutoHideSize; |
1130 return 0; | 1136 return 0; |
1131 } | 1137 } |
1132 | 1138 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 UpdateBoundsAndOpacity(target_bounds, true, NULL); | 1194 UpdateBoundsAndOpacity(target_bounds, true, NULL); |
1189 UpdateVisibilityState(); | 1195 UpdateVisibilityState(); |
1190 } | 1196 } |
1191 | 1197 |
1192 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { | 1198 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { |
1193 UpdateVisibilityState(); | 1199 UpdateVisibilityState(); |
1194 LayoutShelf(); | 1200 LayoutShelf(); |
1195 } | 1201 } |
1196 | 1202 |
1197 } // namespace ash | 1203 } // namespace ash |
OLD | NEW |