Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navbar Buttons #11

Open
wants to merge 3 commits into
base: group/next/upgrade-6.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions components/wayfireipcplugin/wayfireipc.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2024 Alexander Rutz <[email protected]>
// SPDX-FileCopyrightText: 2024 Deepak Kumar <[email protected]>
// SPDX-License-Identifier: GPL-2.0-or-later

#include <QDebug>
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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());
}
}
10 changes: 9 additions & 1 deletion components/wayfireipcplugin/wayfireipc.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2024 Alexander Rutz <[email protected]>
// SPDX-FileCopyrightText: 2024 Deepak Kumar <[email protected]>
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once
Expand All @@ -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);
Expand All @@ -32,4 +40,4 @@ private Q_SLOTS:

QLocalSocket *m_wfsocket = nullptr;
QDataStream m_in;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,7 +65,8 @@ MobileShell.NavigationPanel {
iconSizeFactor: 0.75

onTriggered: {
Plasmoid.triggerTaskSwitcher();
WayfireIpcPlugin.WayfireIPC.toggleScale();
//Plasmoid.triggerTaskSwitcher();
}
}

Expand All @@ -76,29 +79,36 @@ MobileShell.NavigationPanel {
iconSizeFactor: 1

onTriggered: {
MobileShellState.ShellDBusClient.openHomeScreen();
if (WayfireIpcPlugin.WayfireIPC.isAnyAppFocused()) {
WayfireIpcPlugin.WayfireIPC.toggleShowDesktop();
} else {
MobileShellState.ShellDBusClient.openHomeScreen();
}
}
}

// close app/keyboard button
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);
// }
// }
}
}

Expand Down