From 7829afc7f6d49cb00956e05f3e1a2c40d8a79047 Mon Sep 17 00:00:00 2001 From: Andrei Shevchenko Date: Tue, 5 May 2026 03:58:17 +0200 Subject: [PATCH] Force xcb platform on Wayland to fix tab drag indicators Qt Advanced Docking System positions its drop-indicator overlays as top-level Qt::Tool windows using mapToGlobal() + move() to absolute global coordinates. Wayland does not let clients position top-level windows, so during a tab drag the indicators appear at wrong locations. ADS upstream has documented this limitation and recommends running through XWayland. Set QT_QPA_PLATFORM=xcb;wayland on Linux Wayland sessions so the app runs through XWayland where the positioning works correctly. The semicolon-separated form falls back to wayland on systems without xcb. Honor an explicit user-set QT_QPA_PLATFORM, and provide NOTEPADNEXT_FORCE_NATIVE_WAYLAND=1 as an opt-out. --- src/main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index e9e2d7bfe..467248d05 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,6 +29,25 @@ int main(int argc, char *argv[]) { qSetMessagePattern("[%{time process}] %{if-debug}D%{endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}: %{message}"); +#ifdef Q_OS_LINUX + // Qt Advanced Docking System positions its drop-indicator overlays as + // top-level Qt::Tool windows using mapToGlobal() + move() to absolute + // coordinates. Wayland does not let clients position top-level windows, + // so during a tab drag the indicators appear at wrong locations. Run + // through XWayland where the positioning works correctly. Honor an + // explicit QT_QPA_PLATFORM and an opt-out escape hatch. + if (qEnvironmentVariableIsEmpty("QT_QPA_PLATFORM") + && !qEnvironmentVariableIsSet("NOTEPADNEXT_FORCE_NATIVE_WAYLAND")) + { + const QByteArray sessionType = qgetenv("XDG_SESSION_TYPE"); + const bool isWayland = (sessionType == "wayland") + || qEnvironmentVariableIsSet("WAYLAND_DISPLAY"); + if (isWayland) { + qputenv("QT_QPA_PLATFORM", "xcb;wayland"); + } + } +#endif + // Set these since other parts of the app references these QApplication::setOrganizationName("NotepadNext"); QApplication::setApplicationName("NotepadNext");