2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
5 Desc: X11 hidd initialization code.
9 #define __OOP_NOATTRBASES__
16 #include <exec/types.h>
18 #include <proto/exec.h>
19 #include <proto/oop.h>
21 #include <utility/utility.h>
23 #include <hidd/graphics.h>
25 #include <aros/symbolsets.h>
30 #include <aros/debug.h>
32 #include LC_LIBDEFS_FILE
35 #include "fullscreen.h"
37 /****************************************************************************************/
41 /****************************************************************************************/
43 static BOOL
initclasses( struct x11_staticdata
*xsd
);
44 static VOID
freeclasses( struct x11_staticdata
*xsd
);
45 struct Task
*create_x11task( struct x11task_params
*params
);
46 VOID
x11task_entry(struct x11task_params
*xtp
);
48 /****************************************************************************************/
50 static OOP_AttrBase HiddPixFmtAttrBase
;
52 static struct OOP_ABDescr abd
[] =
54 { IID_Hidd_PixFmt
, &HiddPixFmtAttrBase
},
58 /****************************************************************************************/
60 static BOOL
initclasses(struct x11_staticdata
*xsd
)
62 /* Get some attrbases */
64 if (!OOP_ObtainAttrBases(abd
))
75 /****************************************************************************************/
77 static VOID
freeclasses(struct x11_staticdata
*xsd
)
79 OOP_ReleaseAttrBases(abd
);
82 /****************************************************************************************/
84 static int MyErrorHandler (Display
* display
, XErrorEvent
* errevent
)
89 extern int xshm_major
;
91 if ((xshm_major
!= 0) && (errevent
->request_code
== xshm_major
) &&
92 (errevent
->minor_code
== 4) && /* XShmGetImage */
93 (errevent
->error_code
== BadMatch
))
95 /* Ignore this error */
101 XCALL(XGetErrorText
, display
, errevent
->error_code
, buffer
, sizeof (buffer
));
103 kprintf("XError %d (Major=%d, Minor=%d) task = %s\n%s\n",
104 errevent
->error_code
,
105 errevent
->request_code
,
106 errevent
->minor_code
,
107 FindTask(0)->tc_Node
.ln_Name
,
113 /****************************************************************************************/
115 static int MySysErrorHandler (Display
* display
)
117 perror ("X11-Error");
119 // *((ULONG *)0) = 0;
124 /****************************************************************************************/
126 static int X11_Init(LIBBASETYPEPTR LIBBASE
)
128 struct x11_staticdata
*xsd
= &LIBBASE
->xsd
;
130 D(bug("Entering X11_Init\n"));
131 if (LIBBASE
->library
.lib_OpenCnt
) {
132 D(bug("[X11GFX] Already initialized\n"));
136 InitSemaphore( &xsd
->sema
);
137 InitSemaphore( &xsd
->x11sema
);
139 /* Do not need to singlethead this
140 * since no other tasks are using X currently
143 xsd
->display
= XCALL(XOpenDisplay
, NULL
);
144 D(bug("display(%x)\n", xsd
->display
));
147 struct x11task_params xtp
;
148 struct Task
*x11task
;
150 XCALL(XSetErrorHandler
, MyErrorHandler
);
151 XCALL(XSetIOErrorHandler
, MySysErrorHandler
);
154 * XXX on my system, getenv() is declared:
156 * extern char *getenv (__const char *__name) __THROW __nonnull ((1)) * __wur;
158 * the attributes appear to change the calling convention, so a naive
159 * prototype like char *getenv(char *) causes carshes as the returned
160 * address is not a valid pointer.
162 * ideally this configration variable would be brought in via a
163 * bootloader.resource, which hosted doesn't have yet
166 if (getenv, "AROS_X11_FULLSCREEN")
168 xsd->fullscreen = x11_fullscreen_supported(xsd->display);
172 xsd
->delete_win_atom
= XCALL(XInternAtom
, xsd
->display
, "WM_DELETE_WINDOW", FALSE
);
173 xsd
->clipboard_atom
= XCALL(XInternAtom
, xsd
->display
, "CLIPBOARD", FALSE
);
174 xsd
->clipboard_property_atom
= XCALL(XInternAtom
, xsd
->display
, "AROS_HOSTCLIP", FALSE
);
175 xsd
->clipboard_incr_atom
= XCALL(XInternAtom
, xsd
->display
, "INCR", FALSE
);
176 xsd
->clipboard_targets_atom
= XCALL(XInternAtom
, xsd
->display
, "TARGETS", FALSE
);
178 xtp
.parent
= FindTask(NULL
);
179 xtp
.ok_signal
= SIGBREAKF_CTRL_E
;
180 xtp
.fail_signal
= SIGBREAKF_CTRL_F
;
181 xtp
.kill_signal
= SIGBREAKF_CTRL_C
;
184 if ((x11task
= create_x11task(&xtp
)))
186 if (initclasses(xsd
))
188 D(bug("X11_Init succeeded\n"));
192 Signal(x11task
, xtp
.kill_signal
);
195 XCALL(XCloseDisplay
, xsd
->display
);
199 D(bug("X11_Init failed\n"));
204 /****************************************************************************************/
206 ADD2OPENLIB(X11_Init
, 0);