-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add some interfaces about personalization
add some interfaces about personalization Log:
- Loading branch information
wangfei
committed
Oct 10, 2024
1 parent
8cf037d
commit a7d021d
Showing
9 changed files
with
219 additions
and
254 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "personalizationwaylandclientextension.h" | ||
#include "qwayland-treeland-personalization-manager-v1.h" | ||
|
||
#include <qwaylandclientextension.h> | ||
#include <QtWaylandClient/private/qwaylandsurface_p.h> | ||
#include <QtWaylandClient/private/qwaylandwindow_p.h> | ||
|
||
DGUI_BEGIN_NAMESPACE | ||
|
||
class PersonalizationManager_: public PersonalizationManager {}; | ||
Q_GLOBAL_STATIC(PersonalizationManager_, personalizationManager) | ||
|
||
PersonalizationManager::PersonalizationManager() | ||
: QWaylandClientExtensionTemplate<PersonalizationManager>(1) | ||
{ | ||
} | ||
|
||
PersonalizationManager *PersonalizationManager::instance() | ||
{ | ||
return personalizationManager; | ||
} | ||
|
||
PersonalizationWindowContext *PersonalizationManager::getWindowContext(QWindow *window) | ||
{ | ||
Q_ASSERT(!isActive()); | ||
|
||
if (!window) { | ||
return nullptr; | ||
} | ||
window->create(); | ||
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle()); | ||
if (!waylandWindow) { | ||
return nullptr; | ||
} | ||
auto surface = waylandWindow->waylandSurface()->object(); | ||
auto context = get_window_context(surface); | ||
if (m_windowContext.isNull()) { | ||
m_windowContext.reset(new PersonalizationWindowContext(context)); | ||
} | ||
return m_windowContext.data(); | ||
} | ||
|
||
|
||
bool PersonalizationManager::noTitlebar() | ||
{ | ||
return m_windowContext->noTitlebar(); | ||
} | ||
|
||
void PersonalizationManager::setNoTitlebar(bool enable, QWindow *window) | ||
{ | ||
connect(this, &PersonalizationManager::activeChanged, [this, enable, window]{ | ||
if (!isActive()) { | ||
return ; | ||
} | ||
|
||
auto windowContext = this->getWindowContext(window); | ||
if (!windowContext) { | ||
return; | ||
} | ||
windowContext->setNoTitlebar(enable); | ||
}); | ||
} | ||
|
||
PersonalizationWindowContext::PersonalizationWindowContext(struct ::treeland_personalization_window_context_v1 *context) | ||
: QWaylandClientExtensionTemplate<PersonalizationWindowContext>(1) | ||
, QtWayland::treeland_personalization_window_context_v1(context) | ||
{ | ||
} | ||
|
||
|
||
bool PersonalizationWindowContext::noTitlebar() | ||
{ | ||
return m_noTitlebar; | ||
} | ||
|
||
void PersonalizationWindowContext::setNoTitlebar(bool enable) | ||
{ | ||
if (m_noTitlebar == enable) { | ||
return; | ||
} | ||
|
||
m_noTitlebar = enable; | ||
set_no_titlebar(m_noTitlebar ? enable_mode::enable_mode_enable : enable_mode::enable_mode_disable); | ||
} | ||
|
||
PersonalizationAppearanceContext::PersonalizationAppearanceContext(struct ::treeland_personalization_appearance_context_v1 *context) | ||
: QWaylandClientExtensionTemplate<PersonalizationAppearanceContext>(1) | ||
, QtWayland::treeland_personalization_appearance_context_v1(context) | ||
{ | ||
} | ||
|
||
PersonalizationWallpaperContext::PersonalizationWallpaperContext(struct ::treeland_personalization_wallpaper_context_v1 *context) | ||
: QWaylandClientExtensionTemplate<PersonalizationWallpaperContext>(1) | ||
, QtWayland::treeland_personalization_wallpaper_context_v1(context) | ||
{ | ||
} | ||
|
||
PersonalizationCursorContext::PersonalizationCursorContext(struct ::treeland_personalization_cursor_context_v1 *context) | ||
: QWaylandClientExtensionTemplate<PersonalizationCursorContext>(1) | ||
, QtWayland::treeland_personalization_cursor_context_v1(context) | ||
{ | ||
} | ||
DGUI_END_NAMESPACE |
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,79 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include <QtWaylandClient/QWaylandClientExtension> | ||
#include <QWindow> | ||
|
||
#include "qwayland-treeland-personalization-manager-v1.h" | ||
|
||
#include <dtkgui_global.h> | ||
#include <qwaylandclientextension.h> | ||
#include <qwindow.h> | ||
|
||
DGUI_BEGIN_NAMESPACE | ||
class PersonalizationWindowContext; | ||
class PersonalizationManager: public QWaylandClientExtensionTemplate<PersonalizationManager>, | ||
public QtWayland::treeland_personalization_manager_v1 | ||
{ | ||
Q_OBJECT | ||
public: | ||
static PersonalizationManager *instance(); | ||
|
||
bool noTitlebar(); | ||
void setNoTitlebar(bool enable, QWindow *window); | ||
|
||
protected: | ||
explicit PersonalizationManager(); | ||
|
||
private: | ||
PersonalizationWindowContext *getWindowContext(QWindow *window); | ||
|
||
private: | ||
QScopedPointer<PersonalizationWindowContext> m_windowContext; | ||
}; | ||
|
||
class PersonalizationWindowContext : public QWaylandClientExtensionTemplate<PersonalizationWindowContext>, | ||
public QtWayland::treeland_personalization_window_context_v1 | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit PersonalizationWindowContext(struct ::treeland_personalization_window_context_v1 *context); | ||
|
||
bool noTitlebar(); | ||
void setNoTitlebar(bool enable); | ||
|
||
private: | ||
bool m_noTitlebar; | ||
}; | ||
|
||
|
||
class PersonalizationAppearanceContext : public QWaylandClientExtensionTemplate<PersonalizationAppearanceContext>, | ||
public QtWayland::treeland_personalization_appearance_context_v1 | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit PersonalizationAppearanceContext(struct ::treeland_personalization_appearance_context_v1 *context); | ||
|
||
}; | ||
|
||
class PersonalizationWallpaperContext : public QWaylandClientExtensionTemplate<PersonalizationWallpaperContext>, | ||
public QtWayland::treeland_personalization_wallpaper_context_v1 | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit PersonalizationWallpaperContext(struct ::treeland_personalization_wallpaper_context_v1 *context); | ||
|
||
|
||
}; | ||
|
||
class PersonalizationCursorContext : public QWaylandClientExtensionTemplate<PersonalizationCursorContext>, | ||
public QtWayland::treeland_personalization_cursor_context_v1 | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit PersonalizationCursorContext(struct ::treeland_personalization_cursor_context_v1 *context); | ||
|
||
}; | ||
|
||
DGUI_END_NAMESPACE |
Oops, something went wrong.