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.

118 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. /** @internal */
  21. bool juce_handleXEmbedEvent (ComponentPeer*, void*);
  22. /** @internal */
  23. unsigned long juce_getCurrentFocusWindow (ComponentPeer*);
  24. #if JUCE_LINUX || DOXYGEN
  25. //==============================================================================
  26. /**
  27. A Linux-specific class that can embed a foreign X11 widget.
  28. Use this class to embed a foreign X11 widget from other toolkits such as
  29. GTK+ or QT.
  30. There are two ways to initiate the Xembed protocol. Either the client creates
  31. a window and passes this to the host (client initiated) or the host
  32. creates a window in which the client can reparent it's client widget
  33. (host initiated). XEmbedComponent supports both protocol types.
  34. This is how you embed a GTK+ widget: if you are using the client
  35. initiated version of the protocol, then create a new gtk widget with
  36. gtk_plug_new (0). Then query the window id of the plug via gtk_plug_get_id().
  37. Pass this id to the constructor of this class.
  38. If you are using the host initiated version of the protocol, then first create
  39. the XEmbedComponent using the default constructor. Use getHostWindowID to get
  40. the window id of the host, use this to construct your gtk plug via gtk_plug_new.
  41. A similar approach can be used to embed QT widgets via QT's QX11EmbedWidget
  42. class.
  43. Other toolkits or raw X11 widgets should follow the X11 embed protocol:
  44. https://specifications.freedesktop.org/xembed-spec/xembed-spec-latest.html
  45. @tags{GUI}
  46. */
  47. class XEmbedComponent : public Component
  48. {
  49. public:
  50. //==============================================================================
  51. /** Creates a JUCE component wrapping a foreign widget
  52. Use this constructor if you are using the host initiated version
  53. of the XEmbedProtocol. When using this version of the protocol
  54. you must call getHostWindowID() and pass this id to the foreign toolkit.
  55. */
  56. XEmbedComponent (bool wantsKeyboardFocus = true,
  57. bool allowForeignWidgetToResizeComponent = false);
  58. /** Create a JUCE component wrapping the foreign widget with id wID
  59. Use this constructor if you are using the client initiated version
  60. of the XEmbedProtocol.
  61. */
  62. XEmbedComponent (unsigned long wID, bool wantsKeyboardFocus = true,
  63. bool allowForeignWidgetToResizeComponent = false);
  64. /** Destructor. */
  65. ~XEmbedComponent() override;
  66. /** Use this method to retrieve the host's window id when using the
  67. host initiated version of the XEmbedProtocol
  68. */
  69. unsigned long getHostWindowID();
  70. /** Removes the client window from the host. */
  71. void removeClient();
  72. protected:
  73. //==============================================================================
  74. /** @internal */
  75. void paint (Graphics&) override;
  76. void focusGained (FocusChangeType) override;
  77. void focusLost (FocusChangeType) override;
  78. void broughtToFront() override;
  79. private:
  80. friend bool juce::juce_handleXEmbedEvent (ComponentPeer*, void*);
  81. friend unsigned long juce_getCurrentFocusWindow (ComponentPeer*);
  82. class Pimpl;
  83. std::unique_ptr<Pimpl> pimpl;
  84. };
  85. #endif
  86. } // namespace juce