| 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 bool StartProcessingEvents(); | 27 bool StartProcessingEvents(); |
| 27 | 28 |
| 28 // Schedules a flush of the Wayland connection. | 29 // Schedules a flush of the Wayland connection. |
| 29 void ScheduleFlush(); | 30 void ScheduleFlush(); |
| 30 | 31 |
| 31 wl_display* display() { return display_.get(); } | 32 wl_display* display() { return display_.get(); } |
| 32 wl_compositor* compositor() { return compositor_.get(); } | 33 wl_compositor* compositor() { return compositor_.get(); } |
| 33 wl_shm* shm() { return shm_.get(); } | 34 wl_shm* shm() { return shm_.get(); } |
| 34 xdg_shell* shell() { return shell_.get(); } | 35 xdg_shell* shell() { return shell_.get(); } |
| 35 | 36 |
| 36 WaylandWindow* GetWindow(gfx::AcceleratedWidget widget); | 37 WaylandWindow* GetWindow(gfx::AcceleratedWidget widget); |
| 37 void AddWindow(gfx::AcceleratedWidget widget, WaylandWindow* window); | 38 void AddWindow(gfx::AcceleratedWidget widget, WaylandWindow* window); |
| 38 void RemoveWindow(gfx::AcceleratedWidget widget); | 39 void RemoveWindow(gfx::AcceleratedWidget widget); |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 void Flush(); | 42 void Flush(); |
| 43 void DispatchUiEvent(Event* event); |
| 42 | 44 |
| 43 // PlatformEventSource | 45 // PlatformEventSource |
| 44 void OnDispatcherListChanged() override; | 46 void OnDispatcherListChanged() override; |
| 45 | 47 |
| 46 // base::MessagePumpLibevent::Watcher | 48 // base::MessagePumpLibevent::Watcher |
| 47 void OnFileCanReadWithoutBlocking(int fd) override; | 49 void OnFileCanReadWithoutBlocking(int fd) override; |
| 48 void OnFileCanWriteWithoutBlocking(int fd) override; | 50 void OnFileCanWriteWithoutBlocking(int fd) override; |
| 49 | 51 |
| 50 // wl_registry_listener | 52 // wl_registry_listener |
| 51 static void Global(void* data, | 53 static void Global(void* data, |
| 52 wl_registry* registry, | 54 wl_registry* registry, |
| 53 uint32_t name, | 55 uint32_t name, |
| 54 const char* interface, | 56 const char* interface, |
| 55 uint32_t version); | 57 uint32_t version); |
| 56 static void GlobalRemove(void* data, wl_registry* registry, uint32_t name); | 58 static void GlobalRemove(void* data, wl_registry* registry, uint32_t name); |
| 57 | 59 |
| 60 // wl_seat_listener |
| 61 static void Capabilities(void* data, wl_seat* seat, uint32_t capabilities); |
| 62 static void Name(void* data, wl_seat* seat, const char* name); |
| 63 |
| 58 // xdg_shell_listener | 64 // xdg_shell_listener |
| 59 static void Ping(void* data, xdg_shell* shell, uint32_t serial); | 65 static void Ping(void* data, xdg_shell* shell, uint32_t serial); |
| 60 | 66 |
| 61 std::map<gfx::AcceleratedWidget, WaylandWindow*> window_map_; | 67 std::map<gfx::AcceleratedWidget, WaylandWindow*> window_map_; |
| 62 | 68 |
| 63 wl::Object<wl_display> display_; | 69 wl::Object<wl_display> display_; |
| 64 wl::Object<wl_registry> registry_; | 70 wl::Object<wl_registry> registry_; |
| 65 wl::Object<wl_compositor> compositor_; | 71 wl::Object<wl_compositor> compositor_; |
| 72 wl::Object<wl_seat> seat_; |
| 66 wl::Object<wl_shm> shm_; | 73 wl::Object<wl_shm> shm_; |
| 67 wl::Object<xdg_shell> shell_; | 74 wl::Object<xdg_shell> shell_; |
| 68 | 75 |
| 76 scoped_ptr<WaylandPointer> pointer_; |
| 77 |
| 69 bool scheduled_flush_ = false; | 78 bool scheduled_flush_ = false; |
| 70 bool watching_ = false; | 79 bool watching_ = false; |
| 71 base::MessagePumpLibevent::FileDescriptorWatcher controller_; | 80 base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
| 72 | 81 |
| 73 DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); | 82 DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); |
| 74 }; | 83 }; |
| 75 | 84 |
| 76 } // namespace ui | 85 } // namespace ui |
| 77 | 86 |
| 78 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ | 87 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_DISPLAY_H_ |
| OLD | NEW |