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