From c07c9f89fed30f11746e996dbf34ae6c793fe647 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 15 Oct 2019 11:39:17 +0100 Subject: [PATCH] Linux: Fixed an issue in LinuxComponentPeer::getScreenPosition() with embedded windows --- .../native/juce_linux_X11_Windowing.cpp | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp index 06febe1902..c44e331e0b 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp @@ -1261,10 +1261,13 @@ public: Point getScreenPosition (bool physical) const { - if (physical) - return Desktop::getInstance().getDisplays().logicalToPhysical (bounds.getTopLeft()); + auto screenBounds = (parentWindow == 0 ? bounds + : bounds.translated (parentScreenPosition.x, parentScreenPosition.y)); - return bounds.getTopLeft(); + if (physical) + return Desktop::getInstance().getDisplays().logicalToPhysical (screenBounds.getTopLeft()); + + return screenBounds.getTopLeft(); } Rectangle getBounds() const override { return bounds; } @@ -2399,6 +2402,7 @@ private: friend class LinuxRepaintManager; Window windowH = {}, parentWindow = {}, keyProxy = {}; Rectangle bounds; + Point parentScreenPosition; Image taskbarImage; bool fullScreen = false, mapped = false, focused = false; Visual* visual = {}; @@ -2855,9 +2859,23 @@ private: ScopedXLock xlock (display); - if (XGetGeometry (display, (::Drawable) windowH, &root, &wx, &wy, &ww, &wh, &bw, &bitDepth) && parentWindow == 0) - if (! XTranslateCoordinates (display, windowH, root, 0, 0, &wx, &wy, &child)) - wx = wy = 0; + if (XGetGeometry (display, (::Drawable) windowH, &root, &wx, &wy, &ww, &wh, &bw, &bitDepth)) + { + int rootX = 0, rootY = 0; + + if (! XTranslateCoordinates (display, windowH, root, 0, 0, &rootX, &rootY, &child)) + rootX = rootY = 0; + + if (parentWindow == 0) + { + wx = rootX; + wy = rootY; + } + else + { + parentScreenPosition = Desktop::getInstance().getDisplays().physicalToLogical (Point (rootX, rootY)); + } + } Rectangle physicalBounds (wx, wy, (int) ww, (int) wh);