Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake option to disable Wayland support code #1155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(QTERMINAL_VERSION "2.0.1")

option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
option(BUILD_TESTS "Builds tests" ON)
option(ENABLE_WAYLAND "Enable additional support code for the Wayland display server" ON)

if(APPLE)
option(APPLEBUNDLE "Build as qterminal.app bundle" ON)
Expand All @@ -31,7 +32,9 @@ 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(ENABLE_WAYLAND)
find_package(LayerShellQt ${SHELLQT_MINIMUM_VERSION} REQUIRED)
endif()
if(UNIX)
find_package(Qt6DBus ${QT_MINIMUM_VERSION} REQUIRED)
find_package(Qt6 COMPONENTS Core REQUIRED)
Expand Down Expand Up @@ -209,8 +212,11 @@ target_link_libraries(${EXE_NAME}
Qt6::Gui
Qt6::Widgets
qtermwidget6
LayerShellQtInterface
)
if(ENABLE_WAYLAND)
add_definitions(-DHAVE_LAYERSHELLQT)
target_link_libraries(${EXE_NAME} LayerShellQtInterface)
endif()
if(QXT_FOUND)
target_link_libraries(${EXE_NAME} ${QXT_CORE_LIB} ${QXT_GUI_LIB})
endif()
Expand Down
7 changes: 7 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ int main(int argc, char *argv[])
app->installTranslator(&translator);
}

#ifndef HAVE_LAYERSHELLQT
if (QGuiApplication::platformName() == QStringLiteral("wayland"))
{
fprintf(stderr, "Running on Wayland, although Wayland support was disabled at compile-time. Expect errors.\n");
}
#endif

TerminalConfig initConfig = TerminalConfig(workdir, shell_command);
app->newWindow(dropMode, initConfig);

Expand Down
4 changes: 4 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
#include "qterminalapp.h"
#include "dbusaddressable.h"

#ifdef HAVE_LAYERSHELLQT
#include <LayerShellQt/Shell>
#include <LayerShellQt/Window>
#endif

typedef std::function<bool(MainWindow&, QAction *)> checkfn;
Q_DECLARE_METATYPE(checkfn)
Expand Down Expand Up @@ -173,6 +175,7 @@ void MainWindow::enableDropMode()
{
if (QGuiApplication::platformName() == QStringLiteral("wayland"))
{
#ifdef HAVE_LAYERSHELLQT
winId();
if (QWindow *win = windowHandle())
{
Expand All @@ -184,6 +187,7 @@ void MainWindow::enableDropMode()
layershell->setAnchors(anchors);
}
}
#endif
}

setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint);
Expand Down