diff --git a/components/wayfireipcplugin/wayfireipc.cpp b/components/wayfireipcplugin/wayfireipc.cpp index efbaa688e..9dc9f30f3 100644 --- a/components/wayfireipcplugin/wayfireipc.cpp +++ b/components/wayfireipcplugin/wayfireipc.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2024 Alexander Rutz +// SPDX-FileCopyrightText: 2024 Deepak Kumar // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -42,6 +43,46 @@ void WayfireIPC::setFullscreen(int viewId, bool state) sendMessage(jsonDoc); } +void WayfireIPC::toggleShowDesktop() +{ + QJsonObject msgObj; + msgObj["method"] = "wm-actions/plamo_showdesktop"; + + QJsonDocument jsonDoc = QJsonDocument(msgObj); + sendMessage(jsonDoc); + anyAppFocused = false; +} + +void WayfireIPC::toggleScale() +{ + QJsonObject msgObj; + msgObj["method"] = "scale/toggle"; + + QJsonDocument jsonDoc = QJsonDocument(msgObj); + sendMessage(jsonDoc); +} + +void WayfireIPC::stipcBtn(int buttonCode, const QString& mode, bool modifier) +{ + QJsonObject msgObj; + QJsonObject dataObj; + + dataObj["button_code"] = buttonCode; + dataObj["mode"] = mode; + dataObj["modifier"] = modifier; + + msgObj["method"] = "stipc/feed_button"; + msgObj["data"] = dataObj; + + QJsonDocument jsonDoc = QJsonDocument(msgObj); + sendMessage(jsonDoc); +} + +bool WayfireIPC::isAnyAppFocused() +{ + return anyAppFocused; +} + void WayfireIPC::onReadData() { qint64 bytesToRead = m_wfsocket->bytesAvailable(); @@ -58,8 +99,11 @@ void WayfireIPC::onReadData() if(event == "view-mapped" && appId != ""){ Q_EMIT viewMapped(appId); - } else if(event == "view-focused" && appId == "org.kde.polkit-kde-authentication-agent-1"){ - setFullscreen(viewId, false); + } else if(event == "view-focused" && appId != ""){ + anyAppFocused = true; + if (appId == "org.kde.polkit-kde-authentication-agent-1") { + setFullscreen(viewId, false); + } } bytesToRead = m_wfsocket->bytesAvailable(); @@ -70,10 +114,11 @@ void WayfireIPC::onReadData() void WayfireIPC::sendMessage(QJsonDocument jsonDoc) { std::string msgString = jsonDoc.toJson(QJsonDocument::Compact).toStdString(); + qDebug() << "Sending message:" << QString::fromStdString(msgString); QDataStream out; out.setDevice(m_wfsocket); out.setVersion(QDataStream::Qt_6_7); out.setByteOrder(QDataStream::LittleEndian); out.writeBytes(msgString.c_str(), msgString.size()); -} \ No newline at end of file +} diff --git a/components/wayfireipcplugin/wayfireipc.h b/components/wayfireipcplugin/wayfireipc.h index 6b4f78fcd..787b8408e 100644 --- a/components/wayfireipcplugin/wayfireipc.h +++ b/components/wayfireipcplugin/wayfireipc.h @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2024 Alexander Rutz +// SPDX-FileCopyrightText: 2024 Deepak Kumar // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -19,7 +20,14 @@ class WayfireIPC : public QObject public: WayfireIPC(QObject *parent = nullptr); + + bool anyAppFocused = false; + void setFullscreen(int viewId, bool state); + Q_INVOKABLE void toggleScale(); + Q_INVOKABLE void toggleShowDesktop(); + Q_INVOKABLE bool isAnyAppFocused(); + Q_INVOKABLE void stipcBtn(int buttonCode, const QString& mode, bool modifier); Q_SIGNALS: void viewMapped(QString appId); @@ -32,4 +40,4 @@ private Q_SLOTS: QLocalSocket *m_wfsocket = nullptr; QDataStream m_in; -}; \ No newline at end of file +}; diff --git a/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml b/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml index d7aff6e13..0f3c662d0 100644 --- a/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml +++ b/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml @@ -17,6 +17,8 @@ import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings import org.kde.kirigami as Kirigami +import org.kde.plasma.private.mobileshell.wayfireipcplugin as WayfireIpcPlugin + MobileShell.NavigationPanel { id: root required property bool opaqueBar @@ -63,7 +65,8 @@ MobileShell.NavigationPanel { iconSizeFactor: 0.75 onTriggered: { - Plasmoid.triggerTaskSwitcher(); + WayfireIpcPlugin.WayfireIPC.toggleScale(); + //Plasmoid.triggerTaskSwitcher(); } } @@ -76,7 +79,11 @@ MobileShell.NavigationPanel { iconSizeFactor: 1 onTriggered: { - MobileShellState.ShellDBusClient.openHomeScreen(); + if (WayfireIpcPlugin.WayfireIPC.isAnyAppFocused()) { + WayfireIpcPlugin.WayfireIPC.toggleShowDesktop(); + } else { + MobileShellState.ShellDBusClient.openHomeScreen(); + } } } @@ -84,21 +91,24 @@ MobileShell.NavigationPanel { rightAction: MobileShell.NavigationPanelAction { id: closeAppAction - enabled: Keyboards.KWinVirtualKeyboard.active || WindowPlugin.WindowUtil.hasCloseableActiveWindow - iconSource: Keyboards.KWinVirtualKeyboard.active ? "go-down-symbolic" : "mobile-close-app" + //enabled: Keyboards.KWinVirtualKeyboard.active || WindowPlugin.WindowUtil.hasCloseableActiveWindow + enabled: true + //iconSource: Keyboards.KWinVirtualKeyboard.active ? "go-down-symbolic" : "mobile-close-app" + iconSource: "go-previous" // mobile-close-app (from plasma-frameworks) seems to have fewer margins than icons from breeze-icons iconSizeFactor: Keyboards.KWinVirtualKeyboard.active ? 1 : 0.75 onTriggered: { - if (Keyboards.KWinVirtualKeyboard.active) { - // close keyboard if it is open - Keyboards.KWinVirtualKeyboard.active = false; - } else if (WindowPlugin.WindowUtil.hasCloseableActiveWindow) { - // if task switcher is closed, but there is an active window - if (tasksModel.activeTask !== 0) { - tasksModel.requestClose(tasksModel.activeTask); - } - } + WayfireIpcPlugin.WayfireIPC.stipcBtn(1, "press", false); +// if (Keyboards.KWinVirtualKeyboard.active) { +// // close keyboard if it is open +// Keyboards.KWinVirtualKeyboard.active = false; +// } else if (WindowPlugin.WindowUtil.hasCloseableActiveWindow) { +// // if task switcher is closed, but there is an active window +// if (tasksModel.activeTask !== 0) { +// tasksModel.requestClose(tasksModel.activeTask); +// } +// } } }