linux_system.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #pragma once
  2. #include <iron_system.h>
  3. #include <X11/Xatom.h>
  4. #include <X11/Xlib.h>
  5. #include <X11/Xutil.h>
  6. #include <X11/extensions/XInput.h>
  7. #include <X11/extensions/Xrandr.h>
  8. #define MAXIMUM_DISPLAYS 8
  9. struct iron_x11_window {
  10. int display_index;
  11. int width;
  12. int height;
  13. iron_window_mode_t mode;
  14. Window window;
  15. XIM xInputMethod;
  16. XIC xInputContext;
  17. };
  18. struct iron_x11_display {
  19. int index;
  20. int x;
  21. int y;
  22. int width;
  23. int height;
  24. bool primary;
  25. RROutput output;
  26. RRCrtc crtc;
  27. };
  28. struct iron_x11_atoms {
  29. Atom XdndAware;
  30. Atom XdndDrop;
  31. Atom XdndEnter;
  32. Atom XdndTextUriList;
  33. Atom XdndStatus;
  34. Atom XdndActionCopy;
  35. Atom XdndSelection;
  36. Atom CLIPBOARD;
  37. Atom UTF8_STRING;
  38. Atom XSEL_DATA;
  39. Atom TARGETS;
  40. Atom MULTIPLE;
  41. Atom TEXT_PLAIN;
  42. Atom WM_DELETE_WINDOW;
  43. Atom MOTIF_WM_HINTS;
  44. Atom NET_WM_NAME;
  45. Atom NET_WM_ICON_NAME;
  46. Atom NET_WM_STATE;
  47. Atom NET_WM_STATE_FULLSCREEN;
  48. Atom MOUSE;
  49. Atom TABLET;
  50. Atom KEYBOARD;
  51. Atom TOUCHSCREEN;
  52. Atom TOUCHPAD;
  53. Atom BUTTONBOX;
  54. Atom BARCODE;
  55. Atom TRACKBALL;
  56. Atom QUADRATURE;
  57. Atom ID_MODULE;
  58. Atom ONE_KNOB;
  59. Atom NINE_KNOB;
  60. Atom KNOB_BOX;
  61. Atom SPACEBALL;
  62. Atom DATAGLOVE;
  63. Atom EYETRACKER;
  64. Atom CURSORKEYS;
  65. Atom FOOTMOUSE;
  66. Atom JOYSTICK;
  67. };
  68. struct iron_x11_libs {
  69. void *X11;
  70. void *Xcursor;
  71. void *Xi;
  72. void *Xrandr;
  73. };
  74. struct iron_x11_procs {
  75. Display *(*XOpenDisplay)(const char *name);
  76. Status (*XInternAtoms)(Display *display, char **names, int count, Bool only_if_exists, Atom *atoms_return);
  77. int (*XCloseDisplay)(Display *display);
  78. int (*XInitThreads)(void);
  79. XErrorHandler (*XSetErrorHandler)(XErrorHandler handler);
  80. int (*XGetErrorText)(Display *, int, char *, int);
  81. int (*XPending)(Display *display);
  82. int (*XFlush)(Display *display);
  83. int (*XNextEvent)(Display *display, XEvent *event_return);
  84. int (*XPeekEvent)(Display *display, XEvent *event_return);
  85. int (*XRefreshKeyboardMapping)(XMappingEvent *event_map);
  86. int (*XwcLookupString)(XIC, XKeyPressedEvent *, wchar_t *, int, KeySym *, int *);
  87. int (*XFilterEvent)(XEvent *, Window);
  88. int (*XConvertSelection)(Display *, Atom, Atom, Atom, Window, Time);
  89. int (*XSetSelectionOwner)(Display *, Atom, Window, Time);
  90. int (*XLookupString)(XKeyEvent *, char *, int, KeySym *, XComposeStatus *);
  91. KeySym (*XkbKeycodeToKeysym)(Display *, KeyCode, int, int);
  92. int (*XSendEvent)(Display *, Window, int, long, XEvent *);
  93. int (*XGetWindowProperty)(Display *, Window, Atom, long, long, int, Atom, Atom *, int *, unsigned long *, unsigned long *, unsigned char **);
  94. int (*XFree)(void *);
  95. int (*XChangeProperty)(Display *, Window, Atom, Atom, int, int, const unsigned char *, int);
  96. int (*XDefineCursor)(Display *, Window, Cursor);
  97. int (*XUndefineCursor)(Display *, Window);
  98. Pixmap (*XCreateBitmapFromData)(Display *, Drawable, const char *, unsigned int, unsigned int);
  99. Cursor (*XCreatePixmapCursor)(Display *, Pixmap, Pixmap, XColor *, XColor *, unsigned int, unsigned int);
  100. int (*XFreePixmap)(Display *, Pixmap);
  101. Cursor (*XcursorLibraryLoadCursor)(Display *, const char *);
  102. int (*XWarpPointer)(Display *, Window, Window, int, int, unsigned int, unsigned int, int, int);
  103. int (*XQueryPointer)(Display *, Window, Window *, Window *, int *, int *, int *, int *, unsigned int *);
  104. Colormap (*XCreateColormap)(Display *, Window, Visual *, int);
  105. Window (*XCreateWindow)(Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, int depth,
  106. unsigned int class, Visual *visual, unsigned long valuemask, XSetWindowAttributes *attributes);
  107. int (*XMoveWindow)(Display *, Window, int, int);
  108. int (*XResizeWindow)(Display *, Window, unsigned int, unsigned int);
  109. int (*XDestroyWindow)(Display *, Window);
  110. int (*XSetClassHint)(Display *, Window, XClassHint *);
  111. char *(*XSetLocaleModifiers)(const char *);
  112. XIM (*XOpenIM)(Display *, struct _XrmHashBucketRec *, char *, char *);
  113. int (*XCloseIM)(XIM);
  114. XIC (*XCreateIC)(XIM, ...);
  115. void (*XDestroyIC)(XIC);
  116. void (*XSetICFocus)(XIC);
  117. int (*XMapWindow)(Display *, Window);
  118. int (*XUnmapWindow)(Display *, Window);
  119. int (*XSetWMProtocols)(Display *, Window, Atom *, int);
  120. int (*XAllocColor)(Display *, Colormap, XColor *);
  121. XDeviceInfo *(*XListInputDevices)(Display *, int *);
  122. void (*XFreeDeviceList)(XDeviceInfo *);
  123. XDevice *(*XOpenDevice)(Display *display, XID device_id);
  124. int (*XCloseDevice)(Display *display, XDevice *device);
  125. int (*XSelectExtensionEvent)(Display *, Window, XEventClass *, int);
  126. XRRScreenResources *(*XRRGetScreenResourcesCurrent)(Display *dpy, Window window);
  127. RROutput (*XRRGetOutputPrimary)(Display *dpy, Window window);
  128. XRROutputInfo *(*XRRGetOutputInfo)(Display *dpy, XRRScreenResources *resources, RROutput output);
  129. void (*XRRFreeOutputInfo)(XRROutputInfo *outputInfo);
  130. XRRCrtcInfo *(*XRRGetCrtcInfo)(Display *dpy, XRRScreenResources *resources, RRCrtc crtc);
  131. void (*XRRFreeCrtcInfo)(XRRCrtcInfo *crtcInfo);
  132. void (*XRRFreeScreenResources)(XRRScreenResources *resources);
  133. };
  134. struct x11_pen_device {
  135. XID id;
  136. uint32_t motionEvent;
  137. XEventClass motionClass;
  138. uint32_t maxPressure;
  139. float current_pressure;
  140. void (*press)(int /*x*/, int /*y*/, float /*pressure*/);
  141. void (*move)(int /*x*/, int /*y*/, float /*pressure*/);
  142. void (*release)(int /*x*/, int /*y*/, float /*pressure*/);
  143. };
  144. struct x11_context {
  145. Display *display;
  146. struct iron_x11_libs libs;
  147. struct iron_x11_atoms atoms;
  148. struct x11_pen_device pen;
  149. struct x11_pen_device eraser;
  150. struct iron_x11_window windows[1];
  151. int num_displays;
  152. struct iron_x11_display displays[MAXIMUM_DISPLAYS];
  153. };
  154. struct iron_x11_procs xlib;
  155. struct x11_context x11_ctx;
  156. #ifdef WITH_GAMEPAD
  157. void iron_linux_initHIDGamepads();
  158. void iron_linux_updateHIDGamepads();
  159. void iron_linux_closeHIDGamepads();
  160. #endif