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.

763 lines
26KB

  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. //==============================================================================
  20. bool juce_handleXEmbedEvent (ComponentPeer*, void*);
  21. Window juce_getCurrentFocusWindow (ComponentPeer*);
  22. //==============================================================================
  23. unsigned long juce_createKeyProxyWindow (ComponentPeer*);
  24. void juce_deleteKeyProxyWindow (ComponentPeer*);
  25. //==============================================================================
  26. class XEmbedComponent::Pimpl : private ComponentListener
  27. {
  28. public:
  29. //==============================================================================
  30. enum
  31. {
  32. maxXEmbedVersionToSupport = 0
  33. };
  34. enum Flags
  35. {
  36. XEMBED_MAPPED = (1<<0)
  37. };
  38. enum
  39. {
  40. XEMBED_EMBEDDED_NOTIFY = 0,
  41. XEMBED_WINDOW_ACTIVATE = 1,
  42. XEMBED_WINDOW_DEACTIVATE = 2,
  43. XEMBED_REQUEST_FOCUS = 3,
  44. XEMBED_FOCUS_IN = 4,
  45. XEMBED_FOCUS_OUT = 5,
  46. XEMBED_FOCUS_NEXT = 6,
  47. XEMBED_FOCUS_PREV = 7,
  48. XEMBED_MODALITY_ON = 10,
  49. XEMBED_MODALITY_OFF = 11,
  50. XEMBED_REGISTER_ACCELERATOR = 12,
  51. XEMBED_UNREGISTER_ACCELERATOR = 13,
  52. XEMBED_ACTIVATE_ACCELERATOR = 14
  53. };
  54. enum
  55. {
  56. XEMBED_FOCUS_CURRENT = 0,
  57. XEMBED_FOCUS_FIRST = 1,
  58. XEMBED_FOCUS_LAST = 2
  59. };
  60. //==============================================================================
  61. class SharedKeyWindow
  62. {
  63. public:
  64. //==============================================================================
  65. class Ref
  66. {
  67. public:
  68. Ref() : keyWindow (nullptr) {}
  69. Ref (Pimpl& p) { keyWindow = getKeyWindowForPeer (p.owner.getPeer()); }
  70. ~Ref() { free(); }
  71. //==============================================================================
  72. Ref (const Ref& o) : keyWindow (o.keyWindow) { if (keyWindow != nullptr) keyWindow->numRefs++; }
  73. Ref (Ref && o) : keyWindow (o.keyWindow) { o.keyWindow = nullptr; }
  74. Ref (std::nullptr_t) : keyWindow (nullptr) {}
  75. //==============================================================================
  76. Ref& operator= (std::nullptr_t) { free(); return *this; }
  77. Ref& operator= (const Ref& o)
  78. {
  79. free();
  80. keyWindow = o.keyWindow;
  81. if (keyWindow != nullptr)
  82. keyWindow->numRefs++;
  83. return *this;
  84. }
  85. Ref& operator= (Ref && o)
  86. {
  87. if (keyWindow != o.keyWindow)
  88. {
  89. free();
  90. keyWindow = o.keyWindow;
  91. }
  92. o.keyWindow = nullptr;
  93. return *this;
  94. }
  95. //==============================================================================
  96. SharedKeyWindow& operator*() noexcept { return *keyWindow; }
  97. SharedKeyWindow* operator->() noexcept { return keyWindow; }
  98. //==============================================================================
  99. bool operator== (std::nullptr_t) const noexcept { return (keyWindow == nullptr); }
  100. bool operator!= (std::nullptr_t) const noexcept { return (keyWindow != nullptr); }
  101. private:
  102. //==============================================================================
  103. void free()
  104. {
  105. if (keyWindow != nullptr)
  106. {
  107. if (--keyWindow->numRefs == 0)
  108. delete keyWindow;
  109. keyWindow = nullptr;
  110. }
  111. }
  112. SharedKeyWindow* keyWindow;
  113. };
  114. public:
  115. //==============================================================================
  116. Window getHandle() { return keyProxy; }
  117. static Window getCurrentFocusWindow (ComponentPeer* peerToLookFor)
  118. {
  119. if (keyWindows != nullptr && peerToLookFor != nullptr)
  120. {
  121. SharedKeyWindow* foundKeyWindow = (*keyWindows)[peerToLookFor];
  122. if (foundKeyWindow != nullptr)
  123. return foundKeyWindow->keyProxy;
  124. }
  125. return (Window)0;
  126. }
  127. private:
  128. //==============================================================================
  129. SharedKeyWindow (ComponentPeer* peerToUse)
  130. : keyPeer (peerToUse),
  131. keyProxy (juce_createKeyProxyWindow (keyPeer)),
  132. numRefs (1)
  133. {}
  134. ~SharedKeyWindow()
  135. {
  136. juce_deleteKeyProxyWindow (keyPeer);
  137. if (keyWindows != nullptr)
  138. {
  139. keyWindows->remove (keyPeer);
  140. if (keyWindows->size() == 0)
  141. {
  142. delete keyWindows;
  143. keyWindows = nullptr;
  144. }
  145. }
  146. }
  147. ComponentPeer* keyPeer;
  148. Window keyProxy;
  149. int numRefs;
  150. static SharedKeyWindow* getKeyWindowForPeer (ComponentPeer* peerToLookFor)
  151. {
  152. jassert (peerToLookFor != nullptr);
  153. if (keyWindows == nullptr)
  154. keyWindows = new HashMap<ComponentPeer*,SharedKeyWindow*>;
  155. SharedKeyWindow* foundKeyWindow = (*keyWindows)[peerToLookFor];
  156. if (foundKeyWindow == nullptr)
  157. {
  158. foundKeyWindow = new SharedKeyWindow (peerToLookFor);
  159. keyWindows->set (peerToLookFor, foundKeyWindow);
  160. }
  161. return foundKeyWindow;
  162. }
  163. //==============================================================================
  164. friend class Ref;
  165. static HashMap<ComponentPeer*,SharedKeyWindow*>* keyWindows;
  166. };
  167. public:
  168. //==============================================================================
  169. Pimpl (XEmbedComponent& parent, Window x11Window,
  170. bool wantsKeyboardFocus, bool isClientInitiated, bool shouldAllowResize)
  171. : owner (parent), atoms (x11display.get()), clientInitiated (isClientInitiated),
  172. wantsFocus (wantsKeyboardFocus), allowResize (shouldAllowResize)
  173. {
  174. if (widgets == nullptr)
  175. widgets = new Array<Pimpl*>;
  176. widgets->add (this);
  177. createHostWindow();
  178. if (clientInitiated)
  179. setClient (x11Window, true);
  180. owner.setWantsKeyboardFocus (wantsFocus);
  181. owner.addComponentListener (this);
  182. }
  183. ~Pimpl()
  184. {
  185. owner.removeComponentListener (this);
  186. setClient (0, true);
  187. if (host != 0)
  188. {
  189. Display* dpy = getDisplay();
  190. XDestroyWindow (dpy, host);
  191. XSync (dpy, false);
  192. const long mask = NoEventMask | KeyPressMask | KeyReleaseMask
  193. | EnterWindowMask | LeaveWindowMask | PointerMotionMask
  194. | KeymapStateMask | ExposureMask | StructureNotifyMask
  195. | FocusChangeMask;
  196. XEvent event;
  197. while (XCheckWindowEvent (dpy, host, mask, &event) == True)
  198. {}
  199. host = 0;
  200. }
  201. if (widgets != nullptr)
  202. {
  203. widgets->removeAllInstancesOf (this);
  204. if (widgets->size() == 0)
  205. {
  206. delete widgets;
  207. widgets = nullptr;
  208. }
  209. }
  210. }
  211. //==============================================================================
  212. void setClient (Window xembedClient, bool shouldReparent)
  213. {
  214. removeClient();
  215. if (xembedClient != 0)
  216. {
  217. Display* dpy = getDisplay();
  218. client = xembedClient;
  219. // if the client has initiated the component then keep the clients size
  220. // otherwise the client should use the host's window' size
  221. if (clientInitiated)
  222. {
  223. configureNotify();
  224. }
  225. else
  226. {
  227. Rectangle<int> newBounds = getX11BoundsFromJuce();
  228. XResizeWindow (dpy, client, static_cast<unsigned int> (newBounds.getWidth()),
  229. static_cast<unsigned int> (newBounds.getHeight()));
  230. }
  231. XSelectInput (dpy, client, StructureNotifyMask | PropertyChangeMask | FocusChangeMask);
  232. getXEmbedMappedFlag();
  233. if (shouldReparent)
  234. XReparentWindow (dpy, client, host, 0, 0);
  235. if (supportsXembed)
  236. sendXEmbedEvent (CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0, (long) host, xembedVersion);
  237. updateMapping();
  238. }
  239. }
  240. void focusGained (FocusChangeType changeType)
  241. {
  242. if (client != 0 && supportsXembed && wantsFocus)
  243. {
  244. updateKeyFocus();
  245. sendXEmbedEvent (CurrentTime, XEMBED_FOCUS_IN,
  246. (changeType == focusChangedByTabKey ? XEMBED_FOCUS_FIRST : XEMBED_FOCUS_CURRENT));
  247. }
  248. }
  249. void focusLost (FocusChangeType)
  250. {
  251. if (client != 0 && supportsXembed && wantsFocus)
  252. {
  253. sendXEmbedEvent (CurrentTime, XEMBED_FOCUS_OUT);
  254. updateKeyFocus();
  255. }
  256. }
  257. void broughtToFront()
  258. {
  259. if (client != 0 && supportsXembed)
  260. sendXEmbedEvent (CurrentTime, XEMBED_WINDOW_ACTIVATE);
  261. }
  262. unsigned long getHostWindowID()
  263. {
  264. // You are using the client initiated version of the protocol. You cannot
  265. // retrieve the window id of the host. Please read the documentation for
  266. // the XEmebedComponent class.
  267. jassert (! clientInitiated);
  268. return host;
  269. }
  270. private:
  271. //==============================================================================
  272. XEmbedComponent& owner;
  273. Window client = 0, host = 0;
  274. ScopedXDisplay x11display;
  275. Atoms atoms;
  276. bool clientInitiated;
  277. bool wantsFocus = false;
  278. bool allowResize = false;
  279. bool supportsXembed = false;
  280. bool hasBeenMapped = false;
  281. int xembedVersion = maxXEmbedVersionToSupport;
  282. ComponentPeer* lastPeer = nullptr;
  283. SharedKeyWindow::Ref keyWindow;
  284. //==============================================================================
  285. void componentParentHierarchyChanged (Component&) override { peerChanged (owner.getPeer()); }
  286. void componentMovedOrResized (Component&, bool, bool) override
  287. {
  288. if (host != 0 && lastPeer != nullptr)
  289. {
  290. Display* dpy = getDisplay();
  291. Rectangle<int> newBounds = getX11BoundsFromJuce();
  292. XWindowAttributes attr;
  293. if (XGetWindowAttributes (dpy, host, &attr))
  294. {
  295. Rectangle<int> currentBounds (attr.x, attr.y, attr.width, attr.height);
  296. if (currentBounds != newBounds)
  297. {
  298. XMoveResizeWindow (dpy, host, newBounds.getX(), newBounds.getY(),
  299. static_cast<unsigned int> (newBounds.getWidth()),
  300. static_cast<unsigned int> (newBounds.getHeight()));
  301. }
  302. }
  303. if (client != 0 && XGetWindowAttributes (dpy, client, &attr))
  304. {
  305. Rectangle<int> currentBounds (attr.x, attr.y, attr.width, attr.height);
  306. if ((currentBounds.getWidth() != newBounds.getWidth()
  307. || currentBounds.getHeight() != newBounds.getHeight()))
  308. {
  309. XMoveResizeWindow (dpy, client, 0, 0,
  310. static_cast<unsigned int> (newBounds.getWidth()),
  311. static_cast<unsigned int> (newBounds.getHeight()));
  312. }
  313. }
  314. }
  315. }
  316. //==============================================================================
  317. void createHostWindow()
  318. {
  319. Display* dpy = getDisplay();
  320. int defaultScreen = XDefaultScreen (dpy);
  321. Window root = RootWindow (dpy, defaultScreen);
  322. XSetWindowAttributes swa;
  323. swa.border_pixel = 0;
  324. swa.background_pixmap = None;
  325. swa.override_redirect = True;
  326. swa.event_mask = SubstructureNotifyMask | StructureNotifyMask | FocusChangeMask;
  327. host = XCreateWindow (dpy, root, 0, 0, 1, 1, 0, CopyFromParent,
  328. InputOutput, CopyFromParent,
  329. CWEventMask | CWBorderPixel | CWBackPixmap | CWOverrideRedirect,
  330. &swa);
  331. }
  332. void removeClient()
  333. {
  334. if (client != 0)
  335. {
  336. Display* dpy = getDisplay();
  337. XSelectInput (dpy, client, 0);
  338. keyWindow = nullptr;
  339. int defaultScreen = XDefaultScreen (dpy);
  340. Window root = RootWindow (dpy, defaultScreen);
  341. if (hasBeenMapped)
  342. {
  343. XUnmapWindow (dpy, client);
  344. hasBeenMapped = false;
  345. }
  346. XReparentWindow (dpy, client, root, 0, 0);
  347. client = 0;
  348. }
  349. }
  350. void updateMapping()
  351. {
  352. if (client != 0)
  353. {
  354. const bool shouldBeMapped = getXEmbedMappedFlag();
  355. if (shouldBeMapped != hasBeenMapped)
  356. {
  357. hasBeenMapped = shouldBeMapped;
  358. if (shouldBeMapped)
  359. XMapWindow (getDisplay(), client);
  360. else
  361. XUnmapWindow (getDisplay(), client);
  362. }
  363. }
  364. }
  365. Window getParentX11Window()
  366. {
  367. if (ComponentPeer* peer = owner.getPeer())
  368. return reinterpret_cast<Window> (peer->getNativeHandle());
  369. return 0;
  370. }
  371. Display* getDisplay() { return reinterpret_cast<Display*> (x11display.display); }
  372. //==============================================================================
  373. bool getXEmbedMappedFlag()
  374. {
  375. GetXProperty embedInfo (x11display.get(), client, atoms.XembedInfo, 0, 2, false, atoms.XembedInfo);
  376. if (embedInfo.success && embedInfo.actualFormat == 32
  377. && embedInfo.numItems >= 2 && embedInfo.data != nullptr)
  378. {
  379. long* buffer = (long*) embedInfo.data;
  380. supportsXembed = true;
  381. xembedVersion = jmin ((int) maxXEmbedVersionToSupport, (int) buffer[0]);
  382. return ((buffer[1] & XEMBED_MAPPED) != 0);
  383. }
  384. else
  385. {
  386. supportsXembed = false;
  387. xembedVersion = maxXEmbedVersionToSupport;
  388. }
  389. return true;
  390. }
  391. //==============================================================================
  392. void propertyChanged (const Atom& a)
  393. {
  394. if (a == atoms.XembedInfo)
  395. updateMapping();
  396. }
  397. void configureNotify()
  398. {
  399. XWindowAttributes attr;
  400. Display* dpy = getDisplay();
  401. if (XGetWindowAttributes (dpy, client, &attr))
  402. {
  403. XWindowAttributes hostAttr;
  404. if (XGetWindowAttributes (dpy, host, &hostAttr))
  405. if (attr.width != hostAttr.width || attr.height != hostAttr.height)
  406. XResizeWindow (dpy, host, (unsigned int) attr.width, (unsigned int) attr.height);
  407. // as the client window is not on any screen yet, we need to guess
  408. // on which screen it might appear to get a scaling factor :-(
  409. const Desktop::Displays& displays = Desktop::getInstance().getDisplays();
  410. ComponentPeer* peer = owner.getPeer();
  411. const double scale = (peer != nullptr ? displays.getDisplayContaining (peer->getBounds().getCentre())
  412. : displays.getMainDisplay()).scale;
  413. Point<int> topLeftInPeer
  414. = (peer != nullptr ? peer->getComponent().getLocalPoint (&owner, Point<int> (0, 0))
  415. : owner.getBounds().getTopLeft());
  416. Rectangle<int> newBounds (topLeftInPeer.getX(), topLeftInPeer.getY(),
  417. static_cast<int> (static_cast<double> (attr.width) / scale),
  418. static_cast<int> (static_cast<double> (attr.height) / scale));
  419. if (peer != nullptr)
  420. newBounds = owner.getLocalArea (&peer->getComponent(), newBounds);
  421. jassert (newBounds.getX() == 0 && newBounds.getY() == 0);
  422. if (newBounds != owner.getLocalBounds())
  423. owner.setSize (newBounds.getWidth(), newBounds.getHeight());
  424. }
  425. }
  426. void peerChanged (ComponentPeer* newPeer)
  427. {
  428. if (newPeer != lastPeer)
  429. {
  430. if (lastPeer != nullptr)
  431. keyWindow = nullptr;
  432. Display* dpy = getDisplay();
  433. Window rootWindow = RootWindow (dpy, DefaultScreen (dpy));
  434. Rectangle<int> newBounds = getX11BoundsFromJuce();
  435. if (newPeer == nullptr)
  436. XUnmapWindow (dpy, host);
  437. Window newParent = (newPeer != nullptr ? getParentX11Window() : rootWindow);
  438. XReparentWindow (dpy, host, newParent, newBounds.getX(), newBounds.getY());
  439. lastPeer = newPeer;
  440. if (newPeer != nullptr)
  441. {
  442. if (wantsFocus)
  443. {
  444. keyWindow = SharedKeyWindow::Ref (*this);
  445. updateKeyFocus();
  446. }
  447. componentMovedOrResized (owner, true, true);
  448. XMapWindow (dpy, host);
  449. broughtToFront();
  450. }
  451. }
  452. }
  453. void updateKeyFocus()
  454. {
  455. if (lastPeer != nullptr && lastPeer->isFocused())
  456. XSetInputFocus (getDisplay(), getCurrentFocusWindow (lastPeer), RevertToParent, CurrentTime);
  457. }
  458. //==============================================================================
  459. void handleXembedCmd (const ::Time& /*xTime*/, long opcode, long /*detail*/, long /*data1*/, long /*data2*/)
  460. {
  461. switch (opcode)
  462. {
  463. case XEMBED_REQUEST_FOCUS:
  464. if (wantsFocus)
  465. owner.grabKeyboardFocus();
  466. break;
  467. case XEMBED_FOCUS_NEXT:
  468. if (wantsFocus)
  469. owner.moveKeyboardFocusToSibling (true);
  470. break;
  471. case XEMBED_FOCUS_PREV:
  472. if (wantsFocus)
  473. owner.moveKeyboardFocusToSibling (false);
  474. break;
  475. }
  476. }
  477. bool handleX11Event (const XEvent& e)
  478. {
  479. if (e.xany.window == client && client != 0)
  480. {
  481. switch (e.type)
  482. {
  483. case PropertyNotify:
  484. propertyChanged (e.xproperty.atom);
  485. return true;
  486. case ConfigureNotify:
  487. if (allowResize)
  488. configureNotify();
  489. else
  490. MessageManager::callAsync([this] () {componentMovedOrResized (owner, true, true);});
  491. return true;
  492. }
  493. }
  494. else if (e.xany.window == host && host != 0)
  495. {
  496. switch (e.type)
  497. {
  498. case ReparentNotify:
  499. if (e.xreparent.parent == host && e.xreparent.window != client)
  500. {
  501. setClient (e.xreparent.window, false);
  502. return true;
  503. }
  504. break;
  505. case CreateNotify:
  506. if (e.xcreatewindow.parent != e.xcreatewindow.window && e.xcreatewindow.parent == host && e.xcreatewindow.window != client)
  507. {
  508. setClient (e.xcreatewindow.window, false);
  509. return true;
  510. }
  511. break;
  512. case GravityNotify:
  513. componentMovedOrResized (owner, true, true);
  514. return true;
  515. case ClientMessage:
  516. if (e.xclient.message_type == atoms.XembedMsgType && e.xclient.format == 32)
  517. {
  518. handleXembedCmd ((::Time) e.xclient.data.l[0], e.xclient.data.l[1],
  519. e.xclient.data.l[2], e.xclient.data.l[3],
  520. e.xclient.data.l[4]);
  521. return true;
  522. }
  523. break;
  524. }
  525. }
  526. return false;
  527. }
  528. void sendXEmbedEvent (const ::Time& xTime, long opcode,
  529. long opcodeMinor = 0, long data1 = 0, long data2 = 0)
  530. {
  531. XClientMessageEvent msg;
  532. Display* dpy = getDisplay();
  533. ::memset (&msg, 0, sizeof (XClientMessageEvent));
  534. msg.window = client;
  535. msg.type = ClientMessage;
  536. msg.message_type = atoms.XembedMsgType;
  537. msg.format = 32;
  538. msg.data.l[0] = (long) xTime;
  539. msg.data.l[1] = opcode;
  540. msg.data.l[2] = opcodeMinor;
  541. msg.data.l[3] = data1;
  542. msg.data.l[4] = data2;
  543. XSendEvent (dpy, client, False, NoEventMask, (XEvent*) &msg);
  544. XSync (dpy, False);
  545. }
  546. Rectangle<int> getX11BoundsFromJuce()
  547. {
  548. if (ComponentPeer* peer = owner.getPeer())
  549. {
  550. Rectangle<int> r
  551. = peer->getComponent().getLocalArea (&owner, owner.getLocalBounds());
  552. const double scale
  553. = Desktop::getInstance().getDisplays().getDisplayContaining (peer->localToGlobal (r.getCentre())).scale;
  554. return r * scale;
  555. }
  556. return owner.getLocalBounds();
  557. }
  558. //==============================================================================
  559. friend bool juce::juce_handleXEmbedEvent (ComponentPeer*, void*);
  560. friend unsigned long juce::juce_getCurrentFocusWindow (ComponentPeer*);
  561. static Array<Pimpl*>* widgets;
  562. static bool dispatchX11Event (ComponentPeer* p, const XEvent* eventArg)
  563. {
  564. if (widgets != nullptr)
  565. {
  566. if (eventArg != nullptr)
  567. {
  568. const XEvent& e = *eventArg;
  569. Window w = e.xany.window;
  570. if (w == 0) return false;
  571. for (auto && widget : *widgets)
  572. if (w == widget->host || w == widget->client)
  573. return widget->handleX11Event (e);
  574. }
  575. else
  576. {
  577. for (auto && widget : *widgets)
  578. {
  579. if (widget->owner.getPeer() == p)
  580. widget->peerChanged (nullptr);
  581. }
  582. }
  583. }
  584. return false;
  585. }
  586. static Window getCurrentFocusWindow (ComponentPeer* p)
  587. {
  588. if (widgets != nullptr && p != nullptr)
  589. {
  590. for (auto && widget : *widgets)
  591. if (widget->owner.getPeer() == p && widget->owner.hasKeyboardFocus (false))
  592. return widget->client;
  593. }
  594. return SharedKeyWindow::getCurrentFocusWindow (p);
  595. }
  596. };
  597. //==============================================================================
  598. Array<XEmbedComponent::Pimpl*>* XEmbedComponent::Pimpl::widgets = nullptr;
  599. HashMap<ComponentPeer*,XEmbedComponent::Pimpl::SharedKeyWindow*>* XEmbedComponent::Pimpl::SharedKeyWindow::keyWindows = nullptr;
  600. //==============================================================================
  601. XEmbedComponent::XEmbedComponent (bool wantsKeyboardFocus, bool allowForeignWidgetToResizeComponent)
  602. : pimpl (new Pimpl (*this, 0, wantsKeyboardFocus, false, allowForeignWidgetToResizeComponent))
  603. {
  604. setOpaque (true);
  605. }
  606. XEmbedComponent::XEmbedComponent (unsigned long wID, bool wantsKeyboardFocus, bool allowForeignWidgetToResizeComponent)
  607. : pimpl (new Pimpl (*this, wID, wantsKeyboardFocus, true, allowForeignWidgetToResizeComponent))
  608. {
  609. setOpaque (true);
  610. }
  611. XEmbedComponent::~XEmbedComponent() {}
  612. void XEmbedComponent::paint (Graphics& g)
  613. {
  614. g.fillAll (Colours::lightgrey);
  615. }
  616. void XEmbedComponent::focusGained (FocusChangeType changeType) { pimpl->focusGained (changeType); }
  617. void XEmbedComponent::focusLost (FocusChangeType changeType) { pimpl->focusLost (changeType); }
  618. void XEmbedComponent::broughtToFront() { pimpl->broughtToFront(); }
  619. unsigned long XEmbedComponent::getHostWindowID() { return pimpl->getHostWindowID(); }
  620. //==============================================================================
  621. bool juce_handleXEmbedEvent (ComponentPeer* p, void* e)
  622. {
  623. return ::XEmbedComponent::Pimpl::dispatchX11Event (p, reinterpret_cast<const XEvent*> (e));
  624. }
  625. unsigned long juce_getCurrentFocusWindow (ComponentPeer* peer)
  626. {
  627. return (unsigned long) ::XEmbedComponent::Pimpl::getCurrentFocusWindow (peer);
  628. }