OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/wm/immersive_fullscreen_controller.h" | 5 #include "ash/wm/immersive_fullscreen_controller.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // Reset the located event and the focus revealed locks so that they do not | 280 // Reset the located event and the focus revealed locks so that they do not |
281 // affect whether the top-of-window views are hidden. | 281 // affect whether the top-of-window views are hidden. |
282 located_event_revealed_lock_.reset(); | 282 located_event_revealed_lock_.reset(); |
283 focus_revealed_lock_.reset(); | 283 focus_revealed_lock_.reset(); |
284 | 284 |
285 // Try doing the animation. | 285 // Try doing the animation. |
286 MaybeEndReveal(ANIMATE_SLOW); | 286 MaybeEndReveal(ANIMATE_SLOW); |
287 | 287 |
288 if (reveal_state_ == REVEALED) { | 288 if (reveal_state_ == REVEALED) { |
289 // Reveal was unsuccessful. Reacquire the revealed locks if appropriate. | 289 // Reveal was unsuccessful. Reacquire the revealed locks if appropriate. |
290 UpdateLocatedEventRevealedLock(NULL, ALLOW_REVEAL_WHILE_CLOSING_NO); | 290 UpdateLocatedEventRevealedLock(NULL); |
291 UpdateFocusRevealedLock(); | 291 UpdateFocusRevealedLock(); |
292 } | 292 } |
293 } else { | 293 } else { |
294 // Stop cursor-at-top tracking. | 294 // Stop cursor-at-top tracking. |
295 top_edge_hover_timer_.Stop(); | 295 top_edge_hover_timer_.Stop(); |
296 reveal_state_ = CLOSED; | 296 reveal_state_ = CLOSED; |
297 | 297 |
298 delegate_->OnImmersiveFullscreenExited(); | 298 delegate_->OnImmersiveFullscreenExited(); |
299 } | 299 } |
300 } | 300 } |
(...skipping 24 matching lines...) Expand all Loading... |
325 std::vector<gfx::Rect> bounds_in_screen( | 325 std::vector<gfx::Rect> bounds_in_screen( |
326 delegate_->GetVisibleBoundsInScreen()); | 326 delegate_->GetVisibleBoundsInScreen()); |
327 DCHECK(!bounds_in_screen.empty()); | 327 DCHECK(!bounds_in_screen.empty()); |
328 int bottommost_in_screen = bounds_in_screen[0].bottom(); | 328 int bottommost_in_screen = bounds_in_screen[0].bottom(); |
329 for (size_t i = 1; i < bounds_in_screen.size(); ++i) { | 329 for (size_t i = 1; i < bounds_in_screen.size(); ++i) { |
330 if (bounds_in_screen[i].bottom() > bottommost_in_screen) | 330 if (bounds_in_screen[i].bottom() > bottommost_in_screen) |
331 bottommost_in_screen = bounds_in_screen[i].bottom(); | 331 bottommost_in_screen = bounds_in_screen[i].bottom(); |
332 } | 332 } |
333 gfx::Point cursor_pos(0, bottommost_in_screen + 100); | 333 gfx::Point cursor_pos(0, bottommost_in_screen + 100); |
334 aura::Env::GetInstance()->set_last_mouse_location(cursor_pos); | 334 aura::Env::GetInstance()->set_last_mouse_location(cursor_pos); |
335 UpdateLocatedEventRevealedLock(NULL, ALLOW_REVEAL_WHILE_CLOSING_NO); | 335 UpdateLocatedEventRevealedLock(NULL); |
336 } | 336 } |
337 | 337 |
338 //////////////////////////////////////////////////////////////////////////////// | 338 //////////////////////////////////////////////////////////////////////////////// |
339 // ui::EventHandler overrides: | 339 // ui::EventHandler overrides: |
340 | 340 |
341 void ImmersiveFullscreenController::OnMouseEvent(ui::MouseEvent* event) { | 341 void ImmersiveFullscreenController::OnMouseEvent(ui::MouseEvent* event) { |
342 if (!enabled_) | 342 if (!enabled_) |
343 return; | 343 return; |
344 | 344 |
345 if (event->type() != ui::ET_MOUSE_MOVED && | 345 if (event->type() != ui::ET_MOUSE_MOVED && |
346 event->type() != ui::ET_MOUSE_PRESSED && | 346 event->type() != ui::ET_MOUSE_PRESSED && |
347 event->type() != ui::ET_MOUSE_RELEASED && | 347 event->type() != ui::ET_MOUSE_RELEASED && |
348 event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) { | 348 event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) { |
349 return; | 349 return; |
350 } | 350 } |
351 | 351 |
352 // Mouse hover should not initiate revealing the top-of-window views while | 352 // Mouse hover can initiate revealing the top-of-window views while |widget_| |
353 // |native_window_| is inactive. | 353 // is inactive. |
354 if (!views::Widget::GetWidgetForNativeWindow(native_window_)->IsActive()) | |
355 return; | |
356 | 354 |
357 // Mouse hover should not initiate revealing the top-of-window views while | 355 if (reveal_state_ == SLIDING_OPEN || reveal_state_ == REVEALED) { |
358 // a window has mouse capture. | 356 top_edge_hover_timer_.Stop(); |
359 if (aura::client::GetCaptureWindow(native_window_)) | 357 UpdateLocatedEventRevealedLock(event); |
360 return; | 358 } else if (event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) { |
361 | 359 // Trigger a reveal if the cursor pauses at the top of the screen for a |
362 if (IsRevealed()) | 360 // while. |
363 UpdateLocatedEventRevealedLock(event, ALLOW_REVEAL_WHILE_CLOSING_NO); | |
364 | |
365 // Trigger a reveal if the cursor pauses at the top of the screen for a | |
366 // while. | |
367 if (event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) | |
368 UpdateTopEdgeHoverTimer(event); | 361 UpdateTopEdgeHoverTimer(event); |
| 362 } |
369 } | 363 } |
370 | 364 |
371 void ImmersiveFullscreenController::OnTouchEvent(ui::TouchEvent* event) { | 365 void ImmersiveFullscreenController::OnTouchEvent(ui::TouchEvent* event) { |
372 if (!enabled_ || event->type() != ui::ET_TOUCH_PRESSED) | 366 if (!enabled_ || event->type() != ui::ET_TOUCH_PRESSED) |
373 return; | 367 return; |
374 | 368 |
375 UpdateLocatedEventRevealedLock(event, ALLOW_REVEAL_WHILE_CLOSING_NO); | 369 // Touch should not initiate revealing the top-of-window views while |widget_| |
| 370 // is inactive. |
| 371 if (!widget_->IsActive()) |
| 372 return; |
| 373 |
| 374 UpdateLocatedEventRevealedLock(event); |
376 } | 375 } |
377 | 376 |
378 void ImmersiveFullscreenController::OnGestureEvent(ui::GestureEvent* event) { | 377 void ImmersiveFullscreenController::OnGestureEvent(ui::GestureEvent* event) { |
379 if (!enabled_) | 378 if (!enabled_) |
380 return; | 379 return; |
381 | 380 |
382 // Touch gestures should not initiate revealing the top-of-window views while | 381 // Touch gestures should not initiate revealing the top-of-window views while |
383 // |native_window_| is inactive. | 382 // |widget_| is inactive. |
384 if (!views::Widget::GetWidgetForNativeWindow(native_window_)->IsActive()) | 383 if (!widget_->IsActive()) |
385 return; | 384 return; |
386 | 385 |
387 switch (event->type()) { | 386 switch (event->type()) { |
388 case ui::ET_GESTURE_SCROLL_BEGIN: | 387 case ui::ET_GESTURE_SCROLL_BEGIN: |
389 if (ShouldHandleGestureEvent(GetEventLocationInScreen(*event))) { | 388 if (ShouldHandleGestureEvent(GetEventLocationInScreen(*event))) { |
390 gesture_begun_ = true; | 389 gesture_begun_ = true; |
391 event->SetHandled(); | 390 event->SetHandled(); |
392 } | 391 } |
393 break; | 392 break; |
394 case ui::ET_GESTURE_SCROLL_UPDATE: | 393 case ui::ET_GESTURE_SCROLL_UPDATE: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 native_window_ = NULL; | 428 native_window_ = NULL; |
430 | 429 |
431 // Set |enabled_| to false such that any calls to MaybeStartReveal() and | 430 // Set |enabled_| to false such that any calls to MaybeStartReveal() and |
432 // MaybeEndReveal() have no effect. | 431 // MaybeEndReveal() have no effect. |
433 enabled_ = false; | 432 enabled_ = false; |
434 } | 433 } |
435 | 434 |
436 void ImmersiveFullscreenController::OnWidgetActivationChanged( | 435 void ImmersiveFullscreenController::OnWidgetActivationChanged( |
437 views::Widget* widget, | 436 views::Widget* widget, |
438 bool active) { | 437 bool active) { |
439 // Mouse hover should not initiate revealing the top-of-window views while | |
440 // |native_window_| is inactive. | |
441 top_edge_hover_timer_.Stop(); | |
442 | |
443 UpdateFocusRevealedLock(); | 438 UpdateFocusRevealedLock(); |
444 | |
445 // Allow the top-of-window views to stay revealed if all of the revealed locks | |
446 // were released in the process of activating |widget| but the mouse is still | |
447 // hovered above the top-of-window views. For instance, if the bubble which | |
448 // has been keeping the top-of-window views revealed is hidden but the mouse | |
449 // is hovered above the top-of-window views, the top-of-window views should | |
450 // stay revealed. We cannot call UpdateLocatedEventRevealedLock() from | |
451 // BubbleManager::UpdateRevealedLock() because |widget| is not yet active | |
452 // at that time. | |
453 UpdateLocatedEventRevealedLock(NULL, ALLOW_REVEAL_WHILE_CLOSING_YES); | |
454 } | 439 } |
455 | 440 |
456 //////////////////////////////////////////////////////////////////////////////// | 441 //////////////////////////////////////////////////////////////////////////////// |
457 // gfx::AnimationDelegate overrides: | 442 // gfx::AnimationDelegate overrides: |
458 | 443 |
459 void ImmersiveFullscreenController::AnimationEnded( | 444 void ImmersiveFullscreenController::AnimationEnded( |
460 const gfx::Animation* animation) { | 445 const gfx::Animation* animation) { |
461 if (reveal_state_ == SLIDING_OPEN) { | 446 if (reveal_state_ == SLIDING_OPEN) { |
462 OnSlideOpenAnimationCompleted(); | 447 OnSlideOpenAnimationCompleted(); |
463 } else if (reveal_state_ == SLIDING_CLOSED) { | 448 } else if (reveal_state_ == SLIDING_CLOSED) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 } | 498 } |
514 | 499 |
515 //////////////////////////////////////////////////////////////////////////////// | 500 //////////////////////////////////////////////////////////////////////////////// |
516 // private: | 501 // private: |
517 | 502 |
518 void ImmersiveFullscreenController::EnableWindowObservers(bool enable) { | 503 void ImmersiveFullscreenController::EnableWindowObservers(bool enable) { |
519 if (observers_enabled_ == enable) | 504 if (observers_enabled_ == enable) |
520 return; | 505 return; |
521 observers_enabled_ = enable; | 506 observers_enabled_ = enable; |
522 | 507 |
523 views::Widget* widget = | 508 views::FocusManager* focus_manager = widget_->GetFocusManager(); |
524 views::Widget::GetWidgetForNativeWindow(native_window_); | |
525 views::FocusManager* focus_manager = widget->GetFocusManager(); | |
526 | 509 |
527 if (enable) { | 510 if (enable) { |
528 widget->AddObserver(this); | 511 widget_->AddObserver(this); |
529 focus_manager->AddFocusChangeListener(this); | 512 focus_manager->AddFocusChangeListener(this); |
530 Shell::GetInstance()->AddPreTargetHandler(this); | 513 Shell::GetInstance()->AddPreTargetHandler(this); |
531 native_window_->AddObserver(this); | 514 native_window_->AddObserver(this); |
532 | 515 |
533 RecreateBubbleManager(); | 516 RecreateBubbleManager(); |
534 } else { | 517 } else { |
535 widget->RemoveObserver(this); | 518 widget_->RemoveObserver(this); |
536 focus_manager->RemoveFocusChangeListener(this); | 519 focus_manager->RemoveFocusChangeListener(this); |
537 Shell::GetInstance()->RemovePreTargetHandler(this); | 520 Shell::GetInstance()->RemovePreTargetHandler(this); |
538 native_window_->RemoveObserver(this); | 521 native_window_->RemoveObserver(this); |
539 | 522 |
540 // We have stopped observing whether transient children are added or removed | 523 // We have stopped observing whether transient children are added or removed |
541 // to |native_window_|. The set of bubbles that BubbleManager is observing | 524 // to |native_window_|. The set of bubbles that BubbleManager is observing |
542 // will become stale really quickly. Destroy BubbleManager and recreate it | 525 // will become stale really quickly. Destroy BubbleManager and recreate it |
543 // when we start observing |native_window_| again. | 526 // when we start observing |native_window_| again. |
544 bubble_manager_.reset(); | 527 bubble_manager_.reset(); |
545 | 528 |
546 animation_->Stop(); | 529 animation_->Stop(); |
547 } | 530 } |
548 } | 531 } |
549 | 532 |
550 void ImmersiveFullscreenController::UpdateTopEdgeHoverTimer( | 533 void ImmersiveFullscreenController::UpdateTopEdgeHoverTimer( |
551 ui::MouseEvent* event) { | 534 ui::MouseEvent* event) { |
552 DCHECK(enabled_); | 535 DCHECK(enabled_); |
553 // Stop the timer if the top-of-window views are already revealed. | 536 DCHECK(reveal_state_ == SLIDING_CLOSED || reveal_state_ == CLOSED); |
554 if (reveal_state_ == SLIDING_OPEN || reveal_state_ == REVEALED) { | 537 |
555 top_edge_hover_timer_.Stop(); | 538 // Check whether |native_window_| is the event target's parent window instead |
| 539 // of checking for activation. This allows the timer to be started when |
| 540 // |widget_| is inactive but prevents starting the timer if the mouse is over |
| 541 // a portion of the top edge obscured by an unrelated widget. |
| 542 if (!top_edge_hover_timer_.IsRunning() && |
| 543 !native_window_->Contains(static_cast<aura::Window*>(event->target()))) { |
556 return; | 544 return; |
557 } | 545 } |
558 | 546 |
| 547 // Mouse hover should not initiate revealing the top-of-window views while a |
| 548 // window has mouse capture. |
| 549 if (aura::client::GetCaptureWindow(native_window_)) |
| 550 return; |
| 551 |
559 gfx::Point location_in_screen = GetEventLocationInScreen(*event); | 552 gfx::Point location_in_screen = GetEventLocationInScreen(*event); |
560 if (ShouldIgnoreMouseEventAtLocation(location_in_screen)) | 553 if (ShouldIgnoreMouseEventAtLocation(location_in_screen)) |
561 return; | 554 return; |
562 | 555 |
563 // Stop the timer if the cursor left the top edge or is on a different | 556 // Stop the timer if the cursor left the top edge or is on a different |
564 // display. | 557 // display. |
565 gfx::Rect hit_bounds_in_screen = GetDisplayBoundsInScreen(native_window_); | 558 gfx::Rect hit_bounds_in_screen = GetDisplayBoundsInScreen(native_window_); |
566 hit_bounds_in_screen.set_height(kMouseRevealBoundsHeight); | 559 hit_bounds_in_screen.set_height(kMouseRevealBoundsHeight); |
567 if (!hit_bounds_in_screen.Contains(location_in_screen)) { | 560 if (!hit_bounds_in_screen.Contains(location_in_screen)) { |
568 top_edge_hover_timer_.Stop(); | 561 top_edge_hover_timer_.Stop(); |
(...skipping 15 matching lines...) Expand all Loading... |
584 // Timer is stopped when |this| is destroyed, hence Unretained() is safe. | 577 // Timer is stopped when |this| is destroyed, hence Unretained() is safe. |
585 top_edge_hover_timer_.Start( | 578 top_edge_hover_timer_.Start( |
586 FROM_HERE, | 579 FROM_HERE, |
587 base::TimeDelta::FromMilliseconds(kMouseRevealDelayMs), | 580 base::TimeDelta::FromMilliseconds(kMouseRevealDelayMs), |
588 base::Bind( | 581 base::Bind( |
589 &ImmersiveFullscreenController::AcquireLocatedEventRevealedLock, | 582 &ImmersiveFullscreenController::AcquireLocatedEventRevealedLock, |
590 base::Unretained(this))); | 583 base::Unretained(this))); |
591 } | 584 } |
592 | 585 |
593 void ImmersiveFullscreenController::UpdateLocatedEventRevealedLock( | 586 void ImmersiveFullscreenController::UpdateLocatedEventRevealedLock( |
594 ui::LocatedEvent* event, | 587 ui::LocatedEvent* event) { |
595 AllowRevealWhileClosing allow_reveal_while_closing) { | |
596 if (!enabled_) | 588 if (!enabled_) |
597 return; | 589 return; |
598 DCHECK(!event || event->IsMouseEvent() || event->IsTouchEvent()); | 590 DCHECK(!event || event->IsMouseEvent() || event->IsTouchEvent()); |
599 | 591 |
600 // Neither the mouse nor touch can initiate a reveal when the top-of-window | 592 // Neither the mouse nor touch can initiate a reveal when the top-of-window |
601 // views are sliding closed or are closed with the following exceptions: | 593 // views are sliding closed or are closed with the following exceptions: |
602 // - Hovering at y = 0 which is handled in OnMouseEvent(). | 594 // - Hovering at y = 0 which is handled in OnMouseEvent(). |
603 // - Doing a SWIPE_OPEN edge gesture which is handled in OnGestureEvent(). | 595 // - Doing a SWIPE_OPEN edge gesture which is handled in OnGestureEvent(). |
604 if (reveal_state_ == CLOSED || | 596 if (reveal_state_ == CLOSED || reveal_state_ == SLIDING_CLOSED) |
605 (reveal_state_ == SLIDING_CLOSED && | |
606 allow_reveal_while_closing == ALLOW_REVEAL_WHILE_CLOSING_NO)) { | |
607 return; | 597 return; |
608 } | |
609 | 598 |
610 // Neither the mouse nor touch should keep the top-of-window views revealed if | 599 // For the sake of simplicity, ignore |widget_|'s activation in computing |
611 // |native_window_| is not active. | 600 // whether the top-of-window views should stay revealed. Ideally, the |
612 if (!views::Widget::GetWidgetForNativeWindow(native_window_)->IsActive()) { | 601 // top-of-window views would stay revealed only when the mouse cursor is |
613 located_event_revealed_lock_.reset(); | 602 // hovered above a non-obscured portion of the top-of-window views. The |
614 return; | 603 // top-of-window views may be partially obscured when |widget_| is inactive. |
615 } | |
616 | 604 |
617 // Ignore all events while a window has capture. This keeps the top-of-window | 605 // Ignore all events while a window has capture. This keeps the top-of-window |
618 // views revealed during a drag. | 606 // views revealed during a drag. |
619 if (aura::client::GetCaptureWindow(native_window_)) | 607 if (aura::client::GetCaptureWindow(native_window_)) |
620 return; | 608 return; |
621 | 609 |
622 gfx::Point location_in_screen; | 610 gfx::Point location_in_screen; |
623 if (event && event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) { | 611 if (event && event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) { |
624 location_in_screen = GetEventLocationInScreen(*event); | 612 location_in_screen = GetEventLocationInScreen(*event); |
625 } else { | 613 } else { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 // |ImmersiveFullscreenController::animations_disabled_for_test_| is true. | 660 // |ImmersiveFullscreenController::animations_disabled_for_test_| is true. |
673 if (!located_event_revealed_lock_.get()) | 661 if (!located_event_revealed_lock_.get()) |
674 located_event_revealed_lock_.reset(GetRevealedLock(ANIMATE_REVEAL_YES)); | 662 located_event_revealed_lock_.reset(GetRevealedLock(ANIMATE_REVEAL_YES)); |
675 } | 663 } |
676 | 664 |
677 void ImmersiveFullscreenController::UpdateFocusRevealedLock() { | 665 void ImmersiveFullscreenController::UpdateFocusRevealedLock() { |
678 if (!enabled_) | 666 if (!enabled_) |
679 return; | 667 return; |
680 | 668 |
681 bool hold_lock = false; | 669 bool hold_lock = false; |
682 views::Widget* widget = | 670 if (widget_->IsActive()) { |
683 views::Widget::GetWidgetForNativeWindow(native_window_); | 671 views::View* focused_view = widget_->GetFocusManager()->GetFocusedView(); |
684 if (widget->IsActive()) { | |
685 views::View* focused_view = widget->GetFocusManager()->GetFocusedView(); | |
686 if (top_container_->Contains(focused_view)) | 672 if (top_container_->Contains(focused_view)) |
687 hold_lock = true; | 673 hold_lock = true; |
688 } else { | 674 } else { |
689 aura::Window* active_window = aura::client::GetActivationClient( | 675 aura::Window* active_window = aura::client::GetActivationClient( |
690 native_window_->GetRootWindow())->GetActiveWindow(); | 676 native_window_->GetRootWindow())->GetActiveWindow(); |
691 views::BubbleDelegateView* bubble_delegate = | 677 views::BubbleDelegateView* bubble_delegate = |
692 AsBubbleDelegate(active_window); | 678 AsBubbleDelegate(active_window); |
693 if (bubble_delegate && bubble_delegate->anchor_widget()) { | 679 if (bubble_delegate && bubble_delegate->anchor_widget()) { |
694 // BubbleManager will already have locked the top-of-window views if the | 680 // BubbleManager will already have locked the top-of-window views if the |
695 // bubble is anchored to a child of |top_container_|. Don't acquire | 681 // bubble is anchored to a child of |top_container_|. Don't acquire |
(...skipping 26 matching lines...) Expand all Loading... |
722 } | 708 } |
723 } | 709 } |
724 | 710 |
725 bool ImmersiveFullscreenController::UpdateRevealedLocksForSwipe( | 711 bool ImmersiveFullscreenController::UpdateRevealedLocksForSwipe( |
726 SwipeType swipe_type) { | 712 SwipeType swipe_type) { |
727 if (!enabled_ || swipe_type == SWIPE_NONE) | 713 if (!enabled_ || swipe_type == SWIPE_NONE) |
728 return false; | 714 return false; |
729 | 715 |
730 // Swipes while |native_window_| is inactive should have been filtered out in | 716 // Swipes while |native_window_| is inactive should have been filtered out in |
731 // OnGestureEvent(). | 717 // OnGestureEvent(). |
732 DCHECK(views::Widget::GetWidgetForNativeWindow(native_window_)->IsActive()); | 718 DCHECK(widget_->IsActive()); |
733 | 719 |
734 if (reveal_state_ == SLIDING_CLOSED || reveal_state_ == CLOSED) { | 720 if (reveal_state_ == SLIDING_CLOSED || reveal_state_ == CLOSED) { |
735 if (swipe_type == SWIPE_OPEN && !located_event_revealed_lock_.get()) { | 721 if (swipe_type == SWIPE_OPEN && !located_event_revealed_lock_.get()) { |
736 located_event_revealed_lock_.reset(GetRevealedLock(ANIMATE_REVEAL_YES)); | 722 located_event_revealed_lock_.reset(GetRevealedLock(ANIMATE_REVEAL_YES)); |
737 return true; | 723 return true; |
738 } | 724 } |
739 } else { | 725 } else { |
740 if (swipe_type == SWIPE_CLOSE) { | 726 if (swipe_type == SWIPE_CLOSE) { |
741 // Attempt to end the reveal. If other code is holding onto a lock, the | 727 // Attempt to end the reveal. If other code is holding onto a lock, the |
742 // attempt will be unsuccessful. | 728 // attempt will be unsuccessful. |
743 located_event_revealed_lock_.reset(); | 729 located_event_revealed_lock_.reset(); |
744 focus_revealed_lock_.reset(); | 730 focus_revealed_lock_.reset(); |
745 | 731 |
746 if (reveal_state_ == SLIDING_CLOSED || reveal_state_ == CLOSED) | 732 if (reveal_state_ == SLIDING_CLOSED || reveal_state_ == CLOSED) |
747 return true; | 733 return true; |
748 | 734 |
749 // Ending the reveal was unsuccessful. Reaquire the locks if appropriate. | 735 // Ending the reveal was unsuccessful. Reaquire the locks if appropriate. |
750 UpdateLocatedEventRevealedLock(NULL, ALLOW_REVEAL_WHILE_CLOSING_NO); | 736 UpdateLocatedEventRevealedLock(NULL); |
751 UpdateFocusRevealedLock(); | 737 UpdateFocusRevealedLock(); |
752 } | 738 } |
753 } | 739 } |
754 return false; | 740 return false; |
755 } | 741 } |
756 | 742 |
757 int ImmersiveFullscreenController::GetAnimationDuration(Animate animate) const { | 743 int ImmersiveFullscreenController::GetAnimationDuration(Animate animate) const { |
758 switch (animate) { | 744 switch (animate) { |
759 case ANIMATE_NO: | 745 case ANIMATE_NO: |
760 return 0; | 746 return 0; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 } | 787 } |
802 } | 788 } |
803 | 789 |
804 void ImmersiveFullscreenController::OnSlideOpenAnimationCompleted() { | 790 void ImmersiveFullscreenController::OnSlideOpenAnimationCompleted() { |
805 DCHECK_EQ(SLIDING_OPEN, reveal_state_); | 791 DCHECK_EQ(SLIDING_OPEN, reveal_state_); |
806 reveal_state_ = REVEALED; | 792 reveal_state_ = REVEALED; |
807 delegate_->SetVisibleFraction(1); | 793 delegate_->SetVisibleFraction(1); |
808 | 794 |
809 // The user may not have moved the mouse since the reveal was initiated. | 795 // The user may not have moved the mouse since the reveal was initiated. |
810 // Update the revealed lock to reflect the mouse's current state. | 796 // Update the revealed lock to reflect the mouse's current state. |
811 UpdateLocatedEventRevealedLock(NULL, ALLOW_REVEAL_WHILE_CLOSING_NO); | 797 UpdateLocatedEventRevealedLock(NULL); |
812 } | 798 } |
813 | 799 |
814 void ImmersiveFullscreenController::MaybeEndReveal(Animate animate) { | 800 void ImmersiveFullscreenController::MaybeEndReveal(Animate animate) { |
815 if (!enabled_ || revealed_lock_count_ != 0) | 801 if (!enabled_ || revealed_lock_count_ != 0) |
816 return; | 802 return; |
817 | 803 |
818 if (animations_disabled_for_test_) | 804 if (animations_disabled_for_test_) |
819 animate = ANIMATE_NO; | 805 animate = ANIMATE_NO; |
820 | 806 |
821 // Callers with ANIMATE_NO expect this function to synchronously close the | 807 // Callers with ANIMATE_NO expect this function to synchronously close the |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 // user to overshoot the top of the bottom display and still reveal the | 859 // user to overshoot the top of the bottom display and still reveal the |
874 // top-of-window views. | 860 // top-of-window views. |
875 gfx::Rect dead_region = GetDisplayBoundsInScreen(native_window_); | 861 gfx::Rect dead_region = GetDisplayBoundsInScreen(native_window_); |
876 dead_region.set_y(dead_region.y() - kHeightOfDeadRegionAboveTopContainer); | 862 dead_region.set_y(dead_region.y() - kHeightOfDeadRegionAboveTopContainer); |
877 dead_region.set_height(kHeightOfDeadRegionAboveTopContainer); | 863 dead_region.set_height(kHeightOfDeadRegionAboveTopContainer); |
878 return dead_region.Contains(location); | 864 return dead_region.Contains(location); |
879 } | 865 } |
880 | 866 |
881 bool ImmersiveFullscreenController::ShouldHandleGestureEvent( | 867 bool ImmersiveFullscreenController::ShouldHandleGestureEvent( |
882 const gfx::Point& location) const { | 868 const gfx::Point& location) const { |
| 869 DCHECK(widget_->IsActive()); |
883 if (reveal_state_ == REVEALED) { | 870 if (reveal_state_ == REVEALED) { |
884 std::vector<gfx::Rect> hit_bounds_in_screen( | 871 std::vector<gfx::Rect> hit_bounds_in_screen( |
885 delegate_->GetVisibleBoundsInScreen()); | 872 delegate_->GetVisibleBoundsInScreen()); |
886 for (size_t i = 0; i < hit_bounds_in_screen.size(); ++i) { | 873 for (size_t i = 0; i < hit_bounds_in_screen.size(); ++i) { |
887 if (hit_bounds_in_screen[i].Contains(location)) | 874 if (hit_bounds_in_screen[i].Contains(location)) |
888 return true; | 875 return true; |
889 } | 876 } |
890 return false; | 877 return false; |
891 } | 878 } |
892 | 879 |
(...skipping 26 matching lines...) Expand all Loading... |
919 AsBubbleDelegate(transient_child); | 906 AsBubbleDelegate(transient_child); |
920 if (bubble_delegate && | 907 if (bubble_delegate && |
921 bubble_delegate->GetAnchorView() && | 908 bubble_delegate->GetAnchorView() && |
922 top_container_->Contains(bubble_delegate->GetAnchorView())) { | 909 top_container_->Contains(bubble_delegate->GetAnchorView())) { |
923 bubble_manager_->StartObserving(transient_child); | 910 bubble_manager_->StartObserving(transient_child); |
924 } | 911 } |
925 } | 912 } |
926 } | 913 } |
927 | 914 |
928 } // namespace ash | 915 } // namespace ash |
OLD | NEW |