From a3bdc89a0f3e9a9ed97a5d02c2cce1b261c7f983 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 13 Jul 2022 12:08:28 +0300 Subject: [PATCH] wayland:support PipeWire for Plasma 5.24,5.25,5.26 --- plasmoid/package/contents/ui/main.qml | 2 + ...umbnail.qml => PipeWireThumbnail.5.24.qml} | 0 .../ui/previews/PipeWireThumbnail.5.25.qml | 39 ++++++++++++++++++ .../ui/previews/PipeWireThumbnail.5.26.qml | 40 +++++++++++++++++++ .../contents/ui/previews/ToolTipInstance.qml | 14 ++++++- 5 files changed, 94 insertions(+), 1 deletion(-) rename plasmoid/package/contents/ui/previews/{PipeWireThumbnail.qml => PipeWireThumbnail.5.24.qml} (100%) create mode 100644 plasmoid/package/contents/ui/previews/PipeWireThumbnail.5.25.qml create mode 100644 plasmoid/package/contents/ui/previews/PipeWireThumbnail.5.26.qml diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index f1f240a18..3972500f9 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -50,7 +50,9 @@ Item { property bool plasma518: LatteCore.Environment.plasmaDesktopVersion >= LatteCore.Environment.makeVersion(5,18,0) property bool plasma520: LatteCore.Environment.plasmaDesktopVersion >= LatteCore.Environment.makeVersion(5,20,0) property bool plasmaGreaterThan522: LatteCore.Environment.plasmaDesktopVersion >= LatteCore.Environment.makeVersion(5,21,75) + property bool plasmaAtLeast524: LatteCore.Environment.plasmaDesktopVersion >= LatteCore.Environment.makeVersion(5,24,0) property bool plasmaAtLeast525: LatteCore.Environment.plasmaDesktopVersion >= LatteCore.Environment.makeVersion(5,24,75) + property bool plasmaAtLeast526: LatteCore.Environment.plasmaDesktopVersion >= LatteCore.Environment.makeVersion(5,25,75) property bool disableRestoreZoom: false //blocks restore animation in rightClick property bool disableAllWindowsFunctionality: plasmoid.configuration.hideAllTasks diff --git a/plasmoid/package/contents/ui/previews/PipeWireThumbnail.qml b/plasmoid/package/contents/ui/previews/PipeWireThumbnail.5.24.qml similarity index 100% rename from plasmoid/package/contents/ui/previews/PipeWireThumbnail.qml rename to plasmoid/package/contents/ui/previews/PipeWireThumbnail.5.24.qml diff --git a/plasmoid/package/contents/ui/previews/PipeWireThumbnail.5.25.qml b/plasmoid/package/contents/ui/previews/PipeWireThumbnail.5.25.qml new file mode 100644 index 000000000..524adc7a3 --- /dev/null +++ b/plasmoid/package/contents/ui/previews/PipeWireThumbnail.5.25.qml @@ -0,0 +1,39 @@ +/* + SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +import QtQuick 2.15 +import QtQuick.Window 2.15 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.taskmanager 0.1 as TaskManager + +// opacity doesn't work in the root item +Item { + anchors.fill: parent + + TaskManager.PipeWireSourceItem { + id: pipeWireSourceItem + + enabled: false // Must be set in pipewiresourceitem.cpp so opacity animation can work + visible: waylandItem.nodeId > 0 + nodeId: waylandItem.nodeId + + anchors.fill: parent + + opacity: enabled ? 1 : 0 + + TaskManager.ScreencastingRequest { + id: waylandItem + uuid: !windowsPreviewDlg.visible ? "" : thumbnailSourceItem.winId + } + + /*Behavior on opacity { + OpacityAnimator { + duration: PlasmaCore.Units.longDuration + easing.type: Easing.OutCubic + } + }*/ + } +} diff --git a/plasmoid/package/contents/ui/previews/PipeWireThumbnail.5.26.qml b/plasmoid/package/contents/ui/previews/PipeWireThumbnail.5.26.qml new file mode 100644 index 000000000..daa583388 --- /dev/null +++ b/plasmoid/package/contents/ui/previews/PipeWireThumbnail.5.26.qml @@ -0,0 +1,40 @@ +/* + SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +import QtQuick 2.15 +import QtQuick.Window 2.15 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.pipewire 0.1 as PipeWire +import org.kde.taskmanager 0.1 as TaskManager + +// opacity doesn't work in the root item +Item { + anchors.fill: parent + + PipeWire.PipeWireSourceItem { + id: pipeWireSourceItem + + enabled: false // Must be set in pipewiresourceitem.cpp so opacity animation can work + visible: waylandItem.nodeId > 0 + nodeId: waylandItem.nodeId + + anchors.fill: parent + + opacity: enabled ? 1 : 0 + + TaskManager.ScreencastingRequest { + id: waylandItem + uuid: !windowsPreviewDlg.visible ? "" : thumbnailSourceItem.winId + } + + /*Behavior on opacity { + OpacityAnimator { + duration: PlasmaCore.Units.longDuration + easing.type: Easing.OutCubic + } + }*/ + } +} diff --git a/plasmoid/package/contents/ui/previews/ToolTipInstance.qml b/plasmoid/package/contents/ui/previews/ToolTipInstance.qml index f698f0b60..14582599d 100644 --- a/plasmoid/package/contents/ui/previews/ToolTipInstance.qml +++ b/plasmoid/package/contents/ui/previews/ToolTipInstance.qml @@ -192,7 +192,19 @@ Column { anchors.margins: Math.max(2, previewShadow.radius) active: LatteCore.WindowSystem.isPlatformX11 || (root.plasma520 && LatteCore.WindowSystem.isPlatformWayland) visible: !albumArtImage.visible && !thumbnailSourceItem.isMinimized - source: root.plasma520 && LatteCore.WindowSystem.isPlatformWayland ? "PipeWireThumbnail.qml" : "PlasmaCoreThumbnail.qml" + source: { + if (LatteCore.WindowSystem.isPlatformWayland) { + if (root.plasmaAtLeast526) { + return "PipeWireThumbnail.5.26.qml"; + } else if (root.plasmaAtLeast525) { + return "PipeWireThumbnail.5.25.qml"; + } else if (root.plasmaAtLeast524) { + return "PipeWireThumbnail.5.24.qml"; + } + } + + return "PlasmaCoreThumbnail.qml"; + } DropShadow { id: previewShadow