2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
5 Desc: X11 hidd initialization code.
11 #define __OOP_NOATTRBASES__
18 #include <exec/types.h>
20 #include <aros/bootloader.h>
21 #include <proto/bootloader.h>
22 #include <proto/exec.h>
23 #include <proto/oop.h>
25 #include <utility/utility.h>
27 #include <hidd/graphics.h>
29 #include <aros/symbolsets.h>
31 #include LC_LIBDEFS_FILE
34 #include "fullscreen.h"
36 /****************************************************************************************/
40 /****************************************************************************************/
42 static BOOL
initclasses(struct x11_staticdata
*xsd
);
43 static VOID
freeclasses(struct x11_staticdata
*xsd
);
44 struct Task
*create_x11task(struct x11task_params
*params
);
45 VOID
x11task_entry(struct x11task_params
*xtp
);
47 /****************************************************************************************/
49 static OOP_AttrBase HiddPixFmtAttrBase
;
51 static struct OOP_ABDescr abd
[] =
53 { IID_Hidd_PixFmt
, &HiddPixFmtAttrBase
},
57 /****************************************************************************************/
59 static BOOL
initclasses(struct x11_staticdata
*xsd
)
61 D(bug("[X11] %s()\n", __PRETTY_FUNCTION__
));
63 /* Get some attrbases */
65 if (!OOP_ObtainAttrBases(abd
))
70 failure
: freeclasses(xsd
);
75 /****************************************************************************************/
77 static VOID
freeclasses(struct x11_staticdata
*xsd
)
79 D(bug("[X11] %s()\n", __PRETTY_FUNCTION__
));
81 OOP_ReleaseAttrBases(abd
);
84 /****************************************************************************************/
86 static int MyErrorHandler(Display
* display
, XErrorEvent
* errevent
)
91 extern int xshm_major
;
93 if ((xshm_major
!= 0) && (errevent
->request_code
== xshm_major
) &&
94 (errevent
->minor_code
== 4) && /* XShmGetImage */
95 (errevent
->error_code
== BadMatch
))
97 /* Ignore this error */
104 XCALL(XGetErrorText
, display
, errevent
->error_code
, buffer
, sizeof (buffer
));
107 bug("XError %d (Major=%d, Minor=%d) task = %s\n%s\n", errevent
->error_code
, errevent
->request_code
,
108 errevent
->minor_code
, FindTask(0)->tc_Node
.ln_Name
, buffer
);
113 /****************************************************************************************/
115 static int MySysErrorHandler(Display
* display
)
117 /* This should have been host's perror(), not AROS perror()
118 perror ("X11-Error"); */
119 bug("X11 system error!\n");
124 /****************************************************************************************/
126 int X11_Init(struct x11_staticdata
*xsd
)
128 D(bug("[X11] %s()\n", __PRETTY_FUNCTION__
));
132 D(bug("[X11] %s: already initialized\n", __PRETTY_FUNCTION__
));
136 /* Do not need to singlethead this
137 * since no other tasks are using X currently
140 xsd
->display
= XCALL(XOpenDisplay
, NULL
);
141 D(bug("[X11] %s: X display @ 0x%p\n", __PRETTY_FUNCTION__
, xsd
->display
));
145 struct x11task_params xtp
;
146 struct Task
*x11task
;
151 #if DEBUG_X11_SYNCHRON
152 XCALL(XSynchronize
, xsd
->display
, True
);
154 XCALL(XSetErrorHandler
, MyErrorHandler
);
155 XCALL(XSetIOErrorHandler
, MySysErrorHandler
);
157 #if defined(HOST_OS_darwin) || defined(__arm__)
159 * Neither ARM targets nor XQuartz like operations on unmapped window, strange effects occur (bootmenu breaks, for example).
160 * X11 driver needs serious rewrite. For now i hope this will do.
163 /* Do not map (show) X window as long as there's no screen */
164 xsd
->options
|= OPTION_DELAYXWINMAPPING
;
167 BootLoaderBase
= OpenResource("bootloader.resource");
170 * Argument parsing from bootloader.resource
177 args
= GetBootInfo(BL_Args
);
180 for (n
= args
->lh_Head
; n
->ln_Succ
; n
= n
->ln_Succ
)
182 /* do we have fullscreen flag ? */
183 if (!strcmp("--fullscreen", n
->ln_Name
))
185 if (x11_fullscreen_supported(xsd
->display
))
186 xsd
->options
|= OPTION_FULLSCREEN
;
189 if (strcmp("--backingstore", n
->ln_Name
) == 0)
191 xsd
->options
|= OPTION_BACKINGSTORE
;
194 if (strcmp("--forcestdmodes", n
->ln_Name
) == 0)
196 xsd
->options
|= OPTION_FORCESTDMODES
;
199 if (strcmp("--forcedelayxwinmapping", n
->ln_Name
) == 0)
201 xsd
->options
|= OPTION_DELAYXWINMAPPING
;
209 if (xsd
->options
& OPTION_DELAYXWINMAPPING
)
211 D(bug("[X11] %s: option DELAYXWINMAPPING\n", __PRETTY_FUNCTION__
));
215 xsd
->delete_win_atom
= XCALL(XInternAtom
, xsd
->display
, "WM_DELETE_WINDOW", FALSE
);
216 xsd
->clipboard_atom
= XCALL(XInternAtom
, xsd
->display
, "CLIPBOARD", FALSE
);
217 xsd
->clipboard_property_atom
= XCALL(XInternAtom
, xsd
->display
, "AROS_HOSTCLIP", FALSE
);
218 xsd
->clipboard_incr_atom
= XCALL(XInternAtom
, xsd
->display
, "INCR", FALSE
);
219 xsd
->clipboard_targets_atom
= XCALL(XInternAtom
, xsd
->display
, "TARGETS", FALSE
);
221 xtp
.parent
= FindTask(NULL
);
222 xtp
.ok_signal
= SIGBREAKF_CTRL_E
;
223 xtp
.fail_signal
= SIGBREAKF_CTRL_F
;
224 xtp
.kill_signal
= SIGBREAKF_CTRL_C
;
227 if ((x11task
= create_x11task(&xtp
)))
229 if (initclasses(xsd
))
231 D(bug("[X11] %s: task & classes initialized\n", __PRETTY_FUNCTION__
));
235 Signal(x11task
, xtp
.kill_signal
);
238 XCALL(XCloseDisplay
, xsd
->display
);
242 D(bug("[X11] %s: failed to initialize\n", __PRETTY_FUNCTION__
));
247 /****************************************************************************************/