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