Can now flip the floating rule on and off

This commit is contained in:
2025-06-10 15:45:25 +02:00
parent ee3cddc7ca
commit d1a2ef710f
3 changed files with 21 additions and 72 deletions

View File

@@ -19,6 +19,7 @@ class HyprlandService {
static Workspace getCurrentWorkspace();
static std::list<Client> getClients();
static std::list<Client> getClientsOnActiveWorkspace();
static void setFloatingRule(bool);
static void setClientFloating(Client&);
static void setClientTiled(Client&);
static void toggleClientFloating(Client&);

View File

@@ -57,5 +57,14 @@ void HyprlandService::setClientTiled(Client& c) {
}
void HyprlandService::toggleClientFloating(Client& c) {
exec("/usr/bin/hyprctl dispatch togglefloating address:" + c.address);
exec(HYPRCTL_BINARY " dispatch togglefloating address:" + c.address);
};
void HyprlandService::setFloatingRule(bool b) {
if (b) {
exec(SET_FLOATING_RULE);
}
else {
exec(REMOVE_FLOATING_RULE);
}
};

View File

@@ -3,76 +3,15 @@
#include <unistd.h>
int main(int, char**){
Workspace w = HyprlandService::getCurrentWorkspace();
std::cout << "Active workspace:" << std::endl;
std::cout << " id: " << w.id << std::endl;
std::cout << " name: " << w.name << std::endl;
std::cout << " monitor: " << w.monitor << std::endl;
std::cout << " monitorID: " << w.monitorID << std::endl;
std::cout << " windows: " << w.windows << std::endl;
std::cout << " hasfullscreen: " << w.hasfullscreen << std::endl;
std::cout << " lastwindow: " << w.lastwindow << std::endl;
std::cout << " lastwindowtitle: " << w.lastwindowtitle << std::endl;
std::cout << " ispersistent: " << w.ispersistent << std::endl;
std::cout << std::endl;
for (auto& c : HyprlandService::getClientsOnActiveWorkspace()) {
HyprlandService::setClientFloating(c);
}
HyprlandService::setFloatingRule(true);
std::cout << "---------------------------------------------" << std::endl << std::endl;
sleep(5);
std::list<Client> clients = HyprlandService::getClients();
for (const auto& c : clients) {
std::cout << "Client:" << std::endl;
std::cout << " address: " << c.address << std::endl;
std::cout << " mapped: " << c.mapped << std::endl;
std::cout << " hidden: " << c.hidden << std::endl;
std::cout << " size: [" << c.size[0] << ", " << c.size[1] << "]" << std::endl;
std::cout << " workspace.id: " << c.workspace.id << std::endl;
std::cout << " workspace.name: " << c.workspace.name << std::endl;
std::cout << " floating: " << c.floating << std::endl;
std::cout << " pseudo: " << c.pseudo << std::endl;
std::cout << " monitor: " << c.monitor << std::endl;
std::cout << " className: " << c.className << std::endl;
std::cout << " title: " << c.title << std::endl;
std::cout << " initialClass: " << c.initialClass << std::endl;
std::cout << " initialTitle: " << c.initialTitle << std::endl;
std::cout << " pid: " << c.pid << std::endl;
std::cout << " xwayland: " << c.xwayland << std::endl;
std::cout << " pinned: " << c.pinned << std::endl;
std::cout << " fullscreen: " << c.fullscreen << std::endl;
std::cout << " fullscreenClient: " << c.fullscreenClient << std::endl;
std::cout << " swallowing: " << c.swallowing << std::endl;
std::cout << " focusHistory: " << c.focusHistory << std::endl;
std::cout << " inhibitingIdle: " << c.inhibitingIdle << std::endl;
std::cout << " xdgTag: " << c.xdgTag << std::endl;
std::cout << " xdgDescription: " << c.xdgDescription << std::endl;
std::cout << std::endl;
}
std::cout << "---------------------------------------------" << std::endl << std::endl;
std::list<Client> activeClients = HyprlandService::getClientsOnActiveWorkspace();
for (const auto& c : activeClients) {
std::cout << "Active client:" << std::endl;
std::cout << " workspace.id: " << c.workspace.id << std::endl;
std::cout << " workspace.name: " << c.workspace.name << std::endl;
std::cout << " className: " << c.className << std::endl;
std::cout << " title: " << c.title << std::endl;
std::cout << std::endl;
}
std::cout << "Setting " << activeClients.front().className << " into floating mode..." << std::endl;
sleep(2);
HyprlandService::setClientFloating(activeClients.front());
std::cout << "Setting " << activeClients.front().className << " into tiled mode..." << std::endl;
sleep(2);
HyprlandService::setClientTiled(activeClients.front());
std::cout << "Toggling floating mode for " << activeClients.front().className << " ..." << std::endl;
sleep(2);
HyprlandService::toggleClientFloating(activeClients.front());
std::cout << "Toggling floating mode for " << activeClients.front().className << " once more..." << std::endl;
sleep(2);
HyprlandService::toggleClientFloating(activeClients.front());
}
for (auto& c : HyprlandService::getClientsOnActiveWorkspace()) {
HyprlandService::setClientTiled(c);
}
HyprlandService::setFloatingRule(false);
}