Skip to content

Commit ea5cffc

Browse files
committed
XEmbedComponent: Improve formatting
1 parent f48ca1b commit ea5cffc

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

modules/juce_gui_extra/native/juce_XEmbedComponent_linux.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -372,34 +372,34 @@ class XEmbedComponent::Pimpl : private ComponentListener
372372
void componentParentHierarchyChanged (Component&) override { peerChanged (owner.getPeer()); }
373373
void componentMovedOrResized (Component&, bool, bool) override
374374
{
375-
if (host != 0 && lastPeer != nullptr)
376-
{
377-
auto dpy = getDisplay();
378-
auto newBounds = getX11BoundsFromJuce();
379-
XWindowAttributes attr;
375+
if (host == 0 || lastPeer == nullptr)
376+
return;
380377

381-
if (X11Symbols::getInstance()->xGetWindowAttributes (dpy, host, &attr))
378+
auto dpy = getDisplay();
379+
auto newBounds = getX11BoundsFromJuce();
380+
XWindowAttributes attr;
381+
382+
if (X11Symbols::getInstance()->xGetWindowAttributes (dpy, host, &attr))
383+
{
384+
Rectangle currentBounds (attr.x, attr.y, attr.width, attr.height);
385+
if (currentBounds != newBounds)
382386
{
383-
Rectangle<int> currentBounds (attr.x, attr.y, attr.width, attr.height);
384-
if (currentBounds != newBounds)
385-
{
386-
X11Symbols::getInstance()->xMoveResizeWindow (dpy, host, newBounds.getX(), newBounds.getY(),
387-
static_cast<unsigned int> (newBounds.getWidth()),
388-
static_cast<unsigned int> (newBounds.getHeight()));
389-
}
387+
X11Symbols::getInstance()->xMoveResizeWindow (dpy, host, newBounds.getX(), newBounds.getY(),
388+
static_cast<unsigned int> (newBounds.getWidth()),
389+
static_cast<unsigned int> (newBounds.getHeight()));
390390
}
391+
}
391392

392-
if (client != 0 && X11Symbols::getInstance()->xGetWindowAttributes (dpy, client, &attr))
393-
{
394-
Rectangle<int> currentBounds (attr.x, attr.y, attr.width, attr.height);
393+
if (client != 0 && X11Symbols::getInstance()->xGetWindowAttributes (dpy, client, &attr))
394+
{
395+
Rectangle currentBounds (attr.x, attr.y, attr.width, attr.height);
395396

396-
if ((currentBounds.getWidth() != newBounds.getWidth()
397-
|| currentBounds.getHeight() != newBounds.getHeight()))
398-
{
399-
X11Symbols::getInstance()->xMoveResizeWindow (dpy, client, 0, 0,
400-
static_cast<unsigned int> (newBounds.getWidth()),
401-
static_cast<unsigned int> (newBounds.getHeight()));
402-
}
397+
if (std::tuple (currentBounds.getWidth(), currentBounds.getHeight())
398+
!= std::tuple (newBounds.getWidth(), newBounds.getHeight()))
399+
{
400+
X11Symbols::getInstance()->xMoveResizeWindow (dpy, client, 0, 0,
401+
static_cast<unsigned int> (newBounds.getWidth()),
402+
static_cast<unsigned int> (newBounds.getHeight()));
403403
}
404404
}
405405
}
@@ -517,13 +517,13 @@ class XEmbedComponent::Pimpl : private ComponentListener
517517
const double scale = (peer != nullptr ? peer->getPlatformScaleFactor()
518518
: displays.getPrimaryDisplay()->scale);
519519

520-
Point<int> topLeftInPeer
521-
= (peer != nullptr ? peer->getComponent().getLocalPoint (&owner, Point<int> (0, 0))
520+
const auto topLeftInPeer
521+
= (peer != nullptr ? peer->getComponent().getLocalPoint (&owner, Point (0, 0))
522522
: owner.getBounds().getTopLeft());
523523

524-
Rectangle<int> newBounds (topLeftInPeer.getX(), topLeftInPeer.getY(),
525-
static_cast<int> (static_cast<double> (attr.width) / scale),
526-
static_cast<int> (static_cast<double> (attr.height) / scale));
524+
Rectangle newBounds (topLeftInPeer.getX(), topLeftInPeer.getY(),
525+
static_cast<int> (static_cast<double> (attr.width) / scale),
526+
static_cast<int> (static_cast<double> (attr.height) / scale));
527527

528528

529529
if (peer != nullptr)
@@ -545,7 +545,7 @@ class XEmbedComponent::Pimpl : private ComponentListener
545545

546546
auto dpy = getDisplay();
547547
Window rootWindow = X11Symbols::getInstance()->xRootWindow (dpy, DefaultScreen (dpy));
548-
Rectangle<int> newBounds = getX11BoundsFromJuce();
548+
const auto newBounds = getX11BoundsFromJuce();
549549

550550
if (newPeer == nullptr)
551551
hostMapper.unmap();
@@ -619,7 +619,7 @@ class XEmbedComponent::Pimpl : private ComponentListener
619619
if (allowResize)
620620
configureNotify();
621621
else
622-
MessageManager::callAsync ([this] {componentMovedOrResized (owner, true, true);});
622+
MessageManager::callAsync ([this] { componentMovedOrResized (owner, true, true); });
623623

624624
return true;
625625

0 commit comments

Comments
 (0)