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.

115 lines
4.1KB

  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. namespace juce
  20. {
  21. /** @internal */
  22. bool juce_handleXEmbedEvent (ComponentPeer*, void*);
  23. /** @internal */
  24. unsigned long juce_getCurrentFocusWindow (ComponentPeer*);
  25. #if JUCE_LINUX || DOXYGEN
  26. //==============================================================================
  27. /**
  28. A Linux-specific class that can embed a foreign X11 widget.
  29. Use this class to embed a foreign X11 widget from other toolkits such as
  30. GTK+ or QT.
  31. There are two ways to initiate the Xembed protocol. Either the client creates
  32. a window and passes this to the host (client initiated) or the host
  33. creates a window in which the client can reparent it's client widget
  34. (host initiated). XEmbedComponent supports both protocol types.
  35. This is how you embed a GTK+ widget: if you are using the client
  36. initiated version of the protocol, then create a new gtk widget with
  37. gtk_plug_new (0). Then query the window id of the plug via gtk_plug_get_id().
  38. Pass this id to the constructor of this class.
  39. If you are using the host initiated version of the protocol, then first create
  40. the XEmbedComponent using the default constructor. Use getHostWindowID to get
  41. the window id of the host, use this to construct your gtk plug via gtk_plug_new.
  42. A similar approach can be used to embed QT widgets via QT's QX11EmbedWidget
  43. class.
  44. Other toolkits or raw X11 widgets should follow the X11 embed protocol:
  45. https://specifications.freedesktop.org/xembed-spec/xembed-spec-latest.html
  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();
  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. protected:
  71. //==============================================================================
  72. /** @internal */
  73. void paint (Graphics&) override;
  74. void focusGained (FocusChangeType) override;
  75. void focusLost (FocusChangeType) override;
  76. void broughtToFront() override;
  77. private:
  78. friend bool juce::juce_handleXEmbedEvent (ComponentPeer*, void*);
  79. friend unsigned long juce_getCurrentFocusWindow (ComponentPeer*);
  80. class Pimpl;
  81. friend struct ContainerDeletePolicy<Pimpl>;
  82. ScopedPointer<Pimpl> pimpl;
  83. };
  84. #endif
  85. } // namespace juce