Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkgui
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkgui.

Source-pull-request: linuxdeepin/dtkgui#262
  • Loading branch information
deepin-ci-robot authored and mhduiy committed Oct 24, 2024
1 parent f267726 commit 7ef9e99
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ include(kernel/kernel.cmake)
include(private/private.cmake)
include(util/util.cmake)

try_compile(DEEPIN_WAYLAND_TEST_COMPILE_RESULT ${CMAKE_CURRENT_BINARY_DIR}/wayland_test
${CMAKE_CURRENT_LIST_DIR}/wayland/config.tests/wayland_test wayland_test CMAKE_FLAGS -DQT_VERSION_MAJOR=${QT_VERSION_MAJOR})

if(NOT DEEPIN_WAYLAND_TEST_COMPILE_RESULT)
message("wayland_test failed, disable treeland support")
set(DTK_DISABLE_TREELAND ON)
endif()

if(NOT DTK_DISABLE_TREELAND AND TreeLandProtocols_FOUND)
message("Support Treeland!")
if("${QT_VERSION_MAJOR}" STREQUAL "6")
Expand All @@ -28,7 +36,7 @@ if(NOT DTK_DISABLE_TREELAND AND TreeLandProtocols_FOUND)
find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${ECM_MODULE_PATH}")
find_package(QtWaylandScanner)
ecm_add_qtwayland_client_protocol(${LIB_NAME}
ecm_add_qtwayland_client_protocol(CLIENT_LIB_SRCS
PROTOCOL ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-personalization-manager-v1.xml
BASENAME treeland-personalization-manager-v1
)
Expand Down
54 changes: 54 additions & 0 deletions src/wayland/config.tests/wayland_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: LGPL-3.0-or-later

cmake_minimum_required(VERSION 3.16)

project(wayland_test)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(AUTOMOC_COMPILER_PREDEFINES ON)

find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui WaylandClient)
if(${QT_VERSION_MAJOR} STREQUAL "5")
find_package(Qt5 REQUIRED COMPONENTS XkbCommonSupport)
endif()

find_package(PkgConfig REQUIRED)
pkg_check_modules(WAYLAND_CLIENT REQUIRED wayland-client)

find_package(TreeLandProtocols)
set(TreeLandProtocols_FOUND ${TreeLandProtocols_FOUND})

add_executable(${PROJECT_NAME} main.cpp)

if("${QT_VERSION_MAJOR}" STREQUAL "6")
qt6_generate_wayland_protocol_client_sources(${PROJECT_NAME} FILES
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-personalization-manager-v1.xml
)
else()
# ECM setup
include(FeatureSummary)
find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${ECM_MODULE_PATH}")
find_package(QtWaylandScanner)
ecm_add_qtwayland_client_protocol(TABLET_SRCS
PROTOCOL ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-personalization-manager-v1.xml
BASENAME treeland-personalization-manager-v1
)
target_sources(${PROJECT_NAME} PRIVATE ${TABLET_SRCS})

target_link_libraries(${PROJECT_NAME} PRIVATE
Qt${QT_VERSION_MAJOR}::XkbCommonSupportPrivate
)
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::GuiPrivate
Qt${QT_VERSION_MAJOR}::CorePrivate
Qt${QT_VERSION_MAJOR}::WaylandClientPrivate
${WAYLAND_CLIENT_LIBRARIES}
)
36 changes: 36 additions & 0 deletions src/wayland/config.tests/wayland_test/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include <QGuiApplication>

#include <QtWaylandClient/QWaylandClientExtension>
#include <QtWaylandClient/private/qwaylandsurface_p.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>

#include <wayland-client-core.h>
#include "qwayland-treeland-personalization-manager-v1.h"
#include <qwaylandclientextension.h>

#include <private/qguiapplication_p.h>
#include <private/qwaylandintegration_p.h>
#include <private/qwaylandwindow_p.h>
#include <private/qwaylanddisplay_p.h>

class PersonalizationWindowContext : public QWaylandClientExtensionTemplate<PersonalizationWindowContext>,
public QtWayland::treeland_personalization_window_context_v1
{
public:
PersonalizationWindowContext(struct ::treeland_personalization_window_context_v1 *context)
: QWaylandClientExtensionTemplate<PersonalizationWindowContext>(1)
, QtWayland::treeland_personalization_window_context_v1(context)
{
set_titlebar(enable_mode::enable_mode_disable);
}
};

int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
return 0;
}
2 changes: 1 addition & 1 deletion src/wayland/personalizationwaylandclientextension.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "personalizationwaylandclientextension.h"

Expand Down
2 changes: 1 addition & 1 deletion src/wayland/personalizationwaylandclientextension.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-License-Identifier: LGPL-3.0-or-later

#include <QtWaylandClient/QWaylandClientExtension>

Expand Down

0 comments on commit 7ef9e99

Please sign in to comment.