Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
levnikmyskin committed Jun 27, 2024
2 parents fd9f63c + 5522140 commit 751d7c6
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 40 deletions.
9 changes: 9 additions & 0 deletions .github/actions/setup_base/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)!
Expand Down
4 changes: 4 additions & 0 deletions hyprpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
]


Expand Down
4 changes: 3 additions & 1 deletion include/VirtualDesk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
70 changes: 36 additions & 34 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"#({{
Expand All @@ -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);
}
Expand Down Expand Up @@ -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"};
}

0 comments on commit 751d7c6

Please sign in to comment.