1 | /*
|
---|
2 | * Copyright © 2014 Intel Corporation
|
---|
3 | *
|
---|
4 | * Permission to use, copy, modify, distribute, and sell this software
|
---|
5 | * and its documentation for any purpose is hereby granted without
|
---|
6 | * fee, provided that the above copyright notice appear in all copies
|
---|
7 | * and that both that copyright notice and this permission notice
|
---|
8 | * appear in supporting documentation, and that the name of the
|
---|
9 | * copyright holders not be used in advertising or publicity
|
---|
10 | * pertaining to distribution of the software without specific,
|
---|
11 | * written prior permission. The copyright holders make no
|
---|
12 | * representations about the suitability of this software for any
|
---|
13 | * purpose. It is provided "as is" without express or implied
|
---|
14 | * warranty.
|
---|
15 | *
|
---|
16 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
---|
17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
---|
18 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
---|
19 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
---|
20 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
---|
21 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
---|
22 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
23 | * SOFTWARE.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef XWAYLAND_H
|
---|
27 | #define XWAYLAND_H
|
---|
28 |
|
---|
29 | #include <dix-config.h>
|
---|
30 |
|
---|
31 | #include <stdio.h>
|
---|
32 | #include <unistd.h>
|
---|
33 | #include <errno.h>
|
---|
34 |
|
---|
35 | #include <wayland-client.h>
|
---|
36 |
|
---|
37 | #include <X11/X.h>
|
---|
38 |
|
---|
39 | #include <fb.h>
|
---|
40 | #include <input.h>
|
---|
41 | #include <dix.h>
|
---|
42 | #include <randrstr.h>
|
---|
43 | #include <exevents.h>
|
---|
44 |
|
---|
45 | struct xwl_screen {
|
---|
46 | int width;
|
---|
47 | int height;
|
---|
48 | int depth;
|
---|
49 | ScreenPtr screen;
|
---|
50 | WindowPtr pointer_limbo_window;
|
---|
51 | int expecting_event;
|
---|
52 |
|
---|
53 | int wm_fd;
|
---|
54 | int listen_fds[5];
|
---|
55 | int listen_fd_count;
|
---|
56 | int rootless;
|
---|
57 | int glamor;
|
---|
58 |
|
---|
59 | CreateScreenResourcesProcPtr CreateScreenResources;
|
---|
60 | CloseScreenProcPtr CloseScreen;
|
---|
61 | CreateWindowProcPtr CreateWindow;
|
---|
62 | DestroyWindowProcPtr DestroyWindow;
|
---|
63 | RealizeWindowProcPtr RealizeWindow;
|
---|
64 | UnrealizeWindowProcPtr UnrealizeWindow;
|
---|
65 |
|
---|
66 | struct xorg_list output_list;
|
---|
67 | struct xorg_list seat_list;
|
---|
68 | struct xorg_list damage_window_list;
|
---|
69 |
|
---|
70 | int wayland_fd;
|
---|
71 | struct wl_display *display;
|
---|
72 | struct wl_registry *registry;
|
---|
73 | struct wl_registry *input_registry;
|
---|
74 | struct wl_compositor *compositor;
|
---|
75 | struct wl_shm *shm;
|
---|
76 | struct wl_shell *shell;
|
---|
77 |
|
---|
78 | uint32_t serial;
|
---|
79 |
|
---|
80 | #define XWL_FORMAT_ARGB8888 (1 << 0)
|
---|
81 | #define XWL_FORMAT_XRGB8888 (1 << 1)
|
---|
82 | #define XWL_FORMAT_RGB565 (1 << 2)
|
---|
83 |
|
---|
84 | int prepare_read;
|
---|
85 |
|
---|
86 | char *device_name;
|
---|
87 | int drm_fd;
|
---|
88 | int fd_render_node;
|
---|
89 | struct wl_drm *drm;
|
---|
90 | uint32_t formats;
|
---|
91 | uint32_t capabilities;
|
---|
92 | void *egl_display, *egl_context;
|
---|
93 | struct gbm_device *gbm;
|
---|
94 | struct glamor_context *glamor_ctx;
|
---|
95 | };
|
---|
96 |
|
---|
97 | struct xwl_window {
|
---|
98 | struct xwl_screen *xwl_screen;
|
---|
99 | struct wl_surface *surface;
|
---|
100 | struct wl_shell_surface *shell_surface;
|
---|
101 | WindowPtr window;
|
---|
102 | DamagePtr damage;
|
---|
103 | struct xorg_list link_damage;
|
---|
104 | struct wl_callback *frame_callback;
|
---|
105 | };
|
---|
106 |
|
---|
107 | #define MODIFIER_META 0x01
|
---|
108 |
|
---|
109 | struct xwl_touch {
|
---|
110 | struct xwl_window *window;
|
---|
111 | int32_t id;
|
---|
112 | int x, y;
|
---|
113 | struct xorg_list link_touch;
|
---|
114 | };
|
---|
115 |
|
---|
116 | struct xwl_seat {
|
---|
117 | DeviceIntPtr pointer;
|
---|
118 | DeviceIntPtr keyboard;
|
---|
119 | DeviceIntPtr touch;
|
---|
120 | struct xwl_screen *xwl_screen;
|
---|
121 | struct wl_seat *seat;
|
---|
122 | struct wl_pointer *wl_pointer;
|
---|
123 | struct wl_keyboard *wl_keyboard;
|
---|
124 | struct wl_touch *wl_touch;
|
---|
125 | struct wl_array keys;
|
---|
126 | struct xwl_window *focus_window;
|
---|
127 | uint32_t id;
|
---|
128 | uint32_t pointer_enter_serial;
|
---|
129 | struct xorg_list link;
|
---|
130 | CursorPtr x_cursor;
|
---|
131 | struct wl_surface *cursor;
|
---|
132 | struct wl_callback *cursor_frame_cb;
|
---|
133 | Bool cursor_needs_update;
|
---|
134 |
|
---|
135 | struct xorg_list touches;
|
---|
136 |
|
---|
137 | size_t keymap_size;
|
---|
138 | char *keymap;
|
---|
139 | struct wl_surface *keyboard_focus;
|
---|
140 | };
|
---|
141 |
|
---|
142 | struct xwl_output {
|
---|
143 | struct xorg_list link;
|
---|
144 | struct wl_output *output;
|
---|
145 | uint32_t server_output_id;
|
---|
146 | struct xwl_screen *xwl_screen;
|
---|
147 | RROutputPtr randr_output;
|
---|
148 | RRCrtcPtr randr_crtc;
|
---|
149 | int32_t x, y, width, height;
|
---|
150 | Rotation rotation;
|
---|
151 | };
|
---|
152 |
|
---|
153 | struct xwl_pixmap;
|
---|
154 |
|
---|
155 | Bool xwl_screen_init_cursor(struct xwl_screen *xwl_screen);
|
---|
156 |
|
---|
157 | struct xwl_screen *xwl_screen_get(ScreenPtr screen);
|
---|
158 |
|
---|
159 | void xwl_seat_set_cursor(struct xwl_seat *xwl_seat);
|
---|
160 |
|
---|
161 | void xwl_seat_destroy(struct xwl_seat *xwl_seat);
|
---|
162 |
|
---|
163 | void xwl_seat_clear_touch(struct xwl_seat *xwl_seat, WindowPtr window);
|
---|
164 |
|
---|
165 | Bool xwl_screen_init_output(struct xwl_screen *xwl_screen);
|
---|
166 |
|
---|
167 | struct xwl_output *xwl_output_create(struct xwl_screen *xwl_screen,
|
---|
168 | uint32_t id);
|
---|
169 |
|
---|
170 | void xwl_output_destroy(struct xwl_output *xwl_output);
|
---|
171 |
|
---|
172 | RRModePtr xwayland_cvt(int HDisplay, int VDisplay,
|
---|
173 | float VRefresh, Bool Reduced, Bool Interlaced);
|
---|
174 |
|
---|
175 | void xwl_pixmap_set_private(PixmapPtr pixmap, struct xwl_pixmap *xwl_pixmap);
|
---|
176 | struct xwl_pixmap *xwl_pixmap_get(PixmapPtr pixmap);
|
---|
177 |
|
---|
178 |
|
---|
179 | Bool xwl_shm_create_screen_resources(ScreenPtr screen);
|
---|
180 | PixmapPtr xwl_shm_create_pixmap(ScreenPtr screen, int width, int height,
|
---|
181 | int depth, unsigned int hint);
|
---|
182 | Bool xwl_shm_destroy_pixmap(PixmapPtr pixmap);
|
---|
183 | struct wl_buffer *xwl_shm_pixmap_get_wl_buffer(PixmapPtr pixmap);
|
---|
184 |
|
---|
185 |
|
---|
186 | Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
|
---|
187 |
|
---|
188 | Bool xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
|
---|
189 | uint32_t id, uint32_t version);
|
---|
190 | struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap);
|
---|
191 |
|
---|
192 | #endif
|
---|