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.

juce_XEmbedComponent.h 3.9KB

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