]> git.sesse.net Git - pistorm/blob - raylib_pi4_test/external/glfw/src/x11_platform.h
Update raylib files and Makefile for Pi 4 testing
[pistorm] / raylib_pi4_test / external / glfw / src / x11_platform.h
1 //========================================================================
2 // GLFW 3.4 X11 - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2002-2006 Marcus Geelnard
5 // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6 //
7 // This software is provided 'as-is', without any express or implied
8 // warranty. In no event will the authors be held liable for any damages
9 // arising from the use of this software.
10 //
11 // Permission is granted to anyone to use this software for any purpose,
12 // including commercial applications, and to alter it and redistribute it
13 // freely, subject to the following restrictions:
14 //
15 // 1. The origin of this software must not be misrepresented; you must not
16 //    claim that you wrote the original software. If you use this software
17 //    in a product, an acknowledgment in the product documentation would
18 //    be appreciated but is not required.
19 //
20 // 2. Altered source versions must be plainly marked as such, and must not
21 //    be misrepresented as being the original software.
22 //
23 // 3. This notice may not be removed or altered from any source
24 //    distribution.
25 //
26 //========================================================================
27
28 #include <unistd.h>
29 #include <signal.h>
30 #include <stdint.h>
31 #include <dlfcn.h>
32
33 #include <X11/Xlib.h>
34 #include <X11/keysym.h>
35 #include <X11/Xatom.h>
36 #include <X11/Xresource.h>
37 #include <X11/Xcursor/Xcursor.h>
38
39 // The XRandR extension provides mode setting and gamma control
40 #include <X11/extensions/Xrandr.h>
41
42 // The Xkb extension provides improved keyboard support
43 #include <X11/XKBlib.h>
44
45 // The Xinerama extension provides legacy monitor indices
46 #include <X11/extensions/Xinerama.h>
47
48 // The XInput extension provides raw mouse motion input
49 #include <X11/extensions/XInput2.h>
50
51 // The Shape extension provides custom window shapes
52 #include <X11/extensions/shape.h>
53
54 typedef XClassHint* (* PFN_XAllocClassHint)(void);
55 typedef XSizeHints* (* PFN_XAllocSizeHints)(void);
56 typedef XWMHints* (* PFN_XAllocWMHints)(void);
57 typedef int (* PFN_XChangeProperty)(Display*,Window,Atom,Atom,int,int,const unsigned char*,int);
58 typedef int (* PFN_XChangeWindowAttributes)(Display*,Window,unsigned long,XSetWindowAttributes*);
59 typedef Bool (* PFN_XCheckIfEvent)(Display*,XEvent*,Bool(*)(Display*,XEvent*,XPointer),XPointer);
60 typedef Bool (* PFN_XCheckTypedWindowEvent)(Display*,Window,int,XEvent*);
61 typedef int (* PFN_XCloseDisplay)(Display*);
62 typedef Status (* PFN_XCloseIM)(XIM);
63 typedef int (* PFN_XConvertSelection)(Display*,Atom,Atom,Atom,Window,Time);
64 typedef Colormap (* PFN_XCreateColormap)(Display*,Window,Visual*,int);
65 typedef Cursor (* PFN_XCreateFontCursor)(Display*,unsigned int);
66 typedef XIC (* PFN_XCreateIC)(XIM,...);
67 typedef Region (* PFN_XCreateRegion)(void);
68 typedef Window (* PFN_XCreateWindow)(Display*,Window,int,int,unsigned int,unsigned int,unsigned int,int,unsigned int,Visual*,unsigned long,XSetWindowAttributes*);
69 typedef int (* PFN_XDefineCursor)(Display*,Window,Cursor);
70 typedef int (* PFN_XDeleteContext)(Display*,XID,XContext);
71 typedef int (* PFN_XDeleteProperty)(Display*,Window,Atom);
72 typedef void (* PFN_XDestroyIC)(XIC);
73 typedef int (* PFN_XDestroyRegion)(Region);
74 typedef int (* PFN_XDestroyWindow)(Display*,Window);
75 typedef int (* PFN_XDisplayKeycodes)(Display*,int*,int*);
76 typedef int (* PFN_XEventsQueued)(Display*,int);
77 typedef Bool (* PFN_XFilterEvent)(XEvent*,Window);
78 typedef int (* PFN_XFindContext)(Display*,XID,XContext,XPointer*);
79 typedef int (* PFN_XFlush)(Display*);
80 typedef int (* PFN_XFree)(void*);
81 typedef int (* PFN_XFreeColormap)(Display*,Colormap);
82 typedef int (* PFN_XFreeCursor)(Display*,Cursor);
83 typedef void (* PFN_XFreeEventData)(Display*,XGenericEventCookie*);
84 typedef int (* PFN_XGetErrorText)(Display*,int,char*,int);
85 typedef Bool (* PFN_XGetEventData)(Display*,XGenericEventCookie*);
86 typedef char* (* PFN_XGetICValues)(XIC,...);
87 typedef char* (* PFN_XGetIMValues)(XIM,...);
88 typedef int (* PFN_XGetInputFocus)(Display*,Window*,int*);
89 typedef KeySym* (* PFN_XGetKeyboardMapping)(Display*,KeyCode,int,int*);
90 typedef int (* PFN_XGetScreenSaver)(Display*,int*,int*,int*,int*);
91 typedef Window (* PFN_XGetSelectionOwner)(Display*,Atom);
92 typedef XVisualInfo* (* PFN_XGetVisualInfo)(Display*,long,XVisualInfo*,int*);
93 typedef Status (* PFN_XGetWMNormalHints)(Display*,Window,XSizeHints*,long*);
94 typedef Status (* PFN_XGetWindowAttributes)(Display*,Window,XWindowAttributes*);
95 typedef int (* PFN_XGetWindowProperty)(Display*,Window,Atom,long,long,Bool,Atom,Atom*,int*,unsigned long*,unsigned long*,unsigned char**);
96 typedef int (* PFN_XGrabPointer)(Display*,Window,Bool,unsigned int,int,int,Window,Cursor,Time);
97 typedef Status (* PFN_XIconifyWindow)(Display*,Window,int);
98 typedef Status (* PFN_XInitThreads)(void);
99 typedef Atom (* PFN_XInternAtom)(Display*,const char*,Bool);
100 typedef int (* PFN_XLookupString)(XKeyEvent*,char*,int,KeySym*,XComposeStatus*);
101 typedef int (* PFN_XMapRaised)(Display*,Window);
102 typedef int (* PFN_XMapWindow)(Display*,Window);
103 typedef int (* PFN_XMoveResizeWindow)(Display*,Window,int,int,unsigned int,unsigned int);
104 typedef int (* PFN_XMoveWindow)(Display*,Window,int,int);
105 typedef int (* PFN_XNextEvent)(Display*,XEvent*);
106 typedef Display* (* PFN_XOpenDisplay)(const char*);
107 typedef XIM (* PFN_XOpenIM)(Display*,XrmDatabase*,char*,char*);
108 typedef int (* PFN_XPeekEvent)(Display*,XEvent*);
109 typedef int (* PFN_XPending)(Display*);
110 typedef Bool (* PFN_XQueryExtension)(Display*,const char*,int*,int*,int*);
111 typedef Bool (* PFN_XQueryPointer)(Display*,Window,Window*,Window*,int*,int*,int*,int*,unsigned int*);
112 typedef int (* PFN_XRaiseWindow)(Display*,Window);
113 typedef Bool (* PFN_XRegisterIMInstantiateCallback)(Display*,void*,char*,char*,XIDProc,XPointer);
114 typedef int (* PFN_XResizeWindow)(Display*,Window,unsigned int,unsigned int);
115 typedef char* (* PFN_XResourceManagerString)(Display*);
116 typedef int (* PFN_XSaveContext)(Display*,XID,XContext,const char*);
117 typedef int (* PFN_XSelectInput)(Display*,Window,long);
118 typedef Status (* PFN_XSendEvent)(Display*,Window,Bool,long,XEvent*);
119 typedef int (* PFN_XSetClassHint)(Display*,Window,XClassHint*);
120 typedef XErrorHandler (* PFN_XSetErrorHandler)(XErrorHandler);
121 typedef void (* PFN_XSetICFocus)(XIC);
122 typedef char* (* PFN_XSetIMValues)(XIM,...);
123 typedef int (* PFN_XSetInputFocus)(Display*,Window,int,Time);
124 typedef char* (* PFN_XSetLocaleModifiers)(const char*);
125 typedef int (* PFN_XSetScreenSaver)(Display*,int,int,int,int);
126 typedef int (* PFN_XSetSelectionOwner)(Display*,Atom,Window,Time);
127 typedef int (* PFN_XSetWMHints)(Display*,Window,XWMHints*);
128 typedef void (* PFN_XSetWMNormalHints)(Display*,Window,XSizeHints*);
129 typedef Status (* PFN_XSetWMProtocols)(Display*,Window,Atom*,int);
130 typedef Bool (* PFN_XSupportsLocale)(void);
131 typedef int (* PFN_XSync)(Display*,Bool);
132 typedef Bool (* PFN_XTranslateCoordinates)(Display*,Window,Window,int,int,int*,int*,Window*);
133 typedef int (* PFN_XUndefineCursor)(Display*,Window);
134 typedef int (* PFN_XUngrabPointer)(Display*,Time);
135 typedef int (* PFN_XUnmapWindow)(Display*,Window);
136 typedef void (* PFN_XUnsetICFocus)(XIC);
137 typedef VisualID (* PFN_XVisualIDFromVisual)(Visual*);
138 typedef int (* PFN_XWarpPointer)(Display*,Window,Window,int,int,unsigned int,unsigned int,int,int);
139 typedef void (* PFN_XkbFreeKeyboard)(XkbDescPtr,unsigned int,Bool);
140 typedef void (* PFN_XkbFreeNames)(XkbDescPtr,unsigned int,Bool);
141 typedef XkbDescPtr (* PFN_XkbGetMap)(Display*,unsigned int,unsigned int);
142 typedef Status (* PFN_XkbGetNames)(Display*,unsigned int,XkbDescPtr);
143 typedef Status (* PFN_XkbGetState)(Display*,unsigned int,XkbStatePtr);
144 typedef KeySym (* PFN_XkbKeycodeToKeysym)(Display*,KeyCode,int,int);
145 typedef Bool (* PFN_XkbQueryExtension)(Display*,int*,int*,int*,int*,int*);
146 typedef Bool (* PFN_XkbSelectEventDetails)(Display*,unsigned int,unsigned int,unsigned long,unsigned long);
147 typedef Bool (* PFN_XkbSetDetectableAutoRepeat)(Display*,Bool,Bool*);
148 typedef void (* PFN_XrmDestroyDatabase)(XrmDatabase);
149 typedef Bool (* PFN_XrmGetResource)(XrmDatabase,const char*,const char*,char**,XrmValue*);
150 typedef XrmDatabase (* PFN_XrmGetStringDatabase)(const char*);
151 typedef void (* PFN_XrmInitialize)(void);
152 typedef XrmQuark (* PFN_XrmUniqueQuark)(void);
153 typedef Bool (* PFN_XUnregisterIMInstantiateCallback)(Display*,void*,char*,char*,XIDProc,XPointer);
154 typedef int (* PFN_Xutf8LookupString)(XIC,XKeyPressedEvent*,char*,int,KeySym*,Status*);
155 typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char*,char**,int,XSizeHints*,XWMHints*,XClassHint*);
156 #define XAllocClassHint _glfw.x11.xlib.AllocClassHint
157 #define XAllocSizeHints _glfw.x11.xlib.AllocSizeHints
158 #define XAllocWMHints _glfw.x11.xlib.AllocWMHints
159 #define XChangeProperty _glfw.x11.xlib.ChangeProperty
160 #define XChangeWindowAttributes _glfw.x11.xlib.ChangeWindowAttributes
161 #define XCheckIfEvent _glfw.x11.xlib.CheckIfEvent
162 #define XCheckTypedWindowEvent _glfw.x11.xlib.CheckTypedWindowEvent
163 #define XCloseDisplay _glfw.x11.xlib.CloseDisplay
164 #define XCloseIM _glfw.x11.xlib.CloseIM
165 #define XConvertSelection _glfw.x11.xlib.ConvertSelection
166 #define XCreateColormap _glfw.x11.xlib.CreateColormap
167 #define XCreateFontCursor _glfw.x11.xlib.CreateFontCursor
168 #define XCreateIC _glfw.x11.xlib.CreateIC
169 #define XCreateRegion _glfw.x11.xlib.CreateRegion
170 #define XCreateWindow _glfw.x11.xlib.CreateWindow
171 #define XDefineCursor _glfw.x11.xlib.DefineCursor
172 #define XDeleteContext _glfw.x11.xlib.DeleteContext
173 #define XDeleteProperty _glfw.x11.xlib.DeleteProperty
174 #define XDestroyIC _glfw.x11.xlib.DestroyIC
175 #define XDestroyRegion _glfw.x11.xlib.DestroyRegion
176 #define XDestroyWindow _glfw.x11.xlib.DestroyWindow
177 #define XDisplayKeycodes _glfw.x11.xlib.DisplayKeycodes
178 #define XEventsQueued _glfw.x11.xlib.EventsQueued
179 #define XFilterEvent _glfw.x11.xlib.FilterEvent
180 #define XFindContext _glfw.x11.xlib.FindContext
181 #define XFlush _glfw.x11.xlib.Flush
182 #define XFree _glfw.x11.xlib.Free
183 #define XFreeColormap _glfw.x11.xlib.FreeColormap
184 #define XFreeCursor _glfw.x11.xlib.FreeCursor
185 #define XFreeEventData _glfw.x11.xlib.FreeEventData
186 #define XGetErrorText _glfw.x11.xlib.GetErrorText
187 #define XGetEventData _glfw.x11.xlib.GetEventData
188 #define XGetICValues _glfw.x11.xlib.GetICValues
189 #define XGetIMValues _glfw.x11.xlib.GetIMValues
190 #define XGetInputFocus _glfw.x11.xlib.GetInputFocus
191 #define XGetKeyboardMapping _glfw.x11.xlib.GetKeyboardMapping
192 #define XGetScreenSaver _glfw.x11.xlib.GetScreenSaver
193 #define XGetSelectionOwner _glfw.x11.xlib.GetSelectionOwner
194 #define XGetVisualInfo _glfw.x11.xlib.GetVisualInfo
195 #define XGetWMNormalHints _glfw.x11.xlib.GetWMNormalHints
196 #define XGetWindowAttributes _glfw.x11.xlib.GetWindowAttributes
197 #define XGetWindowProperty _glfw.x11.xlib.GetWindowProperty
198 #define XGrabPointer _glfw.x11.xlib.GrabPointer
199 #define XIconifyWindow _glfw.x11.xlib.IconifyWindow
200 #define XInitThreads _glfw.x11.xlib.InitThreads
201 #define XInternAtom _glfw.x11.xlib.InternAtom
202 #define XLookupString _glfw.x11.xlib.LookupString
203 #define XMapRaised _glfw.x11.xlib.MapRaised
204 #define XMapWindow _glfw.x11.xlib.MapWindow
205 #define XMoveResizeWindow _glfw.x11.xlib.MoveResizeWindow
206 #define XMoveWindow _glfw.x11.xlib.MoveWindow
207 #define XNextEvent _glfw.x11.xlib.NextEvent
208 #define XOpenDisplay _glfw.x11.xlib.OpenDisplay
209 #define XOpenIM _glfw.x11.xlib.OpenIM
210 #define XPeekEvent _glfw.x11.xlib.PeekEvent
211 #define XPending _glfw.x11.xlib.Pending
212 #define XQueryExtension _glfw.x11.xlib.QueryExtension
213 #define XQueryPointer _glfw.x11.xlib.QueryPointer
214 #define XRaiseWindow _glfw.x11.xlib.RaiseWindow
215 #define XRegisterIMInstantiateCallback _glfw.x11.xlib.RegisterIMInstantiateCallback
216 #define XResizeWindow _glfw.x11.xlib.ResizeWindow
217 #define XResourceManagerString _glfw.x11.xlib.ResourceManagerString
218 #define XSaveContext _glfw.x11.xlib.SaveContext
219 #define XSelectInput _glfw.x11.xlib.SelectInput
220 #define XSendEvent _glfw.x11.xlib.SendEvent
221 #define XSetClassHint _glfw.x11.xlib.SetClassHint
222 #define XSetErrorHandler _glfw.x11.xlib.SetErrorHandler
223 #define XSetICFocus _glfw.x11.xlib.SetICFocus
224 #define XSetIMValues _glfw.x11.xlib.SetIMValues
225 #define XSetInputFocus _glfw.x11.xlib.SetInputFocus
226 #define XSetLocaleModifiers _glfw.x11.xlib.SetLocaleModifiers
227 #define XSetScreenSaver _glfw.x11.xlib.SetScreenSaver
228 #define XSetSelectionOwner _glfw.x11.xlib.SetSelectionOwner
229 #define XSetWMHints _glfw.x11.xlib.SetWMHints
230 #define XSetWMNormalHints _glfw.x11.xlib.SetWMNormalHints
231 #define XSetWMProtocols _glfw.x11.xlib.SetWMProtocols
232 #define XSupportsLocale _glfw.x11.xlib.SupportsLocale
233 #define XSync _glfw.x11.xlib.Sync
234 #define XTranslateCoordinates _glfw.x11.xlib.TranslateCoordinates
235 #define XUndefineCursor _glfw.x11.xlib.UndefineCursor
236 #define XUngrabPointer _glfw.x11.xlib.UngrabPointer
237 #define XUnmapWindow _glfw.x11.xlib.UnmapWindow
238 #define XUnsetICFocus _glfw.x11.xlib.UnsetICFocus
239 #define XVisualIDFromVisual _glfw.x11.xlib.VisualIDFromVisual
240 #define XWarpPointer _glfw.x11.xlib.WarpPointer
241 #define XkbFreeKeyboard _glfw.x11.xkb.FreeKeyboard
242 #define XkbFreeNames _glfw.x11.xkb.FreeNames
243 #define XkbGetMap _glfw.x11.xkb.GetMap
244 #define XkbGetNames _glfw.x11.xkb.GetNames
245 #define XkbGetState _glfw.x11.xkb.GetState
246 #define XkbKeycodeToKeysym _glfw.x11.xkb.KeycodeToKeysym
247 #define XkbQueryExtension _glfw.x11.xkb.QueryExtension
248 #define XkbSelectEventDetails _glfw.x11.xkb.SelectEventDetails
249 #define XkbSetDetectableAutoRepeat _glfw.x11.xkb.SetDetectableAutoRepeat
250 #define XrmDestroyDatabase _glfw.x11.xrm.DestroyDatabase
251 #define XrmGetResource _glfw.x11.xrm.GetResource
252 #define XrmGetStringDatabase _glfw.x11.xrm.GetStringDatabase
253 #define XrmInitialize _glfw.x11.xrm.Initialize
254 #define XrmUniqueQuark _glfw.x11.xrm.UniqueQuark
255 #define XUnregisterIMInstantiateCallback _glfw.x11.xlib.UnregisterIMInstantiateCallback
256 #define Xutf8LookupString _glfw.x11.xlib.utf8LookupString
257 #define Xutf8SetWMProperties _glfw.x11.xlib.utf8SetWMProperties
258
259 typedef XRRCrtcGamma* (* PFN_XRRAllocGamma)(int);
260 typedef void (* PFN_XRRFreeCrtcInfo)(XRRCrtcInfo*);
261 typedef void (* PFN_XRRFreeGamma)(XRRCrtcGamma*);
262 typedef void (* PFN_XRRFreeOutputInfo)(XRROutputInfo*);
263 typedef void (* PFN_XRRFreeScreenResources)(XRRScreenResources*);
264 typedef XRRCrtcGamma* (* PFN_XRRGetCrtcGamma)(Display*,RRCrtc);
265 typedef int (* PFN_XRRGetCrtcGammaSize)(Display*,RRCrtc);
266 typedef XRRCrtcInfo* (* PFN_XRRGetCrtcInfo) (Display*,XRRScreenResources*,RRCrtc);
267 typedef XRROutputInfo* (* PFN_XRRGetOutputInfo)(Display*,XRRScreenResources*,RROutput);
268 typedef RROutput (* PFN_XRRGetOutputPrimary)(Display*,Window);
269 typedef XRRScreenResources* (* PFN_XRRGetScreenResourcesCurrent)(Display*,Window);
270 typedef Bool (* PFN_XRRQueryExtension)(Display*,int*,int*);
271 typedef Status (* PFN_XRRQueryVersion)(Display*,int*,int*);
272 typedef void (* PFN_XRRSelectInput)(Display*,Window,int);
273 typedef Status (* PFN_XRRSetCrtcConfig)(Display*,XRRScreenResources*,RRCrtc,Time,int,int,RRMode,Rotation,RROutput*,int);
274 typedef void (* PFN_XRRSetCrtcGamma)(Display*,RRCrtc,XRRCrtcGamma*);
275 typedef int (* PFN_XRRUpdateConfiguration)(XEvent*);
276 #define XRRAllocGamma _glfw.x11.randr.AllocGamma
277 #define XRRFreeCrtcInfo _glfw.x11.randr.FreeCrtcInfo
278 #define XRRFreeGamma _glfw.x11.randr.FreeGamma
279 #define XRRFreeOutputInfo _glfw.x11.randr.FreeOutputInfo
280 #define XRRFreeScreenResources _glfw.x11.randr.FreeScreenResources
281 #define XRRGetCrtcGamma _glfw.x11.randr.GetCrtcGamma
282 #define XRRGetCrtcGammaSize _glfw.x11.randr.GetCrtcGammaSize
283 #define XRRGetCrtcInfo _glfw.x11.randr.GetCrtcInfo
284 #define XRRGetOutputInfo _glfw.x11.randr.GetOutputInfo
285 #define XRRGetOutputPrimary _glfw.x11.randr.GetOutputPrimary
286 #define XRRGetScreenResourcesCurrent _glfw.x11.randr.GetScreenResourcesCurrent
287 #define XRRQueryExtension _glfw.x11.randr.QueryExtension
288 #define XRRQueryVersion _glfw.x11.randr.QueryVersion
289 #define XRRSelectInput _glfw.x11.randr.SelectInput
290 #define XRRSetCrtcConfig _glfw.x11.randr.SetCrtcConfig
291 #define XRRSetCrtcGamma _glfw.x11.randr.SetCrtcGamma
292 #define XRRUpdateConfiguration _glfw.x11.randr.UpdateConfiguration
293
294 typedef XcursorImage* (* PFN_XcursorImageCreate)(int,int);
295 typedef void (* PFN_XcursorImageDestroy)(XcursorImage*);
296 typedef Cursor (* PFN_XcursorImageLoadCursor)(Display*,const XcursorImage*);
297 typedef char* (* PFN_XcursorGetTheme)(Display*);
298 typedef int (* PFN_XcursorGetDefaultSize)(Display*);
299 typedef XcursorImage* (* PFN_XcursorLibraryLoadImage)(const char*,const char*,int);
300 #define XcursorImageCreate _glfw.x11.xcursor.ImageCreate
301 #define XcursorImageDestroy _glfw.x11.xcursor.ImageDestroy
302 #define XcursorImageLoadCursor _glfw.x11.xcursor.ImageLoadCursor
303 #define XcursorGetTheme _glfw.x11.xcursor.GetTheme
304 #define XcursorGetDefaultSize _glfw.x11.xcursor.GetDefaultSize
305 #define XcursorLibraryLoadImage _glfw.x11.xcursor.LibraryLoadImage
306
307 typedef Bool (* PFN_XineramaIsActive)(Display*);
308 typedef Bool (* PFN_XineramaQueryExtension)(Display*,int*,int*);
309 typedef XineramaScreenInfo* (* PFN_XineramaQueryScreens)(Display*,int*);
310 #define XineramaIsActive _glfw.x11.xinerama.IsActive
311 #define XineramaQueryExtension _glfw.x11.xinerama.QueryExtension
312 #define XineramaQueryScreens _glfw.x11.xinerama.QueryScreens
313
314 typedef XID xcb_window_t;
315 typedef XID xcb_visualid_t;
316 typedef struct xcb_connection_t xcb_connection_t;
317 typedef xcb_connection_t* (* PFN_XGetXCBConnection)(Display*);
318 #define XGetXCBConnection _glfw.x11.x11xcb.GetXCBConnection
319
320 typedef Bool (* PFN_XF86VidModeQueryExtension)(Display*,int*,int*);
321 typedef Bool (* PFN_XF86VidModeGetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
322 typedef Bool (* PFN_XF86VidModeSetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
323 typedef Bool (* PFN_XF86VidModeGetGammaRampSize)(Display*,int,int*);
324 #define XF86VidModeQueryExtension _glfw.x11.vidmode.QueryExtension
325 #define XF86VidModeGetGammaRamp _glfw.x11.vidmode.GetGammaRamp
326 #define XF86VidModeSetGammaRamp _glfw.x11.vidmode.SetGammaRamp
327 #define XF86VidModeGetGammaRampSize _glfw.x11.vidmode.GetGammaRampSize
328
329 typedef Status (* PFN_XIQueryVersion)(Display*,int*,int*);
330 typedef int (* PFN_XISelectEvents)(Display*,Window,XIEventMask*,int);
331 #define XIQueryVersion _glfw.x11.xi.QueryVersion
332 #define XISelectEvents _glfw.x11.xi.SelectEvents
333
334 typedef Bool (* PFN_XRenderQueryExtension)(Display*,int*,int*);
335 typedef Status (* PFN_XRenderQueryVersion)(Display*dpy,int*,int*);
336 typedef XRenderPictFormat* (* PFN_XRenderFindVisualFormat)(Display*,Visual const*);
337 #define XRenderQueryExtension _glfw.x11.xrender.QueryExtension
338 #define XRenderQueryVersion _glfw.x11.xrender.QueryVersion
339 #define XRenderFindVisualFormat _glfw.x11.xrender.FindVisualFormat
340
341 typedef Bool (* PFN_XShapeQueryExtension)(Display*,int*,int*);
342 typedef Status (* PFN_XShapeQueryVersion)(Display*dpy,int*,int*);
343 typedef void (* PFN_XShapeCombineRegion)(Display*,Window,int,int,int,Region,int);
344 typedef void (* PFN_XShapeCombineMask)(Display*,Window,int,int,int,Pixmap,int);
345
346 #define XShapeQueryExtension _glfw.x11.xshape.QueryExtension
347 #define XShapeQueryVersion _glfw.x11.xshape.QueryVersion
348 #define XShapeCombineRegion _glfw.x11.xshape.ShapeCombineRegion
349 #define XShapeCombineMask _glfw.x11.xshape.ShapeCombineMask
350
351 typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
352 typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
353
354 typedef struct VkXlibSurfaceCreateInfoKHR
355 {
356     VkStructureType             sType;
357     const void*                 pNext;
358     VkXlibSurfaceCreateFlagsKHR flags;
359     Display*                    dpy;
360     Window                      window;
361 } VkXlibSurfaceCreateInfoKHR;
362
363 typedef struct VkXcbSurfaceCreateInfoKHR
364 {
365     VkStructureType             sType;
366     const void*                 pNext;
367     VkXcbSurfaceCreateFlagsKHR  flags;
368     xcb_connection_t*           connection;
369     xcb_window_t                window;
370 } VkXcbSurfaceCreateInfoKHR;
371
372 typedef VkResult (APIENTRY *PFN_vkCreateXlibSurfaceKHR)(VkInstance,const VkXlibSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
373 typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice,uint32_t,Display*,VisualID);
374 typedef VkResult (APIENTRY *PFN_vkCreateXcbSurfaceKHR)(VkInstance,const VkXcbSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
375 typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice,uint32_t,xcb_connection_t*,xcb_visualid_t);
376
377 #include "posix_thread.h"
378 #include "posix_time.h"
379 #include "xkb_unicode.h"
380 #include "glx_context.h"
381 #if defined(__linux__)
382 #include "linux_joystick.h"
383 #else
384 #include "null_joystick.h"
385 #endif
386
387 #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
388 #define _glfw_dlclose(handle) dlclose(handle)
389 #define _glfw_dlsym(handle, name) dlsym(handle, name)
390
391 #define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowX11  x11
392 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11
393 #define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorX11 x11
394 #define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorX11  x11
395
396
397 // X11-specific per-window data
398 //
399 typedef struct _GLFWwindowX11
400 {
401     Colormap        colormap;
402     Window          handle;
403     Window          parent;
404     XIC             ic;
405
406     GLFWbool        overrideRedirect;
407     GLFWbool        iconified;
408     GLFWbool        maximized;
409
410     // Whether the visual supports framebuffer transparency
411     GLFWbool        transparent;
412
413     // Cached position and size used to filter out duplicate events
414     int             width, height;
415     int             xpos, ypos;
416
417     // The last received cursor position, regardless of source
418     int             lastCursorPosX, lastCursorPosY;
419     // The last position the cursor was warped to by GLFW
420     int             warpCursorPosX, warpCursorPosY;
421
422     // The time of the last KeyPress event per keycode, for discarding
423     // duplicate key events generated for some keys by ibus
424     Time            keyPressTimes[256];
425
426 } _GLFWwindowX11;
427
428 // X11-specific global data
429 //
430 typedef struct _GLFWlibraryX11
431 {
432     Display*        display;
433     int             screen;
434     Window          root;
435
436     // System content scale
437     float           contentScaleX, contentScaleY;
438     // Helper window for IPC
439     Window          helperWindowHandle;
440     // Invisible cursor for hidden cursor mode
441     Cursor          hiddenCursorHandle;
442     // Context for mapping window XIDs to _GLFWwindow pointers
443     XContext        context;
444     // XIM input method
445     XIM             im;
446     // Most recent error code received by X error handler
447     int             errorCode;
448     // Primary selection string (while the primary selection is owned)
449     char*           primarySelectionString;
450     // Clipboard string (while the selection is owned)
451     char*           clipboardString;
452     // Key name string
453     char            keynames[GLFW_KEY_LAST + 1][5];
454     // X11 keycode to GLFW key LUT
455     short int       keycodes[256];
456     // GLFW key to X11 keycode LUT
457     short int       scancodes[GLFW_KEY_LAST + 1];
458     // Where to place the cursor when re-enabled
459     double          restoreCursorPosX, restoreCursorPosY;
460     // The window whose disabled cursor mode is active
461     _GLFWwindow*    disabledCursorWindow;
462
463     // Window manager atoms
464     Atom            NET_SUPPORTED;
465     Atom            NET_SUPPORTING_WM_CHECK;
466     Atom            WM_PROTOCOLS;
467     Atom            WM_STATE;
468     Atom            WM_DELETE_WINDOW;
469     Atom            NET_WM_NAME;
470     Atom            NET_WM_ICON_NAME;
471     Atom            NET_WM_ICON;
472     Atom            NET_WM_PID;
473     Atom            NET_WM_PING;
474     Atom            NET_WM_WINDOW_TYPE;
475     Atom            NET_WM_WINDOW_TYPE_NORMAL;
476     Atom            NET_WM_STATE;
477     Atom            NET_WM_STATE_ABOVE;
478     Atom            NET_WM_STATE_FULLSCREEN;
479     Atom            NET_WM_STATE_MAXIMIZED_VERT;
480     Atom            NET_WM_STATE_MAXIMIZED_HORZ;
481     Atom            NET_WM_STATE_DEMANDS_ATTENTION;
482     Atom            NET_WM_BYPASS_COMPOSITOR;
483     Atom            NET_WM_FULLSCREEN_MONITORS;
484     Atom            NET_WM_WINDOW_OPACITY;
485     Atom            NET_WM_CM_Sx;
486     Atom            NET_WORKAREA;
487     Atom            NET_CURRENT_DESKTOP;
488     Atom            NET_ACTIVE_WINDOW;
489     Atom            NET_FRAME_EXTENTS;
490     Atom            NET_REQUEST_FRAME_EXTENTS;
491     Atom            MOTIF_WM_HINTS;
492
493     // Xdnd (drag and drop) atoms
494     Atom            XdndAware;
495     Atom            XdndEnter;
496     Atom            XdndPosition;
497     Atom            XdndStatus;
498     Atom            XdndActionCopy;
499     Atom            XdndDrop;
500     Atom            XdndFinished;
501     Atom            XdndSelection;
502     Atom            XdndTypeList;
503     Atom            text_uri_list;
504
505     // Selection (clipboard) atoms
506     Atom            TARGETS;
507     Atom            MULTIPLE;
508     Atom            INCR;
509     Atom            CLIPBOARD;
510     Atom            PRIMARY;
511     Atom            CLIPBOARD_MANAGER;
512     Atom            SAVE_TARGETS;
513     Atom            NULL_;
514     Atom            UTF8_STRING;
515     Atom            COMPOUND_STRING;
516     Atom            ATOM_PAIR;
517     Atom            GLFW_SELECTION;
518
519     struct {
520         void*       handle;
521         GLFWbool    utf8;
522         PFN_XAllocClassHint AllocClassHint;
523         PFN_XAllocSizeHints AllocSizeHints;
524         PFN_XAllocWMHints AllocWMHints;
525         PFN_XChangeProperty ChangeProperty;
526         PFN_XChangeWindowAttributes ChangeWindowAttributes;
527         PFN_XCheckIfEvent CheckIfEvent;
528         PFN_XCheckTypedWindowEvent CheckTypedWindowEvent;
529         PFN_XCloseDisplay CloseDisplay;
530         PFN_XCloseIM CloseIM;
531         PFN_XConvertSelection ConvertSelection;
532         PFN_XCreateColormap CreateColormap;
533         PFN_XCreateFontCursor CreateFontCursor;
534         PFN_XCreateIC CreateIC;
535         PFN_XCreateRegion CreateRegion;
536         PFN_XCreateWindow CreateWindow;
537         PFN_XDefineCursor DefineCursor;
538         PFN_XDeleteContext DeleteContext;
539         PFN_XDeleteProperty DeleteProperty;
540         PFN_XDestroyIC DestroyIC;
541         PFN_XDestroyRegion DestroyRegion;
542         PFN_XDestroyWindow DestroyWindow;
543         PFN_XDisplayKeycodes DisplayKeycodes;
544         PFN_XEventsQueued EventsQueued;
545         PFN_XFilterEvent FilterEvent;
546         PFN_XFindContext FindContext;
547         PFN_XFlush Flush;
548         PFN_XFree Free;
549         PFN_XFreeColormap FreeColormap;
550         PFN_XFreeCursor FreeCursor;
551         PFN_XFreeEventData FreeEventData;
552         PFN_XGetErrorText GetErrorText;
553         PFN_XGetEventData GetEventData;
554         PFN_XGetICValues GetICValues;
555         PFN_XGetIMValues GetIMValues;
556         PFN_XGetInputFocus GetInputFocus;
557         PFN_XGetKeyboardMapping GetKeyboardMapping;
558         PFN_XGetScreenSaver GetScreenSaver;
559         PFN_XGetSelectionOwner GetSelectionOwner;
560         PFN_XGetVisualInfo GetVisualInfo;
561         PFN_XGetWMNormalHints GetWMNormalHints;
562         PFN_XGetWindowAttributes GetWindowAttributes;
563         PFN_XGetWindowProperty GetWindowProperty;
564         PFN_XGrabPointer GrabPointer;
565         PFN_XIconifyWindow IconifyWindow;
566         PFN_XInitThreads InitThreads;
567         PFN_XInternAtom InternAtom;
568         PFN_XLookupString LookupString;
569         PFN_XMapRaised MapRaised;
570         PFN_XMapWindow MapWindow;
571         PFN_XMoveResizeWindow MoveResizeWindow;
572         PFN_XMoveWindow MoveWindow;
573         PFN_XNextEvent NextEvent;
574         PFN_XOpenDisplay OpenDisplay;
575         PFN_XOpenIM OpenIM;
576         PFN_XPeekEvent PeekEvent;
577         PFN_XPending Pending;
578         PFN_XQueryExtension QueryExtension;
579         PFN_XQueryPointer QueryPointer;
580         PFN_XRaiseWindow RaiseWindow;
581         PFN_XRegisterIMInstantiateCallback RegisterIMInstantiateCallback;
582         PFN_XResizeWindow ResizeWindow;
583         PFN_XResourceManagerString ResourceManagerString;
584         PFN_XSaveContext SaveContext;
585         PFN_XSelectInput SelectInput;
586         PFN_XSendEvent SendEvent;
587         PFN_XSetClassHint SetClassHint;
588         PFN_XSetErrorHandler SetErrorHandler;
589         PFN_XSetICFocus SetICFocus;
590         PFN_XSetIMValues SetIMValues;
591         PFN_XSetInputFocus SetInputFocus;
592         PFN_XSetLocaleModifiers SetLocaleModifiers;
593         PFN_XSetScreenSaver SetScreenSaver;
594         PFN_XSetSelectionOwner SetSelectionOwner;
595         PFN_XSetWMHints SetWMHints;
596         PFN_XSetWMNormalHints SetWMNormalHints;
597         PFN_XSetWMProtocols SetWMProtocols;
598         PFN_XSupportsLocale SupportsLocale;
599         PFN_XSync Sync;
600         PFN_XTranslateCoordinates TranslateCoordinates;
601         PFN_XUndefineCursor UndefineCursor;
602         PFN_XUngrabPointer UngrabPointer;
603         PFN_XUnmapWindow UnmapWindow;
604         PFN_XUnsetICFocus UnsetICFocus;
605         PFN_XVisualIDFromVisual VisualIDFromVisual;
606         PFN_XWarpPointer WarpPointer;
607         PFN_XUnregisterIMInstantiateCallback UnregisterIMInstantiateCallback;
608         PFN_Xutf8LookupString utf8LookupString;
609         PFN_Xutf8SetWMProperties utf8SetWMProperties;
610     } xlib;
611
612     struct {
613         PFN_XrmDestroyDatabase DestroyDatabase;
614         PFN_XrmGetResource GetResource;
615         PFN_XrmGetStringDatabase GetStringDatabase;
616         PFN_XrmInitialize Initialize;
617         PFN_XrmUniqueQuark UniqueQuark;
618     } xrm;
619
620     struct {
621         GLFWbool    available;
622         void*       handle;
623         int         eventBase;
624         int         errorBase;
625         int         major;
626         int         minor;
627         GLFWbool    gammaBroken;
628         GLFWbool    monitorBroken;
629         PFN_XRRAllocGamma AllocGamma;
630         PFN_XRRFreeCrtcInfo FreeCrtcInfo;
631         PFN_XRRFreeGamma FreeGamma;
632         PFN_XRRFreeOutputInfo FreeOutputInfo;
633         PFN_XRRFreeScreenResources FreeScreenResources;
634         PFN_XRRGetCrtcGamma GetCrtcGamma;
635         PFN_XRRGetCrtcGammaSize GetCrtcGammaSize;
636         PFN_XRRGetCrtcInfo GetCrtcInfo;
637         PFN_XRRGetOutputInfo GetOutputInfo;
638         PFN_XRRGetOutputPrimary GetOutputPrimary;
639         PFN_XRRGetScreenResourcesCurrent GetScreenResourcesCurrent;
640         PFN_XRRQueryExtension QueryExtension;
641         PFN_XRRQueryVersion QueryVersion;
642         PFN_XRRSelectInput SelectInput;
643         PFN_XRRSetCrtcConfig SetCrtcConfig;
644         PFN_XRRSetCrtcGamma SetCrtcGamma;
645         PFN_XRRUpdateConfiguration UpdateConfiguration;
646     } randr;
647
648     struct {
649         GLFWbool     available;
650         GLFWbool     detectable;
651         int          majorOpcode;
652         int          eventBase;
653         int          errorBase;
654         int          major;
655         int          minor;
656         unsigned int group;
657         PFN_XkbFreeKeyboard FreeKeyboard;
658         PFN_XkbFreeNames FreeNames;
659         PFN_XkbGetMap GetMap;
660         PFN_XkbGetNames GetNames;
661         PFN_XkbGetState GetState;
662         PFN_XkbKeycodeToKeysym KeycodeToKeysym;
663         PFN_XkbQueryExtension QueryExtension;
664         PFN_XkbSelectEventDetails SelectEventDetails;
665         PFN_XkbSetDetectableAutoRepeat SetDetectableAutoRepeat;
666     } xkb;
667
668     struct {
669         int         count;
670         int         timeout;
671         int         interval;
672         int         blanking;
673         int         exposure;
674     } saver;
675
676     struct {
677         int         version;
678         Window      source;
679         Atom        format;
680     } xdnd;
681
682     struct {
683         void*       handle;
684         PFN_XcursorImageCreate ImageCreate;
685         PFN_XcursorImageDestroy ImageDestroy;
686         PFN_XcursorImageLoadCursor ImageLoadCursor;
687         PFN_XcursorGetTheme GetTheme;
688         PFN_XcursorGetDefaultSize GetDefaultSize;
689         PFN_XcursorLibraryLoadImage LibraryLoadImage;
690     } xcursor;
691
692     struct {
693         GLFWbool    available;
694         void*       handle;
695         int         major;
696         int         minor;
697         PFN_XineramaIsActive IsActive;
698         PFN_XineramaQueryExtension QueryExtension;
699         PFN_XineramaQueryScreens QueryScreens;
700     } xinerama;
701
702     struct {
703         void*       handle;
704         PFN_XGetXCBConnection GetXCBConnection;
705     } x11xcb;
706
707     struct {
708         GLFWbool    available;
709         void*       handle;
710         int         eventBase;
711         int         errorBase;
712         PFN_XF86VidModeQueryExtension QueryExtension;
713         PFN_XF86VidModeGetGammaRamp GetGammaRamp;
714         PFN_XF86VidModeSetGammaRamp SetGammaRamp;
715         PFN_XF86VidModeGetGammaRampSize GetGammaRampSize;
716     } vidmode;
717
718     struct {
719         GLFWbool    available;
720         void*       handle;
721         int         majorOpcode;
722         int         eventBase;
723         int         errorBase;
724         int         major;
725         int         minor;
726         PFN_XIQueryVersion QueryVersion;
727         PFN_XISelectEvents SelectEvents;
728     } xi;
729
730     struct {
731         GLFWbool    available;
732         void*       handle;
733         int         major;
734         int         minor;
735         int         eventBase;
736         int         errorBase;
737         PFN_XRenderQueryExtension QueryExtension;
738         PFN_XRenderQueryVersion QueryVersion;
739         PFN_XRenderFindVisualFormat FindVisualFormat;
740     } xrender;
741
742     struct {
743         GLFWbool    available;
744         void*       handle;
745         int         major;
746         int         minor;
747         int         eventBase;
748         int         errorBase;
749         PFN_XShapeQueryExtension QueryExtension;
750         PFN_XShapeCombineRegion ShapeCombineRegion;
751         PFN_XShapeQueryVersion QueryVersion;
752         PFN_XShapeCombineMask ShapeCombineMask;
753     } xshape;
754
755 } _GLFWlibraryX11;
756
757 // X11-specific per-monitor data
758 //
759 typedef struct _GLFWmonitorX11
760 {
761     RROutput        output;
762     RRCrtc          crtc;
763     RRMode          oldMode;
764
765     // Index of corresponding Xinerama screen,
766     // for EWMH full screen window placement
767     int             index;
768
769 } _GLFWmonitorX11;
770
771 // X11-specific per-cursor data
772 //
773 typedef struct _GLFWcursorX11
774 {
775     Cursor handle;
776
777 } _GLFWcursorX11;
778
779
780 void _glfwPollMonitorsX11(void);
781 void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired);
782 void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor);
783
784 Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot);
785
786 unsigned long _glfwGetWindowPropertyX11(Window window,
787                                         Atom property,
788                                         Atom type,
789                                         unsigned char** value);
790 GLFWbool _glfwIsVisualTransparentX11(Visual* visual);
791
792 void _glfwGrabErrorHandlerX11(void);
793 void _glfwReleaseErrorHandlerX11(void);
794 void _glfwInputErrorX11(int error, const char* message);
795
796 void _glfwPushSelectionToManagerX11(void);
797 void _glfwCreateInputContextX11(_GLFWwindow* window);
798