Linux setGlobalScaleFactor doesn't work correctly

#1

It looks like the GlobalScale is being applied twice on Linux X11. We were not having this issue on JUCE 4.3.1. I am testing on JUCE 5.4.1.

Reproduce by adding Desktop::getInstance().setGlobalScaleFactor(2.0); to the MainAppWindow constructor in DemoRunner.

It looks better if I use the following diff (but I do not have a lot of X11 experience and have not tested this thoroughly - this is not a Pull Request).

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 ab9b9496b..402fe6f35 100644
--- a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp
+++ b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp
@@ -1809,7 +1809,7 @@ public:
    template <typename EventType>
    Point<float> getMousePos (const EventType& e) noexcept
    {
-        return Point<float> ((float) e.x, (float) e.y) / currentScaleFactor;
+        return Point<float> ((float) e.x, (float) e.y);// / currentScaleFactor;^M
    }

    void handleWheelEvent (const XButtonPressedEvent& buttonPressEvent, float amount)
@@ -2307,7 +2307,7 @@ private:
                {
                    std::unique_ptr<LowLevelGraphicsContext> context (peer.getComponent().getLookAndFeel()
                                                                        .createGraphicsContext (image, -totalArea.getPosition(), adjustedList));
-                    context->addTransform (AffineTransform::scale ((float) peer.currentScaleFactor));
+                    //context->addTransform (AffineTransform::scale ((float) peer.currentScaleFactor));^M
                    peer.handlePaint (*context);
                }

UPDATES:

  • Reproduced on 5.4.3-16-g49c631e91 (git describe) and develop
  • I cannot reproduce on 4.3.1
  • That patch is not complete, although scale factors for mouse clicks and widgets seem right the area in the windows that is repainted is sometimes wrong. I had bits of scrollbars stick around when moved and similar.
#2

Does this fix the issue for you?

#3

That looks like it fixes it for me @ed95, cheers

1 Like