Skip to content

Commit

Permalink
sync: from linuxdeepin/qt5platform-plugins
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/qt5platform-plugins.

Source-pull-request: linuxdeepin/qt5platform-plugins#251
  • Loading branch information
deepin-ci-robot committed Aug 14, 2024
1 parent 3dcbbe4 commit 7444b72
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 6 deletions.
10 changes: 10 additions & 0 deletions src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ DEFINE_CONST_CHAR(borderColor);
DEFINE_CONST_CHAR(shadowRadius);
DEFINE_CONST_CHAR(shadowOffset);
DEFINE_CONST_CHAR(shadowColor);
DEFINE_CONST_CHAR(windowStartUpEffect);
DEFINE_CONST_CHAR(clipPath);
DEFINE_CONST_CHAR(frameMask);
DEFINE_CONST_CHAR(frameMargins);
DEFINE_CONST_CHAR(translucentBackground);
DEFINE_CONST_CHAR(enableCloseable);
DEFINE_CONST_CHAR(windowEffect);
DEFINE_CONST_CHAR(enableSystemResize);
DEFINE_CONST_CHAR(enableSystemMove);
DEFINE_CONST_CHAR(enableBlurWindow);
Expand Down Expand Up @@ -88,6 +91,13 @@ DEFINE_CONST_CHAR(enableDwayland);
DEFINE_CONST_CHAR(isEnableDwayland);
DEFINE_CONST_CHAR(setEnableNoTitlebar);
DEFINE_CONST_CHAR(setWindowRadius);
DEFINE_CONST_CHAR(setBorderColor);
DEFINE_CONST_CHAR(setShadowColor);
DEFINE_CONST_CHAR(setShadowRadius);
DEFINE_CONST_CHAR(setShadowOffset);
DEFINE_CONST_CHAR(setBorderWidth);
DEFINE_CONST_CHAR(setWindowEffect);
DEFINE_CONST_CHAR(setWindowStartUpEffect);
DEFINE_CONST_CHAR(isEnableNoTitlebar);
DEFINE_CONST_CHAR(buildNativeSettings);
DEFINE_CONST_CHAR(clearNativeSettings);
Expand Down
67 changes: 64 additions & 3 deletions wayland/dwayland/dwaylandinterfacehook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ static QFunctionPointer getFunction(const QByteArray &function)
{setEnableNoTitlebar, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::setEnableNoTitlebar)},
{isEnableNoTitlebar, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::isEnableNoTitlebar)},
{setWindowRadius, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::setWindowRadius)},
{setBorderColor, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::setBorderColor)},
{setBorderWidth, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::setBorderWidth)},
{setShadowColor, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::setShadowColor)},
{setShadowOffset, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::setShadowOffset)},
{setShadowRadius, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::setShadowRadius)},
{setWindowEffect, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::setWindowEffect)},
{setWindowStartUpEffect, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::setWindowStartUpEffect)},
{setWindowProperty, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::setWindowProperty)},
{popupSystemWindowMenu, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::popupSystemWindowMenu)},
{enableDwayland, reinterpret_cast<QFunctionPointer>(&DWaylandInterfaceHook::enableDwayland)},
Expand Down Expand Up @@ -91,11 +98,65 @@ bool DWaylandInterfaceHook::isEnableNoTitlebar(QWindow *window)
return window->property(noTitlebar).toBool();
}

bool DWaylandInterfaceHook::setWindowRadius(QWindow *window, int value)
void DWaylandInterfaceHook::setWindowRadius(QWindow *window, int value)
{
if (!window)
return false;
return window->setProperty(windowRadius, QVariant{value});
return;
DNoTitlebarWlWindowHelper::setWindowProperty(window, ::windowRadius, value);
}

void DWaylandInterfaceHook::setBorderColor(QWindow *window, const QColor &value)
{
if (!window)
return;
DNoTitlebarWlWindowHelper::setWindowProperty(window, ::borderColor, value);
}

void DWaylandInterfaceHook::setShadowColor(QWindow *window, const QColor &value)
{
if (!window)
return;
DNoTitlebarWlWindowHelper::setWindowProperty(window, ::shadowColor, value);
}

void DWaylandInterfaceHook::setShadowRadius(QWindow *window, int value)
{
if (!window)
return;
DNoTitlebarWlWindowHelper::setWindowProperty(window, ::shadowRadius, value);
}

void DWaylandInterfaceHook::setShadowOffset(QWindow *window, const QPoint &value)
{
if (!window)
return;

QPoint offect = value;
if (window->screen())
offect *= window->screen()->devicePixelRatio();

DNoTitlebarWlWindowHelper::setWindowProperty(window, ::shadowOffset, offect);
}

void DWaylandInterfaceHook::setBorderWidth(QWindow *window, int value)
{
if (!window)
return;
DNoTitlebarWlWindowHelper::setWindowProperty(window, ::borderWidth, value);
}

void DWaylandInterfaceHook::setWindowEffect(QWindow *window, const QVariant &value)
{
if (!window)
return;
DNoTitlebarWlWindowHelper::setWindowProperty(window, ::windowEffect, value);
}

void DWaylandInterfaceHook::setWindowStartUpEffect(QWindow *window, const QVariant &value)
{
if (!window)
return;
DNoTitlebarWlWindowHelper::setWindowProperty(window, ::windowStartUpEffect, value);
}

void DWaylandInterfaceHook::setWindowProperty(QWindow *window, const char *name, const QVariant &value)
Expand Down
11 changes: 10 additions & 1 deletion wayland/dwayland/dwaylandinterfacehook.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ class DWaylandInterfaceHook

static bool setEnableNoTitlebar(QWindow *window, bool enable);
static bool isEnableNoTitlebar(QWindow *window);
static bool setWindowRadius(QWindow *window, int value);

static void setWindowRadius(QWindow *window, int value);
static void setBorderColor(QWindow *window, const QColor &value);
static void setShadowColor(QWindow *window, const QColor &value);
static void setShadowRadius(QWindow *window, int value);
static void setShadowOffset(QWindow *window, const QPoint &value);
static void setBorderWidth(QWindow *window, int value);
static void setWindowEffect(QWindow *window, const QVariant &value);
static void setWindowStartUpEffect(QWindow *window, const QVariant &value);

static void setWindowProperty(QWindow *window, const char *name, const QVariant &value);
static void popupSystemWindowMenu(quintptr wid);
static bool enableDwayland(QWindow *window);
Expand Down
4 changes: 2 additions & 2 deletions wayland/wayland-shell/dwaylandshellmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ void DWaylandShellManager::sendProperty(QWaylandShellSurface *self, const QStrin

if (auto *dde_shell_surface = ensureDDEShellSurface(self)) {
if (!name.compare(noTitlebar)) {
qCDebug(dwlp()) << "### requestNoTitleBar" << value;
qCDebug(dwlp()) << "Request NoTitleBar, value: " << value;
dde_shell_surface->requestNoTitleBarProperty(value.toBool());
}
if (!name.compare(windowRadius)) {
bool ok = false;
qreal radius = value.toInt(&ok);
if (wlWindow->screen())
radius *= wlWindow->screen()->devicePixelRatio();
qCDebug(dwlp()) << "### requestWindowRadius" << radius << value;
qCDebug(dwlp()) << "Rquest window radius, value: " << radius << value;
if (ok)
dde_shell_surface->requestWindowRadiusProperty({radius, radius});
else
Expand Down
46 changes: 46 additions & 0 deletions xcb/dnotitlebarwindowhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ DNoTitlebarWindowHelper::DNoTitlebarWindowHelper(QWindow *window, quint32 window
updateShadowRadiusFromProperty();
updateShadowOffsetFromProperty();
updateShadowColorFromProperty();
updateWindowEffectFromProperty();
updateWindowStartUpEffectFromProperty();
updateEnableSystemResizeFromProperty();
updateEnableSystemMoveFromProperty();
updateEnableBlurWindowFromProperty();
Expand Down Expand Up @@ -203,6 +205,16 @@ QColor DNoTitlebarWindowHelper::shadowColor() const
return qvariant_cast<QColor>(property("shadowColor"));
}

quint32 DNoTitlebarWindowHelper::windowEffect()
{
return qvariant_cast<quint32>(property("windowEffect"));
}

quint32 DNoTitlebarWindowHelper::windowStartUpEffect()
{
return qvariant_cast<quint32>(property("windowStartUpEffect"));
}

QMarginsF DNoTitlebarWindowHelper::mouseInputAreaMargins() const
{
return takeMargins(property("mouseInputAreaMargins"), QMarginsF(0, 0, 0, 0));
Expand Down Expand Up @@ -258,6 +270,16 @@ void DNoTitlebarWindowHelper::setMouseInputAreaMargins(const QMarginsF &mouseInp
.arg(mouseInputAreaMargins.right()).arg(mouseInputAreaMargins.bottom()));
}

void DNoTitlebarWindowHelper::setWindowEffect(quint32 effectScene)
{
setProperty("windowEffect", static_cast<quint32>(effectScene));
}

void DNoTitlebarWindowHelper::setWindowStartUpEffect(quint32 effectType)
{
setProperty("windowStartUpEffect", static_cast<quint32>(effectType));
}

void DNoTitlebarWindowHelper::updateClipPathFromProperty()
{
const QVariant &v = m_window->property(clipPath);
Expand Down Expand Up @@ -358,6 +380,30 @@ void DNoTitlebarWindowHelper::updateShadowColorFromProperty()
}
}

void DNoTitlebarWindowHelper::updateWindowEffectFromProperty()
{
const QVariant &v = m_window->property("_d_windowEffect");
const quint32 &effectScene = qvariant_cast<quint32>(v);

if (effectScene) {
setWindowEffect(effectScene);
} else {
resetProperty("windowEffect");
}
}

void DNoTitlebarWindowHelper::updateWindowStartUpEffectFromProperty()
{
const QVariant &v = m_window->property("_d_windowStartUpEffect");
const quint32 &effectType = qvariant_cast<quint32>(v);

if (effectType) {
setWindowStartUpEffect(effectType);
} else {
resetProperty("windowStartUpEffect");
}
}

void DNoTitlebarWindowHelper::updateEnableSystemResizeFromProperty()
{
const QVariant &v = m_window->property(enableSystemResize);
Expand Down
10 changes: 10 additions & 0 deletions xcb/dnotitlebarwindowhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class DNoTitlebarWindowHelper : public QObject
Q_PROPERTY(qreal shadowRadius READ shadowRadius WRITE setShadowRadius NOTIFY shadowRadiusChanged)
Q_PROPERTY(QPointF shadowOffset READ shadowOffset WRITE setShadowOffect NOTIFY shadowOffectChanged)
Q_PROPERTY(QColor shadowColor READ shadowColor WRITE setShadowColor NOTIFY shadowColorChanged)
Q_PROPERTY(quint32 windowEffect READ windowEffect WRITE setWindowEffect NOTIFY windowEffectChanged)
Q_PROPERTY(quint32 windowStartUpEffect READ windowStartUpEffect WRITE setWindowStartUpEffect NOTIFY windowStartUpEffectChanged)
Q_PROPERTY(QMarginsF mouseInputAreaMargins READ mouseInputAreaMargins WRITE setMouseInputAreaMargins NOTIFY mouseInputAreaMarginsChanged)

public:
Expand All @@ -48,6 +50,8 @@ class DNoTitlebarWindowHelper : public QObject
qreal shadowRadius() const;
QPointF shadowOffset() const;
QColor shadowColor() const;
quint32 windowEffect();
quint32 windowStartUpEffect();
QMarginsF mouseInputAreaMargins() const;

void resetProperty(const QByteArray &property);
Expand All @@ -59,6 +63,8 @@ class DNoTitlebarWindowHelper : public QObject
void setShadowOffect(const QPointF &shadowOffset);
void setShadowColor(const QColor &shadowColor);
void setMouseInputAreaMargins(const QMarginsF &mouseInputAreaMargins);
void setWindowEffect(quint32 effectScene);
void setWindowStartUpEffect(quint32 effectType);

signals:
void themeChanged();
Expand All @@ -68,6 +74,8 @@ class DNoTitlebarWindowHelper : public QObject
void shadowRadiusChanged();
void shadowOffectChanged();
void shadowColorChanged();
void windowEffectChanged();
void windowStartUpEffectChanged();
void mouseInputAreaMarginsChanged();

private slots:
Expand All @@ -80,6 +88,8 @@ private slots:
Q_SLOT void updateShadowRadiusFromProperty();
Q_SLOT void updateShadowOffsetFromProperty();
Q_SLOT void updateShadowColorFromProperty();
Q_SLOT void updateWindowEffectFromProperty();
Q_SLOT void updateWindowStartUpEffectFromProperty();
Q_SLOT void updateEnableSystemResizeFromProperty();
Q_SLOT void updateEnableSystemMoveFromProperty();
Q_SLOT void updateEnableBlurWindowFromProperty();
Expand Down

0 comments on commit 7444b72

Please sign in to comment.