From 643cccb9c655dbbdeb2dbf6a1779c97f05fb708a Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Fri, 27 Dec 2024 16:00:40 +0800 Subject: [PATCH 1/9] opt:add log to windows state when toggle windows --- src/ui/mainwindow.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index 5e85d0798..ef522625e 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -2883,6 +2883,10 @@ void MainWindow::toggleMainWindow( bool ensureShow ) translateBox->setPopupEnabled( false ); } + qDebug() << "current windows state,visible:" << isVisible() << ",minimized:" << isMinimized() + << ",active:" << isActiveWindow() << ",ensureShow:" << ensureShow << ",wasMaximized:" << wasMaximized + << ",preference focus:" << cfg.preferences.raiseWindowOnSearch; + if ( !isVisible() ) { show(); From 8d10663ed491209ed3b299c84d9ccd813754fe70 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Fri, 27 Dec 2024 17:08:42 +0800 Subject: [PATCH 2/9] 1 --- src/ui/mainwindow.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index ef522625e..4e1dde4d2 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -2906,10 +2906,12 @@ void MainWindow::toggleMainWindow( bool ensureShow ) shown = true; } else if ( !isActiveWindow() ) { - activateWindow(); + showNormal(); if ( cfg.preferences.raiseWindowOnSearch ) { raise(); } + activateWindow(); + shown = true; } else if ( !ensureShow ) { From 3940c700028b407369bdaece2466a51f06de47e9 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Fri, 27 Dec 2024 17:10:57 +0800 Subject: [PATCH 3/9] 1 --- src/ui/mainwindow.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index 4e1dde4d2..fee7ed712 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -2906,7 +2906,12 @@ void MainWindow::toggleMainWindow( bool ensureShow ) shown = true; } else if ( !isActiveWindow() ) { - showNormal(); + if ( wasMaximized ) { + showMaximized(); + } + else { + showNormal(); + } if ( cfg.preferences.raiseWindowOnSearch ) { raise(); } From 8f26b2ab08c219ac296915937ee88a9ee445e714 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Fri, 27 Dec 2024 17:44:16 +0800 Subject: [PATCH 4/9] 1 --- src/ui/mainwindow.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index fee7ed712..3091477c1 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -2889,9 +2889,8 @@ void MainWindow::toggleMainWindow( bool ensureShow ) if ( !isVisible() ) { show(); - - activateWindow(); raise(); + activateWindow(); shown = true; } else if ( isMinimized() ) { @@ -2901,17 +2900,12 @@ void MainWindow::toggleMainWindow( bool ensureShow ) else { showNormal(); } - activateWindow(); raise(); + activateWindow(); shown = true; } else if ( !isActiveWindow() ) { - if ( wasMaximized ) { - showMaximized(); - } - else { - showNormal(); - } + show(); if ( cfg.preferences.raiseWindowOnSearch ) { raise(); } From 0e48277aad5d3853650421d53facf7c80679c92e Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Sat, 28 Dec 2024 17:06:49 +0800 Subject: [PATCH 5/9] 1 --- src/ui/mainwindow.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index 3091477c1..01c64f124 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -2911,6 +2911,15 @@ void MainWindow::toggleMainWindow( bool ensureShow ) } activateWindow(); + // Rare cases, on Windows, the window can not be brought to the front. + auto flags = windowFlags(); + setWindowFlags( flags | Qt::WindowStaysOnTopHint ); + + QTimer::singleShot( 10, this, [this]() { + auto flags = windowFlags(); + setWindowFlags( flags & ~Qt::WindowStaysOnTopHint ); + } ); + shown = true; } else if ( !ensureShow ) { From 9851fffe9ac1e66902fc94ff155a17c35675fe96 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sat, 28 Dec 2024 09:08:28 +0000 Subject: [PATCH 6/9] [autofix.ci] apply automated fixes --- src/ui/mainwindow.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index 01c64f124..425bb10a6 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -2915,7 +2915,7 @@ void MainWindow::toggleMainWindow( bool ensureShow ) auto flags = windowFlags(); setWindowFlags( flags | Qt::WindowStaysOnTopHint ); - QTimer::singleShot( 10, this, [this]() { + QTimer::singleShot( 10, this, [ this ]() { auto flags = windowFlags(); setWindowFlags( flags & ~Qt::WindowStaysOnTopHint ); } ); From eafb7dcbccd1140c685b9963aa030a45b3926a03 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Sat, 28 Dec 2024 17:33:01 +0800 Subject: [PATCH 7/9] 1 --- src/ui/mainwindow.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index 425bb10a6..c568d51b5 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -2905,7 +2905,6 @@ void MainWindow::toggleMainWindow( bool ensureShow ) shown = true; } else if ( !isActiveWindow() ) { - show(); if ( cfg.preferences.raiseWindowOnSearch ) { raise(); } @@ -2913,11 +2912,11 @@ void MainWindow::toggleMainWindow( bool ensureShow ) // Rare cases, on Windows, the window can not be brought to the front. auto flags = windowFlags(); - setWindowFlags( flags | Qt::WindowStaysOnTopHint ); + setWindowFlags( flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint ); QTimer::singleShot( 10, this, [ this ]() { auto flags = windowFlags(); - setWindowFlags( flags & ~Qt::WindowStaysOnTopHint ); + setWindowFlags( flags ^ ( Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint ) ); } ); shown = true; From 964c97042b9ebe21c35003ac9001c2828563e635 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Sat, 28 Dec 2024 17:50:47 +0800 Subject: [PATCH 8/9] 1 --- src/ui/mainwindow.cc | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index c568d51b5..4e9210419 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -2905,20 +2905,11 @@ void MainWindow::toggleMainWindow( bool ensureShow ) shown = true; } else if ( !isActiveWindow() ) { + setWindowState( (windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); if ( cfg.preferences.raiseWindowOnSearch ) { raise(); } activateWindow(); - - // Rare cases, on Windows, the window can not be brought to the front. - auto flags = windowFlags(); - setWindowFlags( flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint ); - - QTimer::singleShot( 10, this, [ this ]() { - auto flags = windowFlags(); - setWindowFlags( flags ^ ( Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint ) ); - } ); - shown = true; } else if ( !ensureShow ) { From 50051119fc286cc24efa94ac4e65905efb98203a Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sat, 28 Dec 2024 09:52:06 +0000 Subject: [PATCH 9/9] [autofix.ci] apply automated fixes --- src/ui/mainwindow.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index 4e9210419..1e25ea19b 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -2905,7 +2905,7 @@ void MainWindow::toggleMainWindow( bool ensureShow ) shown = true; } else if ( !isActiveWindow() ) { - setWindowState( (windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); + setWindowState( ( windowState() & ~Qt::WindowMinimized ) | Qt::WindowActive ); if ( cfg.preferences.raiseWindowOnSearch ) { raise(); }