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.

712 lines
24KB

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