From ea5cffcbd2438247dacd7d5b0b7536e8d5d218fe Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 16 Dec 2025 12:27:56 +0000 Subject: [PATCH] XEmbedComponent: Improve formatting --- .../native/juce_XEmbedComponent_linux.cpp | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/modules/juce_gui_extra/native/juce_XEmbedComponent_linux.cpp b/modules/juce_gui_extra/native/juce_XEmbedComponent_linux.cpp index f04eee8f97..8f4d6c009d 100644 --- a/modules/juce_gui_extra/native/juce_XEmbedComponent_linux.cpp +++ b/modules/juce_gui_extra/native/juce_XEmbedComponent_linux.cpp @@ -372,34 +372,34 @@ private: void componentParentHierarchyChanged (Component&) override { peerChanged (owner.getPeer()); } void componentMovedOrResized (Component&, bool, bool) override { - if (host != 0 && lastPeer != nullptr) + if (host == 0 || lastPeer == nullptr) + return; + + auto dpy = getDisplay(); + auto newBounds = getX11BoundsFromJuce(); + XWindowAttributes attr; + + if (X11Symbols::getInstance()->xGetWindowAttributes (dpy, host, &attr)) { - auto dpy = getDisplay(); - auto newBounds = getX11BoundsFromJuce(); - XWindowAttributes attr; - - if (X11Symbols::getInstance()->xGetWindowAttributes (dpy, host, &attr)) + Rectangle currentBounds (attr.x, attr.y, attr.width, attr.height); + if (currentBounds != newBounds) { - Rectangle currentBounds (attr.x, attr.y, attr.width, attr.height); - if (currentBounds != newBounds) - { - X11Symbols::getInstance()->xMoveResizeWindow (dpy, host, newBounds.getX(), newBounds.getY(), - static_cast (newBounds.getWidth()), - static_cast (newBounds.getHeight())); - } + X11Symbols::getInstance()->xMoveResizeWindow (dpy, host, newBounds.getX(), newBounds.getY(), + static_cast (newBounds.getWidth()), + static_cast (newBounds.getHeight())); } + } - if (client != 0 && X11Symbols::getInstance()->xGetWindowAttributes (dpy, client, &attr)) + if (client != 0 && X11Symbols::getInstance()->xGetWindowAttributes (dpy, client, &attr)) + { + Rectangle currentBounds (attr.x, attr.y, attr.width, attr.height); + + if (std::tuple (currentBounds.getWidth(), currentBounds.getHeight()) + != std::tuple (newBounds.getWidth(), newBounds.getHeight())) { - Rectangle currentBounds (attr.x, attr.y, attr.width, attr.height); - - if ((currentBounds.getWidth() != newBounds.getWidth() - || currentBounds.getHeight() != newBounds.getHeight())) - { - X11Symbols::getInstance()->xMoveResizeWindow (dpy, client, 0, 0, - static_cast (newBounds.getWidth()), - static_cast (newBounds.getHeight())); - } + X11Symbols::getInstance()->xMoveResizeWindow (dpy, client, 0, 0, + static_cast (newBounds.getWidth()), + static_cast (newBounds.getHeight())); } } } @@ -517,13 +517,13 @@ private: const double scale = (peer != nullptr ? peer->getPlatformScaleFactor() : displays.getPrimaryDisplay()->scale); - Point topLeftInPeer - = (peer != nullptr ? peer->getComponent().getLocalPoint (&owner, Point (0, 0)) + const auto topLeftInPeer + = (peer != nullptr ? peer->getComponent().getLocalPoint (&owner, Point (0, 0)) : owner.getBounds().getTopLeft()); - Rectangle newBounds (topLeftInPeer.getX(), topLeftInPeer.getY(), - static_cast (static_cast (attr.width) / scale), - static_cast (static_cast (attr.height) / scale)); + Rectangle newBounds (topLeftInPeer.getX(), topLeftInPeer.getY(), + static_cast (static_cast (attr.width) / scale), + static_cast (static_cast (attr.height) / scale)); if (peer != nullptr) @@ -545,7 +545,7 @@ private: auto dpy = getDisplay(); Window rootWindow = X11Symbols::getInstance()->xRootWindow (dpy, DefaultScreen (dpy)); - Rectangle newBounds = getX11BoundsFromJuce(); + const auto newBounds = getX11BoundsFromJuce(); if (newPeer == nullptr) hostMapper.unmap(); @@ -619,7 +619,7 @@ private: if (allowResize) configureNotify(); else - MessageManager::callAsync ([this] {componentMovedOrResized (owner, true, true);}); + MessageManager::callAsync ([this] { componentMovedOrResized (owner, true, true); }); return true;