Skip to content

Commit

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

Source-pull-request: linuxdeepin/dtkgui#258
  • Loading branch information
deepin-ci-robot committed Oct 11, 2024
1 parent 098486f commit 3ac720a
Show file tree
Hide file tree
Showing 10 changed files with 577 additions and 257 deletions.
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ else()
find_package(Qt5 REQUIRED COMPONENTS WaylandClient XkbCommonSupport)
endif()

find_package(TreeLandProtocols REQUIRED)

add_library(${LIB_NAME} SHARED)

include(dbus/dbus.cmake)
Expand All @@ -14,7 +16,7 @@ include(util/util.cmake)

if("${QT_VERSION_MAJOR}" STREQUAL "6")
qt6_generate_wayland_protocol_client_sources(${LIB_NAME} FILES
${CMAKE_CURRENT_SOURCE_DIR}/wayland/protocol/treeland-personalization-manager-v1.xml
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-personalization-manager-v1.xml
)
else()
# ECM setup
Expand All @@ -23,7 +25,7 @@ else()
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${ECM_MODULE_PATH}")
find_package(QtWaylandScanner)
ecm_add_qtwayland_client_protocol(${LIB_NAME}
PROTOCOL ${CMAKE_CURRENT_SOURCE_DIR}/wayland/protocol/treeland-personalization-manager-v1.xml
PROTOCOL ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-personalization-manager-v1.xml
BASENAME treeland-personalization-manager-v1
)
target_sources(${LIB_NAME} PRIVATE
Expand Down
60 changes: 30 additions & 30 deletions src/kernel/dplatformhandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "dplatformhandle.h"
#include "dplatformtheme.h"
#include "dwindowmanagerhelper.h"
#include "wayland/dcontextshellwindow.h"
#include "wayland/personalizationwaylandclientextension.h"
#include <private/qwaylandwindow_p.h>

#include <QWindow>
Expand Down Expand Up @@ -629,31 +629,29 @@ class Q_DECL_HIDDEN CreatorWindowEventFile : public QObject {
}

if (auto *w = qobject_cast<QWindow *>(watched); w && isTreeLand()) {
if(DContextShellWindow *window = DContextShellWindow::get(qobject_cast<QWindow *>(watched))) {
bool is_mouse_move = event->type() == QEvent::MouseMove && static_cast<QMouseEvent*>(event)->buttons() == Qt::LeftButton;
bool is_mouse_move = event->type() == QEvent::MouseMove && static_cast<QMouseEvent*>(event)->buttons() == Qt::LeftButton;

if (event->type() == QEvent::MouseButtonRelease) {
m_windowMoving = false;
}
if (event->type() == QEvent::MouseButtonRelease) {
m_windowMoving = false;
}

// workaround for kwin: Qt receives no release event when kwin finishes MOVE operation,
// which makes app hang in windowMoving state. when a press happens, there's no sense of
// keeping the moving state, we can just reset ti back to normal.
if (event->type() == QEvent::MouseButtonPress) {
m_windowMoving = false;
}
// workaround for kwin: Qt receives no release event when kwin finishes MOVE operation,
// which makes app hang in windowMoving state. when a press happens, there's no sense of
// keeping the moving state, we can just reset ti back to normal.
if (event->type() == QEvent::MouseButtonPress) {
m_windowMoving = false;
}

// FIXME: We need to check whether the event is accepted.
// Only when the upper control does not accept the event,
// the window should be moved through the window.
// But every event here has been accepted. I don't know what happened.
if (is_mouse_move && w->geometry().contains(static_cast<QMouseEvent*>(event)->globalPos())) {
if (!m_windowMoving && window->noTitlebar()) {
m_windowMoving = true;

event->accept();
static_cast<QtWaylandClient::QWaylandWindow *>(w->handle())->startSystemMove();
}
// FIXME: We need to check whether the event is accepted.
// Only when the upper control does not accept the event,
// the window should be moved through the window.
// But every event here has been accepted. I don't know what happened.
if (is_mouse_move && w->geometry().contains(static_cast<QMouseEvent*>(event)->globalPos())) {
if (!m_windowMoving && PersonalizationManager::instance()->noTitlebar()) {
m_windowMoving = true;

event->accept();
static_cast<QtWaylandClient::QWaylandWindow *>(w->handle())->startSystemMove();
}
}
}
Expand Down Expand Up @@ -683,10 +681,7 @@ bool DPlatformHandle::setEnabledNoTitlebarForWindow(QWindow *window, bool enable
return false;

if (window && isTreeLand()) {
DContextShellWindow *contextWindow = DContextShellWindow::get(window);
if (contextWindow->noTitlebar() == enable)
return true;
contextWindow->setNoTitlebar(enable);
PersonalizationManager::instance()->setNoTitlebar(window, enable);
window->installEventFilter(new CreatorWindowEventFile(window));
return true;
}
Expand Down Expand Up @@ -1109,7 +1104,8 @@ void DPlatformHandle::setDisableWindowOverrideCursor(QWindow *window, bool disab

int DPlatformHandle::windowRadius() const
{
return m_window->property(_windowRadius).toInt();
return isTreeLand() ? PersonalizationManager::instance()->windowRadius() :
m_window->property(_windowRadius).toInt();
}

int DPlatformHandle::borderWidth() const
Expand Down Expand Up @@ -1209,8 +1205,12 @@ WId DPlatformHandle::windowLeader()

void DPlatformHandle::setWindowRadius(int windowRadius)
{
setWindowProperty(m_window, _windowRadius, windowRadius);
resolve(m_window, PropRole::WindowRadius);
if (isTreeLand()) {
PersonalizationManager::instance()->setWindowRadius(m_window, windowRadius);
} else {
setWindowProperty(m_window, _windowRadius, windowRadius);
resolve(m_window, PropRole::WindowRadius);
}
}

void DPlatformHandle::setBorderWidth(int borderWidth)
Expand Down
36 changes: 36 additions & 0 deletions src/kernel/dplatformtheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@

#include "dplatformtheme.h"
#include "private/dplatformtheme_p.h"
#include "wayland/personalizationwaylandclientextension.h"

#include <QVariant>
#include <QTimer>
#include <QMetaProperty>
#include <QDebug>

#include <functional>
#include <strstream>

DGUI_BEGIN_NAMESPACE

static bool isTreeLand()
{
return qEnvironmentVariable("DDE_CURRENT_COMPOSITOR") == "TreeLand";
};

// "/deepin/palette" 为调色板属性的存储位置
// 在x11平台下,将使用_DEEPIN_PALETTE作为存储调色板数据的窗口属性
DPlatformThemePrivate::DPlatformThemePrivate(Dtk::Gui::DPlatformTheme *qq)
Expand Down Expand Up @@ -387,6 +394,10 @@ int DPlatformTheme::dndDragThreshold() const

int DPlatformTheme::windowRadius() const
{
if (isTreeLand()) {
return PersonalizationManager::instance()->windowRadius();
}

return windowRadius(-1);
}

Expand Down Expand Up @@ -414,6 +425,10 @@ QByteArray DPlatformTheme::themeName() const

QByteArray DPlatformTheme::iconThemeName() const
{
if (isTreeLand()) {
return PersonalizationManager::instance()->iconTheme().toLatin1();
}

FETCH_PROPERTY("Net/IconThemeName", iconThemeName)

return value.toByteArray();
Expand All @@ -428,13 +443,21 @@ QByteArray DPlatformTheme::soundThemeName() const

QByteArray DPlatformTheme::fontName() const
{
if (isTreeLand()) {
return PersonalizationManager::instance()->fontName().toLatin1();
}

FETCH_PROPERTY("Qt/FontName", fontName)

return value.toByteArray();
}

QByteArray DPlatformTheme::monoFontName() const
{
if (isTreeLand()) {
return PersonalizationManager::instance()->monoFontName().toLatin1();
}

FETCH_PROPERTY("Qt/MonoFontName", monoFontName)

return value.toByteArray();
Expand Down Expand Up @@ -697,6 +720,11 @@ void DPlatformTheme::setThemeName(const QByteArray &themeName)

void DPlatformTheme::setIconThemeName(const QByteArray &iconThemeName)
{
if (isTreeLand()) {
PersonalizationManager::instance()->setIconTheme(iconThemeName);
return;
}

D_D(DPlatformTheme);

d->theme->setSetting("Net/IconThemeName", iconThemeName);
Expand All @@ -711,13 +739,21 @@ void DPlatformTheme::setSoundThemeName(const QByteArray &soundThemeName)

void DPlatformTheme::setFontName(const QByteArray &fontName)
{
if (isTreeLand()) {
PersonalizationManager::instance()->setFontName(fontName);
return;
}
D_D(DPlatformTheme);

d->theme->setSetting("Qt/FontName", fontName);
}

void DPlatformTheme::setMonoFontName(const QByteArray &monoFontName)
{
if (isTreeLand()) {
PersonalizationManager::instance()->setMonoFontName(monoFontName);
return;
}
D_D(DPlatformTheme);

d->theme->setSetting("Qt/MonoFontName", monoFontName);
Expand Down
Loading

0 comments on commit 3ac720a

Please sign in to comment.