OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BLIMP_CLIENT_APP_LINUX_BLIMP_DISPLAY_MANAGER_H_ | |
6 #define BLIMP_CLIENT_APP_LINUX_BLIMP_DISPLAY_MANAGER_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "ui/events/event.h" | |
12 #include "ui/events/gestures/motion_event_aura.h" | |
13 #include "ui/platform_window/platform_window_delegate.h" | |
14 | |
15 namespace gfx { | |
16 class Size; | |
17 } | |
18 | |
19 namespace ui { | |
20 class PlatformEventSource; | |
21 class PlatformWindow; | |
22 } | |
23 | |
24 namespace blimp { | |
25 namespace client { | |
26 | |
27 class BrowserCompositor; | |
28 class BlimpContents; | |
29 class CompositorDependencies; | |
30 | |
31 class BlimpDisplayManagerDelegate { | |
32 public: | |
33 virtual void OnClosed() = 0; | |
34 }; | |
35 | |
36 // Manages an X11 window that interacts with a Compositor by listening to the | |
37 // window's event handlers | |
38 class BlimpDisplayManager : public ui::PlatformWindowDelegate { | |
39 public: | |
40 // |delegate|: The delegate to receive the OnClosed call. | |
41 // |compositor_dependencies|: Set of compositor dependencies provided by the | |
42 // embedder. | |
43 BlimpDisplayManager(BlimpDisplayManagerDelegate* delegate, | |
44 CompositorDependencies* compositor_dependencies); | |
45 ~BlimpDisplayManager() override; | |
46 | |
47 void SetWindowSize(const gfx::Size& window_size); | |
48 void SetBlimpContents(std::unique_ptr<BlimpContents> contents); | |
49 | |
50 // ui::PlatformWindowDelegate implementation. | |
51 void OnBoundsChanged(const gfx::Rect& new_bounds) override; | |
52 void OnDamageRect(const gfx::Rect& damaged_region) override {} | |
53 void DispatchEvent(ui::Event* event) override; | |
54 void OnCloseRequest() override; | |
55 void OnClosed() override; | |
56 void OnWindowStateChanged(ui::PlatformWindowState new_state) override {} | |
57 void OnLostCapture() override {} | |
58 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, | |
59 float device_pixel_ratio) override; | |
60 void OnAcceleratedWidgetDestroyed() override; | |
61 void OnActivationChanged(bool active) override {} | |
62 | |
63 private: | |
64 // Dispatch a given mouse event as a touch event. | |
65 void DispatchMouseEvent(ui::MouseEvent* mouse_event); | |
66 | |
67 // Dispatch a given mousewheel scroll event as a pinch/zoom touch event. | |
68 void DispatchMouseWheelEvent(ui::MouseWheelEvent* mouse_event); | |
69 | |
70 // Dispatch a given touch event as part of a stream of touch events. | |
71 void DispatchMotionEventAura(ui::MotionEventAura* touch_event_stream, | |
72 ui::EventType event_type, | |
73 int pointer_id, | |
74 int pointer_x, | |
75 int pointer_y); | |
76 | |
77 // Simulate a pinch/zoom touch event. | |
78 void Zoom(int pointer_x, int pointer_y, int y_offset, bool zoom_out); | |
79 | |
80 float device_pixel_ratio_; | |
81 | |
82 BlimpDisplayManagerDelegate* delegate_; | |
83 | |
84 std::unique_ptr<BrowserCompositor> compositor_; | |
85 std::unique_ptr<BlimpContents> contents_; | |
86 std::unique_ptr<ui::PlatformEventSource> platform_event_source_; | |
87 std::unique_ptr<ui::PlatformWindow> platform_window_; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(BlimpDisplayManager); | |
90 }; | |
91 | |
92 } // namespace client | |
93 } // namespace blimp | |
94 | |
95 #endif // BLIMP_CLIENT_APP_LINUX_BLIMP_DISPLAY_MANAGER_H_ | |
OLD | NEW |