-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: treeland window background for fullscreen frame
通过 TreeLand 特性让合成器绘制全屏启动器的模糊背景。 Log:
- Loading branch information
Showing
14 changed files
with
407 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
/* | ||
This file is part of KDToolBox. | ||
This file was part of KDToolBox, modified by deepin to fit their own needs. | ||
SPDX-FileCopyrightText: 2018 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> | ||
Author: André Somers <[email protected]> | ||
SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
Author: Wang Zichong <[email protected]> | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
find_package(Qt6 REQUIRED COMPONENTS WaylandClient) | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
||
add_library(treeland-integration OBJECT | ||
personalizationmanager.cpp | ||
personalizationwindow.cpp | ||
) | ||
|
||
qt_generate_wayland_protocol_client_sources(treeland-integration | ||
FILES | ||
${CMAKE_CURRENT_SOURCE_DIR}/treeland-personalization-manager-v1.xml | ||
) | ||
|
||
target_sources(treeland-integration PUBLIC | ||
FILE_SET HEADERS | ||
FILES | ||
personalizationmanager.h | ||
personalizationwindow.h | ||
) | ||
|
||
target_link_libraries(treeland-integration | ||
PRIVATE | ||
Qt6::WaylandClient | ||
Qt6::WaylandClientPrivate | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "personalizationmanager.h" | ||
#include "personalizationwindow.h" | ||
|
||
#include "qwayland-treeland-personalization-manager-v1.h" | ||
|
||
#include <QWindow> | ||
|
||
#include <private/qwaylandwindow_p.h> | ||
#include <qguiapplication.h> | ||
#include <qobject.h> | ||
#include <qtmetamacros.h> | ||
|
||
class PersonalizationManagerPrivate : public QWaylandClientExtensionTemplate<PersonalizationManagerPrivate>, | ||
public QtWayland::treeland_personalization_manager_v1 | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit PersonalizationManagerPrivate(); | ||
bool personalizeWindow(QWindow * window, PersonalizationManager::BgState state); | ||
|
||
private: | ||
bool doPersonalizeWindow(QWindow * window, PersonalizationManager::BgState state); | ||
QList<std::pair<QWindow *, PersonalizationManager::BgState> > m_queue; | ||
}; | ||
|
||
|
||
PersonalizationManagerPrivate::PersonalizationManagerPrivate() | ||
: QWaylandClientExtensionTemplate<PersonalizationManagerPrivate>(1) | ||
{ | ||
connect(this, &PersonalizationManagerPrivate::activeChanged, this, [this](){ | ||
if (!isActive()) return; | ||
for (std::pair<QWindow *, PersonalizationManager::BgState> task_pair : std::as_const(m_queue)) { | ||
doPersonalizeWindow(task_pair.first, task_pair.second); | ||
} | ||
m_queue.clear(); | ||
}); | ||
} | ||
|
||
// return if the window is "personalized" right away. | ||
bool PersonalizationManagerPrivate::personalizeWindow(QWindow * window, PersonalizationManager::BgState state) | ||
{ | ||
if (window && window->handle()) { | ||
QtWaylandClient::QWaylandWindow *waylandWindow = | ||
static_cast<QtWaylandClient::QWaylandWindow *>(window->handle()); | ||
struct wl_surface *surface = waylandWindow->wlSurface(); | ||
} | ||
|
||
if (!isActive()) { | ||
m_queue.append(std::make_pair(window, state)); | ||
return false; | ||
} else { | ||
doPersonalizeWindow(window, state); | ||
return true; | ||
} | ||
} | ||
|
||
// return if success | ||
bool PersonalizationManagerPrivate::doPersonalizeWindow(QWindow * window, PersonalizationManager::BgState state) | ||
{ | ||
Q_ASSERT(isActive()); | ||
if (window && window->handle()) { | ||
QtWaylandClient::QWaylandWindow *waylandWindow = | ||
static_cast<QtWaylandClient::QWaylandWindow *>(window->handle()); | ||
struct wl_surface *surface = waylandWindow->wlSurface(); | ||
if (surface) { | ||
PersonalizationWindow *context = | ||
new PersonalizationWindow(get_window_context(surface)); | ||
context->set_background_type(state); | ||
qDebug() << "Applied background type" << state << "to window" << window; | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
// ---------------------------------------------------- | ||
|
||
PersonalizationManager::PersonalizationManager(QObject * parent) | ||
: QObject(parent) | ||
{ | ||
if (QGuiApplication::platformName() == "wayland") { | ||
m_dptr = new PersonalizationManagerPrivate; | ||
} | ||
} | ||
|
||
PersonalizationManager::~PersonalizationManager() | ||
{ | ||
if (m_dptr) delete m_dptr; | ||
} | ||
|
||
// return if the window is "personalized" right away. | ||
bool PersonalizationManager::personalizeWindow(QWindow * window, PersonalizationManager::BgState state) | ||
{ | ||
return m_dptr ? m_dptr->personalizeWindow(window, state) : true; | ||
} | ||
|
||
#include "personalizationmanager.moc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#pragma once | ||
|
||
#include <QtWaylandClient/QWaylandClientExtension> | ||
|
||
class QWindow; | ||
class PersonalizationManagerPrivate; | ||
class PersonalizationManager : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
enum BgState { | ||
BgNormal = 0, | ||
BgWallpaper = 1, | ||
BgBlurredWallpaper = 2, | ||
}; | ||
|
||
explicit PersonalizationManager(QObject * parent = nullptr); | ||
~PersonalizationManager(); | ||
bool personalizeWindow(QWindow * window, BgState state); | ||
|
||
private: | ||
PersonalizationManagerPrivate * m_dptr = nullptr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "personalizationwindow.h" | ||
|
||
PersonalizationWindow::PersonalizationWindow(struct ::personalization_window_context_v1 *object) | ||
: QWaylandClientExtensionTemplate<PersonalizationWindow>(1) | ||
, QtWayland::personalization_window_context_v1(object) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#pragma once | ||
|
||
#include "qwayland-treeland-personalization-manager-v1.h" | ||
|
||
#include <QtWaylandClient/QWaylandClientExtension> | ||
|
||
class PersonalizationWindow : public QWaylandClientExtensionTemplate<PersonalizationWindow>, | ||
public QtWayland::personalization_window_context_v1 | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit PersonalizationWindow(struct ::personalization_window_context_v1 *object); | ||
}; |
Oops, something went wrong.