Skip to content

Commit

Permalink
feat: add layershell wrap
Browse files Browse the repository at this point in the history
Add layershell qt call and qml plugin

log: ass layershell wrap
Issue: linuxdeepin/developer-center#5808
  • Loading branch information
tsic404 committed Oct 24, 2023
1 parent a2e15e7 commit 7f7a835
Show file tree
Hide file tree
Showing 20 changed files with 1,270 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
build*/
.vscode/settings.json
*.user
.cache/

*/utils/dbus/xml2cpp/*_interface.*
5 changes: 5 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ License: GPL-3.0-or-later
Files: *.json
Copyright: None
License: CC0-1.0

# wayland protocols
Files: frame/layershell/protocol/wlr-layer-shell-unstable-v1.xml
Copyright: 2017 Drew DeVault
License: MIT
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project(DDEShell
VERSION "${DS_VERSION}"
DESCRIPTION "dde-shell"
HOMEPAGE_URL "https://github.com/linuxdeepin/dde-shell"
LANGUAGES CXX
LANGUAGES CXX C
)

set(CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -44,11 +44,13 @@ set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/dde-shell" CACHE STRING "He
set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/DDEShell" CACHE STRING "CMake config file install directory")
set(QML_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/qt${QT_VERSION_MAJOR}/qml" CACHE STRING "Qml plugin install directory")

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
find_package(ECM REQUIRED MO_MODULE)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH};${ECM_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")
include(DDEShellPackageMacros)

find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Concurrent Quick)
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Concurrent Quick WaylandClient)
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui)
find_package(WaylandProtocols REQUIRED)

add_subdirectory(frame)
add_subdirectory(shell)
Expand Down
24 changes: 24 additions & 0 deletions LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
MIT "Expat" License

Copyright (c) 2017 Drew DeVault

Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
the copyright holders not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission. The copyright holders make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.

THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
4 changes: 4 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ Build-Depends:
qt6-declarative-dev,
qt6-base-dev-tools,
qt6-tools-dev,
qt6-wayland-dev(>=6.5),
qt6-wayland-dev-tools,
qt6-wayland-private-dev,
libdtk6gui-dev,
libdtk6core-dev,
libdtkcommon-dev,
extra-cmake-modules,
Standards-Version: 3.9.8
Homepage: http://www.deepin.org

Expand Down
1 change: 1 addition & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ add_subdirectory(applet-example)
add_subdirectory(applet-example-data)
add_subdirectory(containment-example)
add_subdirectory(corona-example)
add_subdirectory(layershell-example)
1 change: 1 addition & 0 deletions example/corona-example/package/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Window {
width: Screen.width
height: 200
D.DWindow.enabled: true
DLayerShellWindow.anchors: DLayerShellWindow.AnchorBottom

Control {
anchors.fill: parent
Expand Down
6 changes: 6 additions & 0 deletions example/layershell-example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

add_executable(layershell-example main.cpp qml.qrc)
target_link_libraries(layershell-example PRIVATE Qt::Gui Qt::Qml)
15 changes: 15 additions & 0 deletions example/layershell-example/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include <QGuiApplication>
#include <QtQml/QQmlApplicationEngine>

int main(int argc, char* argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.addImportPath(QCoreApplication::applicationDirPath() + "/../../plugins/");
engine.load("qrc:///org/deepin/layershell/main.qml");
return app.exec();
}
182 changes: 182 additions & 0 deletions example/layershell-example/main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick 2.15
import QtQuick.Controls
import QtQuick.Layouts
import org.deepin.ds

Window {
id: root
height: 150
width: 780
visible: true
DLayerShellWindow.anchors: DLayerShellWindow.AnchorLeft
DLayerShellWindow.layer: DLayerShellWindow.LayerTop
DLayerShellWindow.exclusionZone: excludezone.value
DLayerShellWindow.keyboardInteractivity: DLayerShellWindow.KeyboardInteractivityExclusive
DLayerShellWindow.leftMargin: left.value
DLayerShellWindow.rightMargin: right.value
DLayerShellWindow.topMargin: top.value
DLayerShellWindow.bottomMargin: bottom.value

Column {
id: comboBox
ComboBox {
id: layerCombox
width: 100
textRole: "text"
anchors.left: parent.left
Component.onCompleted: currentIndex = root.DLayerShellWindow.layer
onActivated: {
root.DLayerShellWindow.layer = model.get(layerCombox.currentIndex).layer
}
model: ListModel {
ListElement { text: "LayerBackground"; layer: DLayerShellWindow.LayerBackground }
ListElement { text: "LayerButtom"; layer: DLayerShellWindow.LayerButtom }
ListElement { text: "LayerTop"; layer: DLayerShellWindow.LayerTop }
ListElement { text: "LayerOverlay"; layer: DLayerShellWindow.LayerOverlay }
}
}

ComboBox {
id: keyboardInteractivityCombox
width: 200
textRole: "text"
anchors.left: parent.left
Component.onCompleted: currentIndex = root.DLayerShellWindow.keyboardInteractivity
onActivated: {
root.DLayerShellWindow.keyboardInteractivity = model.get(keyboardInteractivityCombox.currentIndex).keyboardInteractivity
}
model: ListModel {
ListElement { text: "KeyboardInteractivityNone"; keyboardInteractivity: DLayerShellWindow.KeyboardInteractivityNone }
ListElement { text: "KeyboardInteractivityExclusive"; keyboardInteractivity: DLayerShellWindow.KeyboardInteractivityExclusive }
ListElement { text: "KeyboardInteractivityOnDemand"; keyboardInteractivity: DLayerShellWindow.KeyboardInteractivityOnDemand }
}
}
}

Item {
id: steerwheel
anchors.left: comboBox.right
anchors.leftMargin: 20
width: 100
Column {
spacing: 20
Button {
id: buttonTop
text: "Top"
width: 40
anchors.leftMargin: 30
anchors.left: parent.left
checkable: true
checked: root.DLayerShellWindow.anchors & DLayerShellWindow.AnchorTop
onCheckedChanged: {
if (checked)
root.DLayerShellWindow.anchors = root.DLayerShellWindow.anchors | DLayerShellWindow.AnchorTop
else
root.DLayerShellWindow.anchors = root.DLayerShellWindow.anchors ^ DLayerShellWindow.AnchorTop
}
}
Row {
spacing: 20
Button {
id: buttonLeft
text: "Left"
width: 40
checkable: true
checked: root.DLayerShellWindow.anchors & DLayerShellWindow.AnchorLeft
onCheckedChanged: {
if (checked)
root.DLayerShellWindow.anchors = root.DLayerShellWindow.anchors | DLayerShellWindow.AnchorLeft
else
root.DLayerShellWindow.anchors = root.DLayerShellWindow.anchors ^ DLayerShellWindow.AnchorLeft
}
}
Button {
id: buttonRight
text: "Right"
width: 40
checkable: true
checked: root.DLayerShellWindow.anchors & DLayerShellWindow.AnchorRight
onCheckedChanged: {
if (checked)
root.DLayerShellWindow.anchors = root.DLayerShellWindow.anchors | DLayerShellWindow.AnchorRight
else
root.DLayerShellWindow.anchors = root.DLayerShellWindow.anchors ^ DLayerShellWindow.AnchorRight
}
}
}
Button {
id: buttonBottom
text: "Buttom"
width: 40
anchors.leftMargin: 30
anchors.left: parent.left
checkable: true
checked: root.DLayerShellWindow.anchors & DLayerShellWindow.AnchorBottom
onCheckedChanged: {
if (checked)
root.DLayerShellWindow.anchors = root.DLayerShellWindow.anchors | DLayerShellWindow.AnchorBottom
else
root.DLayerShellWindow.anchors = root.DLayerShellWindow.anchors ^ DLayerShellWindow.AnchorBottom
}
}
}
}

GridLayout {
id: input
anchors.left: steerwheel.right
anchors.leftMargin: 20
columns: 4
Text {
text: "LeftMargin: "
}
SpinBox {
id: left
stepSize: 10
editable: true
value: root.DLayerShellWindow.leftMargin
}
Text {
text: "TopMargin: "
}
SpinBox {
id: top
stepSize: 10
editable: true
value: root.DLayerShellWindow.topMargin
}
Text {
text: "RightMargin: "
}
SpinBox {
id: right
stepSize: 10
editable: true
value: root.DLayerShellWindow.rightMargin
}
Text {
text: "BottomMargin: "
}
SpinBox {
id: bottom
stepSize: 10
editable: true
value: root.DLayerShellWindow.bottomMargin
}
Text {
text: "excludezone: "
}

SpinBox {
id: excludezone
editable: true
from: -1
to: 1080
value: -1
}
}
}
5 changes: 5 additions & 0 deletions example/layershell-example/qml.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/org/deepin/layershell/">
<file>main.qml</file>
</qresource>
</RCC>
12 changes: 11 additions & 1 deletion frame/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: CC0-1.0

set(PUBLIC_HEADERS
dsglobal.h
dstypes.h
Expand All @@ -12,6 +11,7 @@ set(PUBLIC_HEADERS
containment.h
corona.h
qmlengine.h
layershell/dlayershellwindow.h
)
add_library(dde-shell-frame SHARED
${PUBLIC_HEADERS}
Expand All @@ -31,6 +31,14 @@ add_library(dde-shell-frame SHARED
appletitem.cpp
containmentitem.cpp
qmlengine.cpp
layershell/dlayershellwindow.cpp
layershell/qwaylandlayershellsurface.cpp
layershell/qwaylandlayershellintegration.cpp
)

qt_generate_wayland_protocol_client_sources(dde-shell-frame FILES
${CMAKE_CURRENT_SOURCE_DIR}/layershell/protocol/wlr-layer-shell-unstable-v1.xml
${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml
)

set_target_properties(dde-shell-frame PROPERTIES
Expand All @@ -45,6 +53,8 @@ PUBLIC
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Quick
PRIVATE
Qt${QT_VERSION_MAJOR}::WaylandClientPrivate
)
target_include_directories(dde-shell-frame INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
Expand Down
Loading

0 comments on commit 7f7a835

Please sign in to comment.