Skip to content

Commit

Permalink
Refactor tinywl-qtquick example
Browse files Browse the repository at this point in the history
A lot of codes move from qml to Qt/C++, the qml codes only do animation or create GUI items.

--------- Other developers:

Signed-off-by: pengwenhao <[email protected]>
Co-authored-by: rewine <[email protected]>
Co-authored-by: pengwenhao <[email protected]>
Co-authored-by: Lu YaNing <[email protected]>
Co-authored-by: groveer <[email protected]>
  • Loading branch information
5 people authored Oct 15, 2024
1 parent 4516c38 commit 0663991
Show file tree
Hide file tree
Showing 95 changed files with 6,728 additions and 3,396 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ compile_commands.json
# qtcreator
*.autosave

# vscode
.vscode
1 change: 1 addition & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ License: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

# Misc
Files: tests/manual/cursor/res/HandCursor.png
examples/tinywl/res/xx.jpg
Copyright: None
License: CC0-1.0
45 changes: 22 additions & 23 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,39 @@ Source: waylib
Section: libdevel
Priority: optional
Maintainer: JiDe Zhang <[email protected]>
Build-Depends: debhelper (>= 9),
cmake,
pkg-config,
qt6-base-private-dev (>= 6.4.0),
qt6-base-dev-tools (>= 6.4.0),
qt6-declarative-private-dev (>= 6.4.0),
qml6-module-qtquick-templates,
qwlroots,
libwlroots-dev (>= 0.17.0),
libpixman-1-dev,
libxcb-ewmh-dev,
wayland-protocols,
wlr-protocols
Build-Depends: cmake,
debhelper (>= 9),
libpixman-1-dev,
libwlroots-dev (>= 0.17.0),
libxcb-ewmh-dev,
pkg-config,
qml6-module-qtquick-templates,
qt6-base-dev-tools (>= 6.4.0),
qt6-base-private-dev (>= 6.4.0),
qt6-declarative-private-dev (>= 6.4.0),
qwlroots,
wayland-protocols,
wlr-protocols,
Standards-Version: 3.9.8

Package: libwaylib
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Depends: ${misc:Depends}, ${shlibs:Depends},
Multi-Arch: same
Description: A wrapper for wlroots based on Qt
.
This package contains the shared libraries.

Package: libwaylib-dev
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends},
libwaylib (=${binary:Version}),
qt6-base-private-dev (>= 6.6.0),
qt6-base-dev-tools (>= 6.6.0),
qt6-declarative-private-dev (>= 6.6.0),
libwlroots-dev (>= 0.17.0),
wlr-protocols
Depends: libwaylib (=${binary:Version}),
libwlroots-dev (>= 0.17.0),
qt6-base-dev-tools (>= 6.6.0),
qt6-base-private-dev (>= 6.6.0),
qt6-declarative-private-dev (>= 6.6.0),
wlr-protocols,
${misc:Depends},
${shlibs:Depends},
Description: A devel package for libwaylib
.
This package contains the header files and static libraries of waylib.

4 changes: 2 additions & 2 deletions debian/libwaylib-dev.install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
usr/lib/*/lib*.so
usr/include
usr/lib/*/pkgconfig
usr/lib/*/cmake
usr/lib/*/lib*.so
usr/lib/*/pkgconfig
8 changes: 4 additions & 4 deletions examples/blur/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ Item {
cursorDelegate: Cursor {
id: cursorItem

required property QtObject outputCurosr
required property QtObject outputCursor
readonly property point position: parent.mapFromGlobal(cursor.position.x, cursor.position.y)

cursor: outputCurosr.cursor
output: outputCurosr.output.output
cursor: outputCursor.cursor
output: outputCursor.output.output
x: position.x - hotSpot.x
y: position.y - hotSpot.y
visible: valid && outputCurosr.visible
visible: valid && outputCursor.visible
OutputLayer.enabled: true
OutputLayer.keepLayer: true
OutputLayer.flags: OutputLayer.Cursor
Expand Down
8 changes: 4 additions & 4 deletions examples/outputcopy/PrimaryOutputDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ OutputItem {
cursorDelegate: Cursor {
id: cursorItem

required property QtObject outputCurosr
required property QtObject outputCursor
readonly property point position: parent.mapFromGlobal(cursor.position.x, cursor.position.y)

cursor: outputCurosr.cursor
output: outputCurosr.output.output
cursor: outputCursor.cursor
output: outputCursor.output.output
x: position.x - hotSpot.x
y: position.y - hotSpot.y
visible: valid && outputCurosr.visible
visible: valid && outputCursor.visible
OutputLayer.enabled: true
OutputLayer.keepLayer: true
OutputLayer.flags: OutputLayer.Cursor
Expand Down
3 changes: 1 addition & 2 deletions examples/outputcopy/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ int main(int argc, char *argv[]) {
QGuiApplication app(argc, argv);

QQmlApplicationEngine waylandEngine;
waylandEngine.loadFromModule("OutputCopy", "Main");

Helper *helper = waylandEngine.singletonInstance<Helper*>("OutputCopy", "Helper");
Q_ASSERT(helper);
Expand All @@ -222,7 +221,7 @@ int main(int argc, char *argv[]) {
qw_output *newOutput = nullptr;

if (auto x11 = qw_x11_backend::from(backend)) {
newOutput = qw_output::from(x11->output_create());
newOutput = qw_output::from(x11->output_create());
} else if (auto wayland = qw_wayland_backend::from(backend)) {
newOutput = qw_output::from(wayland->output_create());
}
Expand Down
8 changes: 4 additions & 4 deletions examples/outputviewport/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ Item {
cursorDelegate: Cursor {
id: cursorItem

required property QtObject outputCurosr
required property QtObject outputCursor
readonly property point position: parent.mapFromGlobal(cursor.position.x, cursor.position.y)

cursor: outputCurosr.cursor
output: outputCurosr.output.output
cursor: outputCursor.cursor
output: outputCursor.output.output
x: position.x - hotSpot.x
y: position.y - hotSpot.y
visible: valid && outputCurosr.visible
visible: valid && outputCursor.visible
OutputLayer.enabled: true
OutputLayer.keepLayer: true
OutputLayer.flags: OutputLayer.Cursor
Expand Down
8 changes: 4 additions & 4 deletions examples/surface-delegate/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ Item {
cursorDelegate: Cursor {
id: cursorItem

required property QtObject outputCurosr
required property QtObject outputCursor
readonly property point position: parent.mapFromGlobal(cursor.position.x, cursor.position.y)

cursor: outputCurosr.cursor
output: outputCurosr.output.output
cursor: outputCursor.cursor
output: outputCursor.output.output
x: position.x - hotSpot.x
y: position.y - hotSpot.y
visible: valid && outputCurosr.visible
visible: valid && outputCursor.visible
OutputLayer.enabled: true
OutputLayer.keepLayer: true
OutputLayer.flags: OutputLayer.Cursor
Expand Down
36 changes: 36 additions & 0 deletions examples/tinywl/Border.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (C) 2024 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

import QtQuick

Item {
id: root

property real radius: 0

Rectangle {
id: outsideBorder
anchors {
fill: parent
margins: -border.width
}

color: "transparent"
border {
color: "yellow"
width: 1
}
radius: root.radius + border.width
}

Rectangle {
id: insideBorder
anchors.fill: parent
color: "transparent"
border {
color: "green"
width: 1
}
radius: root.radius
}
}
71 changes: 42 additions & 29 deletions examples/tinywl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,72 @@ if(POLICY CMP0071)
cmake_policy(SET CMP0071 NEW)
endif()

set(QML_IMPORT_PATH "${PROJECT_BINARY_DIR}/src/server;${QML_IMPORT_PATH}" CACHE STRING "For LSP" FORCE)
set(QML_IMPORT_PATH ${CMAKE_BINARY_DIR}/src/server/ CACHE STRING "" FORCE)
option(START_DEMO "Start demo when boot" ON)

find_package(PkgConfig REQUIRED)
pkg_search_module(PIXMAN REQUIRED IMPORTED_TARGET pixman-1)
pkg_search_module(WAYLAND REQUIRED IMPORTED_TARGET wayland-server)

add_executable(tinywl-qtquick
main.cpp
)
set(TARGET tinywl-qtquick)

set_source_files_properties(QmlHelper.qml
PROPERTIES
QT_QML_SINGLETON_TYPE TRUE
add_executable(${TARGET}
main.cpp
)

qt_add_qml_module(tinywl-qtquick
qt_add_qml_module(${TARGET}
URI Tinywl
VERSION "1.0"
SOURCES
helper.h
QML_FILES
Main.qml
StackWorkspace.qml
XdgSurface.qml
LayerSurface.qml
TiledWorkspace.qml
QmlHelper.qml
OutputDelegate.qml
StackToplevelHelper.qml
TiledToplevelHelper.qml
WindowDecoration.qml
CloseAnimation.qml
MiniDock.qml
InputPopupSurface.qml
VERSION "2.0"

SOURCES helper.h helper.cpp
SOURCES surfacewrapper.h surfacewrapper.cpp
SOURCES workspace.h workspace.cpp
SOURCES output.h output.cpp
SOURCES qmlengine.h qmlengine.cpp
SOURCES surfacecontainer.h surfacecontainer.cpp
SOURCES layersurfacecontainer.h layersurfacecontainer.cpp
SOURCES rootsurfacecontainer.h rootsurfacecontainer.cpp
SOURCES surfaceproxy.h surfaceproxy.cpp
SOURCES wallpaperprovider.h wallpaperprovider.cpp
SOURCES wallpaperimage.h wallpaperimage.cpp
SOURCES workspacemodel.h workspacemodel.cpp

QML_FILES PrimaryOutput.qml
QML_FILES CopyOutput.qml
QML_FILES TitleBar.qml
QML_FILES Decoration.qml
QML_FILES TaskBar.qml
QML_FILES RoundedClipEffect.qml
QML_FILES SurfaceContent.qml
QML_FILES Shadow.qml
QML_FILES Border.qml
QML_FILES GeometryAnimation.qml
QML_FILES OutputMenuBar.qml
QML_FILES WorkspaceSwitcher.qml
QML_FILES WorkspaceProxy.qml
QML_FILES WindowMenu.qml

RESOURCES
"res/xx.jpg"
)

target_compile_definitions(tinywl-qtquick
target_compile_definitions(${TARGET}
PRIVATE
SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
PROJECT_BINARY_DIR="${PROJECT_BINARY_DIR}"
$<$<BOOL:${START_DEMO}>:START_DEMO>
WLR_USE_UNSTABLE
)

target_link_libraries(tinywl-qtquick
target_link_libraries(${TARGET}
PRIVATE
Qt6::Quick
Qt6::QuickControls2
Qt6::QuickPrivate
Waylib::WaylibServer
PkgConfig::PIXMAN
PkgConfig::WAYLAND
)

if (INSTALL_TINYWL)
install(TARGETS tinywl-qtquick DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS ${TARGET} DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
Loading

0 comments on commit 0663991

Please sign in to comment.