2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
5 Desc: X11 hidd initialization code.
11 #define __OOP_NOATTRBASES__
13 #include <aros/bootloader.h>
14 #include <proto/bootloader.h>
16 #include "x11_types.h"
17 #include LC_LIBDEFS_FILE
18 #include "x11_hostlib.h"
19 #include "x11gfx_fullscreen.h"
21 /****************************************************************************************/
25 /****************************************************************************************/
27 static BOOL
initclasses(struct x11_staticdata
*xsd
);
28 static VOID
freeclasses(struct x11_staticdata
*xsd
);
29 struct Task
*create_x11task(struct x11task_params
*params
);
30 VOID
x11task_entry(struct x11task_params
*xtp
);
32 /****************************************************************************************/
34 static OOP_AttrBase HiddPixFmtAttrBase
;
36 static struct OOP_ABDescr abd
[] =
38 { IID_Hidd_PixFmt
, &HiddPixFmtAttrBase
},
42 /****************************************************************************************/
44 static BOOL
initclasses(struct x11_staticdata
*xsd
)
46 D(bug("[X11] %s()\n", __PRETTY_FUNCTION__
));
48 /* Get some attrbases */
50 if (!OOP_ObtainAttrBases(abd
))
55 failure
: freeclasses(xsd
);
60 /****************************************************************************************/
62 static VOID
freeclasses(struct x11_staticdata
*xsd
)
64 D(bug("[X11] %s()\n", __PRETTY_FUNCTION__
));
66 OOP_ReleaseAttrBases(abd
);
69 /****************************************************************************************/
71 static int MyErrorHandler(Display
* display
, XErrorEvent
* errevent
)
76 extern int xshm_major
;
78 if ((xshm_major
!= 0) && (errevent
->request_code
== xshm_major
) &&
79 (errevent
->minor_code
== 4) && /* XShmGetImage */
80 (errevent
->error_code
== BadMatch
))
82 /* Ignore this error */
89 XCALL(XGetErrorText
, display
, errevent
->error_code
, buffer
, sizeof (buffer
));
92 bug("XError %d (Major=%d, Minor=%d) task = %s\n%s\n", errevent
->error_code
, errevent
->request_code
,
93 errevent
->minor_code
, FindTask(0)->tc_Node
.ln_Name
, buffer
);
98 /****************************************************************************************/
100 static int MySysErrorHandler(Display
* display
)
102 /* This should have been host's perror(), not AROS perror()
103 perror ("X11-Error"); */
104 bug("X11 system error!\n");
109 /****************************************************************************************/
111 int X11_Init(struct x11_staticdata
*xsd
)
113 D(bug("[X11] %s()\n", __PRETTY_FUNCTION__
));
117 D(bug("[X11] %s: already initialized\n", __PRETTY_FUNCTION__
));
121 /* Do not need to single-thread this since no other tasks are using X
124 xsd
->display
= XCALL(XOpenDisplay
, NULL
);
125 D(bug("[X11] %s: X display @ 0x%p\n", __PRETTY_FUNCTION__
, xsd
->display
));
129 struct x11task_params xtp
;
130 struct Task
*x11task
;
135 #if DEBUG_X11_SYNCHRON
136 XCALL(XSynchronize
, xsd
->display
, True
);
138 XCALL(XSetErrorHandler
, MyErrorHandler
);
139 XCALL(XSetIOErrorHandler
, MySysErrorHandler
);
141 #if defined(HOST_OS_darwin) || defined(__arm__)
143 * Neither ARM targets nor XQuartz like operations on unmapped window, strange effects occur (bootmenu breaks, for example).
144 * X11 driver needs serious rewrite. For now i hope this will do.
147 /* Do not map (show) X window as long as there's no screen */
148 xsd
->options
|= OPTION_DELAYXWINMAPPING
;
151 BootLoaderBase
= OpenResource("bootloader.resource");
154 * Argument parsing from bootloader.resource
161 args
= GetBootInfo(BL_Args
);
164 for (n
= args
->lh_Head
; n
->ln_Succ
; n
= n
->ln_Succ
)
166 /* do we have fullscreen flag ? */
167 if (!strcmp("--fullscreen", n
->ln_Name
))
169 if (x11_fullscreen_supported(xsd
->display
))
170 xsd
->options
|= OPTION_FULLSCREEN
;
173 if (strcmp("--backingstore", n
->ln_Name
) == 0)
175 xsd
->options
|= OPTION_BACKINGSTORE
;
178 if (strcmp("--forcestdmodes", n
->ln_Name
) == 0)
180 xsd
->options
|= OPTION_FORCESTDMODES
;
183 if (strcmp("--forcedelayxwinmapping", n
->ln_Name
) == 0)
185 xsd
->options
|= OPTION_DELAYXWINMAPPING
;
193 if (xsd
->options
& OPTION_DELAYXWINMAPPING
)
195 D(bug("[X11] %s: option DELAYXWINMAPPING\n", __PRETTY_FUNCTION__
));
199 xsd
->delete_win_atom
= XCALL(XInternAtom
, xsd
->display
, "WM_DELETE_WINDOW", FALSE
);
200 xsd
->clipboard_atom
= XCALL(XInternAtom
, xsd
->display
, "CLIPBOARD", FALSE
);
201 xsd
->clipboard_property_atom
= XCALL(XInternAtom
, xsd
->display
, "AROS_HOSTCLIP", FALSE
);
202 xsd
->clipboard_incr_atom
= XCALL(XInternAtom
, xsd
->display
, "INCR", FALSE
);
203 xsd
->clipboard_targets_atom
= XCALL(XInternAtom
, xsd
->display
, "TARGETS", FALSE
);
205 xtp
.parent
= FindTask(NULL
);
206 xtp
.ok_signal
= SIGBREAKF_CTRL_E
;
207 xtp
.fail_signal
= SIGBREAKF_CTRL_F
;
208 xtp
.kill_signal
= SIGBREAKF_CTRL_C
;
211 if ((x11task
= create_x11task(&xtp
)))
213 if (initclasses(xsd
))
215 D(bug("[X11] %s: task & classes initialized\n", __PRETTY_FUNCTION__
));
219 Signal(x11task
, xtp
.kill_signal
);
222 XCALL(XCloseDisplay
, xsd
->display
);
226 D(bug("[X11] %s: failed to initialize\n", __PRETTY_FUNCTION__
));
231 /****************************************************************************************/