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