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 | 15 |
15 namespace ui { | 16 namespace ui { |
16 | 17 |
17 class WaylandWindow; | 18 class WaylandWindow; |
18 | 19 |
19 class WaylandDisplay : public PlatformEventSource, | 20 class WaylandDisplay : public PlatformEventSource, |
20 public base::MessagePumpLibevent::Watcher { | 21 public base::MessagePumpLibevent::Watcher { |
21 public: | 22 public: |
22 WaylandDisplay(); | 23 WaylandDisplay(); |
23 ~WaylandDisplay() override; | 24 ~WaylandDisplay() override; |
24 | 25 |
25 bool Initialize(); | 26 bool Initialize(); |
26 | 27 |
27 // Flushes the Wayland connection. | 28 // Flushes the Wayland connection. |
28 void Flush(); | 29 void Flush(); |
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(WaylandWindow* window); | 37 void AddWindow(WaylandWindow* window); |
37 void RemoveWindow(WaylandWindow* window); | 38 void RemoveWindow(WaylandWindow* window); |
38 | 39 |
39 private: | 40 private: |
| 41 void DispatchUiEvent(Event* event); |
| 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 |
| 58 // wl_seat_listener |
| 59 static void Capabilities(void* data, wl_seat* seat, uint32_t capabilities); |
| 60 static void Name(void* data, wl_seat* seat, const char* name); |
| 61 |
55 // xdg_shell_listener | 62 // xdg_shell_listener |
56 static void Ping(void* data, xdg_shell* shell, uint32_t serial); | 63 static void Ping(void* data, xdg_shell* shell, uint32_t serial); |
57 | 64 |
58 std::map<gfx::AcceleratedWidget, WaylandWindow*> window_map_; | 65 std::map<gfx::AcceleratedWidget, WaylandWindow*> window_map_; |
59 | 66 |
60 wl::Object<wl_display> display_; | 67 wl::Object<wl_display> display_; |
61 wl::Object<wl_registry> registry_; | 68 wl::Object<wl_registry> registry_; |
62 wl::Object<wl_compositor> compositor_; | 69 wl::Object<wl_compositor> compositor_; |
| 70 wl::Object<wl_seat> seat_; |
63 wl::Object<wl_shm> shm_; | 71 wl::Object<wl_shm> shm_; |
64 wl::Object<xdg_shell> shell_; | 72 wl::Object<xdg_shell> shell_; |
65 | 73 |
| 74 scoped_ptr<WaylandPointer> pointer_; |
| 75 |
66 bool watching_ = false; | 76 bool watching_ = false; |
67 base::MessagePumpLibevent::FileDescriptorWatcher controller_; | 77 base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
68 | 78 |
69 DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); | 79 DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); |
70 }; | 80 }; |
71 | 81 |
72 } // namespace ui | 82 } // namespace ui |
73 | 83 |
74 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ | 84 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ |
OLD | NEW |