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

This commit is contained in:
谢炜 2022-06-07 18:20:30 +08:00
parent 04d52506b6
commit 1f234b28c3
15 changed files with 90 additions and 72 deletions

View File

@ -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)

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
* 修改为quilt格式

4
debian/control vendored
View File

@ -18,7 +18,6 @@ Build-Depends: cmake,
libkf5windowsystem-dev,
libmtdev-dev,
libqt5x11extras5-dev,
libukui-common-dev,
libxcb-composite0-dev,
libxcb-damage0-dev,
libxcb1-dev,
@ -28,7 +27,7 @@ Build-Depends: cmake,
qtdeclarative5-dev,
qttools5-dev,
qttools5-dev-tools,
ukui-kwin-dev
kwin-dev
Standards-Version: 4.6.0
Homepage: 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,
qml-module-qtquick-controls2,
qml-module-qtquick-templates2,
ukui-kwin,
${misc:Depends},
${shlibs:Depends}
Conflicts: ukui-window-switch

View File

@ -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-kwinkwin
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})

View File

@ -39,7 +39,7 @@ private:
MultitaskViewManager* viewManager_ = nullptr;
QString serviceName_ = "org.ukui.KWin";
QString serviceName_ = "org.kde.KWin";
QString servicePath_ = "/MultitaskView";

View File

@ -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");
}

View File

@ -5,7 +5,7 @@
#include <QQuickView>
#include <ukui-kwin/kwineffects.h>
#include <kwineffects.h>
#include "dbusservice.h"
#include "multitaskviewmodel.h"

View File

@ -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:

View File

@ -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);
}

View File

@ -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);

View File

@ -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

View File

@ -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
}
}

View File

@ -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 }
}

View File

@ -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)});
}
}
}

View File

@ -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
}
}
}