linux_system.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. XErrorHandler (*XSetErrorHandler)(XErrorHandler handler);
  79. int (*XGetErrorText)(Display *, int, char *, int);
  80. int (*XPending)(Display *display);
  81. int (*XFlush)(Display *display);
  82. int (*XNextEvent)(Display *display, XEvent *event_return);
  83. int (*XPeekEvent)(Display *display, XEvent *event_return);
  84. int (*XRefreshKeyboardMapping)(XMappingEvent *event_map);
  85. int (*XwcLookupString)(XIC, XKeyPressedEvent *, wchar_t *, int, KeySym *, int *);
  86. int (*XFilterEvent)(XEvent *, Window);
  87. int (*XConvertSelection)(Display *, Atom, Atom, Atom, Window, Time);
  88. int (*XSetSelectionOwner)(Display *, Atom, Window, Time);
  89. int (*XLookupString)(XKeyEvent *, char *, int, KeySym *, XComposeStatus *);
  90. KeySym (*XkbKeycodeToKeysym)(Display *, KeyCode, int, int);
  91. int (*XSendEvent)(Display *, Window, int, long, XEvent *);
  92. int (*XGetWindowProperty)(Display *, Window, Atom, long, long, int, Atom, Atom *, int *, unsigned long *, unsigned long *, unsigned char **);
  93. int (*XFree)(void *);
  94. int (*XChangeProperty)(Display *, Window, Atom, Atom, int, int, const unsigned char *, int);
  95. int (*XDefineCursor)(Display *, Window, Cursor);
  96. int (*XUndefineCursor)(Display *, Window);
  97. Pixmap (*XCreateBitmapFromData)(Display *, Drawable, const char *, unsigned int, unsigned int);
  98. Cursor (*XCreatePixmapCursor)(Display *, Pixmap, Pixmap, XColor *, XColor *, unsigned int, unsigned int);
  99. int (*XFreePixmap)(Display *, Pixmap);
  100. Cursor (*XcursorLibraryLoadCursor)(Display *, const char *);
  101. int (*XWarpPointer)(Display *, Window, Window, int, int, unsigned int, unsigned int, int, int);
  102. int (*XQueryPointer)(Display *, Window, Window *, Window *, int *, int *, int *, int *, unsigned int *);
  103. Colormap (*XCreateColormap)(Display *, Window, Visual *, int);
  104. Window (*XCreateWindow)(Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, int depth,
  105. unsigned int class, Visual *visual, unsigned long valuemask, XSetWindowAttributes *attributes);
  106. int (*XMoveWindow)(Display *, Window, int, int);
  107. int (*XResizeWindow)(Display *, Window, unsigned int, unsigned int);
  108. int (*XDestroyWindow)(Display *, Window);
  109. int (*XSetClassHint)(Display *, Window, XClassHint *);
  110. char *(*XSetLocaleModifiers)(const char *);
  111. XIM (*XOpenIM)(Display *, struct _XrmHashBucketRec *, char *, char *);
  112. int (*XCloseIM)(XIM);
  113. XIC (*XCreateIC)(XIM, ...);
  114. void (*XDestroyIC)(XIC);
  115. void (*XSetICFocus)(XIC);
  116. int (*XMapWindow)(Display *, Window);
  117. int (*XUnmapWindow)(Display *, Window);
  118. int (*XSetWMProtocols)(Display *, Window, Atom *, int);
  119. int (*XAllocColor)(Display *, Colormap, XColor *);
  120. XDeviceInfo *(*XListInputDevices)(Display *, int *);
  121. void (*XFreeDeviceList)(XDeviceInfo *);
  122. XDevice *(*XOpenDevice)(Display *display, XID device_id);
  123. int (*XCloseDevice)(Display *display, XDevice *device);
  124. int (*XSelectExtensionEvent)(Display *, Window, XEventClass *, int);
  125. XRRScreenResources *(*XRRGetScreenResourcesCurrent)(Display *dpy, Window window);
  126. RROutput (*XRRGetOutputPrimary)(Display *dpy, Window window);
  127. XRROutputInfo *(*XRRGetOutputInfo)(Display *dpy, XRRScreenResources *resources, RROutput output);
  128. void (*XRRFreeOutputInfo)(XRROutputInfo *outputInfo);
  129. XRRCrtcInfo *(*XRRGetCrtcInfo)(Display *dpy, XRRScreenResources *resources, RRCrtc crtc);
  130. void (*XRRFreeCrtcInfo)(XRRCrtcInfo *crtcInfo);
  131. void (*XRRFreeScreenResources)(XRRScreenResources *resources);
  132. };
  133. struct x11_pen_device {
  134. XID id;
  135. uint32_t motionEvent;
  136. XEventClass motionClass;
  137. uint32_t maxPressure;
  138. float current_pressure;
  139. void (*press)(int /*x*/, int /*y*/, float /*pressure*/);
  140. void (*move)(int /*x*/, int /*y*/, float /*pressure*/);
  141. void (*release)(int /*x*/, int /*y*/, float /*pressure*/);
  142. };
  143. struct x11_context {
  144. Display *display;
  145. struct iron_x11_libs libs;
  146. struct iron_x11_atoms atoms;
  147. struct x11_pen_device pen;
  148. struct x11_pen_device eraser;
  149. struct iron_x11_window windows[1];
  150. int num_displays;
  151. struct iron_x11_display displays[MAXIMUM_DISPLAYS];
  152. };
  153. struct iron_x11_procs xlib;
  154. struct x11_context x11_ctx;
  155. #ifdef WITH_GAMEPAD
  156. void iron_linux_initHIDGamepads();
  157. void iron_linux_updateHIDGamepads();
  158. void iron_linux_closeHIDGamepads();
  159. #endif