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.

143 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 AtomType;
  24. typedef unsigned long WindowType;
  25. //==============================================================================
  26. class XWindowSystem : public DeletedAtShutdown
  27. {
  28. public:
  29. XDisplay displayRef() noexcept;
  30. XDisplay displayUnref() noexcept;
  31. JUCE_DECLARE_SINGLETON (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. /** Creates and holds a reference to the X display.
  42. @tags{GUI}
  43. */
  44. struct ScopedXDisplay
  45. {
  46. ScopedXDisplay();
  47. ~ScopedXDisplay();
  48. const XDisplay display;
  49. };
  50. //==============================================================================
  51. /** A handy class that uses XLockDisplay and XUnlockDisplay to lock the X server
  52. using RAII (Only available in Linux!).
  53. @tags{GUI}
  54. */
  55. class ScopedXLock
  56. {
  57. public:
  58. /** Creating a ScopedXLock object locks the X display.
  59. This uses XLockDisplay() to grab the display that JUCE is using.
  60. */
  61. ScopedXLock (XDisplay);
  62. /** Deleting a ScopedXLock object unlocks the X display.
  63. This calls XUnlockDisplay() to release the lock.
  64. */
  65. ~ScopedXLock();
  66. private:
  67. // defined in juce_linux_X11.h
  68. XDisplay display;
  69. };
  70. //==============================================================================
  71. struct Atoms
  72. {
  73. Atoms (XDisplay);
  74. enum ProtocolItems
  75. {
  76. TAKE_FOCUS = 0,
  77. DELETE_WINDOW = 1,
  78. PING = 2
  79. };
  80. AtomType protocols, protocolList[3], changeState, state, userTime,
  81. activeWin, pid, windowType, windowState,
  82. XdndAware, XdndEnter, XdndLeave, XdndPosition, XdndStatus,
  83. XdndDrop, XdndFinished, XdndSelection, XdndTypeList, XdndActionList,
  84. XdndActionDescription, XdndActionCopy, XdndActionPrivate,
  85. XembedMsgType, XembedInfo,
  86. allowedActions[5],
  87. allowedMimeTypes[4];
  88. static const unsigned long DndVersion;
  89. static AtomType getIfExists (XDisplay, const char* name);
  90. static AtomType getCreating (XDisplay, const char* name);
  91. static String getName (XDisplay, AtomType);
  92. static bool isMimeTypeFile (XDisplay, AtomType);
  93. };
  94. //==============================================================================
  95. struct GetXProperty
  96. {
  97. GetXProperty (XDisplay, WindowType, AtomType,
  98. long offset, long length, bool shouldDelete,
  99. AtomType requestedType);
  100. ~GetXProperty();
  101. bool success;
  102. unsigned char* data = nullptr;
  103. unsigned long numItems, bytesLeft;
  104. AtomType actualType;
  105. int actualFormat;
  106. };
  107. } // namespace juce