Skip to content

Commit ff34942

Browse files
committed
fix: cannot build on Archlinux
dock use some only deepin of qt api. Log:
1 parent 9bda8c8 commit ff34942

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,35 @@ include(DDEShellPackageMacros)
5252
include(KDEClangFormat)
5353
include(KDEGitCommitHooks)
5454

55-
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Concurrent Quick WaylandClient DBus LinguistTools Sql)
55+
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Concurrent Quick WaylandClient WaylandCompositor DBus LinguistTools Sql)
5656
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui)
5757
find_package(ICU 74.2 REQUIRED COMPONENTS uc i18n io)
5858
find_package(WaylandProtocols REQUIRED)
5959
find_package(PkgConfig REQUIRED)
6060

61+
set(TEST_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/test_deepin_qt.cpp")
62+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/check/main.cpp ${TEST_SOURCE} COPYONLY)
63+
64+
try_compile(COMPILE_RESULT
65+
${CMAKE_CURRENT_BINARY_DIR}/try_compile_build # Build directory
66+
SOURCES ${TEST_SOURCE} # Test source file
67+
LINK_LIBRARIES
68+
Qt${QT_VERSION_MAJOR}::WaylandCompositorPrivate
69+
Qt${QT_VERSION_MAJOR}::WaylandCompositor
70+
COMPILE_DEFINITIONS
71+
-DQT_WAYLANDCOMPOSITOR_LIB
72+
-DQT_WAYLANDCOMPOSITORPRIVATE_LIB
73+
-DQT_WAYLANDCOMPOSITOR_IMPLEMENTATION
74+
OUTPUT_VARIABLE compile_output
75+
)
76+
77+
if(COMPILE_RESULT)
78+
message(STATUS "Deepin Qt detected (try_compile success)")
79+
add_definitions(-DUSE_DEEPIN_QT)
80+
else()
81+
message(STATUS "Deepin Qt not detected")
82+
endif()
83+
6184
add_subdirectory(frame)
6285
add_subdirectory(shell)
6386
add_subdirectory(example)

panels/dock/pluginmanagerextension.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
#include <private/qwaylandcompositor_p.h>
2323
#undef protected
2424
#include <qpa/qwindowsysteminterface_p.h>
25+
26+
#ifdef USE_DEEPIN_QT
2527
#include <private/qwlqtkey_p.h>
2628
#include <private/qwlqttouch_p.h>
29+
#endif
2730

2831
DGUI_USE_NAMESPACE
2932

@@ -418,11 +421,14 @@ void PluginManager::initialize()
418421
QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(eventHandler);
419422
}
420423

424+
// TODO: Use built-in protocol instead of qt
425+
#ifdef USE_DEEPIN_QT
421426
// 只创建就行
422427
auto qtKey = new QtWayland::QtKeyExtensionGlobal(compositor);
423428
qtKey->setParent(compositor);
424429
auto qtTouch = new QtWayland::TouchExtensionGlobal(compositor);
425430
qtTouch->setParent(compositor);
431+
#endif
426432

427433
init(compositor->display(), 1);
428434
}

tests/check/main.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <QtWaylandCompositor/QWaylandSurface>
2+
#include <QtWaylandCompositor/QWaylandResource>
3+
#include <QtWaylandCompositor/QWaylandCompositor>
4+
5+
#define protected public
6+
#include <private/qwaylandcompositor_p.h>
7+
#undef protected
8+
#include <private/qwlqtkey_p.h>
9+
#include <private/qwlqttouch_p.h>
10+
11+
int main (int argc, char *argv[]) {
12+
new QtWayland::QtKeyExtensionGlobal(nullptr);
13+
return 0;
14+
}

0 commit comments

Comments
 (0)