From 7c7e98d69c1a0738b0082f9258f42aef97863a0a Mon Sep 17 00:00:00 2001 From: Lee Hambley Date: Mon, 27 May 2024 10:51:00 +0200 Subject: [PATCH 1/2] [#3505] use QT APIs screenAdded and screenRemoved to reiniitalize Flameshot when the display configuration changes --- src/main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 23d3157e01..af105a99bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -148,6 +149,17 @@ int main(int argc, char* argv[]) auto c = Flameshot::instance(); FlameshotDaemon::start(); + /* Register handlers for when the screen configuration changes to reinit the app */ + QObject::connect(qApp, &QGuiApplication::screenAdded, [](QScreen *screen){ + qDebug() << "Screen added. Reinitializing application."; + configureApp(true); + }); + QObject::connect(qApp, &QGuiApplication::screenRemoved, [](QScreen *screen){ + // Code to handle screen removed + qDebug() << "Screen removed. Reinitializing application."; + configureApp(true); + }); + #if !(defined(Q_OS_MACOS) || defined(Q_OS_WIN)) new FlameshotDBusAdapter(c); QDBusConnection dbus = QDBusConnection::sessionBus(); From 9e87ec0120b1e6bb5ae4444df9e4de6527d30f29 Mon Sep 17 00:00:00 2001 From: Lee Hambley Date: Mon, 27 May 2024 13:08:00 +0200 Subject: [PATCH 2/2] Improve comments to link issue number Co-authored-by: Adam Stachowicz --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index af105a99bb..1a3ade27d4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -149,7 +149,7 @@ int main(int argc, char* argv[]) auto c = Flameshot::instance(); FlameshotDaemon::start(); - /* Register handlers for when the screen configuration changes to reinit the app */ + /* Register handlers for when the screen configuration changes to reinit the app to fix #3505 */ QObject::connect(qApp, &QGuiApplication::screenAdded, [](QScreen *screen){ qDebug() << "Screen added. Reinitializing application."; configureApp(true);