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.

170 lines
4.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. struct _XDisplay;
  14. namespace juce
  15. {
  16. typedef ::_XDisplay* XDisplay;
  17. typedef unsigned long AtomType;
  18. typedef unsigned long WindowType;
  19. //==============================================================================
  20. class XWindowSystem : public DeletedAtShutdown
  21. {
  22. public:
  23. XDisplay displayRef() noexcept;
  24. XDisplay displayUnref() noexcept;
  25. JUCE_DECLARE_SINGLETON (XWindowSystem, false)
  26. private:
  27. XDisplay display = {};
  28. Atomic<int> displayCount;
  29. XWindowSystem() noexcept;
  30. ~XWindowSystem() noexcept;
  31. void initialiseXDisplay() noexcept;
  32. void destroyXDisplay() noexcept;
  33. };
  34. //==============================================================================
  35. /** Creates and holds a reference to the X display.
  36. @tags{GUI}
  37. */
  38. struct ScopedXDisplay
  39. {
  40. ScopedXDisplay();
  41. ~ScopedXDisplay();
  42. const XDisplay display;
  43. };
  44. //==============================================================================
  45. /** A handy class that uses XLockDisplay and XUnlockDisplay to lock the X server
  46. using RAII (Only available in Linux!).
  47. @tags{GUI}
  48. */
  49. class ScopedXLock
  50. {
  51. public:
  52. /** Creating a ScopedXLock object locks the X display.
  53. This uses XLockDisplay() to grab the display that JUCE is using.
  54. */
  55. ScopedXLock (XDisplay);
  56. /** Deleting a ScopedXLock object unlocks the X display.
  57. This calls XUnlockDisplay() to release the lock.
  58. */
  59. ~ScopedXLock();
  60. private:
  61. // defined in juce_linux_X11.h
  62. XDisplay display;
  63. };
  64. //==============================================================================
  65. struct Atoms
  66. {
  67. Atoms (XDisplay);
  68. enum ProtocolItems
  69. {
  70. TAKE_FOCUS = 0,
  71. DELETE_WINDOW = 1,
  72. PING = 2
  73. };
  74. AtomType protocols, protocolList[3], changeState, state, userTime,
  75. activeWin, pid, windowType, windowState,
  76. XdndAware, XdndEnter, XdndLeave, XdndPosition, XdndStatus,
  77. XdndDrop, XdndFinished, XdndSelection, XdndTypeList, XdndActionList,
  78. XdndActionDescription, XdndActionCopy, XdndActionPrivate,
  79. XembedMsgType, XembedInfo,
  80. allowedActions[5],
  81. allowedMimeTypes[4];
  82. static const unsigned long DndVersion;
  83. static AtomType getIfExists (XDisplay, const char* name);
  84. static AtomType getCreating (XDisplay, const char* name);
  85. static String getName (XDisplay, AtomType);
  86. static bool isMimeTypeFile (XDisplay, AtomType);
  87. };
  88. //==============================================================================
  89. struct GetXProperty
  90. {
  91. GetXProperty (XDisplay, WindowType, AtomType,
  92. long offset, long length, bool shouldDelete,
  93. AtomType requestedType);
  94. ~GetXProperty();
  95. bool success;
  96. unsigned char* data = nullptr;
  97. unsigned long numItems, bytesLeft;
  98. AtomType actualType;
  99. int actualFormat;
  100. };
  101. //==============================================================================
  102. enum
  103. {
  104. maxXEmbedVersionToSupport = 0
  105. };
  106. enum
  107. {
  108. XEMBED_MAPPED = (1<<0)
  109. };
  110. enum
  111. {
  112. XEMBED_EMBEDDED_NOTIFY = 0,
  113. XEMBED_WINDOW_ACTIVATE = 1,
  114. XEMBED_WINDOW_DEACTIVATE = 2,
  115. XEMBED_REQUEST_FOCUS = 3,
  116. XEMBED_FOCUS_IN = 4,
  117. XEMBED_FOCUS_OUT = 5,
  118. XEMBED_FOCUS_NEXT = 6,
  119. XEMBED_FOCUS_PREV = 7,
  120. XEMBED_MODALITY_ON = 10,
  121. XEMBED_MODALITY_OFF = 11,
  122. XEMBED_REGISTER_ACCELERATOR = 12,
  123. XEMBED_UNREGISTER_ACCELERATOR = 13,
  124. XEMBED_ACTIVATE_ACCELERATOR = 14
  125. };
  126. enum
  127. {
  128. XEMBED_FOCUS_CURRENT = 0,
  129. XEMBED_FOCUS_FIRST = 1,
  130. XEMBED_FOCUS_LAST = 2
  131. };
  132. } // namespace juce