| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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 UI_WAYLAND_WAYLAND_DISPLAY_H_ | |
| 6 #define UI_WAYLAND_WAYLAND_DISPLAY_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <list> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 | |
| 14 struct wl_compositor; | |
| 15 struct wl_display; | |
| 16 struct wl_shell; | |
| 17 struct wl_shm; | |
| 18 struct wl_surface; | |
| 19 | |
| 20 namespace ui { | |
| 21 | |
| 22 class WaylandBuffer; | |
| 23 class WaylandInputDevice; | |
| 24 class WaylandScreen; | |
| 25 | |
| 26 // WaylandDisplay is a wrapper around wl_display. Once we get a valid | |
| 27 // wl_display, the Wayland server will send different events to register | |
| 28 // the Wayland compositor, shell, screens, input devices, ... | |
| 29 class WaylandDisplay { | |
| 30 public: | |
| 31 // Attempt to create a connection to the display. If it fails this returns | |
| 32 // NULL | |
| 33 static WaylandDisplay* Connect(char* name); | |
| 34 | |
| 35 // Get the WaylandDisplay associated with the native Wayland display | |
| 36 static WaylandDisplay* GetDisplay(wl_display* display); | |
| 37 | |
| 38 ~WaylandDisplay(); | |
| 39 | |
| 40 // Creates a wayland surface. This is used to create a window surface. | |
| 41 // The returned pointer should be deleted by the caller. | |
| 42 wl_surface* CreateSurface(); | |
| 43 | |
| 44 // Sets the specified buffer as the surface for the cursor. (x, y) is | |
| 45 // the hotspot for the cursor. | |
| 46 void SetCursor(WaylandBuffer* buffer, int32_t x, int32_t y); | |
| 47 | |
| 48 // Returns a pointer to the wl_display. | |
| 49 wl_display* display() const { return display_; } | |
| 50 | |
| 51 // Returns a list of the registered screens. | |
| 52 std::list<WaylandScreen*> GetScreenList() const; | |
| 53 | |
| 54 wl_shell* shell() const { return shell_; } | |
| 55 | |
| 56 wl_shm* shm() const { return shm_; } | |
| 57 | |
| 58 private: | |
| 59 WaylandDisplay(char* name); | |
| 60 | |
| 61 // This handler resolves all server events used in initialization. It also | |
| 62 // handles input device registration, screen registration. | |
| 63 static void DisplayHandleGlobal(wl_display* display, | |
| 64 uint32_t id, | |
| 65 const char* interface, | |
| 66 uint32_t version, | |
| 67 void* data); | |
| 68 | |
| 69 // Used when the shell requires configuration. This is called when a | |
| 70 // window is configured and receives its size. | |
| 71 // TODO(dnicoara) Need to look if there is one shell per window. Then it | |
| 72 // makes more sense to move this into the WaylandWindow and it would keep | |
| 73 // track of the shell. | |
| 74 static void ShellHandleConfigure(void* data, | |
| 75 wl_shell* shell, | |
| 76 uint32_t time, | |
| 77 uint32_t edges, | |
| 78 wl_surface* surface, | |
| 79 int32_t width, | |
| 80 int32_t height); | |
| 81 | |
| 82 // WaylandDisplay manages the memory of all these pointers. | |
| 83 wl_display* display_; | |
| 84 wl_compositor* compositor_; | |
| 85 wl_shell* shell_; | |
| 86 wl_shm* shm_; | |
| 87 std::list<WaylandScreen*> screen_list_; | |
| 88 std::list<WaylandInputDevice*> input_list_; | |
| 89 | |
| 90 DISALLOW_COPY_AND_ASSIGN(WaylandDisplay); | |
| 91 }; | |
| 92 | |
| 93 } // namespace ui | |
| 94 | |
| 95 #endif // UI_WAYLAND_WAYLAND_DISPLAY_H_ | |
| OLD | NEW |