-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Synchronize source files from linuxdeepin/dtkgui. Source-pull-request: linuxdeepin/dtkgui#210
- Loading branch information
1 parent
d96aef2
commit 6b2277e
Showing
10 changed files
with
372 additions
and
0 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,95 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#include "dcontextshellwindow.h" | ||
|
||
#include "qwaylandpersonalizationshellintegration_p.h" | ||
|
||
#include <QLoggingCategory> | ||
#include <QMargins> | ||
#include <QWindow> | ||
#include <QtWaylandClient/private/qwaylandwindow_p.h> | ||
|
||
Q_LOGGING_CATEGORY(layershellwindow, "dde.shell.layershell.window") | ||
|
||
class DContextShellWindowPrivate | ||
{ | ||
public: | ||
explicit DContextShellWindowPrivate(QWindow *window) | ||
: parentWindow(window) | ||
{ | ||
} | ||
|
||
QWindow *parentWindow = nullptr; | ||
int noTitlebar = -1; | ||
}; | ||
|
||
void DContextShellWindow::setNoTitlebar(const int value) | ||
{ | ||
if (value == d->noTitlebar) { | ||
return; | ||
} | ||
d->noTitlebar = value; | ||
} | ||
|
||
int DContextShellWindow::noTitlebar() | ||
{ | ||
return d->noTitlebar; | ||
} | ||
|
||
static QMap<QWindow *, DContextShellWindow *> s_map; | ||
|
||
DContextShellWindow::~DContextShellWindow() | ||
{ | ||
s_map.remove(d->parentWindow); | ||
} | ||
|
||
DContextShellWindow::DContextShellWindow(QWindow *window) | ||
: QObject(window) | ||
, d(new DContextShellWindowPrivate(window)) | ||
{ | ||
s_map.insert(window, this); | ||
window->create(); | ||
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle()); | ||
if (waylandWindow) { | ||
static QWaylandPersonalizationShellIntegration *shellIntegration = nullptr; | ||
if (!shellIntegration) { | ||
shellIntegration = new QWaylandPersonalizationShellIntegration(); | ||
if (!shellIntegration->initialize(waylandWindow->display())) { | ||
delete shellIntegration; | ||
shellIntegration = nullptr; | ||
qCWarning(layershellwindow) << "failed to init dlayershell intergration"; | ||
return; | ||
} | ||
} | ||
waylandWindow->setShellIntegration(shellIntegration); | ||
} | ||
#ifdef BUILD_WITH_X11 | ||
else if (auto xcbWindow = | ||
dynamic_cast<QNativeInterface::Private::QXcbWindow *>(window->handle())) { | ||
new LayerShellEmulation(window, this); | ||
qCWarning(layershellwindow) << "not a wayland window, try to emulate on x11"; | ||
} | ||
#endif | ||
else { | ||
qCWarning(layershellwindow) << "not a wayland window, will not create zwlr_layer_surface"; | ||
} | ||
} | ||
|
||
DContextShellWindow *DContextShellWindow::get(QWindow *window) | ||
{ | ||
auto dlayerShellWindow = s_map.value(window); | ||
if (dlayerShellWindow) { | ||
return dlayerShellWindow; | ||
} | ||
return new DContextShellWindow(window); | ||
} | ||
|
||
DContextShellWindow *DContextShellWindow::qmlAttachedProperties(QObject *object) | ||
{ | ||
auto window = qobject_cast<QWindow *>(object); | ||
if (window) | ||
return get(window); | ||
qCWarning(layershellwindow) << "not a qwindow unable to create DContextShellWindow"; | ||
return 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,39 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#pragma once | ||
|
||
#include <QLoggingCategory> | ||
#include <QObject> | ||
#include <QScreen> | ||
#include <QWindow> | ||
|
||
class DContextShellWindowPrivate; | ||
|
||
class DContextShellWindow : public QObject | ||
{ | ||
Q_OBJECT | ||
Q_PROPERTY(int noTitlebar READ noTitlebar WRITE setNoTitlebar NOTIFY noTitlebarChanged) | ||
|
||
public: | ||
~DContextShellWindow() override; | ||
|
||
void setNoTitlebar(const int value); | ||
int noTitlebar(); | ||
|
||
/** | ||
* Gets the LayerShell Window for a given Qt Window | ||
* Ownership is not transferred | ||
*/ | ||
static DContextShellWindow *get(QWindow *window); | ||
|
||
static DContextShellWindow *qmlAttachedProperties(QObject *object); | ||
|
||
Q_SIGNALS: | ||
void noTitlebarChanged(); | ||
|
||
private: | ||
DContextShellWindow(QWindow *window); | ||
Check warning on line 37 in src/wayland/dcontextshellwindow.h GitHub Actions / cppcheck
|
||
QScopedPointer<DContextShellWindowPrivate> d; | ||
}; |
90 changes: 90 additions & 0 deletions
90
src/wayland/protocol/treeland-personalization-manager-v1.xml
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,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<protocol name="treeland_personalization_manager_v1"> | ||
<copyright> Copyright © 2023 Uniontech | ||
Permission is hereby granted, free of charge, to any person obtaining a | ||
copy of this software and associated documentation files (the "Software"), | ||
to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice (including the next | ||
paragraph) shall be included in all copies or substantial portions of the | ||
Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. | ||
</copyright> | ||
<interface name="treeland_personalization_manager_v1" version="1"> | ||
<description summary="personalization manager"> | ||
This interface allows a client to customized display effects. | ||
|
||
Warning! The protocol described in this file is currently in the testing | ||
phase. Backward compatible changes may be added together with the | ||
corresponding interface version bump. Backward incompatible changes can | ||
only be done by creating a new major version of the extension. | ||
</description> | ||
<request name="get_wallpaper_context"> | ||
<arg name="id" type="new_id" interface="treeland_wallpaper_context_v1" /> | ||
</request> | ||
<request name="get_window_context"> | ||
<arg name="surface" type="object" interface="wl_surface" /> | ||
<arg name="id" type="new_id" interface="treeland_window_context_v1" /> | ||
</request> | ||
</interface> | ||
<interface name="treeland_wallpaper_context_v1" version="1"> | ||
<description summary="client wallpaper context"> | ||
This interface allows a client set window wallpaper. | ||
|
||
Warning! The protocol described in this file is currently in the testing | ||
phase. Backward compatible changes may be added together with the | ||
corresponding interface version bump. Backward incompatible changes can | ||
only be done by creating a new major version of the extension. | ||
</description> | ||
<request name="destroy" type="destructor"> | ||
<description summary="destroy the context object"> | ||
Destroy the context object. | ||
</description> | ||
</request> | ||
</interface> | ||
<interface name="treeland_window_context_v1" version="1"> | ||
<description summary="client window context"> | ||
This interface allows a client set window properties. | ||
|
||
Warning! The protocol described in this file is currently in the testing | ||
phase. Backward compatible changes may be added together with the | ||
corresponding interface version bump. Backward incompatible changes can | ||
only be done by creating a new major version of the extension. | ||
</description> | ||
<request name="set_radius"> | ||
<description summary="the radius which represents the toplevel"> | ||
The radius of the surface specified in this request corresponds to the place where | ||
the app using this protocol represents the given toplevel. | ||
</description> | ||
|
||
<arg name="x" type="int" /> | ||
<arg name="y" type="int" /> | ||
</request> | ||
<request name="set_no_titlebar"> | ||
<description summary="toplevel doesn't need titlebar"> | ||
When the value is non-zero, the toplevel titlebar will be disabled. | ||
</description> | ||
|
||
<arg name="value" type="int" /> | ||
</request> | ||
<request name="destroy" type="destructor"> | ||
<description summary="destroy the context object"> | ||
Destroy the context object. | ||
</description> | ||
</request> | ||
<enum name="error"> | ||
<entry name="invalid_radius" value="0" | ||
summary="the provided radius is invalid" /> | ||
</enum> | ||
</interface> | ||
</protocol> |
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: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "qwaylandpersonalizationshellintegration_p.h" | ||
#include "qwaylandwindowcontextshellsurface_p.h" | ||
#include "wayland-treeland-personalization-manager-v1-client-protocol.h" | ||
|
||
QWaylandPersonalizationShellIntegration::QWaylandPersonalizationShellIntegration() | ||
: QWaylandShellIntegrationTemplate<QWaylandPersonalizationShellIntegration>(4) | ||
{ | ||
} | ||
|
||
QWaylandPersonalizationShellIntegration::~QWaylandPersonalizationShellIntegration() | ||
{ | ||
if (object() | ||
&& treeland_personalization_manager_v1_get_version(object()) | ||
>= TREELAND_WINDOW_CONTEXT_V1_DESTROY_SINCE_VERSION) { | ||
treeland_personalization_manager_v1_destroy(object()); | ||
} | ||
} | ||
|
||
QtWaylandClient::QWaylandShellSurface * | ||
QWaylandPersonalizationShellIntegration::createShellSurface(QtWaylandClient::QWaylandWindow *window) | ||
{ | ||
return new QWaylandWindowContextSurface(this, window); | ||
} |
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,21 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#pragma once | ||
|
||
#include <private/qwaylandshellintegration_p.h> | ||
#include <qwayland-treeland-personalization-manager-v1.h> | ||
|
||
class QWaylandPersonalizationShellIntegration | ||
: public QtWaylandClient::QWaylandShellIntegrationTemplate< | ||
QWaylandPersonalizationShellIntegration>, | ||
public QtWayland::treeland_personalization_manager_v1 | ||
{ | ||
public: | ||
QWaylandPersonalizationShellIntegration(); | ||
~QWaylandPersonalizationShellIntegration() override; | ||
|
||
QtWaylandClient::QWaylandShellSurface * | ||
createShellSurface(QtWaylandClient::QWaylandWindow *window) override; | ||
}; |
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,31 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "dcontextshellwindow.h" | ||
#include "qwaylandwindowcontextshellsurface_p.h" | ||
|
||
#include <QLoggingCategory> | ||
#include <QtWaylandClient/private/qwaylandsurface_p.h> | ||
#include <QtWaylandClient/private/qwaylandwindow_p.h> | ||
|
||
Q_LOGGING_CATEGORY(layershellsurface, "dde.shell.layershell.surface") | ||
|
||
QWaylandWindowContextSurface::QWaylandWindowContextSurface( | ||
QtWayland::treeland_personalization_manager_v1 *shell, QtWaylandClient::QWaylandWindow *window) | ||
: QtWaylandClient::QWaylandShellSurface(window) | ||
, QtWayland::treeland_window_context_v1() | ||
, m_dcontextShellWindow(DContextShellWindow::get(window->window())) | ||
{ | ||
init(shell->get_window_context(window->waylandSurface()->object())); | ||
set_no_titlebar(m_dcontextShellWindow->noTitlebar()); | ||
connect(m_dcontextShellWindow, &DContextShellWindow::noTitlebarChanged, this, [this, window]() { | ||
set_no_titlebar(m_dcontextShellWindow->noTitlebar()); | ||
window->waylandSurface()->commit(); | ||
}); | ||
} | ||
|
||
QWaylandWindowContextSurface::~QWaylandWindowContextSurface() | ||
{ | ||
destroy(); | ||
} |
Oops, something went wrong.