Audio plugin host https://kx.studio/carla
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.

140 lines
3.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. struct _XDisplay;
  20. namespace juce
  21. {
  22. typedef ::_XDisplay* XDisplay;
  23. typedef unsigned long ATOM_TYPE;
  24. typedef unsigned long WINDOW_TYPE;
  25. //==============================================================================
  26. class XWindowSystem
  27. {
  28. public:
  29. XDisplay displayRef() noexcept;
  30. XDisplay displayUnref() noexcept;
  31. juce_DeclareSingleton (XWindowSystem, false)
  32. private:
  33. XDisplay display;
  34. Atomic<int> displayCount;
  35. XWindowSystem() noexcept;
  36. ~XWindowSystem() noexcept;
  37. void initialiseXDisplay() noexcept;
  38. void destroyXDisplay() noexcept;
  39. };
  40. //==============================================================================
  41. class ScopedXDisplay
  42. {
  43. public:
  44. ScopedXDisplay();
  45. ~ScopedXDisplay();
  46. const XDisplay display;
  47. };
  48. //==============================================================================
  49. /** A handy class that uses XLockDisplay and XUnlockDisplay to lock the X server
  50. using RAII (Only available in Linux!).
  51. */
  52. class ScopedXLock
  53. {
  54. public:
  55. /** Creating a ScopedXLock object locks the X display.
  56. This uses XLockDisplay() to grab the display that Juce is using.
  57. */
  58. ScopedXLock (XDisplay);
  59. /** Deleting a ScopedXLock object unlocks the X display.
  60. This calls XUnlockDisplay() to release the lock.
  61. */
  62. ~ScopedXLock();
  63. private:
  64. // defined in juce_linux_X11.h
  65. XDisplay display;
  66. };
  67. //==============================================================================
  68. struct Atoms
  69. {
  70. Atoms (XDisplay);
  71. enum ProtocolItems
  72. {
  73. TAKE_FOCUS = 0,
  74. DELETE_WINDOW = 1,
  75. PING = 2
  76. };
  77. ATOM_TYPE protocols, protocolList[3], changeState, state, userTime,
  78. activeWin, pid, windowType, windowState,
  79. XdndAware, XdndEnter, XdndLeave, XdndPosition, XdndStatus,
  80. XdndDrop, XdndFinished, XdndSelection, XdndTypeList, XdndActionList,
  81. XdndActionDescription, XdndActionCopy, XdndActionPrivate,
  82. XembedMsgType, XembedInfo,
  83. allowedActions[5],
  84. allowedMimeTypes[4];
  85. static const unsigned long DndVersion;
  86. static ATOM_TYPE getIfExists (XDisplay, const char* name);
  87. static ATOM_TYPE getCreating (XDisplay, const char* name);
  88. static String getName (XDisplay, ATOM_TYPE atom);
  89. static bool isMimeTypeFile (XDisplay, ATOM_TYPE atom);
  90. };
  91. //==============================================================================
  92. struct GetXProperty
  93. {
  94. GetXProperty (XDisplay, WINDOW_TYPE window, ATOM_TYPE atom,
  95. long offset, long length, bool shouldDelete,
  96. ATOM_TYPE requestedType);
  97. ~GetXProperty();
  98. bool success;
  99. unsigned char* data;
  100. unsigned long numItems, bytesLeft;
  101. ATOM_TYPE actualType;
  102. int actualFormat;
  103. };
  104. #undef ATOM_TYPE
  105. } // namespace juce