[Feature](wayland): 适配wayland环境

This commit is contained in:
谢炜 2022-06-07 10:23:36 +00:00 committed by cckylin-cibot
parent 6ec4950d69
commit e251795ff1
4 changed files with 582 additions and 3 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
ukui-kwin-effects (1.0.8-ok1) yangtze; urgency=medium
* [Feature](wayland): 适配wayland环境
-- Zou Xiaoyi <zouxiaoyi@kylinos.cn> Tue, 07 Jun 2022 18:20:35 +0800
ukui-kwin-effects (1.0.8-0k0) v101; urgency=medium ukui-kwin-effects (1.0.8-0k0) v101; urgency=medium
* 修改为quilt格式 * 修改为quilt格式

4
debian/control vendored
View File

@ -18,7 +18,6 @@ Build-Depends: cmake,
libkf5windowsystem-dev, libkf5windowsystem-dev,
libmtdev-dev, libmtdev-dev,
libqt5x11extras5-dev, libqt5x11extras5-dev,
libukui-common-dev,
libxcb-composite0-dev, libxcb-composite0-dev,
libxcb-damage0-dev, libxcb-damage0-dev,
libxcb1-dev, libxcb1-dev,
@ -28,7 +27,7 @@ Build-Depends: cmake,
qtdeclarative5-dev, qtdeclarative5-dev,
qttools5-dev, qttools5-dev,
qttools5-dev-tools, qttools5-dev-tools,
ukui-kwin-dev kwin-dev
Standards-Version: 4.6.0 Standards-Version: 4.6.0
Homepage: http://gitlab2.kylin.com/liling/ukui-kwin-effects Homepage: http://gitlab2.kylin.com/liling/ukui-kwin-effects
Vcs-Browser: http://gitlab2.kylin.com/liling/ukui-kwin-effects Vcs-Browser: http://gitlab2.kylin.com/liling/ukui-kwin-effects
@ -40,7 +39,6 @@ Depends: libkf5globalaccel-bin,
plasma-framework, plasma-framework,
qml-module-qtquick-controls2, qml-module-qtquick-controls2,
qml-module-qtquick-templates2, qml-module-qtquick-templates2,
ukui-kwin,
${misc:Depends}, ${misc:Depends},
${shlibs:Depends} ${shlibs:Depends}
Conflicts: ukui-window-switch Conflicts: ukui-window-switch

View File

@ -0,0 +1,574 @@
From: cckylin-cibot <cckylin-cibot@kylinos.cn>
Date: Tue, 7 Jun 2022 10:23:36 +0000
Subject: =?utf-8?b?W0ZlYXR1cmVdKHdheWxhbmQpOiDpgILphY13YXlsYW5k546v5aKD?=
---
CMakeLists.txt | 2 +-
windowsview/CMakeLists.txt | 7 ++--
windowsview/dbusservice.h | 2 +-
windowsview/multitaskviewmanager.cpp | 4 +--
windowsview/multitaskviewmanager.h | 2 +-
windowsview/multitaskviewmanagerpluginfactory.cpp | 4 +--
windowsview/multitaskviewmodel.cpp | 39 ++++++++++++++---------
windowsview/multitaskviewmodel.h | 28 +++++++++++-----
windowsview/qml/AppArea.qml | 9 +++---
windowsview/qml/DesktopArea.qml | 9 +++---
windowsview/qml/PreviewWindow.qml | 4 ++-
windowsview/qml/multitaskview.qml | 24 ++++++++------
windowsview/windowsview.json | 18 +++--------
13 files changed, 83 insertions(+), 69 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9422c65..75ee071 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,7 +18,7 @@ endmacro()
query_qmake("QT_INSTALL_PLUGINS" QT_INSTALL_PLUGINS)
message("QT_INSTALL_PLUGINS=${QT_INSTALL_PLUGINS}")
-set(INSTALL_PATH "${QT_INSTALL_PLUGINS}/ukui-kwin/effects/plugins")
+set(INSTALL_PATH "${QT_INSTALL_PLUGINS}/kwin/effects/plugins")
add_subdirectory(windowsview)
diff --git a/windowsview/CMakeLists.txt b/windowsview/CMakeLists.txt
index 99635e9..d48335a 100644
--- a/windowsview/CMakeLists.txt
+++ b/windowsview/CMakeLists.txt
@@ -28,8 +28,7 @@ find_package(Qt5LinguistTools REQUIRED)
find_package(Qt5 REQUIRED NO_MODULE COMPONENTS X11Extras)
-set(SRCS windowthumbnail.cpp
- desktopbackground.cpp
+set(SRCS desktopbackground.cpp
icontheme.cpp
multitaskviewmodel.cpp
multitaskviewmanager.cpp
@@ -44,7 +43,7 @@ add_library(
)
# 注意要链接到ukui-kwin如果本地安装了kwin的依赖记得注意区分
-include_directories(/usr/include/ukui-kwin/)
+include_directories(/usr/include/kwin/)
target_link_libraries(
${PLUGIN_NAME}
@@ -60,8 +59,6 @@ target_link_libraries(
KF5::CoreAddons
KF5::GlobalAccel
Qt5::X11Extras
- libukui-com4c.so
- libukui-com4cxx.so
)
install(TARGETS ${PLUGIN_NAME} DESTINATION ${INSTALL_PATH})
diff --git a/windowsview/dbusservice.h b/windowsview/dbusservice.h
index 2925f4d..96e75c7 100644
--- a/windowsview/dbusservice.h
+++ b/windowsview/dbusservice.h
@@ -39,7 +39,7 @@ private:
MultitaskViewManager* viewManager_ = nullptr;
- QString serviceName_ = "org.ukui.KWin";
+ QString serviceName_ = "org.kde.KWin";
QString servicePath_ = "/MultitaskView";
diff --git a/windowsview/multitaskviewmanager.cpp b/windowsview/multitaskviewmanager.cpp
index 20d6aa0..3c1e29b 100644
--- a/windowsview/multitaskviewmanager.cpp
+++ b/windowsview/multitaskviewmanager.cpp
@@ -9,7 +9,6 @@
#include "desktopbackground.h"
#include "icontheme.h"
-#include "windowthumbnail.h"
namespace MultitaskView {
@@ -69,8 +68,7 @@ void MultitaskViewManager::initModel()
void MultitaskViewManager::registerQmlTypes()
{
- qmlRegisterType<Plasma::WindowThumbnail>("org.kde.plasma", 2, 0, "WindowThumbnail");
- qmlRegisterType<DesktopBackground>("org.ukui.kwin", 2, 0, "DesktopBackground");
+ qmlRegisterType<DesktopBackground>("org.kde.kwin", 3, 0, "DesktopBackground");
qmlRegisterType<IconTheme>("IconTheme", 1, 0, "IconTheme");
}
diff --git a/windowsview/multitaskviewmanager.h b/windowsview/multitaskviewmanager.h
index 3cb57b9..cfb41a6 100644
--- a/windowsview/multitaskviewmanager.h
+++ b/windowsview/multitaskviewmanager.h
@@ -5,7 +5,7 @@
#include <QQuickView>
-#include <ukui-kwin/kwineffects.h>
+#include <kwineffects.h>
#include "dbusservice.h"
#include "multitaskviewmodel.h"
diff --git a/windowsview/multitaskviewmanagerpluginfactory.cpp b/windowsview/multitaskviewmanagerpluginfactory.cpp
index 08ec71e..f2b5cff 100644
--- a/windowsview/multitaskviewmanagerpluginfactory.cpp
+++ b/windowsview/multitaskviewmanagerpluginfactory.cpp
@@ -1,4 +1,4 @@
-#include <ukui-kwin/kwineffects.h>
+#include <kwineffects.h>
#include "multitaskviewmanager.h"
@@ -8,7 +8,7 @@ class MultitaskViewManagerPluginFactory : public KWin::EffectPluginFactory
Q_INTERFACES(KPluginFactory)
- Q_PLUGIN_METADATA(IID KPluginFactory_iid FILE "windowsview.json")
+ Q_PLUGIN_METADATA(IID EffectPluginFactory_iid FILE "windowsview.json")
public:
diff --git a/windowsview/multitaskviewmodel.cpp b/windowsview/multitaskviewmodel.cpp
index c60501a..4fcb75b 100644
--- a/windowsview/multitaskviewmodel.cpp
+++ b/windowsview/multitaskviewmodel.cpp
@@ -56,7 +56,7 @@ QList<QVariant> MultitaskViewModel::getAppWindowList(int desktopIndex, int scree
return appWindowList;
}
-void MultitaskViewModel::removeAppWindow(int windowId)
+void MultitaskViewModel::removeAppWindow(QUuid windowId)
{
auto* window = KWin::effects->findWindow(windowId);
if (window == nullptr)
@@ -67,7 +67,7 @@ void MultitaskViewModel::removeAppWindow(int windowId)
window->closeWindow();
}
-void MultitaskViewModel::moveAppWindowToDesktop(int windowId,
+void MultitaskViewModel::moveAppWindowToDesktop(QUuid windowId,
int srcDesktopInex,
int destDesktopInex) const
{
@@ -98,7 +98,7 @@ void MultitaskViewModel::moveAppWindowToDesktop(int windowId,
KWin::effects->windowToDesktops(window, desktopIndexList);
}
-void MultitaskViewModel::activateAppWindow(int windowId)
+void MultitaskViewModel::activateAppWindow(QUuid windowId)
{
auto* window = KWin::effects->findWindow(windowId);
if (window == nullptr)
@@ -109,10 +109,10 @@ void MultitaskViewModel::activateAppWindow(int windowId)
KWin::effects->activateWindow(window);
}
-QIcon MultitaskViewModel::getWindowIcon(int windowId)
+QIcon MultitaskViewModel::getWindowIcon(QUuid windowId)
{
- auto id = static_cast<WId>(windowId);
- auto* window = KWin::effects->findWindow(id);
+ // auto id = static_cast<WId>(windowId);
+ auto* window = KWin::effects->findWindow(windowId);
if(window == nullptr)
{
return QIcon("");
@@ -225,11 +225,12 @@ void MultitaskViewModel::setCurrentDesktop(int desktopIndex)
QRect MultitaskViewModel::getFullScreenGeometry(int desktopIndex, int screenIndex) const
{
+ KWin::EffectScreen* screen = KWin::effects->findScreen(screenIndex);
return KWin::effects->clientArea(KWin::clientAreaOption::FullScreenArea,
- screenIndex, desktopIndex);
+ screen, desktopIndex);
}
-bool MultitaskViewModel::hasModalChildWindow(int windowId)
+bool MultitaskViewModel::hasModalChildWindow(QUuid windowId)
{
auto* window = KWin::effects->findWindow(windowId);
if (window == nullptr)
@@ -302,7 +303,7 @@ void MultitaskViewModel::onNumberScreensChanged()
void MultitaskViewModel::updateScreenCount()
{
- screenCount_ = KWin::effects->numScreens();
+ screenCount_ = KWin::effects->screens().size();
}
// static
@@ -323,7 +324,7 @@ bool MultitaskViewModel::isExtensionMode()
int MultitaskViewModel::logicalScreenCount() const
{
- const auto screenCount = KWin::effects->numScreens();
+ const auto screenCount = KWin::effects->screens().size();
if (screenCount == 1
|| !isExtensionMode())
{
@@ -340,6 +341,7 @@ QList<QVariant> MultitaskViewModel::createWindowList(int desktopIndex, int scree
{
return QList<QVariant>();
}
+ KWin::EffectScreen* screen = KWin::effects->findScreen(screenIndex);
QList<QVariant> windowList;
@@ -354,7 +356,7 @@ QList<QVariant> MultitaskViewModel::createWindowList(int desktopIndex, int scree
}
if (!effectWindow->desktops().contains(desktopIndex)
- || effectWindow->screen() != screenIndex)
+ || effectWindow->screen() != screen)
{
continue;
}
@@ -365,7 +367,8 @@ QList<QVariant> MultitaskViewModel::createWindowList(int desktopIndex, int scree
effectWindow->pos().y(),
effectWindow->decorationInnerRect().width(),
effectWindow->decorationInnerRect().height(),
- effectWindow->isMinimized());
+ effectWindow->isMinimized(),
+ getUuid(effectWindow));
windowList.append(QVariant::fromValue(window));
}
@@ -424,7 +427,7 @@ void MultitaskViewModel::moveDesktopWindows(int srcDesktopIndex, int destDesktop
windowIter != windowList.end(); windowIter++)
{
const auto& window = windowIter->value<Window>();
- moveAppWindowToDesktop(window.id(), srcDesktopIndex, destDesktopIndex);
+ moveAppWindowToDesktop(window.uuid(), srcDesktopIndex, destDesktopIndex);
}
}
}
@@ -451,6 +454,12 @@ WId MultitaskViewModel::getWindowId(KWin::EffectWindow *window)
return window->parent()->property("windowId").toULongLong();
}
+QUuid MultitaskViewModel::getUuid(KWin::EffectWindow *window)
+{
+// qDebug() << "Uuid: " << window->parent()->property("internalId").toUuid();
+ return window->parent()->property("internalId").toUuid();
+}
+
// static
QVector<int> MultitaskViewModel::createDesktopIndexList(int srcDesktopIndex, int destDesktopIndex)
{
@@ -513,8 +522,8 @@ void MultitaskViewModel::connectSignals()
this, &MultitaskViewModel::onDesktopPresenceChanged);
QObject::connect(KWin::effects, SIGNAL(desktopChanged(int, int)),
this, SIGNAL(currentDesktopChanged(int, int)));
- QObject::connect(KWin::effects, &KWin::EffectsHandler::numberScreensChanged,
- this, &MultitaskViewModel::onNumberScreensChanged);
+ // QObject::connect(KWin::effects, &KWin::EffectsHandler::numberScreensChanged,
+ // this, &MultitaskViewModel::onNumberScreensChanged);
QObject::connect(KWin::effects, &KWin::EffectsHandler::virtualScreenSizeChanged,
this, &MultitaskViewModel::screenSizeChanged);
}
diff --git a/windowsview/multitaskviewmodel.h b/windowsview/multitaskviewmodel.h
index ac33a62..686df72 100644
--- a/windowsview/multitaskviewmodel.h
+++ b/windowsview/multitaskviewmodel.h
@@ -7,8 +7,9 @@
#include <QMap>
#include <QRect>
#include <QVariantList>
+#include <QUuid>
-#include <ukui-kwin/kwineffects.h>
+#include <kwineffects.h>
namespace MultitaskView {
@@ -30,18 +31,21 @@ class Window
Q_PROPERTY(bool minimized READ minimized)
+ Q_PROPERTY(QUuid uuid READ uuid)
+
public:
Window() = default;
- Window(int id, const QString& caption, int x, int y, int width, int height, bool minimized)
+ Window(int id, const QString& caption, int x, int y, int width, int height, bool minimized, QUuid uuid)
: id_(id),
caption_(caption),
x_(x),
y_(y),
width_(width),
height_(height),
- minimized_(minimized)
+ minimized_(minimized),
+ uuid_(uuid)
{
}
@@ -50,6 +54,11 @@ public:
return id_;
}
+ QUuid uuid() const
+ {
+ return uuid_;
+ }
+
const QString& caption() const
{
return caption_;
@@ -84,6 +93,8 @@ private:
int id_ = 0;
+ QUuid uuid_;
+
QString caption_;
int x_ = 0;
@@ -180,13 +191,13 @@ public:
Q_INVOKABLE QList<QVariant> getAppWindowList(int desktopIndex, int screenIndex) const;
- Q_INVOKABLE void removeAppWindow(int windowId);
+ Q_INVOKABLE void removeAppWindow(QUuid windowId);
- Q_INVOKABLE void moveAppWindowToDesktop(int windowId, int srcDesktopInex, int destDesktopInex) const;
+ Q_INVOKABLE void moveAppWindowToDesktop(QUuid windowId, int srcDesktopInex, int destDesktopInex) const;
- Q_INVOKABLE void activateAppWindow(int windowId);
+ Q_INVOKABLE void activateAppWindow(QUuid windowId);
- Q_INVOKABLE QIcon getWindowIcon(int windowId);
+ Q_INVOKABLE QIcon getWindowIcon(QUuid windowId);
Q_INVOKABLE QList<QVariant> getDesktopList() const;
@@ -202,7 +213,7 @@ public:
Q_INVOKABLE QRect getFullScreenGeometry(int desktopIndex, int screenIndex) const;
- Q_INVOKABLE bool hasModalChildWindow(int windowId);
+ Q_INVOKABLE bool hasModalChildWindow(QUuid windowId);
signals:
@@ -261,6 +272,7 @@ private:
bool validateScreenIndex(int screenIndex) const;
static WId getWindowId(KWin::EffectWindow* window);
+ static QUuid getUuid(KWin::EffectWindow *window);
static bool shouldAcceptWindow(KWin::EffectWindow* window);
diff --git a/windowsview/qml/AppArea.qml b/windowsview/qml/AppArea.qml
index 1b2a8b9..9d7be71 100644
--- a/windowsview/qml/AppArea.qml
+++ b/windowsview/qml/AppArea.qml
@@ -2,7 +2,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import QtQuick.Window 2.12
-import org.kde.plasma 2.0 as PlasmaCore
+import org.kde.kwin 3.0 as KWinComponents
import QtGraphicalEffects 1.0
import "Controller.js" as Controller
import IconTheme 1.0
@@ -190,12 +190,13 @@ Rectangle {
}
}
- PlasmaCore.WindowThumbnail{
+ KWinComponents.WindowThumbnailItem{
id : tmp
anchors.centerIn : parent
+ z: appWindow.dd ? 100 : 20
height : thumbnailitem.thumbheight()
width : thumbnailitem.thumbwidth()
- winId : model.id
+ wId : model.uuid
clip : true
}
}
@@ -203,7 +204,7 @@ Rectangle {
Component.onCompleted : {
appWindow.setCaption(model.caption)
- appWindow.setId(model.id)
+ appWindow.setId(model.uuid)
}
}
}//Rectangle
diff --git a/windowsview/qml/DesktopArea.qml b/windowsview/qml/DesktopArea.qml
index 3b176e9..2b5459e 100644
--- a/windowsview/qml/DesktopArea.qml
+++ b/windowsview/qml/DesktopArea.qml
@@ -2,8 +2,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import QtQuick.Window 2.12
-import org.ukui.kwin 2.0 as KWin
-import org.kde.plasma 2.0 as PlasmaCore
+import org.kde.kwin 3.0 as KWinComponents
import QtGraphicalEffects 1.0
import "Controller.js" as Controller
import IconTheme 1.0
@@ -162,7 +161,7 @@ Rectangle {
}
}
- KWin.DesktopBackground {
+ KWinComponents.DesktopBackground {
id : desktopThumbnailBackground
anchors.centerIn : parent
width : desktopThumbnailWidth
@@ -193,14 +192,14 @@ Rectangle {
id : desktopWindowRepeater
model : listModel.get(index).model
- PlasmaCore.WindowThumbnail{
+ KWinComponents.WindowThumbnailItem{
id : desktopWindowThumbnail
width : model.width * desktopScale
height : model.height * desktopScale
visible : !(model.minimized)
x : (model.x - screenRect.x) * desktopScale
y : (model.y - screenRect.y) * desktopScale
- winId : model.id
+ wId : model.uuid
clip : true
}
}
diff --git a/windowsview/qml/PreviewWindow.qml b/windowsview/qml/PreviewWindow.qml
index a46c546..e675759 100644
--- a/windowsview/qml/PreviewWindow.qml
+++ b/windowsview/qml/PreviewWindow.qml
@@ -22,7 +22,7 @@ Rectangle {
*/
property var stateList : ["default", "hover", "drag", "receive"];
state : "default"
- property int wid : -1
+ property string wid : "";
property int previewAreaWidth : 100
property int previewAreaHeight : 150
property real posX : 0
@@ -37,6 +37,7 @@ Rectangle {
property var captionText : ""
property bool winowDragActive : previewMouseArea.drag.active
property bool nowDragActive : false
+ property bool dd: false
Drag.active : previewMouseArea.drag.active
Drag.source : previewWindow
Drag.hotSpot.x : previewWindow.previewAreaWidth
@@ -259,6 +260,7 @@ Rectangle {
states : State {
when : previewMouseArea.drag.active
ParentChange { target : previewWindow; parent : root }
+ PropertyChanges { target : previewWindow; dd : true }
PropertyChanges { target : previewWindow; borderWidth : 4 }
PropertyChanges { target : previewWindow; titleOpacity : 0 }
}
diff --git a/windowsview/qml/multitaskview.qml b/windowsview/qml/multitaskview.qml
index 51309bc..1d361d3 100644
--- a/windowsview/qml/multitaskview.qml
+++ b/windowsview/qml/multitaskview.qml
@@ -2,8 +2,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import QtQuick.Window 2.12
-import org.ukui.kwin 2.0 as KWin
-import org.kde.plasma 2.0 as PlasmaCore
+import org.kde.kwin 3.0 as KWinComponents
import QtGraphicalEffects 1.0
import "Controller.js" as Controller
import IconTheme 1.0
@@ -134,7 +133,7 @@ Repeater {
}
}
- KWin.DesktopBackground {
+ KWinComponents.DesktopBackground {
id : wholeDesktopBackground
width : root.width
height : root.height
@@ -149,8 +148,10 @@ Repeater {
{
var info = windowInfo[i]
myModel.append({"x" : info.x, "y" : info.y,
- "width" : info.width, "height" : info.height,
- "id" : info.id,"minimized" :info.minimized, "caption" : info.caption});
+ "width" : info.width, "height" : info.height,
+ "id" : info.id,"minimized" :info.minimized, "caption" : info.caption,
+ "uuid" : String(info.uuid)});
+
}
}
@@ -161,8 +162,9 @@ Repeater {
{
var info = windowInfo[i]
myModel.append({"x" : info.x, "y" : info.y,
- "width" : info.width, "height" : info.height,
- "id" : info.id,"minimized" : info.minimized, "caption" : info.caption});
+ "width" : info.width, "height" : info.height,
+ "id" : info.id,"minimized" : info.minimized, "caption" : info.caption,
+ "uuid" : String(info.uuid)});
}
}
@@ -211,7 +213,8 @@ Repeater {
winModel.push({"x": info.x, "y": info.y,
"width": info.width, "height": info.height,
- "id": info.id,"minimized":info.minimized, "caption": info.caption});
+ "id": info.id,"minimized":info.minimized, "caption": info.caption,
+ "uuid": String(info.uuid)});
}
listModel.append({ value: infos.index, model: winModel});
}
@@ -230,8 +233,9 @@ Repeater {
{
var info = appList[j]
listModel.get(i).model.append({"x": info.x, "y": info.y,
- "width": info.width, "height": info.height,
- "id": info.id,"minimized":info.minimized, "caption": info.caption});
+ "width": info.width, "height": info.height,
+ "id": info.id,"minimized":info.minimized, "caption": info.caption,
+ "uuid": String(info.uuid)});
}
}
}
diff --git a/windowsview/windowsview.json b/windowsview/windowsview.json
index de430c2..176c51e 100644
--- a/windowsview/windowsview.json
+++ b/windowsview/windowsview.json
@@ -1,22 +1,14 @@
{
"KPlugin": {
- "Authors": [
- {
- "Email": "zhuyunpeng@kylinos.cn",
- "Name": "Zhu Yunpeng"
- }
- ],
- "Description": "UKUI-KWin Multitasking View",
+ "Category": "Appearance",
+ "Description": "KWin Multitasking View",
"Description[zh_CN]": "麒麟多任务视图",
"EnabledByDefault": true,
- "Id": "UKUI-KWin-Windows-View",
+ "Id": "KWin-Windows-View",
"Name": "WindowsView",
"Name[zh_CN]": "多任务视图",
- "ServiceTypes": [
- "UKUIKWin/Effect"
- ],
- "org.ukui.kwin.effect": {
- "exclusiveGroup": "appearance"
+ "org.kde.kwin.effect": {
+ "enabledByDefaultMethod": true
}
}
}

1
debian/patches/series vendored Normal file
View File

@ -0,0 +1 @@
0001-Feature-wayland-wayland.patch