Skip to content
Merged
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
1 change: 0 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ set(MODULE_PATH ${PROJECT_SOURCE_DIR}/src/modules)
add_subdirectory(test_window_bg)
add_subdirectory(test_wallpaper_color)
add_subdirectory(test_show_desktop)
add_subdirectory(test_window_cursor)
add_subdirectory(test_xdgport_wallpaper)
add_subdirectory(test_virtual_output)
add_subdirectory(test_pinch_handler)
Expand Down
10 changes: 7 additions & 3 deletions examples/test_window_appearance/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# 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

find_package(Qt6 REQUIRED COMPONENTS WaylandClient Gui Widgets)
find_package(TreelandProtocols REQUIRED)

set(BIN_NAME test-window-appearance)

qt_add_executable(${BIN_NAME}
main.cpp
personalization_manager.h
personalization_manager.cpp
appearance_manager.h
appearance_manager.cpp
)

qt_generate_wayland_protocol_client_sources(${BIN_NAME}
FILES
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-personalization-manager-v1.xml
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-appearance-unstable-v1.xml
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-appearance-manager-unstable-v1.xml
)

target_link_libraries(${BIN_NAME}
Expand Down
73 changes: 73 additions & 0 deletions examples/test_window_appearance/appearance_manager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// 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 "appearance_manager.h"

QT_BEGIN_NAMESPACE

AppearanceObserver::AppearanceObserver()
: QWaylandClientExtensionTemplate<AppearanceObserver>(1)
{
}

void AppearanceObserver::treeland_appearance_v1_cursor_theme(const QString &name)

Check warning on line 13 in examples/test_window_appearance/appearance_manager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'treeland_appearance_v1_cursor_theme' is never used.
{
Q_EMIT cursorThemeChanged(name);
}

void AppearanceObserver::treeland_appearance_v1_cursor_size(uint32_t width, uint32_t height)

Check warning on line 18 in examples/test_window_appearance/appearance_manager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'treeland_appearance_v1_cursor_size' is never used.
{
Q_EMIT cursorSizeChanged(width, height);
}

void AppearanceObserver::treeland_appearance_v1_font(const QString &font_name)

Check warning on line 23 in examples/test_window_appearance/appearance_manager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'treeland_appearance_v1_font' is never used.
{
Q_EMIT fontChanged(font_name);
}

void AppearanceObserver::treeland_appearance_v1_monospace_font(const QString &font_name)

Check warning on line 28 in examples/test_window_appearance/appearance_manager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'treeland_appearance_v1_monospace_font' is never used.
{
Q_EMIT monospaceFontChanged(font_name);
}

void AppearanceObserver::treeland_appearance_v1_font_size(uint32_t size)

Check warning on line 33 in examples/test_window_appearance/appearance_manager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'treeland_appearance_v1_font_size' is never used.
{
Q_EMIT fontSizeChanged(size);
}

void AppearanceObserver::treeland_appearance_v1_icon_theme(const QString &theme_name)

Check warning on line 38 in examples/test_window_appearance/appearance_manager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'treeland_appearance_v1_icon_theme' is never used.
{
Q_EMIT iconThemeChanged(theme_name);
}

void AppearanceObserver::treeland_appearance_v1_accent_color(uint32_t r, uint32_t g, uint32_t b)

Check warning on line 43 in examples/test_window_appearance/appearance_manager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'treeland_appearance_v1_accent_color' is never used.
{
Q_EMIT accentColorChanged(r, g, b);
}

void AppearanceObserver::treeland_appearance_v1_window_opacity(wl_fixed_t opacity)

Check warning on line 48 in examples/test_window_appearance/appearance_manager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'treeland_appearance_v1_window_opacity' is never used.
{
Q_EMIT windowOpacityChanged(opacity);
}

void AppearanceObserver::treeland_appearance_v1_color_scheme(uint32_t scheme)

Check warning on line 53 in examples/test_window_appearance/appearance_manager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'treeland_appearance_v1_color_scheme' is never used.
{
Q_EMIT colorSchemeChanged(scheme);
}

void AppearanceObserver::treeland_appearance_v1_titlebar_height(uint32_t height)

Check warning on line 58 in examples/test_window_appearance/appearance_manager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'treeland_appearance_v1_titlebar_height' is never used.
{
Q_EMIT titlebarHeightChanged(height);
}

void AppearanceObserver::treeland_appearance_v1_corner_radius(uint32_t radius)
{
Q_EMIT cornerRadiusChanged(radius);
}

AppearanceManager::AppearanceManager()
: QWaylandClientExtensionTemplate<AppearanceManager>(1)
{
}

QT_END_NAMESPACE
66 changes: 66 additions & 0 deletions examples/test_window_appearance/appearance_manager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 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

#ifndef APPEARANCE_MANAGER_H
#define APPEARANCE_MANAGER_H

#include "qwayland-treeland-appearance-unstable-v1.h"
#include "qwayland-treeland-appearance-manager-unstable-v1.h"

#include <QtWaylandClient/QWaylandClientExtension>

QT_BEGIN_NAMESPACE

// Read-only observer for user-level appearance settings. Any client may bind
// this global; the compositor pushes the current value of every setting
// immediately after bind and broadcasts an event whenever a setting changes.
class AppearanceObserver
: public QWaylandClientExtensionTemplate<AppearanceObserver>
, public QtWayland::treeland_appearance_v1
{
Q_OBJECT
public:
explicit AppearanceObserver();

Q_SIGNALS:
void cursorThemeChanged(const QString &name);
void cursorSizeChanged(uint32_t width, uint32_t height);
void fontChanged(const QString &font_name);
void monospaceFontChanged(const QString &font_name);
void fontSizeChanged(uint32_t size);
void iconThemeChanged(const QString &theme_name);
void accentColorChanged(uint32_t r, uint32_t g, uint32_t b);
void windowOpacityChanged(wl_fixed_t opacity);
void colorSchemeChanged(uint32_t scheme);
void titlebarHeightChanged(uint32_t height);
void cornerRadiusChanged(uint32_t radius);

protected:
void treeland_appearance_v1_cursor_theme(const QString &name) override;
void treeland_appearance_v1_cursor_size(uint32_t width, uint32_t height) override;
void treeland_appearance_v1_font(const QString &font_name) override;
void treeland_appearance_v1_monospace_font(const QString &font_name) override;
void treeland_appearance_v1_font_size(uint32_t size) override;
void treeland_appearance_v1_icon_theme(const QString &theme_name) override;
void treeland_appearance_v1_accent_color(uint32_t r, uint32_t g, uint32_t b) override;
void treeland_appearance_v1_window_opacity(wl_fixed_t opacity) override;
void treeland_appearance_v1_color_scheme(uint32_t scheme) override;
void treeland_appearance_v1_titlebar_height(uint32_t height) override;
void treeland_appearance_v1_corner_radius(uint32_t radius) override;
};

// Privileged manager for modifying user-level appearance settings. Binding
// without compositor-level authorization may result in requests being
// silently ignored or the connection being terminated.
class AppearanceManager
: public QWaylandClientExtensionTemplate<AppearanceManager>
, public QtWayland::treeland_appearance_manager_v1
{
Q_OBJECT
public:
explicit AppearanceManager();
};

QT_END_NAMESPACE

#endif // APPEARANCE_MANAGER_H
Loading
Loading