revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-hosted / hidd / x11 / x11.h
blobd5997c68ad1ca7a22f3e845e360714ef884dabaf
1 #ifndef HIDD_X11_H
2 #define HIDD_X11_H
4 /*
5 Copyright © 1995-2017, 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 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
27 typedef struct _XVisualInfo XVisualInfo; // Used only as pointer
28 #endif
30 /****************************************************************************************/
32 #define USE_X11_DRAWFUNCS 1
33 #define X11SOFTMOUSE 0 /* Use software mouse sprite */
34 #define ADJUST_XWIN_SIZE 1 /* Resize the xwindow to the size of the actual visible screen */
36 /****************************************************************************************/
38 /***** X11Mouse HIDD *******************/
40 /* Private data */
41 struct pHidd_Mouse_Event;
42 struct x11mouse_data
44 VOID (*mouse_callback)(APTR, struct pHidd_Mouse_Event *);
45 APTR callbackdata;
48 /* IDs */
49 #define IID_Hidd_Mouse_X11 "hidd.mouse.x11"
52 /* Methods */
53 enum
55 moHidd_Mouse_X11_HandleEvent
58 struct pHidd_Mouse_X11_HandleEvent
60 OOP_MethodID mID;
61 XEvent *event;
64 VOID Hidd_Mouse_X11_HandleEvent(OOP_Object *o, XEvent *event);
66 /***** X11Kbd HIDD *******************/
68 /* Private data */
69 struct x11kbd_data
71 VOID (*kbd_callback)(APTR, UWORD);
72 APTR callbackdata;
73 UWORD prev_keycode;
76 /* IDs */
77 #define IID_Hidd_Kbd_X11 "hidd.kbd.x11"
79 /* Methods */
80 enum
82 moHidd_Kbd_X11_HandleEvent
85 struct pHidd_Kbd_X11_HandleEvent
87 OOP_MethodID mID;
88 XEvent *event;
91 VOID Hidd_Kbd_X11_HandleEvent(OOP_Object *o, XEvent *event);
92 /* misc */
97 struct x11task_params
99 struct Task *parent;
100 ULONG ok_signal;
101 ULONG fail_signal;
102 ULONG kill_signal;
103 struct x11_staticdata *xsd;
106 struct xwinnode
108 struct MinNode node;
109 Window xwindow;
110 Window masterxwindow;
111 OOP_Object *bmobj;
112 BOOL window_mapped;
116 /* Messages used for sending info to the HIDD's task */
118 enum
120 NOTY_MAPWINDOW,
121 NOTY_WINCREATE,
122 NOTY_WINDISPOSE,
123 NOTY_RESIZEWINDOW,
124 NOTY_NEWCURSOR
128 struct notify_msg
130 struct Message execmsg;
131 ULONG notify_type; /* NOTY_xxxx */
132 Display *xdisplay;
133 Window xwindow;
134 Window masterxwindow;
135 OOP_Object *bmobj;
136 /* Only for NOTY_RESIZEWINDOW */
137 ULONG width;
138 ULONG height;
141 struct x11_staticdata
144 * These three members MUST be in the beginning of this structure
145 * because they are exposed to disk-based part (see x11_class.h)
147 UBYTE keycode2rawkey[256];
148 BOOL havetable;
149 OOP_Class *gfxclass;
151 OOP_Class *bmclass;
152 OOP_Class *mouseclass;
153 OOP_Class *kbdclass;
155 struct SignalSemaphore sema; /* Protecting this whole struct */
157 /* This port is used for asking the x11 task for notifications
158 on when some event occurs, for example MapNotify
160 struct MsgPort *x11task_notify_port;
162 Display *display;
163 BOOL local_display;
165 ULONG refcount;
167 OOP_Object *gfxhidd;
168 OOP_Object *mousehidd;
169 OOP_Object *kbdhidd;
171 #if USE_XSHM
172 struct SignalSemaphore shm_sema; /* singlethread access to shared mem */
173 BOOL use_xshm; /* May we use Xshm? */
174 void *xshm_info;
175 #endif
177 /* This window is used as a friend drawable for pixmaps. The window is
178 never mapped, i.e. it is never shown onscreen.
180 Window dummy_window_for_creating_pixmaps;
182 XVisualInfo *vi;
183 ULONG red_shift;
184 ULONG green_shift;
185 ULONG blue_shift;
187 ULONG depth; /* Size of pixel in bits */ /* stegerg: was called "size" */
188 ULONG bytes_per_pixel;
190 ULONG clut_shift;
191 ULONG clut_mask;
193 Atom delete_win_atom;
194 Atom clipboard_atom;
195 Atom clipboard_property_atom;
196 Atom clipboard_incr_atom;
197 Atom clipboard_targets_atom;
198 Time x_time;
200 VOID (*activecallback)(APTR, OOP_Object *);
201 APTR callbackdata;
203 ULONG options;
205 struct MsgPort *hostclipboardmp;
206 struct Message *hostclipboardmsg;
207 ULONG hostclipboard_readstate;
208 unsigned char *hostclipboard_incrbuffer;
209 ULONG hostclipboard_incrbuffer_size;
210 unsigned char *hostclipboard_writebuffer;
211 ULONG hostclipboard_writebuffer_size;
212 Window hostclipboard_writerequest_window;
213 Atom hostclipboard_writerequest_property;
214 ULONG hostclipboard_write_chunks;
217 #define OPTION_FULLSCREEN (1 << 0)
218 #define OPTION_BACKINGSTORE (1 << 1)
219 #define OPTION_FORCESTDMODES (1 << 2)
220 #define OPTION_DELAYXWINMAPPING (1 << 3)
222 /* Send the message and wait for the reply */
223 static inline void X11DoNotify(struct x11_staticdata *xsd, struct notify_msg *msg)
225 PutMsg(xsd->x11task_notify_port, &msg->execmsg);
226 WaitPort(msg->execmsg.mn_ReplyPort);
227 GetMsg(msg->execmsg.mn_ReplyPort);
230 struct x11clbase
232 struct Library library;
234 struct x11_staticdata xsd;
237 /* Private Attrs and methods for the X11Gfx Hidd */
239 #define CLID_Hidd_Gfx_X11 "hidd.gfx.x11"
240 #define IID_Hidd_Gfx_X11 "hidd.gfx.x11"
242 #define PEN_BITS 4
243 #define NUM_COLORS (1L << PEN_BITS)
244 #define PEN_MASK (NUM_COLORS - 1)
246 /* Private instance data for Gfx hidd class */
247 struct gfx_data
249 Display *display;
250 int screen;
251 int depth;
252 Colormap colmap;
253 Cursor cursor;
255 /* baseclass for CreateObject */
256 OOP_Class *basebm;
259 #define HOSTCLIPBOARDSTATE_IDLE 0
260 #define HOSTCLIPBOARDSTATE_READ 1
261 #define HOSTCLIPBOARDSTATE_READ_INCR 2
262 #define HOSTCLIPBOARDSTATE_WRITE 3
264 VOID get_bitmap_info(struct x11_staticdata *xsd, Drawable d, ULONG *sz, ULONG *bpl);
266 BOOL set_pixelformat(struct TagItem *pftags, struct x11_staticdata *xsd, Drawable d);
269 OOP_Class *init_gfxclass ( struct x11_staticdata * );
270 OOP_Class *init_onbmclass ( struct x11_staticdata * );
271 OOP_Class *init_offbmclass ( struct x11_staticdata * );
272 OOP_Class *init_kbdclass ( struct x11_staticdata * );
273 OOP_Class *init_mouseclass ( struct x11_staticdata * );
275 VOID free_gfxclass ( struct x11_staticdata * );
276 VOID free_onbmclass ( struct x11_staticdata * );
277 VOID free_offbmclass ( struct x11_staticdata * );
278 VOID free_osbmclass ( struct x11_staticdata * );
279 VOID free_kbdclass ( struct x11_staticdata * );
280 VOID free_mouseclass ( struct x11_staticdata * );
282 ULONG x11clipboard_init(struct x11_staticdata *);
283 VOID x11clipboard_handle_commands(struct x11_staticdata *);
284 BOOL x11clipboard_want_event(XEvent *);
285 VOID x11clipboard_handle_event(struct x11_staticdata *, XEvent *);
287 int X11_Init(struct x11_staticdata *xsd);
289 #undef XSD
290 #define XSD(cl) (&((struct x11clbase *)cl->UserData)->xsd)
293 * This lock has two uses:
294 * - Making X calls threadsafe.
295 * - In the bitmap class, protecting the bitmap X GC from changes from other tasks
296 * Since X makes intensive use of malloc(), and can interfere not only with other X calls,
297 * but with all other host OS calls, we use global lock provided by hostlib.resource.
300 #define LOCK_X11 HostLib_Lock();
301 #define UNLOCK_X11 HostLib_Unlock();
303 #endif /* HIDD_X11_H */