Chromium Code Reviews| 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/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" | |
| 11 #include "ash/common/wm/immersive/wm_immersive_fullscreen_controller_delegate.h" | 10 #include "ash/common/wm/immersive/wm_immersive_fullscreen_controller_delegate.h" |
| 12 #include "ash/common/wm/window_state.h" | 11 #include "ash/shared/immersive_context.h" |
| 13 #include "ash/common/wm_lookup.h" | |
| 14 #include "ash/common/wm_root_window_controller.h" | |
| 15 #include "ash/common/wm_shell.h" | |
| 16 #include "ash/common/wm_window.h" | |
| 17 #include "ash/wm/immersive_focus_watcher.h" | 12 #include "ash/wm/immersive_focus_watcher.h" |
| 18 #include "ash/wm/immersive_gesture_handler.h" | 13 #include "ash/wm/immersive_gesture_handler.h" |
| 14 #include "ash/wm/immersive_handler_factory.h" | |
| 19 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 20 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
| 21 #include "ui/display/display.h" | 17 #include "ui/display/display.h" |
| 22 #include "ui/display/screen.h" | 18 #include "ui/display/screen.h" |
| 23 #include "ui/events/base_event_utils.h" | 19 #include "ui/events/base_event_utils.h" |
| 24 #include "ui/gfx/animation/slide_animation.h" | 20 #include "ui/gfx/animation/slide_animation.h" |
| 25 #include "ui/gfx/geometry/point.h" | 21 #include "ui/gfx/geometry/point.h" |
| 26 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
| 27 #include "ui/views/bubble/bubble_dialog_delegate.h" | 23 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 28 #include "ui/views/view.h" | 24 #include "ui/views/view.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 51 // vertical. This is used to make sure that gesture is close to vertical instead | 47 // vertical. This is used to make sure that gesture is close to vertical instead |
| 52 // of just more vertical then horizontal. | 48 // of just more vertical then horizontal. |
| 53 const int kSwipeVerticalThresholdMultiplier = 3; | 49 const int kSwipeVerticalThresholdMultiplier = 3; |
| 54 | 50 |
| 55 // The height in pixels of the region above the top edge of the display which | 51 // The height in pixels of the region above the top edge of the display which |
| 56 // hosts the immersive fullscreen window in which mouse events are ignored | 52 // hosts the immersive fullscreen window in which mouse events are ignored |
| 57 // (cannot reveal or unreveal the top-of-window views). | 53 // (cannot reveal or unreveal the top-of-window views). |
| 58 // See ShouldIgnoreMouseEventAtLocation() for more details. | 54 // See ShouldIgnoreMouseEventAtLocation() for more details. |
| 59 const int kHeightOfDeadRegionAboveTopContainer = 10; | 55 const int kHeightOfDeadRegionAboveTopContainer = 10; |
| 60 | 56 |
| 61 // Returns the bounds of the display nearest to |window| in screen coordinates. | |
| 62 gfx::Rect GetDisplayBoundsInScreen(WmWindow* window) { | |
| 63 return window->GetDisplayNearestWindow().bounds(); | |
| 64 } | |
| 65 | |
| 66 } // namespace | 57 } // namespace |
| 67 | 58 |
| 68 // The height in pixels of the region below the top edge of the display in which | 59 // The height in pixels of the region below the top edge of the display in which |
| 69 // the mouse can trigger revealing the top-of-window views. | 60 // the mouse can trigger revealing the top-of-window views. |
| 70 // The height must be greater than 1px because the top pixel is used to trigger | 61 // The height must be greater than 1px because the top pixel is used to trigger |
| 71 // moving the cursor between displays if the user has a vertical display layout | 62 // moving the cursor between displays if the user has a vertical display layout |
| 72 // (primary display above/below secondary display). | 63 // (primary display above/below secondary display). |
| 73 const int ImmersiveFullscreenController::kMouseRevealBoundsHeight = 3; | 64 const int ImmersiveFullscreenController::kMouseRevealBoundsHeight = 3; |
| 74 | 65 |
| 75 //////////////////////////////////////////////////////////////////////////////// | 66 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 92 EnableWindowObservers(false); | 83 EnableWindowObservers(false); |
| 93 } | 84 } |
| 94 | 85 |
| 95 void ImmersiveFullscreenController::Init( | 86 void ImmersiveFullscreenController::Init( |
| 96 WmImmersiveFullscreenControllerDelegate* delegate, | 87 WmImmersiveFullscreenControllerDelegate* delegate, |
| 97 views::Widget* widget, | 88 views::Widget* widget, |
| 98 views::View* top_container) { | 89 views::View* top_container) { |
| 99 delegate_ = delegate; | 90 delegate_ = delegate; |
| 100 top_container_ = top_container; | 91 top_container_ = top_container; |
| 101 widget_ = widget; | 92 widget_ = widget; |
| 102 widget_window_ = WmLookup::Get()->GetWindowForWidget(widget_); | 93 ImmersiveContext::Get()->InstallResizeHandleWindowTargeter(this); |
| 103 widget_window_->InstallResizeHandleWindowTargeter(this); | |
| 104 } | 94 } |
| 105 | 95 |
| 106 void ImmersiveFullscreenController::SetEnabled(WindowType window_type, | 96 void ImmersiveFullscreenController::SetEnabled(WindowType window_type, |
| 107 bool enabled) { | 97 bool enabled) { |
| 108 if (enabled_ == enabled) | 98 if (enabled_ == enabled) |
| 109 return; | 99 return; |
| 110 enabled_ = enabled; | 100 enabled_ = enabled; |
| 111 | 101 |
| 112 EnableWindowObservers(enabled_); | 102 EnableWindowObservers(enabled_); |
| 113 | 103 |
| 114 wm::WindowState* window_state = widget_window_->GetWindowState(); | 104 ImmersiveContext::Get()->OnEnteringOrExitingImmersive(this, enabled); |
| 115 // Auto hide the shelf in immersive fullscreen instead of hiding it. | |
| 116 window_state->set_shelf_mode_in_fullscreen( | |
| 117 enabled ? ash::wm::WindowState::SHELF_AUTO_HIDE_VISIBLE | |
| 118 : ash::wm::WindowState::SHELF_HIDDEN); | |
| 119 | |
| 120 // Update the window's immersive mode state for the window manager. | |
| 121 window_state->set_in_immersive_fullscreen(enabled); | |
| 122 | |
| 123 for (WmWindow* root_window : WmShell::Get()->GetAllRootWindows()) | |
| 124 root_window->GetRootWindowController()->GetShelf()->UpdateVisibilityState(); | |
| 125 | 105 |
| 126 if (enabled_) { | 106 if (enabled_) { |
| 127 // Animate enabling immersive mode by sliding out the top-of-window views. | 107 // Animate enabling immersive mode by sliding out the top-of-window views. |
| 128 // No animation occurs if a lock is holding the top-of-window views open. | 108 // No animation occurs if a lock is holding the top-of-window views open. |
| 129 | 109 |
| 130 // Do a reveal to set the initial state for the animation. (And any | 110 // Do a reveal to set the initial state for the animation. (And any |
| 131 // required state in case the animation cannot run because of a lock holding | 111 // required state in case the animation cannot run because of a lock holding |
| 132 // the top-of-window views open.) | 112 // the top-of-window views open.) |
| 133 MaybeStartReveal(ANIMATE_NO); | 113 MaybeStartReveal(ANIMATE_NO); |
| 134 | 114 |
| 135 // Reset the located event so that it does not affect whether the | 115 // Reset the located event so that it does not affect whether the |
| 136 // top-of-window views are hidden. | 116 // top-of-window views are hidden. |
| 137 located_event_revealed_lock_.reset(); | 117 located_event_revealed_lock_.reset(); |
| 138 | 118 |
| 139 // Try doing the animation. | 119 // Try doing the animation. |
| 140 MaybeEndReveal(ANIMATE_SLOW); | 120 MaybeEndReveal(ANIMATE_SLOW); |
| 141 | 121 |
| 142 if (reveal_state_ == REVEALED) { | 122 if (reveal_state_ == REVEALED) { |
| 143 // Reveal was unsuccessful. Reacquire the revealed locks if appropriate. | 123 // Reveal was unsuccessful. Reacquire the revealed locks if appropriate. |
| 144 UpdateLocatedEventRevealedLock(); | 124 UpdateLocatedEventRevealedLock(); |
| 145 immersive_focus_watcher_->UpdateFocusRevealedLock(); | 125 if (immersive_focus_watcher_) |
|
James Cook
2016/08/19 00:37:14
It looks like your implementation of CreateFocusWa
sky
2016/08/19 03:30:47
The mash implementation will return null initially
James Cook
2016/08/19 15:49:59
OK. If you end up with a mash implementation that
| |
| 126 immersive_focus_watcher_->UpdateFocusRevealedLock(); | |
| 146 } | 127 } |
| 147 } else { | 128 } else { |
| 148 // Stop cursor-at-top tracking. | 129 // Stop cursor-at-top tracking. |
| 149 top_edge_hover_timer_.Stop(); | 130 top_edge_hover_timer_.Stop(); |
| 150 reveal_state_ = CLOSED; | 131 reveal_state_ = CLOSED; |
| 151 | 132 |
| 152 delegate_->OnImmersiveFullscreenExited(); | 133 delegate_->OnImmersiveFullscreenExited(); |
| 153 } | 134 } |
| 154 | 135 |
| 155 if (enabled_) { | 136 if (enabled_) { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 | 324 |
| 344 //////////////////////////////////////////////////////////////////////////////// | 325 //////////////////////////////////////////////////////////////////////////////// |
| 345 // private: | 326 // private: |
| 346 | 327 |
| 347 void ImmersiveFullscreenController::EnableWindowObservers(bool enable) { | 328 void ImmersiveFullscreenController::EnableWindowObservers(bool enable) { |
| 348 if (observers_enabled_ == enable) | 329 if (observers_enabled_ == enable) |
| 349 return; | 330 return; |
| 350 observers_enabled_ = enable; | 331 observers_enabled_ = enable; |
| 351 | 332 |
| 352 if (enable) { | 333 if (enable) { |
| 353 immersive_focus_watcher_.reset(new ImmersiveFocusWatcher(this)); | 334 immersive_focus_watcher_ = |
| 354 immersive_gesture_handler_.reset(new ImmersiveGestureHandler(this)); | 335 ImmersiveHandlerFactory::Get()->CreateFocusWatcher(this); |
| 336 immersive_gesture_handler_ = | |
| 337 ImmersiveHandlerFactory::Get()->CreateGestureHandler(this); | |
| 355 widget_->AddObserver(this); | 338 widget_->AddObserver(this); |
| 356 const bool wants_moves = true; | 339 const bool wants_moves = true; |
| 357 WmShell::Get()->AddPointerWatcher(this, wants_moves); | 340 ImmersiveContext::Get()->AddPointerWatcher(this, wants_moves); |
| 358 | |
| 359 } else { | 341 } else { |
| 360 WmShell::Get()->RemovePointerWatcher(this); | 342 ImmersiveContext::Get()->RemovePointerWatcher(this); |
| 361 widget_->RemoveObserver(this); | 343 widget_->RemoveObserver(this); |
| 362 immersive_gesture_handler_.reset(); | 344 immersive_gesture_handler_.reset(); |
| 363 immersive_focus_watcher_.reset(); | 345 immersive_focus_watcher_.reset(); |
| 364 | 346 |
| 365 animation_->Stop(); | 347 animation_->Stop(); |
| 366 } | 348 } |
| 367 } | 349 } |
| 368 | 350 |
| 369 void ImmersiveFullscreenController::UpdateTopEdgeHoverTimer( | 351 void ImmersiveFullscreenController::UpdateTopEdgeHoverTimer( |
| 370 const ui::MouseEvent& event, | 352 const ui::MouseEvent& event, |
| 371 const gfx::Point& location_in_screen, | 353 const gfx::Point& location_in_screen, |
| 372 views::Widget* target) { | 354 views::Widget* target) { |
| 373 DCHECK(enabled_); | 355 DCHECK(enabled_); |
| 374 DCHECK(reveal_state_ == SLIDING_CLOSED || reveal_state_ == CLOSED); | 356 DCHECK(reveal_state_ == SLIDING_CLOSED || reveal_state_ == CLOSED); |
| 375 | 357 |
| 376 // Check whether |widget_| is the event target instead of checking for | 358 // Check whether |widget_| is the event target instead of checking for |
| 377 // activation. This allows the timer to be started when |widget_| is inactive | 359 // activation. This allows the timer to be started when |widget_| is inactive |
| 378 // but prevents starting the timer if the mouse is over a portion of the top | 360 // but prevents starting the timer if the mouse is over a portion of the top |
| 379 // edge obscured by an unrelated widget. | 361 // edge obscured by an unrelated widget. |
| 380 if (!top_edge_hover_timer_.IsRunning() && target != widget_) { | 362 if (!top_edge_hover_timer_.IsRunning() && target != widget_) { |
| 381 return; | 363 return; |
| 382 } | 364 } |
| 383 | 365 |
| 384 // Mouse hover should not initiate revealing the top-of-window views while a | 366 // Mouse hover should not initiate revealing the top-of-window views while a |
| 385 // window has mouse capture. | 367 // window has mouse capture. |
| 386 if (WmShell::Get()->GetCaptureWindow()) | 368 if (ImmersiveContext::Get()->DoesAnyWindowHaveCapture()) |
| 387 return; | 369 return; |
| 388 | 370 |
| 389 if (ShouldIgnoreMouseEventAtLocation(location_in_screen)) | 371 if (ShouldIgnoreMouseEventAtLocation(location_in_screen)) |
| 390 return; | 372 return; |
| 391 | 373 |
| 392 // Stop the timer if the cursor left the top edge or is on a different | 374 // Stop the timer if the cursor left the top edge or is on a different |
| 393 // display. | 375 // display. |
| 394 gfx::Rect hit_bounds_in_screen = GetDisplayBoundsInScreen(widget_window_); | 376 gfx::Rect hit_bounds_in_screen = GetDisplayBoundsInScreen(); |
| 395 hit_bounds_in_screen.set_height(kMouseRevealBoundsHeight); | 377 hit_bounds_in_screen.set_height(kMouseRevealBoundsHeight); |
| 396 if (!hit_bounds_in_screen.Contains(location_in_screen)) { | 378 if (!hit_bounds_in_screen.Contains(location_in_screen)) { |
| 397 top_edge_hover_timer_.Stop(); | 379 top_edge_hover_timer_.Stop(); |
| 398 return; | 380 return; |
| 399 } | 381 } |
| 400 | 382 |
| 401 // The cursor is now at the top of the screen. Consider the cursor "not | 383 // The cursor is now at the top of the screen. Consider the cursor "not |
| 402 // moving" even if it moves a little bit because users don't have perfect | 384 // moving" even if it moves a little bit because users don't have perfect |
| 403 // pointing precision. (The y position is not tested because | 385 // pointing precision. (The y position is not tested because |
| 404 // |hit_bounds_in_screen| is short.) | 386 // |hit_bounds_in_screen| is short.) |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 433 return; | 415 return; |
| 434 | 416 |
| 435 // For the sake of simplicity, ignore |widget_|'s activation in computing | 417 // For the sake of simplicity, ignore |widget_|'s activation in computing |
| 436 // whether the top-of-window views should stay revealed. Ideally, the | 418 // whether the top-of-window views should stay revealed. Ideally, the |
| 437 // top-of-window views would stay revealed only when the mouse cursor is | 419 // top-of-window views would stay revealed only when the mouse cursor is |
| 438 // hovered above a non-obscured portion of the top-of-window views. The | 420 // hovered above a non-obscured portion of the top-of-window views. The |
| 439 // top-of-window views may be partially obscured when |widget_| is inactive. | 421 // top-of-window views may be partially obscured when |widget_| is inactive. |
| 440 | 422 |
| 441 // Ignore all events while a window has capture. This keeps the top-of-window | 423 // Ignore all events while a window has capture. This keeps the top-of-window |
| 442 // views revealed during a drag. | 424 // views revealed during a drag. |
| 443 if (WmShell::Get()->GetCaptureWindow()) | 425 if (ImmersiveContext::Get()->DoesAnyWindowHaveCapture()) |
| 444 return; | 426 return; |
| 445 | 427 |
| 446 if ((!event || event->IsMouseEvent()) && | 428 if ((!event || event->IsMouseEvent()) && |
| 447 ShouldIgnoreMouseEventAtLocation(location_in_screen)) { | 429 ShouldIgnoreMouseEventAtLocation(location_in_screen)) { |
| 448 return; | 430 return; |
| 449 } | 431 } |
| 450 | 432 |
| 451 // The visible bounds of |top_container_| should be contained in | 433 // The visible bounds of |top_container_| should be contained in |
| 452 // |hit_bounds_in_screen|. | 434 // |hit_bounds_in_screen|. |
| 453 std::vector<gfx::Rect> hit_bounds_in_screen = | 435 std::vector<gfx::Rect> hit_bounds_in_screen = |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 469 } | 451 } |
| 470 } | 452 } |
| 471 | 453 |
| 472 if (keep_revealed) | 454 if (keep_revealed) |
| 473 AcquireLocatedEventRevealedLock(); | 455 AcquireLocatedEventRevealedLock(); |
| 474 else | 456 else |
| 475 located_event_revealed_lock_.reset(); | 457 located_event_revealed_lock_.reset(); |
| 476 } | 458 } |
| 477 | 459 |
| 478 void ImmersiveFullscreenController::UpdateLocatedEventRevealedLock() { | 460 void ImmersiveFullscreenController::UpdateLocatedEventRevealedLock() { |
| 479 if (!WmShell::Get()->IsMouseEventsEnabled()) { | 461 if (!ImmersiveContext::Get()->IsMouseEventsEnabled()) { |
| 480 // If mouse events are disabled, the user's last interaction was probably | 462 // If mouse events are disabled, the user's last interaction was probably |
| 481 // via touch. Do no do further processing in this case as there is no easy | 463 // via touch. Do no do further processing in this case as there is no easy |
| 482 // way of retrieving the position of the user's last touch. | 464 // way of retrieving the position of the user's last touch. |
| 483 return; | 465 return; |
| 484 } | 466 } |
| 485 UpdateLocatedEventRevealedLock( | 467 UpdateLocatedEventRevealedLock( |
| 486 nullptr, display::Screen::GetScreen()->GetCursorScreenPoint()); | 468 nullptr, display::Screen::GetScreen()->GetCursorScreenPoint()); |
| 487 } | 469 } |
| 488 | 470 |
| 489 void ImmersiveFullscreenController::AcquireLocatedEventRevealedLock() { | 471 void ImmersiveFullscreenController::AcquireLocatedEventRevealedLock() { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 506 if (reveal_state_ == SLIDING_CLOSED || reveal_state_ == CLOSED) { | 488 if (reveal_state_ == SLIDING_CLOSED || reveal_state_ == CLOSED) { |
| 507 if (swipe_type == SWIPE_OPEN && !located_event_revealed_lock_.get()) { | 489 if (swipe_type == SWIPE_OPEN && !located_event_revealed_lock_.get()) { |
| 508 located_event_revealed_lock_.reset(GetRevealedLock(ANIMATE_REVEAL_YES)); | 490 located_event_revealed_lock_.reset(GetRevealedLock(ANIMATE_REVEAL_YES)); |
| 509 return true; | 491 return true; |
| 510 } | 492 } |
| 511 } else { | 493 } else { |
| 512 if (swipe_type == SWIPE_CLOSE) { | 494 if (swipe_type == SWIPE_CLOSE) { |
| 513 // Attempt to end the reveal. If other code is holding onto a lock, the | 495 // Attempt to end the reveal. If other code is holding onto a lock, the |
| 514 // attempt will be unsuccessful. | 496 // attempt will be unsuccessful. |
| 515 located_event_revealed_lock_.reset(); | 497 located_event_revealed_lock_.reset(); |
| 516 immersive_focus_watcher_->ReleaseLock(); | 498 if (immersive_focus_watcher_) |
| 499 immersive_focus_watcher_->ReleaseLock(); | |
| 517 | 500 |
| 518 if (reveal_state_ == SLIDING_CLOSED || reveal_state_ == CLOSED) { | 501 if (reveal_state_ == SLIDING_CLOSED || reveal_state_ == CLOSED) { |
| 519 widget_->GetFocusManager()->ClearFocus(); | 502 widget_->GetFocusManager()->ClearFocus(); |
| 520 return true; | 503 return true; |
| 521 } | 504 } |
| 522 | 505 |
| 523 // Ending the reveal was unsuccessful. Reaquire the locks if appropriate. | 506 // Ending the reveal was unsuccessful. Reaquire the locks if appropriate. |
| 524 UpdateLocatedEventRevealedLock(); | 507 UpdateLocatedEventRevealedLock(); |
| 525 immersive_focus_watcher_->UpdateFocusRevealedLock(); | 508 if (immersive_focus_watcher_) |
| 509 immersive_focus_watcher_->UpdateFocusRevealedLock(); | |
| 526 } | 510 } |
| 527 } | 511 } |
| 528 return false; | 512 return false; |
| 529 } | 513 } |
| 530 | 514 |
| 531 int ImmersiveFullscreenController::GetAnimationDuration(Animate animate) const { | 515 int ImmersiveFullscreenController::GetAnimationDuration(Animate animate) const { |
| 532 switch (animate) { | 516 switch (animate) { |
| 533 case ANIMATE_NO: | 517 case ANIMATE_NO: |
| 534 return 0; | 518 return 0; |
| 535 case ANIMATE_SLOW: | 519 case ANIMATE_SLOW: |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 // fullscreen window on the bottom display. It is really hard to trigger a | 624 // fullscreen window on the bottom display. It is really hard to trigger a |
| 641 // reveal in this case because: | 625 // reveal in this case because: |
| 642 // - It is hard to stop the cursor in the top |kMouseRevealBoundsHeight| | 626 // - It is hard to stop the cursor in the top |kMouseRevealBoundsHeight| |
| 643 // pixels of the bottom display. | 627 // pixels of the bottom display. |
| 644 // - The cursor is warped to the top display if the cursor gets to the top | 628 // - The cursor is warped to the top display if the cursor gets to the top |
| 645 // edge of the bottom display. | 629 // edge of the bottom display. |
| 646 // Mouse events are ignored in the bottom few pixels of the top display | 630 // Mouse events are ignored in the bottom few pixels of the top display |
| 647 // (Mouse events in this region cannot start or end a reveal). This allows a | 631 // (Mouse events in this region cannot start or end a reveal). This allows a |
| 648 // user to overshoot the top of the bottom display and still reveal the | 632 // user to overshoot the top of the bottom display and still reveal the |
| 649 // top-of-window views. | 633 // top-of-window views. |
| 650 gfx::Rect dead_region = GetDisplayBoundsInScreen(widget_window_); | 634 gfx::Rect dead_region = GetDisplayBoundsInScreen(); |
| 651 dead_region.set_y(dead_region.y() - kHeightOfDeadRegionAboveTopContainer); | 635 dead_region.set_y(dead_region.y() - kHeightOfDeadRegionAboveTopContainer); |
| 652 dead_region.set_height(kHeightOfDeadRegionAboveTopContainer); | 636 dead_region.set_height(kHeightOfDeadRegionAboveTopContainer); |
| 653 return dead_region.Contains(location); | 637 return dead_region.Contains(location); |
| 654 } | 638 } |
| 655 | 639 |
| 656 bool ImmersiveFullscreenController::ShouldHandleGestureEvent( | 640 bool ImmersiveFullscreenController::ShouldHandleGestureEvent( |
| 657 const gfx::Point& location) const { | 641 const gfx::Point& location) const { |
| 658 DCHECK(widget_->IsActive()); | 642 DCHECK(widget_->IsActive()); |
| 659 if (reveal_state_ == REVEALED) { | 643 if (reveal_state_ == REVEALED) { |
| 660 std::vector<gfx::Rect> hit_bounds_in_screen( | 644 std::vector<gfx::Rect> hit_bounds_in_screen( |
| 661 delegate_->GetVisibleBoundsInScreen()); | 645 delegate_->GetVisibleBoundsInScreen()); |
| 662 for (size_t i = 0; i < hit_bounds_in_screen.size(); ++i) { | 646 for (size_t i = 0; i < hit_bounds_in_screen.size(); ++i) { |
| 663 if (hit_bounds_in_screen[i].Contains(location)) | 647 if (hit_bounds_in_screen[i].Contains(location)) |
| 664 return true; | 648 return true; |
| 665 } | 649 } |
| 666 return false; | 650 return false; |
| 667 } | 651 } |
| 668 | 652 |
| 669 // When the top-of-window views are not fully revealed, handle gestures which | 653 // When the top-of-window views are not fully revealed, handle gestures which |
| 670 // start in the top few pixels of the screen. | 654 // start in the top few pixels of the screen. |
| 671 gfx::Rect hit_bounds_in_screen(GetDisplayBoundsInScreen(widget_window_)); | 655 gfx::Rect hit_bounds_in_screen(GetDisplayBoundsInScreen()); |
| 672 hit_bounds_in_screen.set_height(kImmersiveFullscreenTopEdgeInset); | 656 hit_bounds_in_screen.set_height(kImmersiveFullscreenTopEdgeInset); |
| 673 if (hit_bounds_in_screen.Contains(location)) | 657 if (hit_bounds_in_screen.Contains(location)) |
| 674 return true; | 658 return true; |
| 675 | 659 |
| 676 // There may be a bezel sensor off screen logically above | 660 // There may be a bezel sensor off screen logically above |
| 677 // |hit_bounds_in_screen|. The check for the event not contained by the | 661 // |hit_bounds_in_screen|. The check for the event not contained by the |
| 678 // closest screen ensures that the event is from a valid bezel (as opposed to | 662 // closest screen ensures that the event is from a valid bezel (as opposed to |
| 679 // another screen in an extended desktop). | 663 // another screen in an extended desktop). |
| 680 gfx::Rect screen_bounds = | 664 gfx::Rect screen_bounds = |
| 681 display::Screen::GetScreen()->GetDisplayNearestPoint(location).bounds(); | 665 display::Screen::GetScreen()->GetDisplayNearestPoint(location).bounds(); |
| 682 return (!screen_bounds.Contains(location) && | 666 return (!screen_bounds.Contains(location) && |
| 683 location.y() < hit_bounds_in_screen.y() && | 667 location.y() < hit_bounds_in_screen.y() && |
| 684 location.x() >= hit_bounds_in_screen.x() && | 668 location.x() >= hit_bounds_in_screen.x() && |
| 685 location.x() < hit_bounds_in_screen.right()); | 669 location.x() < hit_bounds_in_screen.right()); |
| 686 } | 670 } |
| 687 | 671 |
| 672 gfx::Rect ImmersiveFullscreenController::GetDisplayBoundsInScreen() const { | |
| 673 return ImmersiveContext::Get()->GetDisplayBoundsInScreen(widget_); | |
| 674 } | |
| 675 | |
| 688 } // namespace ash | 676 } // namespace ash |
| OLD | NEW |