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 #ifndef UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ | 5 #ifndef UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ |
6 #define UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ | 6 #define UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/message_loop/message_pump_libevent.h" | 10 #include "base/message_loop/message_pump_libevent.h" |
11 #include "ui/events/platform/platform_event_source.h" | 11 #include "ui/events/platform/platform_event_source.h" |
12 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
13 #include "ui/ozone/platform/wayland/wayland_object.h" | 13 #include "ui/ozone/platform/wayland/wayland_object.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 class WaylandWindow; | 17 class WaylandWindow; |
18 | 18 |
19 class WaylandDisplay : public PlatformEventSource, | 19 class WaylandDisplay : public PlatformEventSource, |
20 public base::MessagePumpLibevent::Watcher { | 20 public base::MessagePumpLibevent::Watcher { |
21 public: | 21 public: |
22 WaylandDisplay(); | 22 WaylandDisplay(); |
23 ~WaylandDisplay() override; | 23 ~WaylandDisplay() override; |
24 | 24 |
25 bool Initialize(); | 25 bool Initialize(); |
| 26 bool StartProcessingEvents(); |
26 | 27 |
27 // Flushes the Wayland connection. | 28 // Schedules a flush of the Wayland connection. |
28 void Flush(); | 29 void ScheduleFlush(); |
29 | 30 |
30 wl_display* display() { return display_.get(); } | 31 wl_display* display() { return display_.get(); } |
31 wl_compositor* compositor() { return compositor_.get(); } | 32 wl_compositor* compositor() { return compositor_.get(); } |
32 wl_shm* shm() { return shm_.get(); } | 33 wl_shm* shm() { return shm_.get(); } |
33 xdg_shell* shell() { return shell_.get(); } | 34 xdg_shell* shell() { return shell_.get(); } |
34 | 35 |
35 WaylandWindow* GetWindow(gfx::AcceleratedWidget widget); | 36 WaylandWindow* GetWindow(gfx::AcceleratedWidget widget); |
36 void AddWindow(gfx::AcceleratedWidget widget, WaylandWindow* window); | 37 void AddWindow(gfx::AcceleratedWidget widget, WaylandWindow* window); |
37 void RemoveWindow(gfx::AcceleratedWidget widget); | 38 void RemoveWindow(gfx::AcceleratedWidget widget); |
38 | 39 |
39 private: | 40 private: |
| 41 void Flush(); |
| 42 |
40 // PlatformEventSource | 43 // PlatformEventSource |
41 void OnDispatcherListChanged() override; | 44 void OnDispatcherListChanged() override; |
42 | 45 |
43 // base::MessagePumpLibevent::Watcher | 46 // base::MessagePumpLibevent::Watcher |
44 void OnFileCanReadWithoutBlocking(int fd) override; | 47 void OnFileCanReadWithoutBlocking(int fd) override; |
45 void OnFileCanWriteWithoutBlocking(int fd) override; | 48 void OnFileCanWriteWithoutBlocking(int fd) override; |
46 | 49 |
47 // wl_registry_listener | 50 // wl_registry_listener |
48 static void Global(void* data, | 51 static void Global(void* data, |
49 wl_registry* registry, | 52 wl_registry* registry, |
50 uint32_t name, | 53 uint32_t name, |
51 const char* interface, | 54 const char* interface, |
52 uint32_t version); | 55 uint32_t version); |
53 static void GlobalRemove(void* data, wl_registry* registry, uint32_t name); | 56 static void GlobalRemove(void* data, wl_registry* registry, uint32_t name); |
54 | 57 |
55 // xdg_shell_listener | 58 // xdg_shell_listener |
56 static void Ping(void* data, xdg_shell* shell, uint32_t serial); | 59 static void Ping(void* data, xdg_shell* shell, uint32_t serial); |
57 | 60 |
58 std::map<gfx::AcceleratedWidget, WaylandWindow*> window_map_; | 61 std::map<gfx::AcceleratedWidget, WaylandWindow*> window_map_; |
59 | 62 |
60 wl::Object<wl_display> display_; | 63 wl::Object<wl_display> display_; |
61 wl::Object<wl_registry> registry_; | 64 wl::Object<wl_registry> registry_; |
62 wl::Object<wl_compositor> compositor_; | 65 wl::Object<wl_compositor> compositor_; |
63 wl::Object<wl_shm> shm_; | 66 wl::Object<wl_shm> shm_; |
64 wl::Object<xdg_shell> shell_; | 67 wl::Object<xdg_shell> shell_; |
65 | 68 |
| 69 bool scheduled_flush_ = false; |
66 bool watching_ = false; | 70 bool watching_ = false; |
67 base::MessagePumpLibevent::FileDescriptorWatcher controller_; | 71 base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
68 | 72 |
69 DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); | 73 DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); |
70 }; | 74 }; |
71 | 75 |
72 } // namespace ui | 76 } // namespace ui |
73 | 77 |
74 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ | 78 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ |
OLD | NEW |