5 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
8 Desc: Include for the x11 HIDD.
12 #include <exec/libraries.h>
13 #include <exec/semaphores.h>
16 #include <proto/exec.h>
17 #include <proto/hostlib.h>
19 #define timeval sys_timeval
21 # include <X11/Xlib.h>
25 # include <X11/Xutil.h>
30 #include "x11_hostlib.h"
32 /***** X11Mouse HIDD *******************/
35 struct pHidd_Mouse_Event
;
38 VOID (*mouse_callback
)(APTR
, struct pHidd_Mouse_Event
*);
43 #define IID_Hidd_X11Mouse "hidd.mouse.x11"
49 moHidd_X11Mouse_HandleEvent
52 struct pHidd_X11Mouse_HandleEvent
58 VOID
Hidd_X11Mouse_HandleEvent(OOP_Object
*o
, XEvent
*event
);
60 /***** X11Kbd HIDD *******************/
65 VOID (*kbd_callback
)(APTR
, UWORD
);
71 #define IID_Hidd_X11Kbd "hidd.kbd.x11"
76 moHidd_X11Kbd_HandleEvent
79 struct pHidd_X11Kbd_HandleEvent
85 VOID
Hidd_X11Kbd_HandleEvent(OOP_Object
*o
, XEvent
*event
);
97 struct x11_staticdata
*xsd
;
109 /* Message used for getting info on when a window has been mapped */
122 struct Message execmsg
;
123 ULONG notify_type
; /* NOTY_xxxx */
126 Window masterxwindow
;
128 /* Only for NOTY_RESIZEWINDOW */
133 struct x11_staticdata
136 * These three members MUST be in the beginning of this structure
137 * because they are exposed to disk-based part (see x11_class.h)
139 UBYTE keycode2rawkey
[256];
144 OOP_Class
*mouseclass
;
147 struct SignalSemaphore sema
; /* Protecting this whole struct */
149 /* This port is used for asking the x11 task for notifications
150 on when some event occurs, for example MapNotify
152 struct MsgPort
*x11task_notify_port
;
160 OOP_Object
*mousehidd
;
164 struct SignalSemaphore shm_sema
; /* singlethread access to shared mem */
165 BOOL use_xshm
; /* May we use Xshm ? */
169 /* This window is used as a frien drawable for pixmaps. The window is
170 never mapped, ie. it is never shown onscreen.
172 Window dummy_window_for_creating_pixmaps
;
179 ULONG depth
; /* Size of pixel in bits */ /* stegerg: was called "size" */
180 ULONG bytes_per_pixel
;
185 Atom delete_win_atom
;
187 Atom clipboard_property_atom
;
188 Atom clipboard_incr_atom
;
189 Atom clipboard_targets_atom
;
192 VOID (*activecallback
)(APTR
, OOP_Object
*);
197 struct MsgPort
*hostclipboardmp
;
198 struct Message
*hostclipboardmsg
;
199 ULONG hostclipboard_readstate
;
200 unsigned char *hostclipboard_incrbuffer
;
201 ULONG hostclipboard_incrbuffer_size
;
202 unsigned char *hostclipboard_writebuffer
;
203 ULONG hostclipboard_writebuffer_size
;
204 Window hostclipboard_writerequest_window
;
205 Atom hostclipboard_writerequest_property
;
206 ULONG hostclipboard_write_chunks
;
209 #define OPTION_FULLSCREEN (1 << 0)
210 #define OPTION_BACKINGSTORE (1 << 1)
211 #define OPTION_FORCESTDMODES (1 << 2)
212 #define OPTION_DELAYXWINMAPPING (1 << 3)
214 /* Send the message and wait for the reply */
215 static inline void X11DoNotify(struct x11_staticdata
*xsd
, struct notify_msg
*msg
)
217 PutMsg(xsd
->x11task_notify_port
, &msg
->execmsg
);
218 WaitPort(msg
->execmsg
.mn_ReplyPort
);
219 GetMsg(msg
->execmsg
.mn_ReplyPort
);
224 struct Library library
;
226 struct x11_staticdata xsd
;
229 /* Private instance data for Gfx hidd class */
239 #define HOSTCLIPBOARDSTATE_IDLE 0
240 #define HOSTCLIPBOARDSTATE_READ 1
241 #define HOSTCLIPBOARDSTATE_READ_INCR 2
242 #define HOSTCLIPBOARDSTATE_WRITE 3
244 VOID
get_bitmap_info(struct x11_staticdata
*xsd
, Drawable d
, ULONG
*sz
, ULONG
*bpl
);
246 BOOL
set_pixelformat(struct TagItem
*pftags
, struct x11_staticdata
*xsd
, Drawable d
);
249 OOP_Class
*init_gfxclass ( struct x11_staticdata
* );
250 OOP_Class
*init_onbmclass ( struct x11_staticdata
* );
251 OOP_Class
*init_offbmclass ( struct x11_staticdata
* );
252 OOP_Class
*init_kbdclass ( struct x11_staticdata
* );
253 OOP_Class
*init_mouseclass ( struct x11_staticdata
* );
255 VOID
free_gfxclass ( struct x11_staticdata
* );
256 VOID
free_onbmclass ( struct x11_staticdata
* );
257 VOID
free_offbmclass ( struct x11_staticdata
* );
258 VOID
free_osbmclass ( struct x11_staticdata
* );
259 VOID
free_kbdclass ( struct x11_staticdata
* );
260 VOID
free_mouseclass ( struct x11_staticdata
* );
262 ULONG
x11clipboard_init(struct x11_staticdata
*);
263 VOID
x11clipboard_handle_commands(struct x11_staticdata
*);
264 BOOL
x11clipboard_want_event(XEvent
*);
265 VOID
x11clipboard_handle_event(struct x11_staticdata
*, XEvent
*);
267 int X11_Init(struct x11_staticdata
*xsd
);
270 #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 from other tasks
276 * Since X makes intensive use of malloc(), and can interfere not only with other X calls,
277 * but with all other host OS calls, we use global lock provided by hostlib.resource.
280 #define LOCK_X11 HostLib_Lock();
281 #define UNLOCK_X11 HostLib_Unlock();
283 #endif /* HIDD_X11_H */