From 136a7f619af0091df1c11aad0ca5bedd6747b5bf Mon Sep 17 00:00:00 2001 From: Standreas Date: Fri, 24 May 2024 19:14:32 +0200 Subject: [PATCH] Set layer overlay for dropdown terminal on wayland (#1113) --- CMakeLists.txt | 3 +++ src/mainwindow.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57d0aeb2..d0426684 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,11 +24,13 @@ endif() set(LXQTBT_MINIMUM_VERSION "2.0.0") set(QT_MINIMUM_VERSION "6.6.0") set(QT_MAJOR_VERSION "6") +set(SHELLQT_MINIMUM_VERSION "6.0.0") find_package(Qt6Core ${QT_MINIMUM_VERSION} REQUIRED) find_package(Qt6Gui ${QT_MINIMUM_VERSION} REQUIRED) find_package(Qt6LinguistTools ${QT_MINIMUM_VERSION} REQUIRED) find_package(Qt6Widgets ${QT_MINIMUM_VERSION} REQUIRED) +find_package(LayerShellQt ${SHELLQT_MINIMUM_VERSION} REQUIRED) if(UNIX) find_package(Qt6DBus ${QT_MINIMUM_VERSION} REQUIRED) find_package(Qt6 COMPONENTS Core REQUIRED) @@ -206,6 +208,7 @@ target_link_libraries(${EXE_NAME} Qt6::Gui Qt6::Widgets qtermwidget6 + LayerShellQtInterface ) if(QXT_FOUND) target_link_libraries(${EXE_NAME} ${QXT_CORE_LIB} ${QXT_GUI_LIB}) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index de960d4a..ade0105e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -44,6 +44,9 @@ #include "qterminalapp.h" #include "dbusaddressable.h" +#include +#include + typedef std::function checkfn; Q_DECLARE_METATYPE(checkfn) @@ -168,6 +171,21 @@ MainWindow::~MainWindow() void MainWindow::enableDropMode() { + if (QGuiApplication::platformName() == QStringLiteral("wayland")) + { + winId(); + if (QWindow *win = windowHandle()) + { + if (LayerShellQt::Window* layershell = LayerShellQt::Window::get(win)) + { + layershell->setLayer(LayerShellQt::Window::Layer::LayerOverlay); + layershell->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityOnDemand); + LayerShellQt::Window::Anchors anchors = {LayerShellQt::Window::AnchorTop}; + layershell->setAnchors(anchors); + } + } + } + setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint); m_dropLockButton = new QToolButton(this);