mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-04 17:30:55 +00:00
Properly use X11 startup ids
When one instance of Dolphin activates another it passes a startupId (X11) / activation token (wayland) along. On X11 this is passed using the DESKTOP_STARTUP_ID environment variable. The code tries to read that through KStartupInfo::startupId(). That doesn't work though, since Qt at startup reads the environment variable afterwards. However, it is nice enough to allow us to access it through QX11Info::nextStartupId(). Use that to read the token in the first instance and pass it to the second instance like we do on Wayland The user-facing impact of this is minimal since KStartupInfo::setNewStartupId internally falls back to KWindowSystem::forceActiveWindow when no startupId is passed.
This commit is contained in:
parent
414311b8c8
commit
6d21deb6e4
|
@ -50,6 +50,14 @@ find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
|
||||||
DBus
|
DBus
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (UNIX AND NOT APPLE)
|
||||||
|
set(HAVE_X11 TRUE)
|
||||||
|
|
||||||
|
if (QT_MAJOR_VERSION STREQUAL "5")
|
||||||
|
find_package(Qt5X11Extras REQUIRED)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
|
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
|
||||||
KCMUtils
|
KCMUtils
|
||||||
NewStuff
|
NewStuff
|
||||||
|
|
|
@ -471,6 +471,14 @@ target_link_libraries(dolphin
|
||||||
KF5::Crash
|
KF5::Crash
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (HAVE_X11)
|
||||||
|
if (QT_MAJOR_VERSION STREQUAL "5")
|
||||||
|
target_link_libraries(dolphin PRIVATE Qt5::X11Extras)
|
||||||
|
else()
|
||||||
|
target_link_libraries(dolphin PRIVATE Qt::GuiPrivate)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
include(DbusInterfaceMacros)
|
include(DbusInterfaceMacros)
|
||||||
|
|
||||||
generate_and_install_dbus_interface(
|
generate_and_install_dbus_interface(
|
||||||
|
|
|
@ -3,3 +3,4 @@
|
||||||
#cmakedefine01 HAVE_KUSERFEEDBACK
|
#cmakedefine01 HAVE_KUSERFEEDBACK
|
||||||
#cmakedefine01 HAVE_PACKAGEKIT
|
#cmakedefine01 HAVE_PACKAGEKIT
|
||||||
#cmakedefine01 HAVE_TERMINAL
|
#cmakedefine01 HAVE_TERMINAL
|
||||||
|
#cmakedefine01 HAVE_X11
|
||||||
|
|
|
@ -289,7 +289,7 @@ void DolphinMainWindow::activateWindow(const QString &activationToken)
|
||||||
if (KWindowSystem::isPlatformWayland()) {
|
if (KWindowSystem::isPlatformWayland()) {
|
||||||
KWindowSystem::setCurrentXdgActivationToken(activationToken);
|
KWindowSystem::setCurrentXdgActivationToken(activationToken);
|
||||||
} else {
|
} else {
|
||||||
KStartupInfo::setNewStartupId(window()->windowHandle(), KStartupInfo::startupId());
|
KStartupInfo::setNewStartupId(window()->windowHandle(), activationToken.toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
KWindowSystem::activateWindow(window()->windowHandle());
|
KWindowSystem::activateWindow(window()->windowHandle());
|
||||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -35,6 +35,14 @@
|
||||||
#include <QDBusConnectionInterface>
|
#include <QDBusConnectionInterface>
|
||||||
#include <QSessionManager>
|
#include <QSessionManager>
|
||||||
|
|
||||||
|
#if HAVE_X11
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
#include <private/qtx11extras_p.h>
|
||||||
|
#else
|
||||||
|
#include <QX11Info>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -181,6 +189,10 @@ int main(int argc, char **argv)
|
||||||
if (KWindowSystem::isPlatformWayland()) {
|
if (KWindowSystem::isPlatformWayland()) {
|
||||||
token = qEnvironmentVariable("XDG_ACTIVATION_TOKEN");
|
token = qEnvironmentVariable("XDG_ACTIVATION_TOKEN");
|
||||||
qunsetenv("XDG_ACTIVATION_TOKEN");
|
qunsetenv("XDG_ACTIVATION_TOKEN");
|
||||||
|
} else if (KWindowSystem::isPlatformX11()) {
|
||||||
|
#if HAVE_X11
|
||||||
|
token = QX11Info::nextStartupId();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Dolphin::attachToExistingInstance(urls, openFiles, splitView, QString(), token)) {
|
if (Dolphin::attachToExistingInstance(urls, openFiles, splitView, QString(), token)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user