From dfd8112f76bd88ed3389d6f07cbdaa250957129b Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Sat, 13 May 2023 20:05:47 +0800 Subject: [PATCH] fix: multi monitor issue taken the changes from From https://github.com/goldendict/goldendict/commit/83020389c802577075831f7b45cc1a4d3017c86f --- src/ui/scanflag.cc | 6 +++++- src/ui/scanpopup.cc | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ui/scanflag.cc b/src/ui/scanflag.cc index 8a85a448..b3b33aa3 100644 --- a/src/ui/scanflag.cc +++ b/src/ui/scanflag.cc @@ -52,7 +52,11 @@ void ScanFlag::showScanFlag() QPoint currentPos = QCursor::pos(); - QRect desktop = QGuiApplication::primaryScreen()->geometry(); + auto screen = QGuiApplication::screenAt( currentPos ); + if ( !screen ) + return; + + QRect desktop = screen->geometry(); QSize windowSize = geometry().size(); diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index 5276134e..1885eaf9 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -522,7 +522,11 @@ void ScanPopup::engagePopup( bool forcePopup, bool giveFocus ) QPoint currentPos = QCursor::pos(); - QRect desktop = QGuiApplication::primaryScreen()->geometry(); + auto screen = QGuiApplication::screenAt( currentPos ); + if ( !screen ) + return; + + QRect desktop = screen->geometry(); QSize windowSize = geometry().size();