mirror of
https://github.com/levnikmyskin/hyprland-virtual-desktops.git
synced 2024-10-03 22:07:19 +03:00
Merge branch 'main' into dev
This commit is contained in:
commit
751d7c6722
9
.github/actions/setup_base/action.yml
vendored
9
.github/actions/setup_base/action.yml
vendored
@ -80,6 +80,15 @@ runs:
|
||||
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
|
||||
cmake --install build
|
||||
|
||||
- name: Get hyprutils
|
||||
shell: bash
|
||||
run: |
|
||||
git clone https://github.com/hyprwm/hyprutils.git
|
||||
cd hyprutils
|
||||
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build
|
||||
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf _NPROCESSORS_CONF`
|
||||
cmake --install build
|
||||
|
||||
- name: Get Xorg pacman pkgs
|
||||
shell: bash
|
||||
if: inputs.INSTALL_XORG_PKGS == 'true'
|
||||
|
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
@ -28,8 +28,8 @@ jobs:
|
||||
if: github.ref == 'refs/heads/main'|| github.base_ref == 'main'
|
||||
with:
|
||||
INSTALL_XORG_PKGS: true
|
||||
branch: 'v0.40.0'
|
||||
hyprwayland: 'v0.3.4'
|
||||
branch: 'v0.41.1'
|
||||
hyprwayland: 'v0.3.10'
|
||||
|
||||
- name: Setup base on dev
|
||||
uses: ./.github/actions/setup_base
|
||||
|
@ -1,9 +1,10 @@
|
||||
# Virtual desktops for Hyprland ![hyprico](.github/hyprland.ico)
|
||||
`virtual-desktops` is a plugin for the [Hyprland](https://github.com/hyprwm/Hyprland) compositor. `virtual-desktops` manages multiple screens workspaces as if they were a single virtual desktop.
|
||||
|
||||
## WARNING
|
||||
You are on the `dev` branch. This branch unconsistently gather updates and fixes to follow `hyprland-git`. By unconsistently, I mean that there is NO GUARANTEE that this branch will work with `hyprland-git` at any given time.
|
||||
This plugin **DOES NOT** support `hyprland-git`, please refrain from opening issues if virtual-desktop does not compile with the latest commit on hyprland. Feel free to contribute to this branch via PRs though.
|
||||
This plugin **only supports official releases of Hyprland** (e.g., v0.39.x, v0.40.x).
|
||||
If you are on `hyprland-git`, please try compiling this plugin from the [dev branch](https://github.com/levnikmyskin/hyprland-virtual-desktops/tree/dev).
|
||||
There is **NO GUARANTEE** that the plugin will compile succesfully on the latest Hyprland commit, but we try our best to keep it updated. Also, always check the [PR section](https://github.com/levnikmyskin/hyprland-virtual-desktops/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc),
|
||||
as there might be a draft PR for the next Hyprland release, where you can check the status of development.
|
||||
|
||||
|
||||
Feel free to join our [matrix room](https://matrix.to/#/#hypr-virtual-desktops:matrix.org)!
|
||||
|
@ -24,6 +24,10 @@ commit_pins = [
|
||||
["fe7b748eb668136dd0558b7c8279bfcd7ab4d759", "2a90d57bdfdee1a153fd321bc2da0924b8409c3b"],
|
||||
# Hyprland v0.40.0
|
||||
["cba1ade848feac44b2eda677503900639581c3f4", "e3bad3b9ab3dac25ad77641a2037601035125535"],
|
||||
# Hyprland v0.41.0
|
||||
["ea2501d4556f84d3de86a4ae2f4b22a474555b9f", "e42e505ce82b2ad0d33b56e9e1e600db7ebb9e7a"],
|
||||
# Hyprland v0.41.1
|
||||
["9e781040d9067c2711ec2e9f5b47b76ef70762b3", "b5121a450a66382fd8e6e28e93d83430c86043a6"]
|
||||
]
|
||||
|
||||
|
||||
|
@ -12,7 +12,9 @@
|
||||
#include "utils.hpp"
|
||||
#include <hyprland/src/Compositor.hpp>
|
||||
|
||||
typedef std::unordered_map<int, int> WorkspaceMap;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
typedef std::unordered_map<int, int> WorkspaceMap;
|
||||
// map with CMonitor* -> hyprland workspace id
|
||||
typedef std::unordered_map<const CMonitor*, int> Layout;
|
||||
typedef std::string MonitorName;
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <string>
|
||||
#include <hyprland/src/Compositor.hpp>
|
||||
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
const std::string VIRTUALDESK_NAMES_CONF = "plugin:virtual-desktops:names";
|
||||
const std::string CYCLEWORKSPACES_CONF = "plugin:virtual-desktops:cycleworkspaces";
|
||||
const std::string REMEMBER_LAYOUT_CONF = "plugin:virtual-desktops:rememberlayout";
|
||||
|
70
src/main.cpp
70
src/main.cpp
@ -14,21 +14,23 @@
|
||||
#include <any>
|
||||
#include <vector>
|
||||
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
static CSharedPointer<HOOK_CALLBACK_FN> onWorkspaceChangeHook = nullptr;
|
||||
static CSharedPointer<HOOK_CALLBACK_FN> onWindowOpenHook = nullptr;
|
||||
static CSharedPointer<HOOK_CALLBACK_FN> onConfigReloadedHook = nullptr;
|
||||
|
||||
inline CFunctionHook* g_pMonitorConnectHook = nullptr;
|
||||
inline CFunctionHook* g_pMonitorDisconnectHook = nullptr;
|
||||
typedef void (*origMonitorConnect)(void*, bool);
|
||||
typedef void (*origMonitorDisconnect)(void*, bool);
|
||||
typedef void (*origMonitorConnect)(void*, bool);
|
||||
typedef void (*origMonitorDisconnect)(void*, bool);
|
||||
|
||||
std::unique_ptr<VirtualDeskManager> manager = std::make_unique<VirtualDeskManager>();
|
||||
std::vector<StickyApps::SStickyRule> stickyRules;
|
||||
bool notifiedInit = false;
|
||||
bool monitorLayoutChanging = false;
|
||||
std::unique_ptr<VirtualDeskManager> manager = std::make_unique<VirtualDeskManager>();
|
||||
std::vector<StickyApps::SStickyRule> stickyRules;
|
||||
bool notifiedInit = false;
|
||||
bool monitorLayoutChanging = false;
|
||||
|
||||
void parseNamesConf(std::string& conf) {
|
||||
void parseNamesConf(std::string& conf) {
|
||||
size_t pos;
|
||||
size_t delim;
|
||||
std::string rule;
|
||||
@ -178,38 +180,36 @@ std::string printStateDispatch(eHyprCtlOutputFormat format, std::string arg) {
|
||||
if (format == eHyprCtlOutputFormat::FORMAT_NORMAL) {
|
||||
out += "Virtual desks\n";
|
||||
int index = 0;
|
||||
for(auto const& [vdeskId, desk] : manager->vdesksMap) {
|
||||
for (auto const& [vdeskId, desk] : manager->vdesksMap) {
|
||||
unsigned int windows = 0;
|
||||
std::string workspaces;
|
||||
bool first = true;
|
||||
for(auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) {
|
||||
std::string workspaces;
|
||||
bool first = true;
|
||||
for (auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) {
|
||||
windows += g_pCompositor->getWindowsOnWorkspace(workspaceId);
|
||||
if(!first) workspaces += ", ";
|
||||
else first = false;
|
||||
if (!first)
|
||||
workspaces += ", ";
|
||||
else
|
||||
first = false;
|
||||
workspaces += std::format("{}", workspaceId);
|
||||
}
|
||||
out += std::format(
|
||||
"- {}: {}\n Focused: {}\n Populated: {}\n Workspaces: {}\n Windows: {}\n",
|
||||
desk->name,
|
||||
desk->id,
|
||||
manager->activeVdesk().get() == desk.get(),
|
||||
windows > 0,
|
||||
workspaces,
|
||||
windows
|
||||
);
|
||||
if(index++ < manager->vdesksMap.size() - 1) out += "\n";
|
||||
out += std::format("- {}: {}\n Focused: {}\n Populated: {}\n Workspaces: {}\n Windows: {}\n", desk->name, desk->id, manager->activeVdesk().get() == desk.get(),
|
||||
windows > 0, workspaces, windows);
|
||||
if (index++ < manager->vdesksMap.size() - 1)
|
||||
out += "\n";
|
||||
}
|
||||
} else if(format == eHyprCtlOutputFormat::FORMAT_JSON) {
|
||||
} else if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
|
||||
std::string vdesks;
|
||||
int index = 0;
|
||||
for(auto const& [vdeskId, desk] : manager->vdesksMap) {
|
||||
int index = 0;
|
||||
for (auto const& [vdeskId, desk] : manager->vdesksMap) {
|
||||
unsigned int windows = 0;
|
||||
std::string workspaces;
|
||||
bool first = true;
|
||||
for(auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) {
|
||||
std::string workspaces;
|
||||
bool first = true;
|
||||
for (auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) {
|
||||
windows += g_pCompositor->getWindowsOnWorkspace(workspaceId);
|
||||
if(!first) workspaces += ", ";
|
||||
else first = false;
|
||||
if (!first)
|
||||
workspaces += ", ";
|
||||
else
|
||||
first = false;
|
||||
workspaces += std::format("{}", workspaceId);
|
||||
}
|
||||
vdesks += std::format(R"#({{
|
||||
@ -219,8 +219,10 @@ std::string printStateDispatch(eHyprCtlOutputFormat format, std::string arg) {
|
||||
"populated": {},
|
||||
"workspaces": [{}],
|
||||
"windows": {}
|
||||
}})#", vdeskId, desk->name, manager->activeVdesk().get() == desk.get(), windows > 0, workspaces, windows);
|
||||
if(index++ < manager->vdesksMap.size() - 1) vdesks += ",";
|
||||
}})#",
|
||||
vdeskId, desk->name, manager->activeVdesk().get() == desk.get(), windows > 0, workspaces, windows);
|
||||
if (index++ < manager->vdesksMap.size() - 1)
|
||||
vdesks += ",";
|
||||
}
|
||||
out += std::format(R"#([{}])#", vdesks);
|
||||
}
|
||||
@ -417,5 +419,5 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||
|
||||
// Initialize first vdesk
|
||||
HyprlandAPI::reloadConfig();
|
||||
return {"virtual-desktops", "Virtual desktop like workspaces", "LevMyskin", "2.2.2"};
|
||||
return {"virtual-desktops", "Virtual desktop like workspaces", "LevMyskin", "2.2.4"};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user