1 /*
2 * Xephyr - A kdrive X server thats runs in a host X window.
3 * Authored by Matthew Allum <mallum@o-hand.com>
4 *
5 * Copyright © 2004 Nokia
6 *
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of Nokia not be used in
12 * advertising or publicity pertaining to distribution of the software without
13 * specific, written prior permission. Nokia makes no
14 * representations about the suitability of this software for any purpose. It
15 * is provided "as is" without express or implied warranty.
16 *
17 * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
19 * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23 * PERFORMANCE OF THIS SOFTWARE.
24 */
25
26 #ifndef _EPHYR_H_
27 #define _EPHYR_H_
28 #include <stdio.h>
29 #include <unistd.h>
30 #include <libgen.h>
31 #include <xcb/xcb_image.h>
32
33 #include "os.h" /* for OsSignal() */
34 #include "kdrive.h"
35 #include "hostx.h"
36 #include "exa.h"
37
38 #ifdef RANDR
39 #include "randrstr.h"
40 #endif
41
42 #include "damage.h"
43
44 typedef struct _ephyrPriv {
45 CARD8 *base;
46 int bytes_per_line;
47 } EphyrPriv;
48
49 typedef struct _ephyrFakexaPriv {
50 ExaDriverPtr exa;
51 Bool is_synced;
52
53 /* The following are arguments and other information from Prepare* calls
54 * which are stored for use in the inner calls.
55 */
56 int op;
57 PicturePtr pSrcPicture, pMaskPicture, pDstPicture;
58 void *saved_ptrs[3];
59 PixmapPtr pDst, pSrc, pMask;
60 GCPtr pGC;
61 } EphyrFakexaPriv;
62
63 typedef struct _ephyrScrPriv {
64 /* ephyr server info */
65 Rotation randr;
66 Bool shadow;
67 DamagePtr pDamage;
68 EphyrFakexaPriv *fakexa;
69
70 /* Host X window info */
71 xcb_window_t win;
72 xcb_window_t win_pre_existing; /* Set via -parent option like xnest */
73 xcb_window_t peer_win; /* Used for GL; should be at most one */
74 xcb_image_t *ximg;
75 Bool win_explicit_position;
76 int win_x, win_y;
77 int win_width, win_height;
78 int server_depth;
79 const char *output; /* Set via -output option */
80 unsigned char *fb_data; /* only used when host bpp != server bpp */
81 xcb_shm_segment_info_t shminfo;
82 size_t shmsize;
83
84 KdScreenInfo *screen;
85 int mynum; /* Screen number */
86 unsigned long cmap[256];
87
88 ScreenBlockHandlerProcPtr BlockHandler;
89
90 /**
91 * Per-screen Xlib-using state for glamor (private to
92 * ephyr_glamor_glx.c)
93 */
94 struct ephyr_glamor *glamor;
95 } EphyrScrPriv;
96
97 extern KdCardFuncs ephyrFuncs;
98 extern KdKeyboardInfo *ephyrKbd;
99 extern KdPointerInfo *ephyrMouse;
100
101 extern miPointerScreenFuncRec ephyrPointerScreenFuncs;
102
103 Bool
104 ephyrInitialize(KdCardInfo * card, EphyrPriv * priv);
105
106 Bool
107 ephyrCardInit(KdCardInfo * card);
108
109 Bool
110 ephyrScreenInitialize(KdScreenInfo *screen);
111
112 Bool
113 ephyrInitScreen(ScreenPtr pScreen);
114
115 Bool
116 ephyrFinishInitScreen(ScreenPtr pScreen);
117
118 Bool
119 ephyrCreateResources(ScreenPtr pScreen);
120
121 void
122 ephyrPreserve(KdCardInfo * card);
123
124 Bool
125 ephyrEnable(ScreenPtr pScreen);
126
127 Bool
128 ephyrDPMS(ScreenPtr pScreen, int mode);
129
130 void
131 ephyrDisable(ScreenPtr pScreen);
132
133 void
134 ephyrRestore(KdCardInfo * card);
135
136 void
137 ephyrScreenFini(KdScreenInfo * screen);
138
139 void
140 ephyrCloseScreen(ScreenPtr pScreen);
141
142 void
143 ephyrCardFini(KdCardInfo * card);
144
145 void
146 ephyrGetColors(ScreenPtr pScreen, int n, xColorItem * pdefs);
147
148 void
149 ephyrPutColors(ScreenPtr pScreen, int n, xColorItem * pdefs);
150
151 Bool
152 ephyrMapFramebuffer(KdScreenInfo * screen);
153
154 void *ephyrWindowLinear(ScreenPtr pScreen,
155 CARD32 row,
156 CARD32 offset, int mode, CARD32 *size, void *closure);
157
158 void
159 ephyrSetScreenSizes(ScreenPtr pScreen);
160
161 Bool
162 ephyrUnmapFramebuffer(KdScreenInfo * screen);
163
164 void
165 ephyrUnsetInternalDamage(ScreenPtr pScreen);
166
167 Bool
168 ephyrSetInternalDamage(ScreenPtr pScreen);
169
170 Bool
171 ephyrCreateColormap(ColormapPtr pmap);
172
173 #ifdef RANDR
174 Bool
175 ephyrRandRGetInfo(ScreenPtr pScreen, Rotation * rotations);
176
177 Bool
178
179 ephyrRandRSetConfig(ScreenPtr pScreen,
180 Rotation randr, int rate, RRScreenSizePtr pSize);
181 Bool
182 ephyrRandRInit(ScreenPtr pScreen);
183
184 void
185 ephyrShadowUpdate(ScreenPtr pScreen, shadowBufPtr pBuf);
186
187 #endif
188
189 void
190 ephyrUpdateModifierState(unsigned int state);
191
192 extern KdPointerDriver EphyrMouseDriver;
193
194 extern KdKeyboardDriver EphyrKeyboardDriver;
195
196 extern Bool ephyrCursorInit(ScreenPtr pScreen);
197
198 extern int ephyrBufferHeight(KdScreenInfo * screen);
199
200 /* ephyr_draw.c */
201
202 Bool
203 ephyrDrawInit(ScreenPtr pScreen);
204
205 void
206 ephyrDrawEnable(ScreenPtr pScreen);
207
208 void
209 ephyrDrawDisable(ScreenPtr pScreen);
210
211 void
212 ephyrDrawFini(ScreenPtr pScreen);
213
214 /* hostx.c glamor support */
215 Bool ephyr_glamor_init(ScreenPtr pScreen);
216 Bool ephyr_glamor_create_screen_resources(ScreenPtr pScreen);
217 void ephyr_glamor_enable(ScreenPtr pScreen);
218 void ephyr_glamor_disable(ScreenPtr pScreen);
219 void ephyr_glamor_fini(ScreenPtr pScreen);
220 void ephyr_glamor_host_paint_rect(ScreenPtr pScreen);
221
222 /*ephyvideo.c*/
223
224 Bool ephyrInitVideo(ScreenPtr pScreen);
225
226 /* ephyr_glamor_xv.c */
227 #ifdef GLAMOR
228 void ephyr_glamor_xv_init(ScreenPtr screen);
229 #else /* !GLAMOR */
230 static inline void
ephyr_glamor_xv_init(ScreenPtr screen)231 ephyr_glamor_xv_init(ScreenPtr screen)
232 {
233 }
234 #endif /* !GLAMOR */
235
236 #endif
237