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 #ifndef ASH_WM_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ | 5 #ifndef ASH_SHARED_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ |
6 #define ASH_WM_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ | 6 #define ASH_SHARED_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "ash/common/wm/immersive/wm_immersive_fullscreen_controller.h" | 12 #include "ash/shared/immersive_revealed_lock.h" |
13 #include "ash/common/wm/immersive_revealed_lock.h" | |
14 #include "base/macros.h" | 13 #include "base/macros.h" |
15 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
16 #include "ui/gfx/animation/animation_delegate.h" | 15 #include "ui/gfx/animation/animation_delegate.h" |
17 #include "ui/views/pointer_watcher.h" | 16 #include "ui/views/pointer_watcher.h" |
18 #include "ui/views/widget/widget_observer.h" | 17 #include "ui/views/widget/widget_observer.h" |
19 | 18 |
20 namespace gfx { | 19 namespace gfx { |
21 class Point; | 20 class Point; |
22 class SlideAnimation; | 21 class SlideAnimation; |
23 } | 22 } |
24 | 23 |
25 namespace ui { | 24 namespace ui { |
26 class GestureEvent; | 25 class GestureEvent; |
27 class LocatedEvent; | 26 class LocatedEvent; |
28 class MouseEvent; | 27 class MouseEvent; |
29 class TouchEvent; | 28 class TouchEvent; |
30 } | 29 } |
31 | 30 |
32 namespace views { | 31 namespace views { |
33 class View; | 32 class View; |
34 class Widget; | 33 class Widget; |
35 } | 34 } |
36 | 35 |
37 namespace ash { | 36 namespace ash { |
38 | 37 |
39 class ImmersiveFocusWatcher; | 38 class ImmersiveFocusWatcher; |
| 39 class ImmersiveFullscreenControllerDelegate; |
40 class ImmersiveFullscreenControllerTestApi; | 40 class ImmersiveFullscreenControllerTestApi; |
41 class ImmersiveGestureHandler; | 41 class ImmersiveGestureHandler; |
42 class WmWindow; | 42 class WmWindow; |
43 | 43 |
44 class ASH_EXPORT ImmersiveFullscreenController | 44 class ASH_EXPORT ImmersiveFullscreenController |
45 : public WmImmersiveFullscreenController, | 45 : public gfx::AnimationDelegate, |
46 public gfx::AnimationDelegate, | |
47 public views::PointerWatcher, | 46 public views::PointerWatcher, |
48 public views::WidgetObserver, | 47 public views::WidgetObserver, |
49 public ImmersiveRevealedLock::Delegate { | 48 public ImmersiveRevealedLock::Delegate { |
50 public: | 49 public: |
| 50 // The enum is used for an enumerated histogram. New items should be only |
| 51 // added to the end. |
| 52 enum WindowType { |
| 53 WINDOW_TYPE_OTHER, |
| 54 WINDOW_TYPE_BROWSER, |
| 55 WINDOW_TYPE_HOSTED_APP, |
| 56 WINDOW_TYPE_PACKAGED_APP, |
| 57 WINDOW_TYPE_COUNT |
| 58 }; |
| 59 |
| 60 // How many pixels are reserved for touch-events towards the top of an |
| 61 // immersive-fullscreen window. |
| 62 static const int kImmersiveFullscreenTopEdgeInset; |
| 63 |
| 64 // The height in pixels of the region below the top edge of the display in |
| 65 // which the mouse can trigger revealing the top-of-window views. The height |
| 66 // must be greater than 1px because the top pixel is used to trigger moving |
| 67 // the cursor between displays if the user has a vertical display layout |
| 68 // (primary display above/below secondary display). |
51 static const int kMouseRevealBoundsHeight; | 69 static const int kMouseRevealBoundsHeight; |
52 | 70 |
53 ImmersiveFullscreenController(); | 71 ImmersiveFullscreenController(); |
54 ~ImmersiveFullscreenController() override; | 72 ~ImmersiveFullscreenController() override; |
55 | 73 |
56 // WmImmersiveFullscreenController overrides: | 74 // Initializes the controller. Must be called prior to enabling immersive |
57 void Init(WmImmersiveFullscreenControllerDelegate* delegate, | 75 // fullscreen via SetEnabled(). |top_container| is used to keep the |
| 76 // top-of-window views revealed when a child of |top_container| has focus. |
| 77 // |top_container| does not affect which mouse and touch events keep the |
| 78 // top-of-window views revealed. |widget| is the widget to make fullscreen. |
| 79 void Init(ImmersiveFullscreenControllerDelegate* delegate, |
58 views::Widget* widget, | 80 views::Widget* widget, |
59 views::View* top_container) override; | 81 views::View* top_container); |
60 void SetEnabled(WindowType window_type, bool enable) override; | 82 |
61 bool IsEnabled() const override; | 83 // Enables or disables immersive fullscreen. |
62 bool IsRevealed() const override; | 84 // |window_type| is the type of window which is put in immersive fullscreen. |
| 85 // It is only used for histogramming. |
| 86 void SetEnabled(WindowType window_type, bool enable); |
| 87 |
| 88 // Returns true if in immersive fullscreen. |
| 89 bool IsEnabled() const; |
| 90 |
| 91 // Returns true if in immersive fullscreen and the top-of-window views are |
| 92 // fully or partially visible. |
| 93 bool IsRevealed() const; |
63 | 94 |
64 // Returns a lock which will keep the top-of-window views revealed for its | 95 // Returns a lock which will keep the top-of-window views revealed for its |
65 // lifetime. Several locks can be obtained. When all of the locks are | 96 // lifetime. Several locks can be obtained. When all of the locks are |
66 // destroyed, if immersive fullscreen is enabled and there is nothing else | 97 // destroyed, if immersive fullscreen is enabled and there is nothing else |
67 // keeping the top-of-window views revealed, the top-of-window views will be | 98 // keeping the top-of-window views revealed, the top-of-window views will be |
68 // closed. This method always returns a valid lock regardless of whether | 99 // closed. This method always returns a valid lock regardless of whether |
69 // immersive fullscreen is enabled. The lock's lifetime can span immersive | 100 // immersive fullscreen is enabled. The lock's lifetime can span immersive |
70 // fullscreen being enabled / disabled. If acquiring the lock causes a reveal, | 101 // fullscreen being enabled / disabled. If acquiring the lock causes a reveal, |
71 // the top-of-window views will animate according to |animate_reveal|. The | 102 // the top-of-window views will animate according to |animate_reveal|. The |
72 // caller takes ownership of the returned lock. | 103 // caller takes ownership of the returned lock. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // the top container is closed "near" means either within the displayed | 218 // the top container is closed "near" means either within the displayed |
188 // bounds, above it, or within a few pixels below it. This allow the container | 219 // bounds, above it, or within a few pixels below it. This allow the container |
189 // to steal enough pixels to detect a swipe in and handles the case that there | 220 // to steal enough pixels to detect a swipe in and handles the case that there |
190 // is a bezel sensor above the top container. | 221 // is a bezel sensor above the top container. |
191 bool ShouldHandleGestureEvent(const gfx::Point& location) const; | 222 bool ShouldHandleGestureEvent(const gfx::Point& location) const; |
192 | 223 |
193 // Returns the display bounds of the screen |widget_| is on. | 224 // Returns the display bounds of the screen |widget_| is on. |
194 gfx::Rect GetDisplayBoundsInScreen() const; | 225 gfx::Rect GetDisplayBoundsInScreen() const; |
195 | 226 |
196 // Not owned. | 227 // Not owned. |
197 WmImmersiveFullscreenControllerDelegate* delegate_; | 228 ImmersiveFullscreenControllerDelegate* delegate_; |
198 views::View* top_container_; | 229 views::View* top_container_; |
199 views::Widget* widget_; | 230 views::Widget* widget_; |
200 // The WmWindow for |widget_|. | 231 // The WmWindow for |widget_|. |
201 WmWindow* widget_window_ = nullptr; | 232 WmWindow* widget_window_ = nullptr; |
202 | 233 |
203 // True if the observers have been enabled. | 234 // True if the observers have been enabled. |
204 bool observers_enabled_; | 235 bool observers_enabled_; |
205 | 236 |
206 // True when in immersive fullscreen. | 237 // True when in immersive fullscreen. |
207 bool enabled_; | 238 bool enabled_; |
(...skipping 29 matching lines...) Expand all Loading... |
237 std::unique_ptr<ImmersiveFocusWatcher> immersive_focus_watcher_; | 268 std::unique_ptr<ImmersiveFocusWatcher> immersive_focus_watcher_; |
238 std::unique_ptr<ImmersiveGestureHandler> immersive_gesture_handler_; | 269 std::unique_ptr<ImmersiveGestureHandler> immersive_gesture_handler_; |
239 | 270 |
240 base::WeakPtrFactory<ImmersiveFullscreenController> weak_ptr_factory_; | 271 base::WeakPtrFactory<ImmersiveFullscreenController> weak_ptr_factory_; |
241 | 272 |
242 DISALLOW_COPY_AND_ASSIGN(ImmersiveFullscreenController); | 273 DISALLOW_COPY_AND_ASSIGN(ImmersiveFullscreenController); |
243 }; | 274 }; |
244 | 275 |
245 } // namespace ash | 276 } // namespace ash |
246 | 277 |
247 #endif // ASH_WM_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ | 278 #endif // ASH_SHARED_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ |
OLD | NEW |