Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/treeland-deepin-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
rm -rf /etc/apt/sources.list.d

apt-get update
apt-get install -y devscripts equivs git
apt-get install -y libdtkdata devscripts equivs git

# Save the treeland workspace directory
TREELAND_DIR="$PWD"
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ qt_add_qml_module(libtreeland
core/imcandidatepanelmanager.h
core/shellhandler.cpp
core/shellhandler.h
core/treelandinit.cpp
core/treeland.cpp
core/treeland.h
core/windowpicker.cpp
Expand Down
44 changes: 44 additions & 0 deletions src/core/treelandinit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (C) 2026 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
#include "treelandinit.h"
#include <DGuiApplicationHelper>

Check warning on line 4 in src/core/treelandinit.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DGuiApplicationHelper> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QGuiApplication>

Check warning on line 5 in src/core/treelandinit.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGuiApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <wrenderhelper.h>

Check warning on line 6 in src/core/treelandinit.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <wrenderhelper.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <wbackend.h>

Check warning on line 7 in src/core/treelandinit.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <wbackend.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <wserver.h>

Check warning on line 8 in src/core/treelandinit.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <wserver.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <wlr_all.h>

Check warning on line 10 in src/core/treelandinit.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <wlr_all.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

WAYLIB_SERVER_USE_NAMESPACE
DCORE_USE_NAMESPACE

namespace Treeland {

void preInit(const InitOptions &opts)
{
if (opts.headless) {
const auto testBackends = qgetenv("TREELAND_TEST_WLR_BACKENDS");
qputenv("WLR_BACKENDS", testBackends.isEmpty() ? "headless" : testBackends);
}
DTK_GUI_NAMESPACE::DGuiApplicationHelper::setAttribute(
DTK_GUI_NAMESPACE::DGuiApplicationHelper::DontSaveApplicationTheme, true);
WServer::initializeQPA({}, opts.createPlatformTheme);
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
QGuiApplication::setQuitOnLastWindowClosed(false);
}

void initTestServer(WServer *server)
{
auto *backend = server->attach<WBackend>();
auto *renderer = WRenderHelper::createRenderer(backend->handle());
wlr_compositor_create(server->handle(), 6, renderer);
wlr_subcompositor_create(server->handle());
}

void postInit()

Check warning on line 39 in src/core/treelandinit.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'postInit' is never used.
{
WRenderHelper::setupRendererBackend();
}

}
20 changes: 20 additions & 0 deletions src/core/treelandinit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2026 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
#include <wglobal.h>

Check warning on line 3 in src/core/treelandinit.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <wglobal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <functional>

Check warning on line 4 in src/core/treelandinit.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <functional> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QString>

Check warning on line 5 in src/core/treelandinit.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QString> not found. Please note: Cppcheck does not need standard library headers to get proper results.
class QPlatformTheme;

WAYLIB_SERVER_BEGIN_NAMESPACE
class WServer;
WAYLIB_SERVER_END_NAMESPACE

namespace Treeland {
struct InitOptions {
bool headless = false;
std::function<QPlatformTheme *(const QString &)> createPlatformTheme;
};
void preInit(const InitOptions &opts = {});
void postInit();
void initTestServer(WAYLIB_SERVER_NAMESPACE::WServer *server);
}
10 changes: 7 additions & 3 deletions src/core/windowpicker.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024 UnionTech Software Technology Co., Ltd.
// Copyright (C) 2024-2026 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
#include "windowpicker.h"

Expand Down Expand Up @@ -47,8 +47,12 @@ QRectF WindowPicker::selectionRegion() const
return m_itemSelector->selectionRegion();
}

void WindowPicker::mousePressEvent([[maybe_unused]] QMouseEvent *event)
void WindowPicker::selectWindow(WSurfaceItem *window)
{
auto window = qobject_cast<WSurfaceItem *>(m_itemSelector->hoveredItem());
Q_EMIT windowPicked(window);
}

void WindowPicker::mousePressEvent([[maybe_unused]] QMouseEvent *event)
{
selectWindow(qobject_cast<WSurfaceItem *>(m_itemSelector->hoveredItem()));
}
3 changes: 2 additions & 1 deletion src/core/windowpicker.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024 UnionTech Software Technology Co., Ltd.
// Copyright (C) 2024-2026 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
#pragma once

Expand Down Expand Up @@ -26,6 +26,7 @@ class WindowPicker : public QQuickItem
void setHint(const QString &hint);
QQuickItem *hoveredItem() const;
QRectF selectionRegion() const;
void selectWindow(WAYLIB_SERVER_NAMESPACE::WSurfaceItem *window);

Q_SIGNALS:
void windowPicked(WAYLIB_SERVER_NAMESPACE::WSurfaceItem *window);
Expand Down
27 changes: 8 additions & 19 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <wlogging.h>
#include "core/treeland.h"
#include "core/treelandinit.h"
#include "utils/cmdline.h"

#include <wrenderhelper.h>
Expand All @@ -11,9 +12,7 @@

#include <DGuiApplicationHelper>
#include <DLog>

#include <QGuiApplication>
#include <QMetaType>
#include <QPalette>
#include <QQuickStyle>

Expand Down Expand Up @@ -46,39 +45,29 @@ class QDeepinTheme : public QGenericUnixTheme

int main(int argc, char *argv[])
{
WLog::init();
DTK_GUI_NAMESPACE::DGuiApplicationHelper::setAttribute(
DTK_GUI_NAMESPACE::DGuiApplicationHelper::DontSaveApplicationTheme,
true);
WServer::initializeQPA({}, [](const QString &) {
return static_cast<QPlatformTheme *>(new QDeepinTheme());
Treeland::preInit(Treeland::InitOptions{
.createPlatformTheme = [](const QString &) {
return static_cast<QPlatformTheme *>(new QDeepinTheme());
},
});
QQuickStyle::setStyle("Chameleon");

QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
QGuiApplication::setQuitOnLastWindowClosed(false);

QGuiApplication app(argc, argv);

app.setOrganizationName("deepin");
app.setApplicationName("treeland");

#ifdef QT_DEBUG
DLogManager::registerConsoleAppender();
#endif

// Enable console logging in non-debug builds via --console-log flag
CmdLine::ref();
#ifndef QT_DEBUG
if (CmdLine::ref().consoleLog()) {
if (CmdLine::ref().consoleLog())
DLogManager::registerConsoleAppender();
}
#endif
DLogManager::registerJournalAppender();

WRenderHelper::setupRendererBackend();
Treeland::postInit();

if (CmdLine::ref().tryExec())
return 0;
Q_ASSERT(waylib_buffer_get_count() == 0);
Expand Down
18 changes: 14 additions & 4 deletions src/modules/capture/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,19 @@ CaptureSource *CaptureSourceSelector::selectedSource() const
return m_selectedSource;
}

void CaptureSourceSelector::selectSurface(WSurfaceItemContent *surfaceItemContent)
{
if (!surfaceItemContent)
return;

const QRect region = surfaceItemContent
->mapRectToItem(this, surfaceItemContent->boundingRect())
.toRect();
setSelectedSource(new CaptureSourceSurface(surfaceItemContent,
surfaceItemContent->devicePixelRatio()),
region);
}

void CaptureSourceSelector::setSelectedSource(CaptureSource *newSelectedSource, const QRect &region)
{
if (m_selectedSource == newSelectedSource)
Expand Down Expand Up @@ -879,10 +892,7 @@ void CaptureSourceSelector::mouseReleaseEvent([[maybe_unused]] QMouseEvent *even
}
case SelectionMode::SelectWindow: {
if (auto surfaceItemContent = qobject_cast<WSurfaceItemContent *>(hoveredItem())) {
setSelectedSource(
new CaptureSourceSurface(surfaceItemContent,
m_itemSelector->outputItem()->devicePixelRatio()),
selectionRegion().toRect());
selectSurface(surfaceItemContent);
}
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/capture/capture.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ class CaptureSourceSelector : public SurfaceContainer
ToolBarModel *toolBarModel() const;
void doneSelection();
void cancelSelection();
void selectSurface(WSurfaceItemContent *surfaceItemContent);

Q_SIGNALS:
void hoveredItemChanged();
Expand Down
11 changes: 7 additions & 4 deletions src/modules/wallpaper/wallpapershellinterfacev1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,16 @@ void TreelandWallpaperSurfaceInterfaceV1Private::ready([[maybe_unused]] Resource
return;
}

if (q->wSurface()->mapped()) {
const auto markReady = [this] {
wallpaperReady = true;
Q_EMIT q->ready();
};

if (q->wSurface()->mapped() || !q->wSurface()->bufferSize().isEmpty()) {
markReady();
} else {
QObject::connect(q->wSurface(), &WSurface::commit, q, [this](quint32) {
wallpaperReady = true;
Q_EMIT q->ready();
QObject::connect(q->wSurface(), &WSurface::commit, q, [markReady](quint32) {
markReady();
}, Qt::SingleShotConnection);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/lockscreen/qml/ShutdownButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Button {
hovered: Qt.rgba(1.0, 1.0, 1.0, 0.5)
pressed: Qt.rgba(1.0, 1.0, 1.0, 0.1)
}
textColor: D.Palette {
normal: Qt.rgba(1.0, 1.0, 1.0, 1.0)
hovered: Qt.rgba(0.0, 0.0, 0.0, 0.7)
pressed: Qt.rgba(0.0, 0.0, 0.0, 0.7)
}
// textColor: D.Palette {
// normal: Qt.rgba(1.0, 1.0, 1.0, 1.0)
// hovered: Qt.rgba(0.0, 0.0, 0.0, 0.7)
// pressed: Qt.rgba(0.0, 0.0, 0.0, 0.7)
// }

icon {
width: 40
Expand Down
3 changes: 2 additions & 1 deletion src/seat/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ void Helper::init(Treeland::Treeland *treeland)
}
});
connect(m_ddeShellV1,
&DDEShellManagerInterfaceV1::requestPickWindow,
&DDEShellManagerInterfaceV1::PickerCreated,
this,
&Helper::handleWindowPicker);
connect(m_ddeShellV1,
Expand Down Expand Up @@ -2189,6 +2189,7 @@ void Helper::init(Treeland::Treeland *treeland)
&Treeland::Treeland::SessionChanged,
m_shortcutManager,
&ShortcutManagerV2::onSessionChanged);
m_shortcutManager->onSessionChanged();
auto shortcutControl = m_shortcutManager->controller();
auto *shortcutRunner = new ShortcutRunner(shortcutControl);
connect(shortcutControl,
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
add_subdirectory(protocols)

add_subdirectory(test_protocol_personalization)
add_subdirectory(test_protocol_primary-output)
Expand Down
47 changes: 47 additions & 0 deletions tests/protocols/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
find_package(TreelandProtocols REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(WAYLAND_CLIENT REQUIRED IMPORTED_TARGET wayland-client)
pkg_check_modules(XKBCOMMON REQUIRED IMPORTED_TARGET xkbcommon)

option(TREELAND_ENABLE_UINPUT_PROTOCOL_TESTS
"Build optional /dev/uinput protocol integration tests" OFF)

include(${CMAKE_CURRENT_SOURCE_DIR}/framework/ProtocolTest.cmake)

add_subdirectory(desktop-integration-fixture)
add_subdirectory(rendered-output-fixture)
add_subdirectory(treeland-app-id-resolver-v1)
add_subdirectory(treeland-app-id-resolver-desktop-v1)
add_subdirectory(treeland-capture-unstable-v1)
add_subdirectory(treeland-capture-desktop-v1)
add_subdirectory(treeland-dde-shell-v1)
add_subdirectory(treeland-dde-shell-desktop-v1)
add_subdirectory(treeland-dde-shell-lockscreen-desktop-v1)
add_subdirectory(treeland-dde-shell-multitask-desktop-v1)
add_subdirectory(treeland-dde-shell-picker-desktop-v1)
add_subdirectory(treeland-ddm-v1)
add_subdirectory(treeland-foreign-toplevel-manager-v1)
add_subdirectory(treeland-input-manager-unstable-v1)
if(TREELAND_ENABLE_UINPUT_PROTOCOL_TESTS AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_subdirectory(treeland-input-manager-uinput-v1)
endif()
add_subdirectory(treeland-keyboard-state-notify-unstable-v1)
add_subdirectory(treeland-output-manager-v1)
add_subdirectory(treeland-personalization-manager-v1)
add_subdirectory(treeland-personalization-desktop-v1)
add_subdirectory(treeland-prelaunch-splash-v2)
add_subdirectory(treeland-prelaunch-splash-desktop-v2)
add_subdirectory(treeland-screensaver-v1)
add_subdirectory(treeland-screensaver-desktop-v1)
add_subdirectory(treeland-shortcut-manager-v2)
add_subdirectory(treeland-shortcut-manager-desktop-v2)
add_subdirectory(treeland-virtual-output-manager-v1)
add_subdirectory(treeland-virtual-output-desktop-v1)
add_subdirectory(treeland-wallpaper-color-v1)
add_subdirectory(treeland-wallpaper-manager-unstable-v1)
add_subdirectory(treeland-wallpaper-shell-unstable-v1)
add_subdirectory(treeland-wallpaper-desktop-v1)
add_subdirectory(treeland-window-management-v1)
add_subdirectory(treeland-window-management-desktop-v1)
add_subdirectory(treeland-wine-window-state-unstable-v1)
add_subdirectory(treeland-wine-window-management-unstable-v1)
Loading
Loading