hostx.h revision 706f2543
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 _XLIBS_STUFF_H_
27#define _XLIBS_STUFF_H_
28
29#include <X11/X.h>
30#include <X11/Xmd.h>
31
32#define EPHYR_WANT_DEBUG 0
33
34#if (EPHYR_WANT_DEBUG)
35#define EPHYR_DBG(x, a...) \
36 fprintf(stderr, __FILE__ ":%d,%s() " x "\n", __LINE__, __func__, ##a)
37#else
38#define EPHYR_DBG(x, a...) do {} while (0)
39#endif
40
41typedef struct EphyrHostXVars  EphyrHostXVars;
42typedef struct EphyrHostXEvent EphyrHostXEvent;
43typedef void* EphyrScreenInfo ;
44typedef enum EphyrHostXEventType
45{
46  EPHYR_EV_MOUSE_MOTION,
47  EPHYR_EV_MOUSE_PRESS,
48  EPHYR_EV_MOUSE_RELEASE,
49  EPHYR_EV_KEY_PRESS,
50  EPHYR_EV_KEY_RELEASE,
51  EPHYR_EV_EXPOSE
52}
53EphyrHostXEventType;
54
55/* I can't believe it's not a KeySymsRec. */
56typedef struct {
57  int             minKeyCode;
58  int             maxKeyCode;
59  int             mapWidth;
60  CARD32         *map;
61} EphyrKeySyms;
62
63struct EphyrHostXEvent
64{
65  EphyrHostXEventType type;
66
67  union
68  {
69    struct mouse_motion {
70      int x;
71      int y;
72      int screen;
73      int window;
74    } mouse_motion;
75
76    struct mouse_down {
77      int button_num;
78    } mouse_down;
79
80    struct mouse_up {
81      int button_num;
82    } mouse_up;
83
84    struct key_up {
85      int scancode;
86    } key_up;
87
88    struct key_down {
89      int scancode;
90    } key_down;
91
92    struct expose {
93      int window;
94    } expose;
95
96  } data;
97
98  int key_state;
99};
100
101typedef struct {
102  VisualID visualid;
103  int screen;
104  int depth;
105  int class;
106  unsigned long red_mask;
107  unsigned long green_mask;
108  unsigned long blue_mask;
109  int colormap_size;
110  int bits_per_rgb;
111} EphyrHostVisualInfo;
112
113typedef struct {
114    int x, y;
115    int width, height ;
116    int visualid ;
117} EphyrHostWindowAttributes;
118
119typedef struct {
120    int x,y,width,height;
121} EphyrBox;
122
123typedef struct {
124    short x1,y1,x2,y2;
125} EphyrRect;
126
127int
128hostx_want_screen_size(EphyrScreenInfo screen, int *width, int *height);
129
130int
131hostx_want_host_cursor(void);
132
133void
134hostx_use_host_cursor(void);
135
136void
137hostx_use_fullscreen(void);
138
139int
140hostx_want_fullscreen(void);
141
142int
143hostx_want_preexisting_window(EphyrScreenInfo screen);
144
145void
146hostx_use_preexisting_window(unsigned long win_id);
147
148void
149hostx_use_resname (char *name, int fromcmd);
150
151void
152hostx_set_title(char *name);
153
154void
155hostx_handle_signal(int signum);
156
157int
158hostx_init(void);
159
160void
161hostx_add_screen(EphyrScreenInfo screen, unsigned long win_id, int screen_num);
162
163void
164hostx_set_display_name(char *name);
165
166void
167hostx_set_screen_number(EphyrScreenInfo screen, int number);
168
169void
170hostx_set_win_title(EphyrScreenInfo screen, char *extra_text);
171
172int
173hostx_get_depth (void);
174
175int
176hostx_get_server_depth (EphyrScreenInfo screen);
177
178void
179hostx_set_server_depth(EphyrScreenInfo screen, int depth);
180
181int
182hostx_get_bpp(void *info);
183
184void
185hostx_get_visual_masks (void   *info,
186			CARD32 *rmsk,
187			CARD32 *gmsk,
188			CARD32 *bmsk);
189void
190hostx_set_cmap_entry(unsigned char idx,
191		     unsigned char r,
192		     unsigned char g,
193		     unsigned char b);
194
195void*
196hostx_screen_init (EphyrScreenInfo screen,
197                   int width, int height,
198                   int buffer_height);
199
200void
201hostx_paint_rect(EphyrScreenInfo screen,
202		 int sx,    int sy,
203		 int dx,    int dy,
204		 int width, int height);
205
206
207void
208hostx_load_keymap (void);
209
210int
211hostx_get_event (EphyrHostXEvent *ev);
212
213void*
214hostx_get_display (void) ;
215
216int
217hostx_get_window (int a_screen_number) ;
218
219int
220hostx_get_window_attributes (int a_window, EphyrHostWindowAttributes *a_attr)  ;
221
222int
223hostx_get_extension_info (const char *a_ext_name,
224                          int *a_major_opcode,
225                          int *a_first_even,
226                          int *a_first_error) ;
227int
228hostx_get_visuals_info (EphyrHostVisualInfo **a_visuals,
229                        int *a_num_entries) ;
230
231int hostx_create_window (int a_screen_number,
232                         EphyrBox *a_geometry,
233                         int a_visual_id,
234                         int *a_host_win /*out parameter*/) ;
235
236int hostx_destroy_window (int a_win) ;
237
238int hostx_set_window_geometry (int a_win, EphyrBox *a_geo) ;
239
240
241int hostx_set_window_bounding_rectangles (int a_window,
242                                          EphyrRect *a_rects,
243                                          int a_num_rects) ;
244
245int hostx_set_window_clipping_rectangles (int a_window,
246                                          EphyrRect *a_rects,
247                                          int a_num_rects) ;
248int hostx_has_xshape (void) ;
249
250#ifdef XF86DRI
251int hostx_lookup_peer_window (void *a_local_window,
252                              int *a_host_peer /*out parameter*/) ;
253int
254hostx_allocate_resource_id_peer (int a_local_resource_id,
255                                 int *a_remote_resource_id) ;
256int
257hostx_get_resource_id_peer (int a_local_resource_id,
258                            int *a_remote_resource_id) ;
259int hostx_has_dri (void) ;
260
261int hostx_has_glx (void) ;
262#endif /* XF86DRI */
263
264#endif /*_XLIBS_STUFF_H_*/
265