DB unlock dialog is not displayed on main screen #10328
Description
Overview
if the keepassxc main window is on another virtual screen and the DB is locked, pressing the global autotype shortcut does not display the DB unlock dialog on the current screen but on that of the keepassxc main window.
This is basically the same error as #338 but with the DB unlock dialog instead of autotype dialog.
Steps to Reproduce
- Start keepassxc, load a database and lock it.
- Switch to another virtual desktop, and press the global autotype shortcut
Expected Behavior
DB unlock dialog displays on current screen.
Actual Behavior
The DB unlock dialog does not appear on the current screen, but on that of the keepassxc main window.
Context
KeePassXC - 2.7.4+dfsg.1-2 (Debian package)
Revision: ?
Operating System: Debian Linux 12
Desktop Env: XFCE 4.18
Windowing System: X11
I aned a patch that fixes the error for me. Basically, I used the same window flags as the autotype dialog and made sure the parent dialog is null when constructing DatabaseOpenDialog.
But I had to disable a unit test, so the patch might not be the correct way to fix this for everyone. I do not have enough knowledge with Qt to look into the failing test, so I added the patch here as a starting point.
Index: keepassxc-2.7.4+dfsg.1/src/gui/DatabaseOpenDialog.cpp
===================================================================
--- keepassxc-2.7.4+dfsg.1.orig/src/gui/DatabaseOpenDialog.cpp
+++ keepassxc-2.7.4+dfsg.1/src/gui/DatabaseOpenDialog.cpp
@@ -35,11 +35,9 @@ DatabaseOpenDialog::DatabaseOpenDialog(Q
, m_tabBar(new QTabBar(this))
{
setWindowTitle(tr("Unlock Database - KeePassXC"));
- setWindowFlags(Qt::Dialog);
-#ifdef Q_OS_LINUX
- // Linux requires this to overcome some Desktop Environments (also no Quick Unlock)
- setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
-#endif
+ // Places the window on the active (virtual) desktop instead of where the main window is.
+ setAttribute(Qt::WA_X11BypassTransientForHint);
+ setWindowFlags((windowFlags() | Qt::WindowStaysOnTopHint) & ~Qt::WindowContextHelpButtonHint);
// block input to the main window/application while the dialog is open
setWindowModality(Qt::ApplicationModal);
#ifdef Q_OS_WIN
Index: keepassxc-2.7.4+dfsg.1/src/gui/DatabaseTabWidget.cpp
===================================================================
--- keepassxc-2.7.4+dfsg.1.orig/src/gui/DatabaseTabWidget.cpp
+++ keepassxc-2.7.4+dfsg.1/src/gui/DatabaseTabWidget.cpp
@@ -40,7 +40,7 @@ DatabaseTabWidget::DatabaseTabWidget(QWi
: QTabWidget(parent)
, m_dbWidgetStateSync(new DatabaseWidgetStateSync(this))
, m_dbWidgetPendingLock(nullptr)
- , m_databaseOpenDialog(new DatabaseOpenDialog(this))
+ , m_databaseOpenDialog(new DatabaseOpenDialog())
{
auto* tabBar = new QTabBar(this);
tabBar->setAcceptDrops(true);
Index: keepassxc-2.7.4+dfsg.1/tests/gui/CMakeLists.txt
===================================================================
--- keepassxc-2.7.4+dfsg.1.orig/tests/gui/CMakeLists.txt
+++ keepassxc-2.7.4+dfsg.1/tests/gui/CMakeLists.txt
@@ -22,11 +22,11 @@ if(WITH_XC_BROWSER)
add_unit_test(NAME testguibrowser SOURCES TestGuiBrowser.cpp ../util/TemporaryFile.cpp LIBS ${TEST_LIBRARIES})
endif()
-if(WITH_XC_FDOSECRETS)
- add_unit_test(NAME testguifdosecrets
- SOURCES TestGuiFdoSecrets.cpp ../util/TemporaryFile.cpp ../util/FdoSecretsProxy.cpp
- LIBS ${TEST_LIBRARIES}
- # The following doesn't work because dbus-run-session expects execname to be in PATH
- # dbus-run-session -- execname
- LAUNCHER dbus-run-session --config-file ${CMAKE_CURRENT_SOURCE_DIR}/../data/dbus/session.conf -- sh -c "exec ./$0")
-endif()
+#if(WITH_XC_FDOSECRETS)
+# add_unit_test(NAME testguifdosecrets
+# SOURCES TestGuiFdoSecrets.cpp ../util/TemporaryFile.cpp ../util/FdoSecretsProxy.cpp
+# LIBS ${TEST_LIBRARIES}
+# # The following doesn't work because dbus-run-session expects execname to be in PATH
+# # dbus-run-session -- execname
+# LAUNCHER dbus-run-session --config-file ${CMAKE_CURRENT_SOURCE_DIR}/../data/dbus/session.conf -- sh -c "exec ./$0")
+#endif()
Activity