The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.0KB

  1. #ifndef JUCE_XWINDOWSYSTEM_H_INCLUDED
  2. #define JUCE_XWINDOWSYSTEM_H_INCLUDED
  3. // Hack to forward declare _XDisplay outside the
  4. // juce namespace
  5. }
  6. struct _XDisplay;
  7. #define ATOM_TYPE unsigned long
  8. #define WINDOW_TYPE unsigned long
  9. namespace juce {
  10. //==============================================================================
  11. class XWindowSystem
  12. {
  13. public:
  14. ::_XDisplay* displayRef() noexcept;
  15. ::_XDisplay* displayUnref() noexcept;
  16. juce_DeclareSingleton (XWindowSystem, false)
  17. private:
  18. ::_XDisplay* display;
  19. Atomic<int> displayCount;
  20. XWindowSystem() noexcept;
  21. ~XWindowSystem() noexcept;
  22. void initialiseXDisplay() noexcept;
  23. void destroyXDisplay() noexcept;
  24. };
  25. //==============================================================================
  26. class ScopedXDisplay
  27. {
  28. public:
  29. ScopedXDisplay();
  30. ~ScopedXDisplay();
  31. ::_XDisplay* get();
  32. private:
  33. ::_XDisplay* display;
  34. };
  35. /** A handy class that uses XLockDisplay and XUnlockDisplay to lock the X server
  36. using RAII (Only available in Linux!).
  37. */
  38. class ScopedXLock
  39. {
  40. public:
  41. /** Creating a ScopedXLock object locks the X display.
  42. This uses XLockDisplay() to grab the display that Juce is using.
  43. */
  44. ScopedXLock (::_XDisplay* _display);
  45. /** Deleting a ScopedXLock object unlocks the X display.
  46. This calls XUnlockDisplay() to release the lock.
  47. */
  48. ~ScopedXLock();
  49. private:
  50. // defined in juce_linux_X11.h
  51. ::_XDisplay* display;
  52. };
  53. //==============================================================================
  54. struct Atoms
  55. {
  56. Atoms(::_XDisplay* display);
  57. enum ProtocolItems
  58. {
  59. TAKE_FOCUS = 0,
  60. DELETE_WINDOW = 1,
  61. PING = 2
  62. };
  63. ATOM_TYPE protocols, protocolList[3], changeState, state, userTime,
  64. activeWin, pid, windowType, windowState,
  65. XdndAware, XdndEnter, XdndLeave, XdndPosition, XdndStatus,
  66. XdndDrop, XdndFinished, XdndSelection, XdndTypeList, XdndActionList,
  67. XdndActionDescription, XdndActionCopy, XdndActionPrivate,
  68. allowedActions[5],
  69. allowedMimeTypes[4];
  70. static const unsigned long DndVersion;
  71. static ATOM_TYPE getIfExists (::_XDisplay* display, const char* name);
  72. static ATOM_TYPE getCreating (::_XDisplay* display, const char* name);
  73. static String getName (::_XDisplay* display, const ATOM_TYPE atom);
  74. static bool isMimeTypeFile (::_XDisplay* display, const ATOM_TYPE atom);
  75. };
  76. //==============================================================================
  77. struct GetXProperty
  78. {
  79. GetXProperty (::_XDisplay* display, WINDOW_TYPE window, ATOM_TYPE atom,
  80. long offset, long length, bool shouldDelete,
  81. ATOM_TYPE requestedType);
  82. ~GetXProperty();
  83. bool success;
  84. unsigned char* data;
  85. unsigned long numItems, bytesLeft;
  86. ATOM_TYPE actualType;
  87. int actualFormat;
  88. };
  89. #undef ATOM_TYPE
  90. #endif // JUCE_XWINDOWSYSTEM_H_INCLUDED