From 839980192d1608134c40735b8d75fd2ccd832e0f Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 25 Oct 2020 11:41:20 +0200 Subject: [PATCH] wayland:enable previews for Plasma 5.20 BUG:426913 --- plasmoid/package/contents/ui/main.qml | 5 +-- .../ui/previews/PipeWireThumbnail.qml | 33 +++++++++++++++++++ .../ui/previews/PlasmaCoreThumbnail.qml | 33 +++++++++++++++++++ .../contents/ui/previews/ToolTipInstance.qml | 20 +++-------- 4 files changed, 74 insertions(+), 17 deletions(-) create mode 100644 plasmoid/package/contents/ui/previews/PipeWireThumbnail.qml create mode 100644 plasmoid/package/contents/ui/previews/PlasmaCoreThumbnail.qml diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index de0c67312..b1f689493 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -61,8 +61,9 @@ Item { LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft && !root.vertical LayoutMirroring.childrenInherit: true - property bool plasma515: latteView ? latteView.plasma515 : LatteCore.Environment.plasmaDesktopVersion >= LatteCore.Environment.makeVersion(5,15,0) - property bool plasma518: latteView ? latteView.plasma518 : LatteCore.Environment.plasmaDesktopVersion >= LatteCore.Environment.makeVersion(5,18,0) + property bool plasma515: LatteCore.Environment.plasmaDesktopVersion >= LatteCore.Environment.makeVersion(5,15,0) + 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 editMode: latteView ? latteView.editMode : plasmoid.userConfiguring property bool inConfigureAppletsMode: latteView ? latteView.inConfigureAppletsMode : true diff --git a/plasmoid/package/contents/ui/previews/PipeWireThumbnail.qml b/plasmoid/package/contents/ui/previews/PipeWireThumbnail.qml new file mode 100644 index 000000000..3057653f1 --- /dev/null +++ b/plasmoid/package/contents/ui/previews/PipeWireThumbnail.qml @@ -0,0 +1,33 @@ +/* + * Copyright 2020 Aleix Pol Gonzalez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. + */ + +import QtQuick.Window 2.6 +import org.kde.taskmanager 0.1 as TaskManager + +TaskManager.PipeWireSourceItem { + visible: waylandItem.nodeId > 0 + nodeId: waylandItem.nodeId + + anchors.fill: parent + + TaskManager.ScreencastingRequest { + id: waylandItem + uuid: !windowsPreviewDlg.visible ? "" : thumbnailSourceItem.winId + } +} diff --git a/plasmoid/package/contents/ui/previews/PlasmaCoreThumbnail.qml b/plasmoid/package/contents/ui/previews/PlasmaCoreThumbnail.qml new file mode 100644 index 000000000..efea184af --- /dev/null +++ b/plasmoid/package/contents/ui/previews/PlasmaCoreThumbnail.qml @@ -0,0 +1,33 @@ +/* +* Copyright 2020 Michail Vourlakos +* +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +import QtQuick 2.6 +import org.kde.plasma.core 2.0 as PlasmaCore + +PlasmaCore.WindowThumbnail { + winId: thumbnailSourceItem.winId + + onWinIdChanged: { + //! WORKAROUND, in order for toolTipDelegate to re-instantiate the previews model when + //! previews are changing from single instance preview to another single instance + visible = false; + visible = true; + } +} diff --git a/plasmoid/package/contents/ui/previews/ToolTipInstance.qml b/plasmoid/package/contents/ui/previews/ToolTipInstance.qml index 31e38b5ba..1faf64a97 100644 --- a/plasmoid/package/contents/ui/previews/ToolTipInstance.qml +++ b/plasmoid/package/contents/ui/previews/ToolTipInstance.qml @@ -187,7 +187,7 @@ Column { readonly property bool isMinimized: isGroup ? instance.isMinimized : mainToolTip.isMinimizedParent // TODO: this causes XCB error message when being visible the first time - property int winId: isWin && windows[flatIndex] !== undefined ? windows[flatIndex] : 0 + readonly property var winId: isWin && windows[flatIndex] !== undefined ? windows[flatIndex] : 0 // There's no PlasmaComponents3 version PlasmaComponents.Highlight { @@ -197,22 +197,12 @@ Column { } Loader{ - id:previewThumbX11Loader + id:previewThumbLoader anchors.fill: parent anchors.margins: 2 - active: !LatteCore.WindowSystem.isPlatformWayland + active: LatteCore.WindowSystem.isPlatformX11 || (root.plasma520 && LatteCore.WindowSystem.isPlatformWayland) visible: !albumArtImage.visible && !thumbnailSourceItem.isMinimized - - sourceComponent: PlasmaCore.WindowThumbnail { - winId: thumbnailSourceItem.winId - - onWinIdChanged: { - //! WORKAROUND, in order for toolTipDelegate to re-instantiate the previews model when - //! previews are changing from single instance preview to another single instance - visible = false; - visible = true; - } - } + source: root.plasma520 && LatteCore.WindowSystem.isPlatformWayland ? "PipeWireThumbnail.qml" : "PlasmaCoreThumbnail.qml" } ToolTipWindowMouseArea { @@ -262,7 +252,7 @@ Column { animated: false usesPlasmaTheme: false visible: (thumbnailSourceItem.isMinimized && !albumArtImage.visible) //X11 case - || (!previewThumbX11Loader.active && !albumArtImage.visible) //Wayland case + || (!previewThumbLoader.active && !albumArtImage.visible) //Wayland case } }