From 6acff43ba247db1ee7bd10886f732b459f7e6938 Mon Sep 17 00:00:00 2001 From: WangFei <102005754+FeiWang1119@users.noreply.github.com> Date: Tue, 13 Jun 2023 17:28:10 +0800 Subject: [PATCH] chore: change qmake to cmake (#185) * chore: change qmake to cmake change qmake project to cmake project Log: change qmake to cmake * chore(debian): add the kf5wayland-dev depend in control file To resolve the issue that Imported target "Deepin::WaylandClient" includes non-existent path /usr/include/KF5 in its INTERFACE_INCLUDE_DIRECTORIES. Log: add the kf5wayland-dev depend in control file --------- Co-authored-by: wangfei --- CMakeLists.txt | 31 +++++ archlinux/PKGBUILD | 20 +--- debian/control | 4 +- qt5platform-plugins.pro | 9 -- src/src.cmake | 32 +++++ wayland/CMakeLists.txt | 6 + wayland/dwayland/CMakeLists.txt | 54 +++++++++ wayland/dwayland/dwayland.pro | 78 ------------- wayland/wayland-shell/CMakeLists.txt | 66 +++++++++++ .../deepin-kwin-test/CMakeLists.txt | 29 +++++ .../deepin-kwin-test/deepin-kwin-test.pro | 3 - .../config.tests/wayland_test/CMakeLists.txt | 33 ++++++ .../wayland_test/wayland_test.pro | 24 ---- wayland/wayland-shell/main.cpp | 5 +- wayland/wayland-shell/wayland-shell.cmake | 14 +++ wayland/wayland-shell/wayland-shell.pro | 83 ------------- wayland/wayland-shell/wayland_depends.pri | 11 -- wayland/wayland.pro | 4 - xcb/CMakeLists.txt | 59 ++++++++++ xcb/linux.cmake | 68 +++++++++++ xcb/linux.pri | 105 ----------------- xcb/windows.pri | 0 xcb/xcb.pro | 109 ------------------ 23 files changed, 404 insertions(+), 443 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 qt5platform-plugins.pro create mode 100644 src/src.cmake create mode 100644 wayland/CMakeLists.txt create mode 100644 wayland/dwayland/CMakeLists.txt delete mode 100644 wayland/dwayland/dwayland.pro create mode 100644 wayland/wayland-shell/CMakeLists.txt create mode 100644 wayland/wayland-shell/config.tests/deepin-kwin-test/CMakeLists.txt delete mode 100644 wayland/wayland-shell/config.tests/deepin-kwin-test/deepin-kwin-test.pro create mode 100644 wayland/wayland-shell/config.tests/wayland_test/CMakeLists.txt delete mode 100644 wayland/wayland-shell/config.tests/wayland_test/wayland_test.pro create mode 100644 wayland/wayland-shell/wayland-shell.cmake delete mode 100644 wayland/wayland-shell/wayland-shell.pro delete mode 100644 wayland/wayland-shell/wayland_depends.pri delete mode 100644 wayland/wayland.pro create mode 100644 xcb/CMakeLists.txt create mode 100644 xcb/linux.cmake delete mode 100644 xcb/linux.pri delete mode 100644 xcb/windows.pri delete mode 100644 xcb/xcb.pro diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..be821cc4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,31 @@ +# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: LGPL-3.0-or-later + +cmake_minimum_required(VERSION 3.10) + +set(VERSION + "5.6.8" + CACHE STRING "define project version" +) + +project(qt5platform-plugins + VERSION ${VERSION} + DESCRIPTION "DTK platform plugin module" + HOMEPAGE_URL "https://github.com/linuxdeepin/qt5platform-plugins" + LANGUAGES CXX C +) + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(REQUIRED_QT_VERSION 5.15.0) + +add_subdirectory(xcb) +add_subdirectory(wayland) diff --git a/archlinux/PKGBUILD b/archlinux/PKGBUILD index 64863d19..0c6fc52a 100644 --- a/archlinux/PKGBUILD +++ b/archlinux/PKGBUILD @@ -17,22 +17,14 @@ groups=('deepin-git') source=("${sourcetars[@]}") sha512sums=('SKIP') -prepare() { - cd $sourcedir - - rm -r xcb/libqt5xcbqpa-dev wayland/qtwayland-dev - # Disable wayland for now: https://github.com/linuxdeepin/qt5platform-plugins/issues/47 - sed -i '/wayland/d' qt5platform-plugins.pro - sed -i 's|error(Not support Qt Version: .*)|INCLUDEPATH += /usr/include/qtxcb-private|' xcb/linux.pri - sed -i "/qtwayland-dev/a /usr/include/qt/QtWaylandClient/$(expac %v qt5-wayland | cut -d - -f 1) /usr/include/qt/QtXkbCommonSupport/$(expac %v qt5-base | cut -d - -f 1) \\\\" wayland/wayland.pro - # https://github.com/linuxdeepin/qt5platform-plugins/pull/48 - sed -i 's/xcbWindow-/window-/' xcb/windoweventhook.cpp -} - build() { cd $sourcedir - qmake-qt5 PREFIX=/usr QT_XCB_PRIVATE_INCLUDE=/usr/include/qtxcb-private - make + cmake . -GNinja \ + -DMKSPECS_INSTALL_DIR=lib/qt/mkspecs/modules/\ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release + ninja } package() { diff --git a/debian/control b/debian/control index 75b5111e..9b5edcc0 100644 --- a/debian/control +++ b/debian/control @@ -8,10 +8,10 @@ Build-Depends: debhelper (>=9), qtbase5-dev, qtbase5-private-dev, libmtdev-dev, libxkbcommon-x11-dev, libdbus-1-dev, libqt5opengl5-dev, libudev-dev, libxrender-dev,libxi-dev, libsm-dev, libxcb-xinerama0-dev, libfontconfig1-dev, libfreetype6-dev, libglib2.0-dev, libxcb-damage0-dev, - libxcb-composite0-dev, libcairo2-dev, libdwayland-dev | libkf5wayland-dev, + libxcb-composite0-dev, libcairo2-dev, libkf5wayland-dev, libdwayland-dev, qtwayland5-private-dev | libqt5waylandclient5-dev, libwayland-dev, libxcb-xinput-dev, libxcb-util-dev | libxcb-util0-dev, - libx11-xcb-dev, libxcb-sync-dev, libxcb-randr0-dev + libx11-xcb-dev, libxcb-sync-dev, libxcb-randr0-dev, cmake Standards-Version: 3.9.8 Package: dde-qt5xcb-plugin diff --git a/qt5platform-plugins.pro b/qt5platform-plugins.pro deleted file mode 100644 index 74da034d..00000000 --- a/qt5platform-plugins.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = subdirs - -!DISABLE_WAYLAND { - SUBDIRS += wayland/wayland.pro -} - -!DISABLE_XCB { - SUBDIRS += xcb/xcb.pro -} diff --git a/src/src.cmake b/src/src.cmake new file mode 100644 index 00000000..6fb56993 --- /dev/null +++ b/src/src.cmake @@ -0,0 +1,32 @@ +# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: LGPL-3.0-or-later + +list(APPEND GLOBAL_HEADERS + ${CMAKE_CURRENT_LIST_DIR}/dbackingstoreproxy.h + ${CMAKE_CURRENT_LIST_DIR}/dnativesettings.h + ${CMAKE_CURRENT_LIST_DIR}/dopenglpaintdevice.h + ${CMAKE_CURRENT_LIST_DIR}/dxcbxsettings.h + ${CMAKE_CURRENT_LIST_DIR}/global.h + ${CMAKE_CURRENT_LIST_DIR}/vtablehook.h + ${CMAKE_CURRENT_LIST_DIR}/dplatformsettings.h + ${CMAKE_CURRENT_LIST_DIR}/ddesktopinputselectioncontrol.h + ${CMAKE_CURRENT_LIST_DIR}/dinputselectionhandle.h + ${CMAKE_CURRENT_LIST_DIR}/dapplicationeventmonitor.h + ${CMAKE_CURRENT_LIST_DIR}/dselectedtexttooltip.h +) +list(APPEND GLOBAL_SOURCES + ${CMAKE_CURRENT_LIST_DIR}/dbackingstoreproxy.cpp + ${CMAKE_CURRENT_LIST_DIR}/dnativesettings.cpp + ${CMAKE_CURRENT_LIST_DIR}/dopenglpaintdevice.cpp + ${CMAKE_CURRENT_LIST_DIR}/dxcbxsettings.cpp + ${CMAKE_CURRENT_LIST_DIR}/global.cpp + ${CMAKE_CURRENT_LIST_DIR}/vtablehook.cpp + ${CMAKE_CURRENT_LIST_DIR}/dplatformsettings.cpp + ${CMAKE_CURRENT_LIST_DIR}/ddesktopinputselectioncontrol.cpp + ${CMAKE_CURRENT_LIST_DIR}/dinputselectionhandle.cpp + ${CMAKE_CURRENT_LIST_DIR}/dapplicationeventmonitor.cpp + ${CMAKE_CURRENT_LIST_DIR}/dselectedtexttooltip.cpp +) + +include_directories(${CMAKE_CURRENT_LIST_DIR}) diff --git a/wayland/CMakeLists.txt b/wayland/CMakeLists.txt new file mode 100644 index 00000000..baaed46f --- /dev/null +++ b/wayland/CMakeLists.txt @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: LGPL-3.0-or-later + +add_subdirectory(dwayland) +add_subdirectory(wayland-shell) diff --git a/wayland/dwayland/CMakeLists.txt b/wayland/dwayland/CMakeLists.txt new file mode 100644 index 00000000..ef493585 --- /dev/null +++ b/wayland/dwayland/CMakeLists.txt @@ -0,0 +1,54 @@ +# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: LGPL-3.0-or-later + +project(dwayland) + +find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui WaylandClient XkbCommonSupport) + +add_definitions(-DQT5DWAYLANDPLUGIN_LIBRARY -DQT_DEPRECATED_WARNINGS) + +file(GLOB GLOBAL_HEADERS + ${CMAKE_CURRENT_LIST_DIR}/*.h + ${CMAKE_SOURCE_DIR}/src/global.h + ${CMAKE_SOURCE_DIR}/src/vtablehook.h + ${CMAKE_SOURCE_DIR}/src/dxcbxsettings.h + ${CMAKE_SOURCE_DIR}/src/dplatformsettings.h + ${CMAKE_SOURCE_DIR}/src/dnativesettings.h +) +file(GLOB GLOBAL_SOURCES + ${CMAKE_CURRENT_LIST_DIR}/*.cpp + ${CMAKE_SOURCE_DIR}/src/global.cpp + ${CMAKE_SOURCE_DIR}/src/vtablehook.cpp + ${CMAKE_SOURCE_DIR}/src/dxcbxsettings.cpp + ${CMAKE_SOURCE_DIR}/src/dplatformsettings.cpp + ${CMAKE_SOURCE_DIR}/src/dnativesettings.cpp +) + +set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/plugins/platforms) + +add_library(${PROJECT_NAME} MODULE main.cpp ${GLOBAL_SOURCES} ${GLOBAL_HEADERS}) + +target_compile_definitions(${PROJECT_NAME} +PRIVATE + QT5DWAYLANDPLUGIN_LIBRARY + QT_DEPRECATED_WARNINGS +) + +target_include_directories(${PROJECT_NAME} +PRIVATE + ${CMAKE_SOURCE_DIR}/src +) + +target_link_libraries(${PROJECT_NAME} +PRIVATE + Qt5::Core + Qt5::GuiPrivate + Qt5::XkbCommonSupportPrivate + Qt5::WaylandClientPrivate +) + +if(NOT INSTALL_PATH) + set(INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/qt5/plugins/platforms) +endif() +install(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_PATH}) diff --git a/wayland/dwayland/dwayland.pro b/wayland/dwayland/dwayland.pro deleted file mode 100644 index 7431bffe..00000000 --- a/wayland/dwayland/dwayland.pro +++ /dev/null @@ -1,78 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2020-04-29T13:23:01 -# -#------------------------------------------------- - -TARGET = dwayland -TEMPLATE = lib - -CONFIG += link_pkgconfig plugin -PKGCONFIG += Qt5WaylandClient - -# Qt >= 5.8 -greaterThan(QT_MINOR_VERSION, 7): QT += gui-private -else: QT += platformsupport-private - -DESTDIR = $$_PRO_FILE_PWD_/../../bin/plugins/platforms - -DEFINES += QT5DWAYLANDPLUGIN_LIBRARY - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -isEmpty(VERSION) { - isEmpty(VERSION): VERSION = $$system(git describe --tags --abbrev=0) - VERSION = $$replace(VERSION, [^0-9.],) - isEmpty(VERSION): VERSION = 1.1.11 -} - -SOURCES += \ - $$PWD/dwaylandinterfacehook.cpp \ - $$PWD/main.cpp \ - $$PWD/dwaylandintegration.cpp \ - $$PWD/dnotitlebarwindowhelper_wl.cpp \ - $$PWD/dhighdpi.cpp \ - $$PWD/dxsettings.cpp \ - $$PWD/../../src/global.cpp \ - $$PWD/../../src/vtablehook.cpp \ - $$PWD/../../src/dxcbxsettings.cpp \ - $$PWD/../../src/dplatformsettings.cpp \ - $$PWD/../../src/dnativesettings.cpp - -HEADERS += \ - $$PWD/dwaylandinterfacehook.h \ - $$PWD/dwaylandintegration.h \ - $$PWD/dnotitlebarwindowhelper_wl.h \ - $$PWD/dhighdpi.h \ - $$PWD/dxsettings.h \ - $$PWD/../../src/global.h \ - $$PWD/../../src/vtablehook.h \ - $$PWD/../../src/dxcbxsettings.h \ - $$PWD/../../src/dplatformsettings.h \ - $$PWD/../../src/dnativesettings.h - - -qtHaveModule(waylandclient_private) : QT += waylandclient_private -else: INCLUDEPATH += $$PWD/../qtwayland-dev - -INCLUDEPATH += ../../src - -OTHER_FILES += \ - dwayland.json - -isEmpty(INSTALL_PATH) { - target.path = $$[QT_INSTALL_PLUGINS]/platforms -} else { - target.path = $$INSTALL_PATH -} - -INSTALLS += target diff --git a/wayland/wayland-shell/CMakeLists.txt b/wayland/wayland-shell/CMakeLists.txt new file mode 100644 index 00000000..f3b6d63f --- /dev/null +++ b/wayland/wayland-shell/CMakeLists.txt @@ -0,0 +1,66 @@ +# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: LGPL-3.0-or-later + +project(kwayland-shell) + +find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Widgets XkbCommonSupport WaylandClient) + +include(wayland-shell.cmake) + +try_compile(DEEPIN_KWIN_TEST_COMPILE_RESULT ${CMAKE_CURRENT_BINARY_DIR}/deepin-kwin-test + ${CMAKE_CURRENT_LIST_DIR}/config.tests/deepin-kwin-test deepin-kwin-test) + +try_compile(WAYLAND_TEST_COMPILE_RESULT ${CMAKE_CURRENT_BINARY_DIR}/wayland_test + ${CMAKE_CURRENT_LIST_DIR}/config.tests/wayland_test wayland_test) + +if(WAYLAND_TEST_COMPILE_RESULT) + add_definitions(-DUSE_DEEPIN_WAYLAND) + set(GLOBAL_HEADERS + dwaylandshellmanager.h + dkeyboard.h + ${CMAKE_SOURCE_DIR}/src/global.h + ${CMAKE_SOURCE_DIR}/src/vtablehook.h + ) + set(GLOBAL_SOURCES + dwaylandshellmanager.cpp + dkeyboard.cpp + ${CMAKE_SOURCE_DIR}/src/global.cpp + ${CMAKE_SOURCE_DIR}/src/vtablehook.cpp + ) +else() + message(WARNING "QtWayland version incompatible") +endif() + +set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/plugins/wayland-shell-integration) + +add_library(${PROJECT_NAME} MODULE main.cpp ${GLOBAL_SOURCES} ${GLOBAL_HEADERS}) + +target_compile_definitions(${PROJECT_NAME} + PRIVATE + QT5DWAYLANDPLUGIN_LIBRARY + QT_DEPRECATED_WARNINGS +) + +if(DEEPIN_KWIN_TEST_COMPILE_RESULT) + target_compile_definitions(${PROJECT_NAME} PRIVATE D_DEEPIN_KWIN) +endif() + +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src) + +list(APPEND COMMON_LIBS + Qt5::Core + Qt5::Gui + Qt5::GuiPrivate + Qt5::Widgets + Qt5::WidgetsPrivate + Qt5::WaylandClient + Qt5::WaylandClientPrivate + Qt5::XkbCommonSupportPrivate +) +target_link_libraries(${PROJECT_NAME} ${COMMON_LIBS}) + +if(NOT INSTALL_PATH) + set(INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/qt5/plugins/wayland-shell-integration) +endif() +install(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_PATH}) diff --git a/wayland/wayland-shell/config.tests/deepin-kwin-test/CMakeLists.txt b/wayland/wayland-shell/config.tests/deepin-kwin-test/CMakeLists.txt new file mode 100644 index 00000000..6455b5d1 --- /dev/null +++ b/wayland/wayland-shell/config.tests/deepin-kwin-test/CMakeLists.txt @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: LGPL-3.0-or-later + +cmake_minimum_required(VERSION 3.10) + +project(deepin-kwin-test) + +set(REQUIRED_QT_VERSION 5.15.0) +find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS WaylandClient) + +include(../../wayland-shell.cmake) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(AUTOMOC_COMPILER_PREDEFINES ON) + +add_executable(${PROJECT_NAME} main.cpp) + +list(APPEND COMMON_LIBS + Qt5::WaylandClientPrivate +) +target_link_libraries(${PROJECT_NAME} PUBLIC ${COMMON_LIBS}) + +target_include_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR} +) diff --git a/wayland/wayland-shell/config.tests/deepin-kwin-test/deepin-kwin-test.pro b/wayland/wayland-shell/config.tests/deepin-kwin-test/deepin-kwin-test.pro deleted file mode 100644 index fbf1bef7..00000000 --- a/wayland/wayland-shell/config.tests/deepin-kwin-test/deepin-kwin-test.pro +++ /dev/null @@ -1,3 +0,0 @@ -CONFIG += qt -include(../../wayland_depends.pri) -SOURCES += main.cpp diff --git a/wayland/wayland-shell/config.tests/wayland_test/CMakeLists.txt b/wayland/wayland-shell/config.tests/wayland_test/CMakeLists.txt new file mode 100644 index 00000000..b7b9ba31 --- /dev/null +++ b/wayland/wayland-shell/config.tests/wayland_test/CMakeLists.txt @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: LGPL-3.0-or-later + +cmake_minimum_required(VERSION 3.10) + +project(wayland_test) + +set(REQUIRED_QT_VERSION 5.15.0) +find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui WaylandClient XkbCommonSupport) + +include(../../wayland-shell.cmake) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(AUTOMOC_COMPILER_PREDEFINES ON) + +add_executable(${PROJECT_NAME} main.cpp) + +list(APPEND COMMON_LIBS + Qt5::Core + Qt5::CorePrivate + Qt5::GuiPrivate + Qt5::WaylandClientPrivate + Qt5::XkbCommonSupportPrivate +) +target_link_libraries(${PROJECT_NAME} PUBLIC ${COMMON_LIBS}) + +target_include_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR} +) diff --git a/wayland/wayland-shell/config.tests/wayland_test/wayland_test.pro b/wayland/wayland-shell/config.tests/wayland_test/wayland_test.pro deleted file mode 100644 index 86c97be1..00000000 --- a/wayland/wayland-shell/config.tests/wayland_test/wayland_test.pro +++ /dev/null @@ -1,24 +0,0 @@ -TEMPLATE = app - -CONFIG += qt - -QT += core -QT += gui -QT += core-private -QT += gui-private -QT += waylandclient -QT += waylandclient-private - -TARGET = wayland_test - -include(../../wayland_depends.pri) - -CONFIG += link_pkgconfig -PKGCONFIG += Qt5WaylandClient -# xkb -QT += xkbcommon_support-private - -CONFIG += c++17 - -SOURCES += main.cpp - diff --git a/wayland/wayland-shell/main.cpp b/wayland/wayland-shell/main.cpp index 97fe1491..c2106efc 100644 --- a/wayland/wayland-shell/main.cpp +++ b/wayland/wayland-shell/main.cpp @@ -15,6 +15,7 @@ class QKWaylandShellIntegrationPlugin : public QWaylandShellIntegrationPlugin QWaylandShellIntegration *create(const QString &key, const QStringList ¶mList) override { Q_UNUSED(key); Q_UNUSED(paramList); + qWarning() << "shell is nullptr" << shellVersion; return nullptr; } }; @@ -127,8 +128,10 @@ QWaylandShellIntegration *QKWaylandShellIntegrationPlugin::create(const QString QString shellVersion = registry->hasInterface(Registry::Interface::XdgShellUnstableV6) ? "xdg-shell-v6" : "xdg-shell"; QWaylandShellIntegration *shell = wayland_integration->createShellIntegration(shellVersion); - if (!shell) + if (!shell) { + qInfo() << "Failed to create kwayland-shell and the shell is nullptr."; return nullptr; + } HookOverride(shell, &QWaylandShellIntegration::createShellSurface, DWaylandShellManager::createShellSurface); diff --git a/wayland/wayland-shell/wayland-shell.cmake b/wayland/wayland-shell/wayland-shell.cmake new file mode 100644 index 00000000..9e31fc9d --- /dev/null +++ b/wayland/wayland-shell/wayland-shell.cmake @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: LGPL-3.0-or-later + +find_package(DWayland) +if(DWayland_FOUND) + add_definitions(-DD_DEEPIN_IS_DWAYLAND) + set(COMMON_LIBS Deepin::WaylandClient) + message("Using the DWayland module") +else() + find_package(KF5Wayland REQUIRED) + set(COMMON_LIBS KF5::WaylandClient) + message("Using the KF5Wayland module") +endif() diff --git a/wayland/wayland-shell/wayland-shell.pro b/wayland/wayland-shell/wayland-shell.pro deleted file mode 100644 index 0f6a1929..00000000 --- a/wayland/wayland-shell/wayland-shell.pro +++ /dev/null @@ -1,83 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2020-04-29T13:23:01 -# -#------------------------------------------------- - -include(wayland_depends.pri) - -# qtCompileTest 容易失败,加 recheck 更新缓存 -CONFIG += link_pkgconfig plugin recheck -PKGCONFIG += Qt5WaylandClient - -# Qt >= 5.8 -greaterThan(QT_MINOR_VERSION, 7): QT += gui-private widgets-private -else: QT += platformsupport-private - -# xkb -QT += xkbcommon_support-private - -TARGET = kwayland-shell -TEMPLATE = lib - -load(configure) -qtCompileTest(deepin-kwin-test) { - DEFINES += D_DEEPIN_KWIN -} - -DESTDIR = $$_PRO_FILE_PWD_/../../bin/plugins/wayland-shell-integration -DEFINES += QT5DWAYLANDPLUGIN_LIBRARY - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -isEmpty(VERSION) { - isEmpty(VERSION): VERSION = $$system(git describe --tags --abbrev=0) - VERSION = $$replace(VERSION, [^0-9.],) - isEmpty(VERSION): VERSION = 1.1.11 -} - -qtCompileTest(wayland_test) { - DEFINES += USE_DEEPIN_WAYLAND - SOURCES += \ - $$PWD/dwaylandshellmanager.cpp \ - $$PWD/dkeyboard.cpp \ - $$PWD/../../src/global.cpp \ - $$PWD/../../src/vtablehook.cpp - - HEADERS += \ - $$PWD/qt5dwayland-plugin_global.h \ - $$PWD/dwaylandshellmanager.h \ - $$PWD/dkeyboard.h \ - $$PWD/../../src/global.h \ - $$PWD/../../src/vtablehook.h -} else { - warning("QtWayland version incompatible") -} - -SOURCES += \ - $$PWD/main.cpp \ - -qtHaveModule(waylandclient-private) : QT += waylandclient-private -else: INCLUDEPATH += $$PWD/../qtwayland-dev - -INCLUDEPATH += ../../src - -OTHER_FILES += \ - kwayland-shell.json - -isEmpty(INSTALL_PATH) { - target.path = $$[QT_INSTALL_PLUGINS]/wayland-shell-integration -} else { - target.path = $$INSTALL_PATH -} - -INSTALLS += target diff --git a/wayland/wayland-shell/wayland_depends.pri b/wayland/wayland-shell/wayland_depends.pri deleted file mode 100644 index f2a4a090..00000000 --- a/wayland/wayland-shell/wayland_depends.pri +++ /dev/null @@ -1,11 +0,0 @@ -qtHaveModule(DWaylandClient) { - QT += DWaylandClient - LIBS += -lDWaylandClient - - DEFINES += D_DEEPIN_IS_DWAYLAND -} else { -qtHaveModule(KWaylandClient) { - QT += KWaylandClient - LIBS += -lKF5WaylandClient -} -} diff --git a/wayland/wayland.pro b/wayland/wayland.pro deleted file mode 100644 index 6b2bdb91..00000000 --- a/wayland/wayland.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS += \ - wayland-shell/wayland-shell.pro \ - dwayland/dwayland.pro diff --git a/xcb/CMakeLists.txt b/xcb/CMakeLists.txt new file mode 100644 index 00000000..d8575ab6 --- /dev/null +++ b/xcb/CMakeLists.txt @@ -0,0 +1,59 @@ +# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: LGPL-3.0-or-later + +project(dxcb) + +find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Widgets DBus XcbQpa X11Extras EdidSupport XkbCommonSupport) + +# NOTE(sbw): 禁止语法树上的 vrp 优化,-O2/-O3 默认开启,会导致测试虚析构函数 HOOK 失败 +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-tree-vrp" CACHE STRING "disable vrp optimization" FORCE) + +add_definitions(-DDXCB_VERSION=\"${VERSION}\") +if(CMAKE_BUILD_TYPE STREQUAL "Release") + add_definitions(-DQT_NO_DEBUG_OUTPUT=true) +endif() +file(GLOB GLOBAL_HEADERS ${CMAKE_CURRENT_LIST_DIR}/*.h) +file(GLOB GLOBAL_SOURCES ${CMAKE_CURRENT_LIST_DIR}/*.cpp ${CMAKE_CURRENT_LIST_DIR}/3rdparty/*.c) +file(GLOB RCC_QRCS ${CMAKE_CURRENT_LIST_DIR}/cursors/cursor.qrc) +add_definitions(-DUSE_NEW_IMPLEMENTING) +set(USE_NEW_IMPLEMENTING TRUE) +if (USE_NEW_IMPLEMENTING) + list(REMOVE_ITEM GLOBAL_HEADERS + ${CMAKE_CURRENT_LIST_DIR}/dplatformbackingstore.h + ${CMAKE_CURRENT_LIST_DIR}/dplatformwindowhook.h) + list(REMOVE_ITEM GLOBAL_SOURCES + ${CMAKE_CURRENT_LIST_DIR}/dplatformbackingstore.cpp + ${CMAKE_CURRENT_LIST_DIR}/dplatformwindowhook.cpp) +endif() + +include(${CMAKE_SOURCE_DIR}/src/src.cmake) + +qt5_add_dbus_interface(DBUS_INTERFACE_XMLS ${CMAKE_SOURCE_DIR}/misc/com.deepin.im.xml im_interface) +qt5_add_dbus_interface(DBUS_INTERFACE_XMLS ${CMAKE_SOURCE_DIR}/misc/org.freedesktop.DBus.xml dbus_interface) + +set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/plugins/platforms) + +add_library(${PROJECT_NAME} MODULE ${GLOBAL_SOURCES} ${GLOBAL_HEADERS} ${RCC_QRCS} ${DBUS_INTERFACE_XMLS}) + +include(${CMAKE_CURRENT_LIST_DIR}/linux.cmake) + +target_link_libraries(${PROJECT_NAME} +PRIVATE + Qt5::Core + Qt5::CorePrivate + Qt5::Gui + Qt5::GuiPrivate + Qt5::Widgets + Qt5::XcbQpa + Qt5::EdidSupport + Qt5::EdidSupportPrivate + Qt5::XkbCommonSupport + Qt5::XkbCommonSupportPrivate + Qt5::X11Extras +) + +if(NOT INSTALL_PATH) + set(INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/qt5/plugins/platforms) +endif() +install(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_PATH}) diff --git a/xcb/linux.cmake b/xcb/linux.cmake new file mode 100644 index 00000000..d367d26c --- /dev/null +++ b/xcb/linux.cmake @@ -0,0 +1,68 @@ +# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: LGPL-3.0-or-later + +find_package(PkgConfig REQUIRED) + +pkg_check_modules( + XCB + REQUIRED IMPORTED_TARGET + x11-xcb + xi + xcb-renderutil + sm + ice + xcb-render + dbus-1 + xcb + xcb-image + xcb-icccm + xcb-sync + xcb-xfixes + xcb-shm + xcb-randr + xcb-shape + xcb-keysyms + xcb-xkb + xcb-composite + xkbcommon-x11 + xcb-damage + xcb-xinerama + mtdev + egl +) +target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::XCB) + +# Don't link cairo library +pkg_check_modules(CAIRO REQUIRED IMPORTED_TARGET cairo) +target_include_directories(${PROJECT_NAME} PRIVATE ${CAIRO_INCLUDE_DIRS}) + +get_property(QT_ENABLED_PRIVATE_FEATURES TARGET Qt5::Gui PROPERTY QT_ENABLED_PRIVATE_FEATURES) + +macro(try_add_defines feature defines) + list(FIND QT_ENABLED_PRIVATE_FEATURES ${feature} index) + if (index GREATER 0) + add_definitions(${defines}) + endif() +endmacro() + +try_add_defines("xcb-xlib" "-DXCB_USE_XLIB -DXCB_USE_XINPUT2 -DXCB_USE_XINPUT21 -DXCB_USE_XINPUT22") +try_add_defines("xcb-sm" "-DXCB_USE_SM") +try_add_defines("xcb-qt" "-DXCB_USE_RENDER") + +list(FIND QT_ENABLED_PRIVATE_FEATURES "system-xcb" index) +if (index GREATER 0) + try_add_defines("xcb-render" "-DXCB_USE_RENDER") + try_add_defines("xkb" "-DXCB_USE_RENDER") +else() + add_definitions(-DXCB_USE_RENDER) +endif() + +list(GET Qt5Core_INCLUDE_DIRS 0 dir) +if(EXISTS ${dir}QtXcb/${Qt5_VERSION}/QtXcb/private) + include_directories(${dir}QtXcb/${Qt5_VERSION}/QtXcb/private) +elseif(EXISTS ${CMAKE_CURRENT_LIST_DIR}/libqt5xcbqpa-dev/${Qt5_VERSION}) + include_directories(${CMAKE_CURRENT_LIST_DIR}/libqt5xcbqpa-dev/${Qt5_VERSION}) +else() + message(FATAL_ERROR "Not support Qt Version: ${Qt5_VERSION}") +endif() diff --git a/xcb/linux.pri b/xcb/linux.pri deleted file mode 100644 index 9873e82a..00000000 --- a/xcb/linux.pri +++ /dev/null @@ -1,105 +0,0 @@ -TARGET = dxcb -CONFIG += link_pkgconfig - -PKGCONFIG += x11-xcb xi xcb-renderutil sm ice xcb-render dbus-1 xcb\ - xcb-image xcb-icccm xcb-sync xcb-xfixes xcb-shm xcb-randr\ - xcb-shape xcb-keysyms xcb-xkb xcb-composite xkbcommon-x11\ - xcb-damage mtdev egl - -# Don't link cairo library -QMAKE_CXXFLAGS += $$system(pkg-config --cflags-only-I cairo) - -greaterThan(QT_MINOR_VERSION, 5): PKGCONFIG += xcb-xinerama - -#LIBS += -ldl - -greaterThan(QT_MINOR_VERSION, 4): LIBS += -lQt5XcbQpa - -HEADERS += \ - $$PWD/windoweventhook.h \ - $$PWD/xcbnativeeventfilter.h \ - $$PWD/dxcbwmsupport.h - -SOURCES += \ - $$PWD/windoweventhook.cpp \ - $$PWD/xcbnativeeventfilter.cpp \ - $$PWD/utility_x11.cpp \ - $$PWD/dxcbwmsupport.cpp \ - $$PWD/dforeignplatformwindow_x11.cpp - -contains(QT_CONFIG, xcb-xlib)|qtConfig(xcb-xlib) { - DEFINES += XCB_USE_XLIB - QMAKE_USE += xcb_xlib - - greaterThan(QT_MINOR_VERSION, 14) { - DEFINES += XCB_USE_XINPUT2 XCB_USE_XINPUT21 XCB_USE_XINPUT22 - QMAKE_USE += xcb_xinput - - !isEmpty(QMAKE_LIBXI_VERSION_MAJOR) { - DEFINES += LIBXI_MAJOR=$$QMAKE_LIBXI_VERSION_MAJOR \ - LIBXI_MINOR=$$QMAKE_LIBXI_VERSION_MINOR \ - LIBXI_PATCH=$$QMAKE_LIBXI_VERSION_PATCH - } - } else { - greaterThan(QT_MINOR_VERSION, 11) { - contains(QT_CONFIG, xcb-xinput)|qtConfig(xcb-xinput) { - DEFINES += XCB_USE_XINPUT2 XCB_USE_XINPUT21 XCB_USE_XINPUT22 - QMAKE_USE += xcb_xinput - - !isEmpty(QMAKE_LIBXI_VERSION_MAJOR) { - DEFINES += LIBXI_MAJOR=$$QMAKE_LIBXI_VERSION_MAJOR \ - LIBXI_MINOR=$$QMAKE_LIBXI_VERSION_MINOR \ - LIBXI_PATCH=$$QMAKE_LIBXI_VERSION_PATCH - } - } - } else { - contains(QT_CONFIG, xinput2)|qtConfig(xinput2) { - DEFINES += XCB_USE_XINPUT2 - QMAKE_USE += xinput2 - - !isEmpty(QMAKE_LIBXI_VERSION_MAJOR) { - DEFINES += LIBXI_MAJOR=$$QMAKE_LIBXI_VERSION_MAJOR \ - LIBXI_MINOR=$$QMAKE_LIBXI_VERSION_MINOR \ - LIBXI_PATCH=$$QMAKE_LIBXI_VERSION_PATCH - } - } - } - } -} - -# build with session management support -contains(QT_CONFIG, xcb-sm)|qtConfig(xcb-sm) { - DEFINES += XCB_USE_SM - QMAKE_USE += x11sm -} - -!contains(QT_CONFIG, system-xcb)|qtConfig(system-xcb) { - DEFINES += XCB_USE_RENDER - QMAKE_USE += xcb -} else { - LIBS += -lxcb-xinerama ### there is no configure test for this! - contains(QT_CONFIG, xkb)|qtConfig(xkb): QMAKE_USE += xcb_xkb - # to support custom cursors with depth > 1 - contains(QT_CONFIG, xcb-render)|qtConfig(xkb) { - DEFINES += XCB_USE_RENDER - QMAKE_USE += xcb_render - } - QMAKE_USE += xcb_syslibs -} - -contains(QT_CONFIG, xcb-qt) { - DEFINES += XCB_USE_RENDER -} - -!isEmpty(QT_XCB_PRIVATE_INCLUDE) { - INCLUDEPATH += $$QT_XCB_PRIVATE_INCLUDE -} else:exists($$PWD/libqt5xcbqpa-dev/$$QT_VERSION) { - INCLUDEPATH += $$PWD/libqt5xcbqpa-dev/$$QT_VERSION -} else:exists($$[QT_INSTALL_HEADERS]/QtXcb/$$[QT_VERSION]) { - INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtXcb/$$[QT_VERSION]/QtXcb/private -} else { - error(Not support Qt Version: $$QT_VERSION) -} - -INCLUDEPATH += $$PWD/../xcb -include($$_PRO_FILE_PWD_/../src/src.pri) diff --git a/xcb/windows.pri b/xcb/windows.pri deleted file mode 100644 index e69de29b..00000000 diff --git a/xcb/xcb.pro b/xcb/xcb.pro deleted file mode 100644 index 47eb001f..00000000 --- a/xcb/xcb.pro +++ /dev/null @@ -1,109 +0,0 @@ - -# NOTE(sbw): 禁止语法树上的 vrp 优化,-O2/-O3 默认开启,会导致测试虚析构函数 HOOK 失败 -QMAKE_CXXFLAGS_RELEASE += -fno-tree-vrp - -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = DXcbIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - - -DESTDIR = $$_PRO_FILE_PWD_/../bin/plugins/platforms - -QT += opengl x11extras dbus -QT += core-private #xcb_qpa_lib-private -greaterThan(QT_MAJOR_VERSION, 4) { - # Qt >= 5.8 - greaterThan(QT_MINOR_VERSION, 7): QT += gui-private - else: QT += platformsupport-private - - # Qt >= 5.10 - greaterThan(QT_MINOR_VERSION, 9): QT += edid_support-private - - # Qt >= 5.13 - greaterThan(QT_MINOR_VERSION, 12): QT += xkbcommon_support-private -} - -TEMPLATE = lib - -isEmpty(VERSION) { - isEmpty(VERSION): VERSION = $$system(git describe --tags --abbrev=0) - VERSION = $$replace(VERSION, [^0-9.],) - isEmpty(VERSION): VERSION = 1.1.11 -} - -DEFINES += DXCB_VERSION=\\\"$$VERSION\\\" - -linux: include($$PWD/linux.pri) -windows: include($$PWD/windows.pri) - -CONFIG += plugin c++11 - -SOURCES += \ - $$PWD/main.cpp \ - $$PWD/dplatformintegration.cpp \ - $$PWD/dplatformnativeinterfacehook.cpp \ - dhighdpi.cpp \ - dnotitlebarwindowhelper.cpp \ - 3rdparty/dsimple.c \ - 3rdparty/clientwin.c \ - $$PWD/dplatforminputcontexthook.cpp - -HEADERS += \ - $$PWD/dplatformintegration.h \ - $$PWD/utility.h \ - $$PWD/dplatformnativeinterfacehook.h \ - $$PWD/dforeignplatformwindow.h \ - $$PWD/dwmsupport.h \ - dhighdpi.h \ - dnotitlebarwindowhelper.h \ - 3rdparty/dsimple.h \ - 3rdparty/clientwin.h \ - $$PWD/dplatforminputcontexthook.h - -INCLUDEPATH += $$PWD/../src - -DISTFILES += \ - $$PWD/dpp.json - -isEmpty(INSTALL_PATH) { - target.path = $$[QT_INSTALL_PLUGINS]/platforms -} else { - target.path = $$INSTALL_PATH -} - -DBUS_INTERFACES += ../misc/com.deepin.im.xml -DBUS_INTERFACES += ../misc/org.freedesktop.DBus.xml - -message($$target.path) - -INSTALLS += target - -CONFIG(release, debug|release) { - DEFINES += QT_NO_DEBUG_OUTPUT USE_NEW_IMPLEMENTING -} else { - DEFINES += USE_NEW_IMPLEMENTING -} - -contains(DEFINES, USE_NEW_IMPLEMENTING) { - SOURCES += \ - $$PWD/dframewindow.cpp \ - $$PWD/dplatformwindowhelper.cpp \ - $$PWD/dplatformbackingstorehelper.cpp \ - $$PWD/dplatformopenglcontexthelper.cpp - - HEADERS += \ - $$PWD/dframewindow.h \ - $$PWD/dplatformwindowhelper.h \ - $$PWD/dplatformbackingstorehelper.h \ - $$PWD/dplatformopenglcontexthelper.h -} else { - SOURCES += \ - $$PWD/dplatformbackingstore.cpp \ - $$PWD/dplatformwindowhook.cpp - - HEADERS += \ - $$PWD/dplatformbackingstore.h \ - $$PWD/dplatformwindowhook.h -} - -RESOURCES += \ - cursors/cursor.qrc