Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
#
# SPDX-License-Identifier: CC0-1.0

cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.16)

project(dde-appearance)

cmake_policy(SET CMP0160 OLD)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
Expand All @@ -18,6 +21,12 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Werror=return-type -fno-omit-frame-pointer -Wextra")
endif()

set(QT_VERSION_MAJOR 6)
set(DTK_VERSION_MAJOR 6)

set(TRANS_FILE_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}src/service/impl/appearancemanager.cpp)
set(PLUGIN_NAME "plugin-dde-appearance")

add_subdirectory(src)
add_subdirectory(misc)
add_subdirectory(fakewm)
17 changes: 8 additions & 9 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@ Maintainer: Deepin Packages Builder <packages@deepin.com>
Build-Depends: debhelper (>= 9),
cmake,
pkg-config,
qtbase5-dev,
libdtkcore-dev,
libdtkgui-dev,
libpolkit-qt5-1-dev,
qt6-base-dev,
qt6-tools-dev-tools,
libdtk6core-dev,
libdtk6gui-dev,
libpolkit-qt6-1-dev,
libgdk-pixbuf2.0-0,
libgsettings-qt-dev,
libglib2.0-dev,
libxcursor-dev,
libgtk-3-dev,
libxcb1-dev,
libxcb-cursor-dev,
libxcb-randr0-dev,
libxcb-render0-dev,
qttools5-dev-tools,
libssl-dev,
libkf5globalaccel-dev,
libkf5windowsystem-dev,
libkf5config-dev,
libkf6globalaccel-dev,
libkf6windowsystem-dev,
libkf6config-dev,
Standards-Version: 3.9.8
Homepage: http://www.deepin.org

Expand Down
31 changes: 14 additions & 17 deletions fakewm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ set(CMAKE_AUTOMOC ON)
include(FindPkgConfig)
find_package(PkgConfig REQUIRED)

find_package(Qt5 REQUIRED COMPONENTS Core DBus Concurrent Gui)
find_package(DtkCore REQUIRED)
find_package(DtkGui REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(KF5Config REQUIRED)
find_package(KF5WindowSystem REQUIRED)
find_package(KF5GlobalAccel REQUIRED)
find_package(Dtk REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core DBus Concurrent Gui)
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui)
find_package(KF6Config REQUIRED)
find_package(KF6WindowSystem REQUIRED)
find_package(KF6GlobalAccel REQUIRED)

set(SRCS
./dbus/deepinwmfaker.h
./dbus/deepinwmfaker.cpp
main.cpp
)

qt5_add_dbus_adaptor(
qt_add_dbus_adaptor(
wm_SRCS
../dbus/com.deepin.wm.xml
./dbus/deepinwmfaker.h
Expand All @@ -36,14 +33,14 @@ add_executable(dde-fakewm
)

target_link_libraries(dde-fakewm
Qt5::Core
Qt5::DBus
Qt5::Concurrent
Qt5::Gui
KF5::ConfigCore
KF5::WindowSystem
KF5::GlobalAccel
Dtk::Core
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::Gui
Dtk${DTK_VERSION_MAJOR}::Core
KF6::ConfigCore
KF6::WindowSystem
KF6::GlobalAccel
)

install(TARGETS dde-fakewm DESTINATION ${CMAKE_INSTALL_BINDIR})
68 changes: 46 additions & 22 deletions fakewm/dbus/deepinwmfaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "deepinwmfaker.h"

#include <QDBusConnection>
#include <QDBusMessage>
#include <QDebug>
#include <QJsonArray>
Expand All @@ -14,16 +13,19 @@
#include <QProcess>
#include <QStringList>
#include <QFileInfo>
#include <QDBusReply>
#include <QMetaEnum>
#include <QDBusConnectionInterface>
#include <mutex>

#include <KF5/KConfigCore/KConfig>
#include <KF5/KConfigCore/KConfigGroup>
#include <KF5/KConfigCore/KSharedConfig>
#include <KF5/KWindowSystem/KWindowSystem>
#include <KF5/KWindowSystem/KWindowEffects>
#include <KF5/KGlobalAccel/KGlobalAccel>
#include <KF6/KConfigCore/KConfigGroup>
#include <KF6/KConfigCore/KSharedConfig>
#include <KF6/KGlobalAccel/KGlobalAccel>
#include <KF6/KWindowSystem/KWindowSystem>
#include <KF6/KWindowSystem/KWindowEffects>
#include <KWindowInfo>
#include <KX11Extras>

#include <DConfig>

#ifndef DISABLE_DEEPIN_WM
#define DconfigBackgroundUri "Background_Uris"
Expand Down Expand Up @@ -327,11 +329,11 @@ DeepinWMFaker::DeepinWMFaker(QObject* appearance)
#ifndef DISABLE_DEEPIN_WM
m_currentDesktop = m_kwinConfig->group("Workspace").readEntry<int>("CurrentDesktop", 1);

connect(m_windowSystem, &KWindowSystem::currentDesktopChanged, this, [this] (int to) {
connect(KX11Extras::self(), &KX11Extras::currentDesktopChanged, this, [this] (int to) {
Q_EMIT WorkspaceSwitched(m_currentDesktop, to);
m_currentDesktop = to;
});
connect(m_windowSystem, &KWindowSystem::numberOfDesktopsChanged, this, &DeepinWMFaker::workspaceCountChanged);
connect(KX11Extras::self(), &KX11Extras::numberOfDesktopsChanged, this, &DeepinWMFaker::workspaceCountChanged);
connect(m_appearance.data(), SIGNAL(valueChanged(const QString &)),this,SLOT(DeepinWMFaker::onGsettingsDDEAppearanceChanged));
#endif // DISABLE_DEEPIN_WM

Expand Down Expand Up @@ -580,7 +582,7 @@ void DeepinWMFaker::SetTransientBackground(const QString &uri)

void DeepinWMFaker::SetTransientBackgroundForMonitor(const QString &uri, const QString &strMonitorName)
{
int current = m_windowSystem->currentDesktop();
int current = KX11Extras::currentDesktop();

m_transientBackgroundUri = uri;
Q_EMIT WorkspaceBackgroundChangedForMonitor( current,strMonitorName,uri );
Expand Down Expand Up @@ -879,11 +881,13 @@ void DeepinWMFaker::PreviewWindow(uint xid)
}

// 使用kwin自带的预览特效
if (KWindowEffects::isEffectAvailable(KWindowEffects::HighlightWindows)) {
if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.KWin.HighlightWindow")) {
//if (KWindowEffects::isEffectAvailable(KWindowEffects::HighlightWindows)) {
// ###(zccrs): 按道理讲 previewingController 应该为dock的预览展示窗口(发起预览请求的窗口)
// 不过,dde-dock中不支持此种用法,而且对kwin接口的调用仅仅是fallback,因此直接将xid作为预览请求的controller窗口
previewingController = xid;
KWindowEffects::highlightWindows(previewingController, {xid});
//previewingController = xid;
//KWindowEffects::highlightWindows(previewingController, {xid});
callHighlightWindows({QString::number(xid)});
return;
}

Expand All @@ -894,7 +898,7 @@ void DeepinWMFaker::PreviewWindow(uint xid)
// qDebug() << "order" << m_windowSystem->stackingOrder();
// qDebug() << "contains" << m_windowSystem->hasWId(xid);

m_windowSystem->forceActiveWindow(xid);
KX11Extras::forceActiveWindow(xid);
m_previewWinMiniPair.first = xid;
m_previewWinMiniPair.second = false;

Expand All @@ -918,20 +922,23 @@ void DeepinWMFaker::CancelPreviewWindow()

// 退出kwin自带的预览特效
if (previewingController) {
KWindowEffects::highlightWindows(previewingController, {});
//KWindowEffects::highlightWindows(previewingController, {});
callHighlightWindows({QString::number(previewingController)});
previewingController = 0;
return;
}

// FIXME: same as above
if (m_windowSystem->windows().contains(m_previewWinMiniPair.first)) {
if (KX11Extras::windows().contains(m_previewWinMiniPair.first)) {
if (m_previewWinMiniPair.second) {
// m_windowSystem->minimizeWindow(m_previewWinMiniPair.first);
// m_windowSystem->minimizeWindow(m_previewWinMiniPair.first);
// using this way to minimize a window without animation
m_windowSystem->setState(m_previewWinMiniPair.first, NET::Hidden);
KX11Extras::setState(m_previewWinMiniPair.first, NET::Hidden);
return;
}
m_windowSystem->lowerWindow(m_previewWinMiniPair.first);
// TODO, in kf6, lowerWindow is deprecated and be removed,and the source code lowerWindow implementation is empty
// https://github.com/KDE/kwindowsystem/blob/kf5/src/kwindowsystem.cpp
//m_windowSystem->lowerWindow(m_previewWinMiniPair.first);
}
}

Expand Down Expand Up @@ -980,7 +987,7 @@ void DeepinWMFaker::ToggleActiveWindowMaximize()

void DeepinWMFaker::MinimizeActiveWindow()
{
m_windowSystem->minimizeWindow(m_windowSystem->activeWindow());
KX11Extras::minimizeWindow(KX11Extras::activeWindow());
}

void DeepinWMFaker::SetDecorationTheme(const QString &type, const QString &name)
Expand Down Expand Up @@ -1043,6 +1050,22 @@ bool DeepinWMFaker::maybeShowWarningDialog()
return false;
}

void DeepinWMFaker::callHighlightWindows(const QStringList &windowIds)
{
QDBusInterface interface("org.kde.KWin.HighlightWindow", "/org/kde/KWin/HighlightWindow",
"org.kde.KWin.HighlightWindow", QDBusConnection::sessionBus());
if (interface.isValid()) {
QDBusReply<void> reply = interface.call("highlightWindows", QVariant::fromValue(windowIds));
if (reply.isValid()) {
qDebug() << "Successfully called highlightWindows with" << windowIds;
} else {
qWarning() << "Failed to call highlightWindows:" << reply.error().message();
}
} else {
qWarning() << "Failed to call highlightWindows:" << interface.lastError().message();
}
}

void DeepinWMFaker::ShowAllWindow()
{
if (maybeShowWarningDialog())
Expand Down Expand Up @@ -1122,7 +1145,8 @@ void DeepinWMFaker::PresentWindows(const QList<uint> &xids)
for (uint w : xids)
windows << w;

KWindowEffects::presentWindows(windows.first(), windows);
// TODO kf6 has no method to present windows
//KWindowEffects::presentWindows(windows.first(), windows);
} else {
QDBusInterface Interface("org.kde.KWin",
"/org/kde/KWin/PresentWindows",
Expand Down
1 change: 1 addition & 0 deletions fakewm/dbus/deepinwmfaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public Q_SLOTS:
void syncConfigForKWin();
void updateCursorConfig();
bool maybeShowWarningDialog();
void callHighlightWindows(const QStringList &windowIds);

KWindowSystem *m_windowSystem;
KConfig *m_deepinWMConfig;
Expand Down
4 changes: 2 additions & 2 deletions misc/dbusservice/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
configure_file(
com.deepin.wm.service.in
com.deepin.wm.service
ONLY
@ONLY
)
configure_file(
org.deepin.dde.Appearance1.service.in
org.deepin.dde.Appearance1.service
ONLY
@ONLY
)

set(DBUS_SERVICE_FILES
Expand Down
2 changes: 1 addition & 1 deletion misc/systemd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
configure_file(
dde-fakewm.service.in
dde-fakewm.service
ONLY
@ONLY
)

set(SYSTEMD_SERVICE_FILES
Expand Down
38 changes: 33 additions & 5 deletions misc/translations/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
# generate qm
execute_process(COMMAND bash "misc/translations/translate_generation.sh"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
# SPDX-FileCopyrightText: 2017 - 2024 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

file(GLOB QM_FILES "translations/*.qm")
install(FILES ${QM_FILES} DESTINATION share/${PROJECT_NAME}/translations)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core LinguistTools)

# can use qt_standard_project_setup(I18N_TRANSLATED_LANGUAGES xx xx) from Qt6.7
set(TRANSLATION_LANGUAGES
af ak am_ET ar ar_EG ast az bg bn bo br ca cgg cs da de de_CH el en en_AU
en_GB en_US eo es es_MX et eu fa fi fil fr gl_ES he hi_IN hr hu hy id it
ja kab ka kk km_KH kn_IN ko ku ku_IQ ky ky@Arab la lo lt lv ml mn mr ms
nb ne nl pa pam pl ps pt pt_BR ro ru sc si sk sl sq sr sv sw ta te th tr
tzm ug uk ur uz vi zh_CN zh_HK zh_TW
)

set(TRANSLATION_FILES "")
list(APPEND TRANSLATION_FILES "${PROJECT_SOURCE_DIR}/translations/dde-appearance.ts")

foreach(LANG ${TRANSLATION_LANGUAGES})
list(APPEND TRANSLATION_FILES "${PROJECT_SOURCE_DIR}/translations/dde-appearance_${LANG}.ts")
endforeach()

set_source_files_properties(app_en.ts app_de.ts
PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")

# can generate ts and qm file
qt_add_translations(${PLUGIN_NAME}
TS_FILES ${TRANSLATION_FILES}
SOURCES ${TRANS_FILE_SOURCE}
QM_FILES_OUTPUT_VARIABLE TR_QM_FILES
)

## qm files
install(FILES ${TR_QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/${PLUGIN_NAME}/translations)
Loading