From 46b2a99bf2d8882c01e445b7e808e10dae6f6d55 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 7 Aug 2020 10:24:22 +0200 Subject: More agressive delay and retry after screen layout changed We still sometimes end up with an improper layout after running xrandr on X11 startup. I suspect this is a race condition between xrandr setting the resolutions and scren geometry, and Qt receiving this event too early, still omehow reading stale information when querying X for the current setup. So we now wait 300ms instead of 100, and additionally retry again after a second. If this doesn't fix the issues, the root cause must be something else. --- src/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 50816ec..c25d7df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,8 +86,11 @@ int main(int argc, char *argv[]) QObject::connect(&setupDelay, &QTimer::timeout, []() { setupScreens(); + QTimer::singleShot(1000, []() { + setupScreens(); + }); }); - setupDelay.setInterval(100); + setupDelay.setInterval(300); setupDelay.setSingleShot(true); setupDelay.start(); @@ -119,7 +122,10 @@ int main(int argc, char *argv[]) static void watch(const QScreen *scrn) { - QObject::connect(scrn, &QScreen::geometryChanged, [](const QRect &geom) { + QObject::connect(scrn, &QScreen::geometryChanged, [](const QRect &) { + setupDelay.start(); + }); + QObject::connect(scrn, &QScreen::virtualGeometryChanged, [](const QRect &) { setupDelay.start(); }); } -- cgit v1.2.3-55-g7522