Squashed commit of 'x11-hostlib' branch
[tangerine.git] / arch / all-x11 / hidd / x11.h
blob82113336534352cd26c46bebb2a61b02ecd1655c
1 #ifndef HIDD_X11_H
2 #define HIDD_X11_H
4 /*
5 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Include for the x11 HIDD.
9 Lang: English.
13 #ifndef EXEC_LIBRARIES_H
14 # include <exec/libraries.h>
15 #endif
17 #ifndef OOP_OOP_H
18 # include <oop/oop.h>
19 #endif
21 #define timeval sys_timeval
22 #ifndef _XLIB_H_
23 # include <X11/Xlib.h>
24 #endif
26 #ifndef _XUTIL_H
27 # include <X11/Xutil.h>
28 #endif
29 #undef timeval
31 #ifndef EXEC_SEMAPHORES_H
32 # include <exec/semaphores.h>
33 #endif
35 #include "xshm.h"
37 #define X11_LOAD_KEYMAPTABLE 1
39 #include "x11_hostlib.h"
42 /***** X11Mouse HIDD *******************/
44 /* Private data */
45 struct pHidd_Mouse_Event;
46 struct x11mouse_data
48 VOID (*mouse_callback)(APTR, struct pHidd_Mouse_Event *);
49 APTR callbackdata;
52 /* IDs */
53 #define IID_Hidd_X11Mouse "hidd.mouse.x11"
54 #define CLID_Hidd_X11Mouse "hidd.mouse.x11"
57 /* Methods */
58 enum
60 moHidd_X11Mouse_HandleEvent
63 struct pHidd_X11Mouse_HandleEvent
65 OOP_MethodID mID;
66 XEvent *event;
69 VOID Hidd_X11Mouse_HandleEvent(OOP_Object *o, XEvent *event);
71 /***** X11Kbd HIDD *******************/
73 /* Private data */
74 struct x11kbd_data
76 VOID (*kbd_callback)(APTR, UWORD);
77 APTR callbackdata;
78 UWORD prev_keycode;
81 /* IDs */
82 #define IID_Hidd_X11Kbd "hidd.kbd.x11"
83 #define CLID_Hidd_X11Kbd "hidd.kbd.x11"
85 /* Methods */
86 enum
88 moHidd_X11Kbd_HandleEvent
91 struct pHidd_X11Kbd_HandleEvent
93 OOP_MethodID mID;
94 XEvent *event;
97 VOID Hidd_X11Kbd_HandleEvent(OOP_Object *o, XEvent *event);
98 /* misc */
103 struct x11task_params
105 struct Task *parent;
106 ULONG ok_signal;
107 ULONG fail_signal;
108 ULONG kill_signal;
109 struct x11_staticdata *xsd;
112 struct xwinnode
114 struct MinNode node;
115 Window xwindow;
116 OOP_Object *bmobj;
117 BOOL window_mapped;
121 /* Message used for getting info on when a window has been mapped */
123 enum
125 NOTY_MAPWINDOW,
126 NOTY_WINCREATE,
127 NOTY_WINDISPOSE,
128 NOTY_RESIZEWINDOW
132 struct notify_msg
134 struct Message execmsg;
135 ULONG notify_type; /* NOTY_xxxx */
136 Display *xdisplay;
137 Window xwindow;
138 Window masterxwindow;
139 OOP_Object *bmobj;
140 /* Only for NOTY_RESIZEWINDOW */
141 ULONG width;
142 ULONG height;
146 struct x11_staticdata
148 struct SignalSemaphore sema; /* Protecting this whole struct */
149 struct SignalSemaphore x11sema;
151 /* This port is used for asking the x11 task for notifications
152 on when some event occurs, for example MapNotify
154 struct MsgPort *x11task_notify_port;
155 struct MsgPort *x11task_quit_port;
156 struct ExecBase *sysbase;
158 Display *display;
159 BOOL local_display;
161 ULONG refcount;
163 OOP_Class *gfxclass;
164 OOP_Class *onbmclass;
165 OOP_Class *offbmclass;
166 OOP_Class *mouseclass;
167 OOP_Class *kbdclass;
169 OOP_Object *gfxhidd;
170 OOP_Object *mousehidd;
171 OOP_Object *kbdhidd;
173 #if USE_XSHM
174 struct SignalSemaphore shm_sema; /* singlethread access to shared mem */
175 BOOL use_xshm; /* May we use Xshm ? */
176 void *xshm_info;
177 #endif
179 /* This window is used as a frien drawable for pixmaps. The window is
180 never mapped, ie. it is never shown onscreen.
182 Window dummy_window_for_creating_pixmaps;
184 XVisualInfo vi;
185 ULONG red_shift;
186 ULONG green_shift;
187 ULONG blue_shift;
189 ULONG depth; /* Size of pixel in bits */ /* stegerg: was called "size" */
190 ULONG bytes_per_pixel;
192 ULONG clut_shift;
193 ULONG clut_mask;
195 Atom delete_win_atom;
196 Atom clipboard_atom;
197 Atom clipboard_property_atom;
198 Atom clipboard_incr_atom;
199 Atom clipboard_targets_atom;
200 Time x_time;
201 #if 0
202 VOID (*activecallback)(APTR, OOP_Object *, BOOL);
203 APTR callbackdata;
204 #endif
206 BOOL fullscreen;
208 struct MsgPort *hostclipboardmp;
209 struct Message *hostclipboardmsg;
210 ULONG hostclipboard_readstate;
211 unsigned char *hostclipboard_incrbuffer;
212 ULONG hostclipboard_incrbuffer_size;
213 unsigned char *hostclipboard_writebuffer;
214 ULONG hostclipboard_writebuffer_size;
215 Window hostclipboard_writerequest_window;
216 Atom hostclipboard_writerequest_property;
217 ULONG hostclipboard_write_chunks;
220 struct x11clbase
222 struct Library library;
223 BPTR seglist;
225 struct x11_staticdata xsd;
228 /* Private instance data for Gfx hidd class */
229 struct gfx_data
231 Display *display;
232 int screen;
233 int depth;
234 Colormap colmap;
235 Cursor cursor;
236 Window fbwin; /* Frame buffer window */
237 //#if ADJUST_XWIN_SIZE
238 Window masterwin;
239 //#endif
242 #define HOSTCLIPBOARDSTATE_IDLE 0
243 #define HOSTCLIPBOARDSTATE_READ 1
244 #define HOSTCLIPBOARDSTATE_READ_INCR 2
245 #define HOSTCLIPBOARDSTATE_WRITE 3
247 VOID get_bitmap_info(struct x11_staticdata *xsd, Drawable d, ULONG *sz, ULONG *bpl);
249 BOOL set_pixelformat(struct TagItem *pftags, struct x11_staticdata *xsd, Drawable d);
252 OOP_Class *init_gfxclass ( struct x11_staticdata * );
253 OOP_Class *init_onbmclass ( struct x11_staticdata * );
254 OOP_Class *init_offbmclass ( struct x11_staticdata * );
255 OOP_Class *init_kbdclass ( struct x11_staticdata * );
256 OOP_Class *init_mouseclass ( struct x11_staticdata * );
258 VOID free_gfxclass ( struct x11_staticdata * );
259 VOID free_onbmclass ( struct x11_staticdata * );
260 VOID free_offbmclass ( struct x11_staticdata * );
261 VOID free_osbmclass ( struct x11_staticdata * );
262 VOID free_kbdclass ( struct x11_staticdata * );
263 VOID free_mouseclass ( struct x11_staticdata * );
265 ULONG x11clipboard_init(struct x11_staticdata *);
266 VOID x11clipboard_handle_commands(struct x11_staticdata *);
267 BOOL x11clipboard_want_event(XEvent *);
268 VOID x11clipboard_handle_event(struct x11_staticdata *, XEvent *);
270 #undef XSD
271 #define XSD(cl) (&((struct x11clbase *)cl->UserData)->xsd)
273 /* This lock has two uses:
274 - Making X calls threadsafe.
275 - In the bitmap class, protecting the bimtap X GC from changes
276 from other tasks
279 #define LOCK_X11 ObtainSemaphore (&XSD(cl)->x11sema);
280 #define UNLOCK_X11 ReleaseSemaphore(&XSD(cl)->x11sema);
282 #endif /* HIDD_X11_H */