Skip to content

Commit

Permalink
Set layer overlay for dropdown terminal on wayland (#1113)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefonarch authored May 24, 2024
1 parent ee11676 commit 136a7f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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})
Expand Down
18 changes: 18 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#include "qterminalapp.h"
#include "dbusaddressable.h"

#include <LayerShellQt/Shell>
#include <LayerShellQt/Window>

typedef std::function<bool(MainWindow&, QAction *)> checkfn;
Q_DECLARE_METATYPE(checkfn)

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 136a7f6

Please sign in to comment.