x11.hidd: clean up includes to fix build under linux-armhf
[AROS.git] / arch / all-hosted / hidd / x11 / x11.h
blobf6e2f262cc51101f41c728c73f1856a137a5f26d
1 #ifndef HIDD_X11_H
2 #define HIDD_X11_H
4 /*
5 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Include for the x11 HIDD.
9 Lang: English.
12 #include <aros/config.h>
14 #include <oop/oop.h>
15 #include <proto/exec.h>
17 #ifndef X11_TYPES_H
18 /* Note: x11_types.h is not included intentionally to resolve compilation
19 * issues on linux-armhf where certain definitions collide between AROS
20 * and Linux.
21 * In every source file x11_types.h needs to be included before to x11.h
23 #include <X11/X.h> // Simple types definitions
24 typedef struct _XEvent XEvent; // Used only as pointer
25 typedef struct _Display Display; // Used only as pointer
26 typedef APTR GC; // GC is a pointer type
28 typedef struct _Visual Visual;
29 typedef struct {
30 Visual *visual;
31 VisualID visualid;
32 int screen;
33 int depth;
34 #if defined(__cplusplus) || defined(c_plusplus)
35 int c_class; /* C++ */
36 #else
37 int class;
38 #endif
39 unsigned long red_mask;
40 unsigned long green_mask;
41 unsigned long blue_mask;
42 int colormap_size;
43 int bits_per_rgb;
44 } XVisualInfo;
45 #endif
47 /****************************************************************************************/
49 #define USE_X11_DRAWFUNCS 1
50 #define X11SOFTMOUSE 1 /* Use software mouse sprite */
51 #define ADJUST_XWIN_SIZE 1 /* Resize the xwindow to the size of the actual visible screen */
53 /****************************************************************************************/
55 /***** X11Mouse HIDD *******************/
57 /* Private data */
58 struct pHidd_Mouse_Event;
59 struct x11mouse_data
61 VOID (*mouse_callback)(APTR, struct pHidd_Mouse_Event *);
62 APTR callbackdata;
65 /* IDs */
66 #define IID_Hidd_X11Mouse "hidd.mouse.x11"
69 /* Methods */
70 enum
72 moHidd_X11Mouse_HandleEvent
75 struct pHidd_X11Mouse_HandleEvent
77 OOP_MethodID mID;
78 XEvent *event;
81 VOID Hidd_X11Mouse_HandleEvent(OOP_Object *o, XEvent *event);
83 /***** X11Kbd HIDD *******************/
85 /* Private data */
86 struct x11kbd_data
88 VOID (*kbd_callback)(APTR, UWORD);
89 APTR callbackdata;
90 UWORD prev_keycode;
93 /* IDs */
94 #define IID_Hidd_X11Kbd "hidd.kbd.x11"
96 /* Methods */
97 enum
99 moHidd_X11Kbd_HandleEvent
102 struct pHidd_X11Kbd_HandleEvent
104 OOP_MethodID mID;
105 XEvent *event;
108 VOID Hidd_X11Kbd_HandleEvent(OOP_Object *o, XEvent *event);
109 /* misc */
114 struct x11task_params
116 struct Task *parent;
117 ULONG ok_signal;
118 ULONG fail_signal;
119 ULONG kill_signal;
120 struct x11_staticdata *xsd;
123 struct xwinnode
125 struct MinNode node;
126 Window xwindow;
127 Window masterxwindow;
128 OOP_Object *bmobj;
129 BOOL window_mapped;
133 /* Message used for getting info on when a window has been mapped */
135 enum
137 NOTY_MAPWINDOW,
138 NOTY_WINCREATE,
139 NOTY_WINDISPOSE,
140 NOTY_RESIZEWINDOW
144 struct notify_msg
146 struct Message execmsg;
147 ULONG notify_type; /* NOTY_xxxx */
148 Display *xdisplay;
149 Window xwindow;
150 Window masterxwindow;
151 OOP_Object *bmobj;
152 /* Only for NOTY_RESIZEWINDOW */
153 ULONG width;
154 ULONG height;
157 struct x11_staticdata
160 * These three members MUST be in the beginning of this structure
161 * because they are exposed to disk-based part (see x11_class.h)
163 UBYTE keycode2rawkey[256];
164 BOOL havetable;
165 OOP_Class *gfxclass;
167 OOP_Class *bmclass;;
168 OOP_Class *mouseclass;
169 OOP_Class *kbdclass;
171 struct SignalSemaphore sema; /* Protecting this whole struct */
173 /* This port is used for asking the x11 task for notifications
174 on when some event occurs, for example MapNotify
176 struct MsgPort *x11task_notify_port;
178 Display *display;
179 BOOL local_display;
181 ULONG refcount;
183 OOP_Object *gfxhidd;
184 OOP_Object *mousehidd;
185 OOP_Object *kbdhidd;
187 #if USE_XSHM
188 struct SignalSemaphore shm_sema; /* singlethread access to shared mem */
189 BOOL use_xshm; /* May we use Xshm ? */
190 void *xshm_info;
191 #endif
193 /* This window is used as a friend drawable for pixmaps. The window is
194 never mapped, i.e. it is never shown onscreen.
196 Window dummy_window_for_creating_pixmaps;
198 XVisualInfo vi;
199 ULONG red_shift;
200 ULONG green_shift;
201 ULONG blue_shift;
203 ULONG depth; /* Size of pixel in bits */ /* stegerg: was called "size" */
204 ULONG bytes_per_pixel;
206 ULONG clut_shift;
207 ULONG clut_mask;
209 Atom delete_win_atom;
210 Atom clipboard_atom;
211 Atom clipboard_property_atom;
212 Atom clipboard_incr_atom;
213 Atom clipboard_targets_atom;
214 Time x_time;
216 VOID (*activecallback)(APTR, OOP_Object *);
217 APTR callbackdata;
219 ULONG options;
221 struct MsgPort *hostclipboardmp;
222 struct Message *hostclipboardmsg;
223 ULONG hostclipboard_readstate;
224 unsigned char *hostclipboard_incrbuffer;
225 ULONG hostclipboard_incrbuffer_size;
226 unsigned char *hostclipboard_writebuffer;
227 ULONG hostclipboard_writebuffer_size;
228 Window hostclipboard_writerequest_window;
229 Atom hostclipboard_writerequest_property;
230 ULONG hostclipboard_write_chunks;
233 #define OPTION_FULLSCREEN (1 << 0)
234 #define OPTION_BACKINGSTORE (1 << 1)
235 #define OPTION_FORCESTDMODES (1 << 2)
236 #define OPTION_DELAYXWINMAPPING (1 << 3)
238 /* Send the message and wait for the reply */
239 static inline void X11DoNotify(struct x11_staticdata *xsd, struct notify_msg *msg)
241 PutMsg(xsd->x11task_notify_port, &msg->execmsg);
242 WaitPort(msg->execmsg.mn_ReplyPort);
243 GetMsg(msg->execmsg.mn_ReplyPort);
246 struct x11clbase
248 struct Library library;
250 struct x11_staticdata xsd;
253 /* Private Attrs and methods for the X11Gfx Hidd */
255 #define CLID_Hidd_Gfx_X11 "hidd.gfx.x11"
256 #define IID_Hidd_Gfx_X11 "hidd.gfx.x11"
258 #define PEN_BITS 4
259 #define NUM_COLORS (1L << PEN_BITS)
260 #define PEN_MASK (NUM_COLORS - 1)
262 /* Private instance data for Gfx hidd class */
263 struct gfx_data
265 Display *display;
266 int screen;
267 int depth;
268 Colormap colmap;
269 Cursor cursor;
271 /* baseclass for CreateObject */
272 OOP_Class *basebm;
275 #define HOSTCLIPBOARDSTATE_IDLE 0
276 #define HOSTCLIPBOARDSTATE_READ 1
277 #define HOSTCLIPBOARDSTATE_READ_INCR 2
278 #define HOSTCLIPBOARDSTATE_WRITE 3
280 VOID get_bitmap_info(struct x11_staticdata *xsd, Drawable d, ULONG *sz, ULONG *bpl);
282 BOOL set_pixelformat(struct TagItem *pftags, struct x11_staticdata *xsd, Drawable d);
285 OOP_Class *init_gfxclass ( struct x11_staticdata * );
286 OOP_Class *init_onbmclass ( struct x11_staticdata * );
287 OOP_Class *init_offbmclass ( struct x11_staticdata * );
288 OOP_Class *init_kbdclass ( struct x11_staticdata * );
289 OOP_Class *init_mouseclass ( struct x11_staticdata * );
291 VOID free_gfxclass ( struct x11_staticdata * );
292 VOID free_onbmclass ( struct x11_staticdata * );
293 VOID free_offbmclass ( struct x11_staticdata * );
294 VOID free_osbmclass ( struct x11_staticdata * );
295 VOID free_kbdclass ( struct x11_staticdata * );
296 VOID free_mouseclass ( struct x11_staticdata * );
298 ULONG x11clipboard_init(struct x11_staticdata *);
299 VOID x11clipboard_handle_commands(struct x11_staticdata *);
300 BOOL x11clipboard_want_event(XEvent *);
301 VOID x11clipboard_handle_event(struct x11_staticdata *, XEvent *);
303 int X11_Init(struct x11_staticdata *xsd);
305 #undef XSD
306 #define XSD(cl) (&((struct x11clbase *)cl->UserData)->xsd)
309 * This lock has two uses:
310 * - Making X calls threadsafe.
311 * - In the bitmap class, protecting the bitmap X GC from changes from other tasks
312 * Since X makes intensive use of malloc(), and can interfere not only with other X calls,
313 * but with all other host OS calls, we use global lock provided by hostlib.resource.
316 #define LOCK_X11 HostLib_Lock();
317 #define UNLOCK_X11 HostLib_Unlock();
319 #endif /* HIDD_X11_H */