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