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 #include "ui/ozone/platform/wayland/wayland_pointer.h" | 14 #include "ui/ozone/platform/wayland/wayland_pointer.h" |
15 #include "ui/ozone/platform/wayland/wayland_screen.h" | |
15 | 16 |
16 namespace ui { | 17 namespace ui { |
17 | 18 |
18 class WaylandWindow; | 19 class WaylandWindow; |
19 | 20 |
20 class WaylandDisplay : public PlatformEventSource, | 21 class WaylandDisplay : public PlatformEventSource, |
21 public base::MessagePumpLibevent::Watcher { | 22 public base::MessagePumpLibevent::Watcher { |
22 public: | 23 public: |
23 WaylandDisplay(); | 24 WaylandDisplay(); |
24 ~WaylandDisplay() override; | 25 ~WaylandDisplay() override; |
25 | 26 |
27 static WaylandDisplay* GetInstance() { return instance_; } | |
26 bool Initialize(); | 28 bool Initialize(); |
27 bool StartProcessingEvents(); | 29 bool StartProcessingEvents(); |
28 | 30 |
29 // Schedules a flush of the Wayland connection. | 31 // Schedules a flush of the Wayland connection. |
30 void ScheduleFlush(); | 32 void ScheduleFlush(); |
31 | 33 |
32 wl_display* display() { return display_.get(); } | 34 wl_display* display() { return display_.get(); } |
33 wl_compositor* compositor() { return compositor_.get(); } | 35 wl_compositor* compositor() { return compositor_.get(); } |
34 wl_shm* shm() { return shm_.get(); } | 36 wl_shm* shm() { return shm_.get(); } |
35 xdg_shell* shell() { return shell_.get(); } | 37 xdg_shell* shell() { return shell_.get(); } |
36 | 38 |
37 WaylandWindow* GetWindow(gfx::AcceleratedWidget widget); | 39 WaylandWindow* GetWindow(gfx::AcceleratedWidget widget); |
38 void AddWindow(gfx::AcceleratedWidget widget, WaylandWindow* window); | 40 void AddWindow(gfx::AcceleratedWidget widget, WaylandWindow* window); |
39 void RemoveWindow(gfx::AcceleratedWidget widget); | 41 void RemoveWindow(gfx::AcceleratedWidget widget); |
40 | 42 |
43 const std::vector<WaylandScreen*>& GetScreenList() const; | |
44 WaylandScreen* PrimaryScreen() const { return primary_screen_; } | |
tonikitoo
2016/06/06 21:35:15
Minor: For the purposes of a simple API, I believ
joone
2016/06/07 22:27:00
Done.
| |
45 void OutputSizeChanged(int32_t name, unsigned width, unsigned height); | |
46 | |
47 void SetOutputCompleteClosure(const base::Closure&); | |
48 | |
41 private: | 49 private: |
42 void Flush(); | 50 void Flush(); |
43 void DispatchUiEvent(Event* event); | 51 void DispatchUiEvent(Event* event); |
44 | 52 |
45 // PlatformEventSource | 53 // PlatformEventSource |
46 void OnDispatcherListChanged() override; | 54 void OnDispatcherListChanged() override; |
47 | 55 |
48 // base::MessagePumpLibevent::Watcher | 56 // base::MessagePumpLibevent::Watcher |
49 void OnFileCanReadWithoutBlocking(int fd) override; | 57 void OnFileCanReadWithoutBlocking(int fd) override; |
50 void OnFileCanWriteWithoutBlocking(int fd) override; | 58 void OnFileCanWriteWithoutBlocking(int fd) override; |
51 | 59 |
52 // wl_registry_listener | 60 // wl_registry_listener |
53 static void Global(void* data, | 61 static void Global(void* data, |
54 wl_registry* registry, | 62 wl_registry* registry, |
55 uint32_t name, | 63 uint32_t name, |
56 const char* interface, | 64 const char* interface, |
57 uint32_t version); | 65 uint32_t version); |
58 static void GlobalRemove(void* data, wl_registry* registry, uint32_t name); | 66 static void GlobalRemove(void* data, wl_registry* registry, uint32_t name); |
59 | 67 |
60 // wl_seat_listener | 68 // wl_seat_listener |
61 static void Capabilities(void* data, wl_seat* seat, uint32_t capabilities); | 69 static void Capabilities(void* data, wl_seat* seat, uint32_t capabilities); |
62 static void Name(void* data, wl_seat* seat, const char* name); | 70 static void Name(void* data, wl_seat* seat, const char* name); |
63 | 71 |
64 // xdg_shell_listener | 72 // xdg_shell_listener |
65 static void Ping(void* data, xdg_shell* shell, uint32_t serial); | 73 static void Ping(void* data, xdg_shell* shell, uint32_t serial); |
66 | 74 |
67 std::map<gfx::AcceleratedWidget, WaylandWindow*> window_map_; | 75 std::map<gfx::AcceleratedWidget, WaylandWindow*> window_map_; |
76 static WaylandDisplay* instance_; | |
68 | 77 |
69 wl::Object<wl_display> display_; | 78 wl::Object<wl_display> display_; |
70 wl::Object<wl_registry> registry_; | 79 wl::Object<wl_registry> registry_; |
71 wl::Object<wl_compositor> compositor_; | 80 wl::Object<wl_compositor> compositor_; |
72 wl::Object<wl_seat> seat_; | 81 wl::Object<wl_seat> seat_; |
73 wl::Object<wl_shm> shm_; | 82 wl::Object<wl_shm> shm_; |
74 wl::Object<xdg_shell> shell_; | 83 wl::Object<xdg_shell> shell_; |
75 | 84 |
76 std::unique_ptr<WaylandPointer> pointer_; | 85 std::unique_ptr<WaylandPointer> pointer_; |
77 | 86 |
78 bool scheduled_flush_ = false; | 87 bool scheduled_flush_ = false; |
79 bool watching_ = false; | 88 bool watching_ = false; |
80 base::MessagePumpLibevent::FileDescriptorWatcher controller_; | 89 base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
81 | 90 |
91 WaylandScreen* primary_screen_; | |
92 std::vector<WaylandScreen*> screen_list_; | |
93 | |
94 base::Closure output_complete_closure_; | |
95 | |
82 DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); | 96 DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); |
83 }; | 97 }; |
84 | 98 |
85 } // namespace ui | 99 } // namespace ui |
86 | 100 |
87 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ | 101 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ |
OLD | NEW |