| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_context_ash.h" | 5 #include "ash/wm/immersive_context_ash.h" |
| 6 | 6 |
| 7 #include "ash/shared/immersive_fullscreen_controller.h" | 7 #include "ash/shared/immersive_fullscreen_controller.h" |
| 8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_port.h" | 10 #include "ash/shell_port.h" |
| 11 #include "ash/wm/resize_handle_window_targeter.h" |
| 11 #include "ash/wm/window_state.h" | 12 #include "ash/wm/window_state.h" |
| 12 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 13 #include "ash/wm_window.h" | |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "ui/display/display.h" | 15 #include "ui/display/display.h" |
| 16 #include "ui/display/screen.h" | 16 #include "ui/display/screen.h" |
| 17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 | 18 |
| 19 namespace ash { | 19 namespace ash { |
| 20 | 20 |
| 21 ImmersiveContextAsh::ImmersiveContextAsh() {} | 21 ImmersiveContextAsh::ImmersiveContextAsh() {} |
| 22 | 22 |
| 23 ImmersiveContextAsh::~ImmersiveContextAsh() {} | 23 ImmersiveContextAsh::~ImmersiveContextAsh() {} |
| 24 | 24 |
| 25 void ImmersiveContextAsh::InstallResizeHandleWindowTargeter( | 25 void ImmersiveContextAsh::InstallResizeHandleWindowTargeter( |
| 26 ImmersiveFullscreenController* controller) { | 26 ImmersiveFullscreenController* controller) { |
| 27 WmWindow* window = WmWindow::Get(controller->widget()->GetNativeWindow()); | 27 aura::Window* window = controller->widget()->GetNativeWindow(); |
| 28 window->InstallResizeHandleWindowTargeter(controller); | 28 window->SetEventTargeter( |
| 29 base::MakeUnique<ResizeHandleWindowTargeter>(window, controller)); |
| 29 } | 30 } |
| 30 | 31 |
| 31 void ImmersiveContextAsh::OnEnteringOrExitingImmersive( | 32 void ImmersiveContextAsh::OnEnteringOrExitingImmersive( |
| 32 ImmersiveFullscreenController* controller, | 33 ImmersiveFullscreenController* controller, |
| 33 bool entering) { | 34 bool entering) { |
| 34 WmWindow* window = WmWindow::Get(controller->widget()->GetNativeWindow()); | 35 aura::Window* window = controller->widget()->GetNativeWindow(); |
| 35 wm::WindowState* window_state = window->GetWindowState(); | 36 wm::WindowState* window_state = wm::GetWindowState(window); |
| 36 // Auto hide the shelf in immersive fullscreen instead of hiding it. | 37 // Auto hide the shelf in immersive fullscreen instead of hiding it. |
| 37 window_state->set_hide_shelf_when_fullscreen(!entering); | 38 window_state->set_hide_shelf_when_fullscreen(!entering); |
| 38 // Update the window's immersive mode state for the window manager. | 39 // Update the window's immersive mode state for the window manager. |
| 39 window_state->set_in_immersive_fullscreen(entering); | 40 window_state->set_in_immersive_fullscreen(entering); |
| 40 | 41 |
| 41 for (aura::Window* root_window : Shell::GetAllRootWindows()) | 42 for (aura::Window* root_window : Shell::GetAllRootWindows()) |
| 42 Shelf::ForWindow(root_window)->UpdateVisibilityState(); | 43 Shelf::ForWindow(root_window)->UpdateVisibilityState(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 gfx::Rect ImmersiveContextAsh::GetDisplayBoundsInScreen(views::Widget* widget) { | 46 gfx::Rect ImmersiveContextAsh::GetDisplayBoundsInScreen(views::Widget* widget) { |
| 46 WmWindow* window = WmWindow::Get(widget->GetNativeWindow()); | 47 display::Display display = |
| 47 return window->GetDisplayNearestWindow().bounds(); | 48 display::Screen::GetScreen()->GetDisplayNearestWindow( |
| 49 widget->GetNativeWindow()); |
| 50 return display.bounds(); |
| 48 } | 51 } |
| 49 | 52 |
| 50 void ImmersiveContextAsh::AddPointerWatcher( | 53 void ImmersiveContextAsh::AddPointerWatcher( |
| 51 views::PointerWatcher* watcher, | 54 views::PointerWatcher* watcher, |
| 52 views::PointerWatcherEventTypes events) { | 55 views::PointerWatcherEventTypes events) { |
| 53 ShellPort::Get()->AddPointerWatcher(watcher, events); | 56 ShellPort::Get()->AddPointerWatcher(watcher, events); |
| 54 } | 57 } |
| 55 | 58 |
| 56 void ImmersiveContextAsh::RemovePointerWatcher(views::PointerWatcher* watcher) { | 59 void ImmersiveContextAsh::RemovePointerWatcher(views::PointerWatcher* watcher) { |
| 57 ShellPort::Get()->RemovePointerWatcher(watcher); | 60 ShellPort::Get()->RemovePointerWatcher(watcher); |
| 58 } | 61 } |
| 59 | 62 |
| 60 bool ImmersiveContextAsh::DoesAnyWindowHaveCapture() { | 63 bool ImmersiveContextAsh::DoesAnyWindowHaveCapture() { |
| 61 return wm::GetCaptureWindow() != nullptr; | 64 return wm::GetCaptureWindow() != nullptr; |
| 62 } | 65 } |
| 63 | 66 |
| 64 bool ImmersiveContextAsh::IsMouseEventsEnabled() { | 67 bool ImmersiveContextAsh::IsMouseEventsEnabled() { |
| 65 return ShellPort::Get()->IsMouseEventsEnabled(); | 68 return ShellPort::Get()->IsMouseEventsEnabled(); |
| 66 } | 69 } |
| 67 | 70 |
| 68 } // namespace ash | 71 } // namespace ash |
| OLD | NEW |