fixup: fix breakage from hyprland#5380

This commit is contained in:
outfoxxed 2024-04-03 21:45:40 -07:00
parent ea9074a2af
commit fdc4749ac7
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
10 changed files with 143 additions and 158 deletions

7
flake.lock generated
View file

@ -37,16 +37,15 @@
"xdph": "xdph" "xdph": "xdph"
}, },
"locked": { "locked": {
"lastModified": 1711996237, "lastModified": 1712189807,
"narHash": "sha256-oa82eFINs1HkEnx3Nu+GEQQxXXNkJzSci3HZU//OJ2Y=", "narHash": "sha256-hmEBPDk1GbpPzpa0gLhJ0XJ5rvt+dMddKNQGr9J8XyA=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "Hyprland", "repo": "Hyprland",
"rev": "3875679755014997776e091ff8903acfb311dd2f", "rev": "b7d71bc0e1084bc1a296ae906503709a74fde4d9",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "hyprwm", "owner": "hyprwm",
"ref": "v0.38.0",
"repo": "Hyprland", "repo": "Hyprland",
"type": "github" "type": "github"
} }

View file

@ -1,6 +1,6 @@
{ {
inputs = { inputs = {
hyprland.url = "github:hyprwm/Hyprland?ref=v0.38.0"; hyprland.url = "github:hyprwm/Hyprland";
}; };
outputs = { self, hyprland, ... }: let outputs = { self, hyprland, ... }: let

View file

@ -2,6 +2,7 @@
#include <set> #include <set>
#include <hyprland/src/Compositor.hpp> #include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/DesktopTypes.hpp>
#include <hyprland/src/plugins/PluginAPI.hpp> #include <hyprland/src/plugins/PluginAPI.hpp>
#include <ranges> #include <ranges>
@ -36,7 +37,7 @@ bool performContainment(Hy3Node& node, bool contained, CWindow* window) {
node.layout->nodes.push_back({ node.layout->nodes.push_back({
.parent = &node, .parent = &node,
.data = window, .data = window,
.workspace_id = node.workspace_id, .workspace = node.workspace,
.layout = node.layout, .layout = node.layout,
}); });
@ -78,7 +79,7 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) {
(uintptr_t) window, (uintptr_t) window,
window->m_bIsFloating, window->m_bIsFloating,
window->m_iMonitorID, window->m_iMonitorID,
window->m_iWorkspaceID window->m_pWorkspace->m_iID
); );
if (window->m_bIsFloating) return; if (window->m_bIsFloating) return;
@ -97,7 +98,7 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) {
this->nodes.push_back({ this->nodes.push_back({
.parent = nullptr, .parent = nullptr,
.data = window, .data = window,
.workspace_id = window->m_iWorkspaceID, .workspace = window->m_pWorkspace,
.layout = this, .layout = this,
}); });
@ -115,26 +116,24 @@ void Hy3Layout::insertNode(Hy3Node& node) {
return; return;
} }
auto* workspace = g_pCompositor->getWorkspaceByID(node.workspace_id); if (!valid(node.workspace)) {
if (workspace == nullptr) {
hy3_log( hy3_log(
ERR, ERR,
"insertNode called for node {:x} with invalid workspace id {}", "insertNode called for node {:x} with invalid workspace id {}",
(uintptr_t) &node, (uintptr_t) &node,
node.workspace_id node.workspace->m_iID
); );
return; return;
} }
node.reparenting = true; node.reparenting = true;
auto* monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID); auto* monitor = g_pCompositor->getMonitorFromID(node.workspace->m_iMonitorID);
Hy3Node* opening_into; Hy3Node* opening_into;
Hy3Node* opening_after = nullptr; Hy3Node* opening_after = nullptr;
auto* root = this->getWorkspaceRootGroup(node.workspace_id); auto* root = this->getWorkspaceRootGroup(node.workspace);
if (root != nullptr) { if (root != nullptr) {
opening_after = root->getFocusedNode(); opening_after = root->getFocusedNode();
@ -148,7 +147,7 @@ void Hy3Layout::insertNode(Hy3Node& node) {
if (opening_after == nullptr) { if (opening_after == nullptr) {
if (g_pCompositor->m_pLastWindow != nullptr if (g_pCompositor->m_pLastWindow != nullptr
&& g_pCompositor->m_pLastWindow->m_iWorkspaceID == node.workspace_id && g_pCompositor->m_pLastWindow->m_pWorkspace == node.workspace
&& !g_pCompositor->m_pLastWindow->m_bIsFloating && !g_pCompositor->m_pLastWindow->m_bIsFloating
&& (node.data.type == Hy3NodeType::Window && (node.data.type == Hy3NodeType::Window
|| g_pCompositor->m_pLastWindow != node.data.as_window) || g_pCompositor->m_pLastWindow != node.data.as_window)
@ -161,7 +160,7 @@ void Hy3Layout::insertNode(Hy3Node& node) {
RESERVED_EXTENTS | INPUT_EXTENTS RESERVED_EXTENTS | INPUT_EXTENTS
); );
if (mouse_window != nullptr && mouse_window->m_iWorkspaceID == node.workspace_id) { if (mouse_window != nullptr && mouse_window->m_pWorkspace == node.workspace) {
opening_after = this->getNodeFromWindow(mouse_window); opening_after = this->getNodeFromWindow(mouse_window);
} }
} }
@ -178,7 +177,7 @@ void Hy3Layout::insertNode(Hy3Node& node) {
if (opening_after != nullptr) { if (opening_after != nullptr) {
opening_into = opening_after->parent; opening_into = opening_after->parent;
} else { } else {
if ((opening_into = this->getWorkspaceRootGroup(node.workspace_id)) == nullptr) { if ((opening_into = this->getWorkspaceRootGroup(node.workspace)) == nullptr) {
static const auto tab_first_window = static const auto tab_first_window =
ConfigValue<Hyprlang::INT>("plugin:hy3:tab_first_window"); ConfigValue<Hyprlang::INT>("plugin:hy3:tab_first_window");
@ -191,7 +190,7 @@ void Hy3Layout::insertNode(Hy3Node& node) {
.data = height > width ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH, .data = height > width ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH,
.position = monitor->vecPosition + monitor->vecReservedTopLeft, .position = monitor->vecPosition + monitor->vecReservedTopLeft,
.size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
.workspace_id = node.workspace_id, .workspace = node.workspace,
.layout = this, .layout = this,
}); });
@ -203,7 +202,7 @@ void Hy3Layout::insertNode(Hy3Node& node) {
.data = Hy3GroupLayout::Tabbed, .data = Hy3GroupLayout::Tabbed,
.position = parent.position, .position = parent.position,
.size = parent.size, .size = parent.size,
.workspace_id = node.workspace_id, .workspace = node.workspace,
.layout = this, .layout = this,
}); });
@ -220,14 +219,14 @@ void Hy3Layout::insertNode(Hy3Node& node) {
return; return;
} }
if (opening_into->workspace_id != node.workspace_id) { if (opening_into->workspace != node.workspace) {
hy3_log( hy3_log(
WARN, WARN,
"opening_into node ({:x}) is on workspace {} which does not match the new window " "opening_into node ({:x}) is on workspace {} which does not match the new window "
"(workspace {})", "(workspace {})",
(uintptr_t) opening_into, (uintptr_t) opening_into,
opening_into->workspace_id, opening_into->workspace->m_iID,
node.workspace_id node.workspace->m_iID
); );
} }
@ -244,7 +243,7 @@ void Hy3Layout::insertNode(Hy3Node& node) {
auto& target_group = opening_into->data.as_group; auto& target_group = opening_into->data.as_group;
if (*at_enable && opening_after != nullptr && target_group.children.size() > 1 if (*at_enable && opening_after != nullptr && target_group.children.size() > 1
&& target_group.layout != Hy3GroupLayout::Tabbed && target_group.layout != Hy3GroupLayout::Tabbed
&& this->shouldAutotileWorkspace(opening_into->workspace_id)) && this->shouldAutotileWorkspace(opening_into->workspace))
{ {
auto is_horizontal = target_group.layout == Hy3GroupLayout::SplitH; auto is_horizontal = target_group.layout == Hy3GroupLayout::SplitH;
auto trigger = is_horizontal ? *at_trigger_width : *at_trigger_height; auto trigger = is_horizontal ? *at_trigger_width : *at_trigger_height;
@ -380,7 +379,7 @@ void Hy3Layout::recalculateMonitor(const int& monitor_id) {
top_node->recalcSizePosRecursive(); top_node->recalcSizePosRecursive();
} }
top_node = this->getWorkspaceRootGroup(monitor->specialWorkspaceID); top_node = this->getWorkspaceRootGroup(monitor->activeSpecialWorkspace);
if (top_node != nullptr) { if (top_node != nullptr) {
top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft; top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft;
@ -500,15 +499,14 @@ void Hy3Layout::fullscreenRequestForWindow(
bool on bool on
) { ) {
if (!g_pCompositor->windowValidMapped(window)) return; if (!g_pCompositor->windowValidMapped(window)) return;
if (on == window->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)) if (on == window->m_bIsFullscreen || window->m_pWorkspace->m_bIsSpecialWorkspace)
return; return;
const auto monitor = g_pCompositor->getMonitorFromID(window->m_iMonitorID); const auto monitor = g_pCompositor->getMonitorFromID(window->m_iMonitorID);
const auto workspace = g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID); if (window->m_pWorkspace->m_bHasFullscreenWindow && on) return;
if (workspace->m_bHasFullscreenWindow && on) return;
window->m_bIsFullscreen = on; window->m_bIsFullscreen = on;
workspace->m_bHasFullscreenWindow = !workspace->m_bHasFullscreenWindow; window->m_pWorkspace->m_bHasFullscreenWindow = !window->m_pWorkspace->m_bHasFullscreenWindow;
if (!window->m_bIsFullscreen) { if (!window->m_bIsFullscreen) {
auto* node = this->getNodeFromWindow(window); auto* node = this->getNodeFromWindow(window);
@ -526,7 +524,7 @@ void Hy3Layout::fullscreenRequestForWindow(
window->m_sSpecialRenderData.decorate = true; window->m_sSpecialRenderData.decorate = true;
} }
} else { } else {
workspace->m_efFullscreenMode = fullscreen_mode; window->m_pWorkspace->m_efFullscreenMode = fullscreen_mode;
// save position and size if floating // save position and size if floating
if (window->m_bIsFloating) { if (window->m_bIsFloating) {
@ -565,7 +563,7 @@ void Hy3Layout::fullscreenRequestForWindow(
.size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
.gap_topleft_offset = gap_pos_offset, .gap_topleft_offset = gap_pos_offset,
.gap_bottomright_offset = gap_size_offset, .gap_bottomright_offset = gap_size_offset,
.workspace_id = window->m_iWorkspaceID, .workspace = window->m_pWorkspace,
}; };
this->applyNodeDataToWindow(&fakeNode); this->applyNodeDataToWindow(&fakeNode);
@ -628,17 +626,15 @@ void Hy3Layout::alterSplitRatio(CWindow* pWindow, float delta, bool exact) {
std::string Hy3Layout::getLayoutName() { return "hy3"; } std::string Hy3Layout::getLayoutName() { return "hy3"; }
CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) { CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) {
auto* workspace = g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID); if (window->m_pWorkspace->m_bHasFullscreenWindow) {
return g_pCompositor->getFullscreenWindowOnWorkspace(window->m_pWorkspace->m_iID);
if (workspace->m_bHasFullscreenWindow) {
return g_pCompositor->getFullscreenWindowOnWorkspace(window->m_iWorkspaceID);
} }
// return the first floating window on the same workspace that has not asked not to be focused // return the first floating window on the same workspace that has not asked not to be focused
if (window->m_bIsFloating) { if (window->m_bIsFloating) {
for (auto& w: g_pCompositor->m_vWindows | std::views::reverse) { for (auto& w: g_pCompositor->m_vWindows | std::views::reverse) {
if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2
&& w->m_iWorkspaceID == window->m_iWorkspaceID && !w->m_bX11ShouldntFocus && w->m_pWorkspace == window->m_pWorkspace && !w->m_bX11ShouldntFocus
&& !w->m_sAdditionalConfigData.noFocus && w.get() != window) && !w->m_sAdditionalConfigData.noFocus && w.get() != window)
{ {
return w.get(); return w.get();
@ -646,7 +642,7 @@ CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) {
} }
} }
auto* node = this->getWorkspaceFocusedNode(window->m_iWorkspaceID, true); auto* node = this->getWorkspaceFocusedNode(window->m_pWorkspace, true);
if (node == nullptr) return nullptr; if (node == nullptr) return nullptr;
switch (node->data.type) { switch (node->data.type) {
@ -706,7 +702,7 @@ void Hy3Layout::onDisable() {
} }
void Hy3Layout::makeGroupOnWorkspace( void Hy3Layout::makeGroupOnWorkspace(
int workspace, const PHLWORKSPACE& workspace,
Hy3GroupLayout layout, Hy3GroupLayout layout,
GroupEphemeralityOption ephemeral GroupEphemeralityOption ephemeral
) { ) {
@ -714,40 +710,40 @@ void Hy3Layout::makeGroupOnWorkspace(
this->makeGroupOn(node, layout, ephemeral); this->makeGroupOn(node, layout, ephemeral);
} }
void Hy3Layout::makeOppositeGroupOnWorkspace(int workspace, GroupEphemeralityOption ephemeral) { void Hy3Layout::makeOppositeGroupOnWorkspace(const PHLWORKSPACE& workspace, GroupEphemeralityOption ephemeral) {
auto* node = this->getWorkspaceFocusedNode(workspace); auto* node = this->getWorkspaceFocusedNode(workspace);
this->makeOppositeGroupOn(node, ephemeral); this->makeOppositeGroupOn(node, ephemeral);
} }
void Hy3Layout::changeGroupOnWorkspace(int workspace, Hy3GroupLayout layout) { void Hy3Layout::changeGroupOnWorkspace(const PHLWORKSPACE& workspace, Hy3GroupLayout layout) {
auto* node = this->getWorkspaceFocusedNode(workspace); auto* node = this->getWorkspaceFocusedNode(workspace);
if (node == nullptr) return; if (node == nullptr) return;
this->changeGroupOn(*node, layout); this->changeGroupOn(*node, layout);
} }
void Hy3Layout::untabGroupOnWorkspace(int workspace) { void Hy3Layout::untabGroupOnWorkspace(const PHLWORKSPACE& workspace) {
auto* node = this->getWorkspaceFocusedNode(workspace); auto* node = this->getWorkspaceFocusedNode(workspace);
if (node == nullptr) return; if (node == nullptr) return;
this->untabGroupOn(*node); this->untabGroupOn(*node);
} }
void Hy3Layout::toggleTabGroupOnWorkspace(int workspace) { void Hy3Layout::toggleTabGroupOnWorkspace(const PHLWORKSPACE& workspace) {
auto* node = this->getWorkspaceFocusedNode(workspace); auto* node = this->getWorkspaceFocusedNode(workspace);
if (node == nullptr) return; if (node == nullptr) return;
this->toggleTabGroupOn(*node); this->toggleTabGroupOn(*node);
} }
void Hy3Layout::changeGroupToOppositeOnWorkspace(int workspace) { void Hy3Layout::changeGroupToOppositeOnWorkspace(const PHLWORKSPACE& workspace) {
auto* node = this->getWorkspaceFocusedNode(workspace); auto* node = this->getWorkspaceFocusedNode(workspace);
if (node == nullptr) return; if (node == nullptr) return;
this->changeGroupToOppositeOn(*node); this->changeGroupToOppositeOn(*node);
} }
void Hy3Layout::changeGroupEphemeralityOnWorkspace(int workspace, bool ephemeral) { void Hy3Layout::changeGroupEphemeralityOnWorkspace(const PHLWORKSPACE& workspace, bool ephemeral) {
auto* node = this->getWorkspaceFocusedNode(workspace); auto* node = this->getWorkspaceFocusedNode(workspace);
if (node == nullptr) return; if (node == nullptr) return;
@ -868,19 +864,18 @@ void Hy3Layout::shiftNode(Hy3Node& node, ShiftDirection direction, bool once, bo
} }
} }
void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction, bool once, bool visible) { void Hy3Layout::shiftWindow(const PHLWORKSPACE& workspace, ShiftDirection direction, bool once, bool visible) {
auto* node = this->getWorkspaceFocusedNode(workspace); auto* node = this->getWorkspaceFocusedNode(workspace);
if (node == nullptr) return; if (node == nullptr) return;
this->shiftNode(*node, direction, once, visible); this->shiftNode(*node, direction, once, visible);
} }
void Hy3Layout::shiftFocus(int workspace, ShiftDirection direction, bool visible) { void Hy3Layout::shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection direction, bool visible) {
auto* current_window = g_pCompositor->m_pLastWindow; auto* current_window = g_pCompositor->m_pLastWindow;
if (current_window != nullptr) { if (current_window != nullptr) {
auto* p_workspace = g_pCompositor->getWorkspaceByID(current_window->m_iWorkspaceID); if (current_window->m_pWorkspace->m_bHasFullscreenWindow) return;
if (p_workspace->m_bHasFullscreenWindow) return;
if (current_window->m_bIsFloating) { if (current_window->m_bIsFloating) {
auto* next_window = g_pCompositor->getWindowInDirection( auto* next_window = g_pCompositor->getWindowInDirection(
@ -908,12 +903,12 @@ void Hy3Layout::shiftFocus(int workspace, ShiftDirection direction, bool visible
} }
} }
void changeNodeWorkspaceRecursive(Hy3Node& node, CWorkspace* workspace) { void changeNodeWorkspaceRecursive(Hy3Node& node, const PHLWORKSPACE& workspace) {
node.workspace_id = workspace->m_iID; node.workspace = workspace;
if (node.data.type == Hy3NodeType::Window) { if (node.data.type == Hy3NodeType::Window) {
auto* window = node.data.as_window; auto* window = node.data.as_window;
window->moveToWorkspace(workspace->m_iID); window->moveToWorkspace(workspace);
window->updateToplevel(); window->updateToplevel();
window->updateDynamicRules(); window->updateDynamicRules();
} else { } else {
@ -923,42 +918,39 @@ void changeNodeWorkspaceRecursive(Hy3Node& node, CWorkspace* workspace) {
} }
} }
void Hy3Layout::moveNodeToWorkspace(int origin, std::string wsname, bool follow) { void Hy3Layout::moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow) {
std::string target_name; std::string target_name;
auto target = getWorkspaceIDFromString(wsname, target_name); auto target_id = getWorkspaceIDFromString(wsname, target_name);
if (target == WORKSPACE_INVALID) { if (target_id == WORKSPACE_INVALID) {
hy3_log(ERR, "moveNodeToWorkspace called with invalid workspace {}", wsname); hy3_log(ERR, "moveNodeToWorkspace called with invalid workspace {}", wsname);
return; return;
} }
if (origin == target) return; auto workspace = g_pCompositor->getWorkspaceByID(target_id);
if (origin == workspace) return;
auto* node = this->getWorkspaceFocusedNode(origin); auto* node = this->getWorkspaceFocusedNode(origin);
auto* focused_window = g_pCompositor->m_pLastWindow; auto* focused_window = g_pCompositor->m_pLastWindow;
auto* focused_window_node = this->getNodeFromWindow(focused_window); auto* focused_window_node = this->getNodeFromWindow(focused_window);
auto* workspace = g_pCompositor->getWorkspaceByID(target); auto origin_ws = node != nullptr ? node->workspace
: focused_window != nullptr ? focused_window->m_pWorkspace
: nullptr;
auto wsid = node != nullptr ? node->workspace_id if (!valid(origin_ws)) return;
: focused_window != nullptr ? focused_window->m_iWorkspaceID
: WORKSPACE_INVALID;
if (wsid == WORKSPACE_INVALID) return;
auto* origin_ws = g_pCompositor->getWorkspaceByID(wsid);
if (workspace == nullptr) { if (workspace == nullptr) {
hy3_log(LOG, "creating target workspace {} for node move", target); hy3_log(LOG, "creating target workspace {} for node move", target_id);
workspace = g_pCompositor->createNewWorkspace(target, origin_ws->m_iMonitorID, target_name); workspace = g_pCompositor->createNewWorkspace(target_id, origin_ws->m_iMonitorID, target_name);
} }
// floating or fullscreen // floating or fullscreen
if (focused_window != nullptr if (focused_window != nullptr
&& (focused_window_node == nullptr || focused_window->m_bIsFullscreen)) && (focused_window_node == nullptr || focused_window->m_bIsFullscreen))
{ {
hy3_log(LOG, "{:x}, {:x}", (uintptr_t) focused_window, (uintptr_t) workspace);
g_pCompositor->moveWindowToWorkspaceSafe(focused_window, workspace); g_pCompositor->moveWindowToWorkspaceSafe(focused_window, workspace);
} else { } else {
if (node == nullptr) return; if (node == nullptr) return;
@ -967,8 +959,8 @@ void Hy3Layout::moveNodeToWorkspace(int origin, std::string wsname, bool follow)
LOG, LOG,
"moving node {:x} from workspace {} to workspace {} (follow: {})", "moving node {:x} from workspace {} to workspace {} (follow: {})",
(uintptr_t) node, (uintptr_t) node,
origin, origin->m_iID,
target, workspace->m_iID,
follow follow
); );
@ -997,7 +989,7 @@ void Hy3Layout::moveNodeToWorkspace(int origin, std::string wsname, bool follow)
} }
} }
void Hy3Layout::changeFocus(int workspace, FocusShift shift) { void Hy3Layout::changeFocus(const PHLWORKSPACE& workspace, FocusShift shift) {
auto* node = this->getWorkspaceFocusedNode(workspace); auto* node = this->getWorkspaceFocusedNode(workspace);
if (node == nullptr) return; if (node == nullptr) return;
@ -1117,7 +1109,7 @@ Hy3Node* findTabBarAt(Hy3Node& node, Vector2D pos, Hy3Node** focused_node) {
} }
void Hy3Layout::focusTab( void Hy3Layout::focusTab(
int workspace, const PHLWORKSPACE& workspace,
TabFocus target, TabFocus target,
TabFocusMousePriority mouse, TabFocusMousePriority mouse,
bool wrap_scroll, bool wrap_scroll,
@ -1209,7 +1201,7 @@ hastab:
tab_node->recalcSizePosRecursive(); tab_node->recalcSizePosRecursive();
} }
void Hy3Layout::setNodeSwallow(int workspace, SetSwallowOption option) { void Hy3Layout::setNodeSwallow(const PHLWORKSPACE& workspace, SetSwallowOption option) {
auto* node = this->getWorkspaceFocusedNode(workspace); auto* node = this->getWorkspaceFocusedNode(workspace);
if (node == nullptr || node->parent == nullptr) return; if (node == nullptr || node->parent == nullptr) return;
@ -1221,7 +1213,7 @@ void Hy3Layout::setNodeSwallow(int workspace, SetSwallowOption option) {
} }
} }
void Hy3Layout::killFocusedNode(int workspace) { void Hy3Layout::killFocusedNode(const PHLWORKSPACE& workspace) {
if (g_pCompositor->m_pLastWindow != nullptr && g_pCompositor->m_pLastWindow->m_bIsFloating) { if (g_pCompositor->m_pLastWindow != nullptr && g_pCompositor->m_pLastWindow->m_bIsFloating) {
g_pCompositor->closeWindow(g_pCompositor->m_pLastWindow); g_pCompositor->closeWindow(g_pCompositor->m_pLastWindow);
} else { } else {
@ -1238,11 +1230,10 @@ void Hy3Layout::killFocusedNode(int workspace) {
} }
} }
void Hy3Layout::expand(int workspace_id, ExpandOption option, ExpandFullscreenOption fs_option) { void Hy3Layout::expand(const PHLWORKSPACE& workspace, ExpandOption option, ExpandFullscreenOption fs_option) {
auto* node = this->getWorkspaceFocusedNode(workspace_id, false, true); auto* node = this->getWorkspaceFocusedNode(workspace, false, true);
if (node == nullptr) return; if (node == nullptr) return;
const auto workspace = g_pCompositor->getWorkspaceByID(workspace_id);
const auto monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID); const auto monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID);
switch (option) { switch (option) {
@ -1300,7 +1291,7 @@ void Hy3Layout::expand(int workspace_id, ExpandOption option, ExpandFullscreenOp
fullscreen: fullscreen:
if (node->data.type != Hy3NodeType::Window) return; if (node->data.type != Hy3NodeType::Window) return;
window = node->data.as_window; window = node->data.as_window;
if (!window->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)) return; if (!window->m_bIsFullscreen || window->m_pWorkspace->m_bIsSpecialWorkspace) return;
if (workspace->m_bHasFullscreenWindow) return; if (workspace->m_bHasFullscreenWindow) return;
@ -1325,7 +1316,7 @@ fsupdate:
bool Hy3Layout::shouldRenderSelected(CWindow* window) { bool Hy3Layout::shouldRenderSelected(CWindow* window) {
if (window == nullptr) return false; if (window == nullptr) return false;
auto* root = this->getWorkspaceRootGroup(window->m_iWorkspaceID); auto* root = this->getWorkspaceRootGroup(window->m_pWorkspace);
if (root == nullptr || root->data.as_group.focused_child == nullptr) return false; if (root == nullptr || root->data.as_group.focused_child == nullptr) return false;
auto* focused = root->getFocusedNode(); auto* focused = root->getFocusedNode();
if (focused == nullptr if (focused == nullptr
@ -1344,9 +1335,9 @@ bool Hy3Layout::shouldRenderSelected(CWindow* window) {
} }
} }
Hy3Node* Hy3Layout::getWorkspaceRootGroup(const int& workspace) { Hy3Node* Hy3Layout::getWorkspaceRootGroup(const PHLWORKSPACE& workspace) {
for (auto& node: this->nodes) { for (auto& node: this->nodes) {
if (node.workspace_id == workspace && node.parent == nullptr if (node.workspace == workspace && node.parent == nullptr
&& node.data.type == Hy3NodeType::Group && !node.reparenting) && node.data.type == Hy3NodeType::Group && !node.reparenting)
{ {
return &node; return &node;
@ -1357,7 +1348,7 @@ Hy3Node* Hy3Layout::getWorkspaceRootGroup(const int& workspace) {
} }
Hy3Node* Hy3Layout::getWorkspaceFocusedNode( Hy3Node* Hy3Layout::getWorkspaceFocusedNode(
const int& workspace, const PHLWORKSPACE& workspace,
bool ignore_group_focus, bool ignore_group_focus,
bool stop_at_expanded bool stop_at_expanded
) { ) {
@ -1449,21 +1440,19 @@ Hy3Node* Hy3Layout::getNodeFromWindow(CWindow* window) {
void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) {
if (node->data.type != Hy3NodeType::Window) return; if (node->data.type != Hy3NodeType::Window) return;
auto* window = node->data.as_window; auto* window = node->data.as_window;
auto root_node = this->getWorkspaceRootGroup(window->m_iWorkspaceID); auto root_node = this->getWorkspaceRootGroup(window->m_pWorkspace);
CMonitor* monitor = nullptr; CMonitor* monitor = nullptr;
auto* workspace = g_pCompositor->getWorkspaceByID(node->workspace_id); if (node->workspace->m_bIsSpecialWorkspace) {
if (g_pCompositor->isWorkspaceSpecial(node->workspace_id)) {
for (auto& m: g_pCompositor->m_vMonitors) { for (auto& m: g_pCompositor->m_vMonitors) {
if (m->specialWorkspaceID == node->workspace_id) { if (m->activeSpecialWorkspace == node->workspace) {
monitor = m.get(); monitor = m.get();
break; break;
} }
} }
} else { } else {
monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID); monitor = g_pCompositor->getMonitorFromID(node->workspace->m_iMonitorID);
} }
if (monitor == nullptr) { if (monitor == nullptr) {
@ -1476,7 +1465,7 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) {
return; return;
} }
const auto workspace_rules = g_pConfigManager->getWorkspaceRulesFor(workspace); const auto workspace_rules = g_pConfigManager->getWorkspaceRulesFor(node->workspace);
// clang-format off // clang-format off
static const auto gaps_in = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_in"); static const auto gaps_in = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_in");
@ -1507,10 +1496,10 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) {
auto only_node = root_node != nullptr && root_node->data.as_group.children.size() == 1 auto only_node = root_node != nullptr && root_node->data.as_group.children.size() == 1
&& root_node->data.as_group.children.front()->data.type == Hy3NodeType::Window; && root_node->data.as_group.children.front()->data.type == Hy3NodeType::Window;
if (!g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID) if (!window->m_pWorkspace->m_bIsSpecialWorkspace
&& ((*no_gaps_when_only != 0 && (only_node || window->m_bIsFullscreen)) && ((*no_gaps_when_only != 0 && (only_node || window->m_bIsFullscreen))
|| (window->m_bIsFullscreen || (window->m_bIsFullscreen
&& g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID)->m_efFullscreenMode && window->m_pWorkspace->m_efFullscreenMode
== FULLSCREEN_FULL))) == FULLSCREEN_FULL)))
{ {
window->m_sSpecialRenderData.border = *no_gaps_when_only == 2; window->m_sSpecialRenderData.border = *no_gaps_when_only == 2;
@ -1640,7 +1629,7 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(
.data = shiftIsVertical(direction) ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH, .data = shiftIsVertical(direction) ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH,
.position = break_parent->position, .position = break_parent->position,
.size = break_parent->size, .size = break_parent->size,
.workspace_id = break_parent->workspace_id, .workspace = break_parent->workspace,
.layout = this, .layout = this,
}); });
@ -1848,10 +1837,10 @@ void Hy3Layout::updateAutotileWorkspaces() {
} }
} }
bool Hy3Layout::shouldAutotileWorkspace(int workspace_id) { bool Hy3Layout::shouldAutotileWorkspace(const PHLWORKSPACE& workspace) {
if (this->autotile.workspace_blacklist) { if (this->autotile.workspace_blacklist) {
return !this->autotile.workspaces.contains(workspace_id); return !this->autotile.workspaces.contains(workspace->m_iID);
} else { } else {
return this->autotile.workspaces.empty() || this->autotile.workspaces.contains(workspace_id); return this->autotile.workspaces.empty() || this->autotile.workspaces.contains(workspace->m_iID);
} }
} }

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <hyprland/src/desktop/DesktopTypes.hpp>
class Hy3Layout; class Hy3Layout;
enum class GroupEphemeralityOption { enum class GroupEphemeralityOption {
@ -95,13 +96,13 @@ public:
virtual void onDisable(); virtual void onDisable();
void insertNode(Hy3Node& node); void insertNode(Hy3Node& node);
void makeGroupOnWorkspace(int workspace, Hy3GroupLayout, GroupEphemeralityOption); void makeGroupOnWorkspace(const PHLWORKSPACE& workspace, Hy3GroupLayout, GroupEphemeralityOption);
void makeOppositeGroupOnWorkspace(int workspace, GroupEphemeralityOption); void makeOppositeGroupOnWorkspace(const PHLWORKSPACE& workspace, GroupEphemeralityOption);
void changeGroupOnWorkspace(int workspace, Hy3GroupLayout); void changeGroupOnWorkspace(const PHLWORKSPACE& workspace, Hy3GroupLayout);
void untabGroupOnWorkspace(int workspace); void untabGroupOnWorkspace(const PHLWORKSPACE& workspace);
void toggleTabGroupOnWorkspace(int workspace); void toggleTabGroupOnWorkspace(const PHLWORKSPACE& workspace);
void changeGroupToOppositeOnWorkspace(int workspace); void changeGroupToOppositeOnWorkspace(const PHLWORKSPACE& workspace);
void changeGroupEphemeralityOnWorkspace(int workspace, bool ephemeral); void changeGroupEphemeralityOnWorkspace(const PHLWORKSPACE& workspace, bool ephemeral);
void makeGroupOn(Hy3Node*, Hy3GroupLayout, GroupEphemeralityOption); void makeGroupOn(Hy3Node*, Hy3GroupLayout, GroupEphemeralityOption);
void makeOppositeGroupOn(Hy3Node*, GroupEphemeralityOption); void makeOppositeGroupOn(Hy3Node*, GroupEphemeralityOption);
void changeGroupOn(Hy3Node&, Hy3GroupLayout); void changeGroupOn(Hy3Node&, Hy3GroupLayout);
@ -110,20 +111,20 @@ public:
void changeGroupToOppositeOn(Hy3Node&); void changeGroupToOppositeOn(Hy3Node&);
void changeGroupEphemeralityOn(Hy3Node&, bool ephemeral); void changeGroupEphemeralityOn(Hy3Node&, bool ephemeral);
void shiftNode(Hy3Node&, ShiftDirection, bool once, bool visible); void shiftNode(Hy3Node&, ShiftDirection, bool once, bool visible);
void shiftWindow(int workspace, ShiftDirection, bool once, bool visible); void shiftWindow(const PHLWORKSPACE& workspace, ShiftDirection, bool once, bool visible);
void shiftFocus(int workspace, ShiftDirection, bool visible); void shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection, bool visible);
void moveNodeToWorkspace(int origin, std::string wsname, bool follow); void moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow);
void changeFocus(int workspace, FocusShift); void changeFocus(const PHLWORKSPACE& workspace, FocusShift);
void focusTab(int workspace, TabFocus target, TabFocusMousePriority, bool wrap_scroll, int index); void focusTab(const PHLWORKSPACE& workspace, TabFocus target, TabFocusMousePriority, bool wrap_scroll, int index);
void setNodeSwallow(int workspace, SetSwallowOption); void setNodeSwallow(const PHLWORKSPACE& workspace, SetSwallowOption);
void killFocusedNode(int workspace); void killFocusedNode(const PHLWORKSPACE& workspace);
void expand(int workspace, ExpandOption, ExpandFullscreenOption); void expand(const PHLWORKSPACE& workspace, ExpandOption, ExpandFullscreenOption);
bool shouldRenderSelected(CWindow*); bool shouldRenderSelected(CWindow*);
Hy3Node* getWorkspaceRootGroup(const int& workspace); Hy3Node* getWorkspaceRootGroup(const PHLWORKSPACE& workspace);
Hy3Node* getWorkspaceFocusedNode( Hy3Node* getWorkspaceFocusedNode(
const int& workspace, const PHLWORKSPACE& workspace,
bool ignore_group_focus = false, bool ignore_group_focus = false,
bool stop_at_expanded = false bool stop_at_expanded = false
); );
@ -146,7 +147,7 @@ private:
Hy3Node* shiftOrGetFocus(Hy3Node&, ShiftDirection, bool shift, bool once, bool visible); Hy3Node* shiftOrGetFocus(Hy3Node&, ShiftDirection, bool shift, bool once, bool visible);
void updateAutotileWorkspaces(); void updateAutotileWorkspaces();
bool shouldAutotileWorkspace(int); bool shouldAutotileWorkspace(const PHLWORKSPACE& workspace);
void resizeNode(Hy3Node*, Vector2D, ShiftDirection resize_edge_x, ShiftDirection resize_edge_y); void resizeNode(Hy3Node*, Vector2D, ShiftDirection resize_edge_x, ShiftDirection resize_edge_y);
struct { struct {

View file

@ -290,10 +290,9 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
// clang-format on // clang-format on
if (this->data.type == Hy3NodeType::Window && this->data.as_window->m_bIsFullscreen) { if (this->data.type == Hy3NodeType::Window && this->data.as_window->m_bIsFullscreen) {
auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id); auto* monitor = g_pCompositor->getMonitorFromID(this->workspace->m_iMonitorID);
auto* monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID);
if (workspace->m_efFullscreenMode == FULLSCREEN_FULL) { if (this->workspace->m_efFullscreenMode == FULLSCREEN_FULL) {
this->data.as_window->m_vRealPosition = monitor->vecPosition; this->data.as_window->m_vRealPosition = monitor->vecPosition;
this->data.as_window->m_vRealSize = monitor->vecSize; this->data.as_window->m_vRealSize = monitor->vecSize;
return; return;
@ -305,7 +304,7 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
.size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
.gap_topleft_offset = gap_topleft_offset, .gap_topleft_offset = gap_topleft_offset,
.gap_bottomright_offset = gap_bottomright_offset, .gap_bottomright_offset = gap_bottomright_offset,
.workspace_id = this->workspace_id, .workspace = this->workspace,
}; };
this->layout->applyNodeDataToWindow(&fake_node); this->layout->applyNodeDataToWindow(&fake_node);
@ -522,7 +521,7 @@ void Hy3Node::updateTabBar(bool no_animation) {
FindTopWindowInNodeResult result; FindTopWindowInNodeResult result;
findTopWindowInNode(*this, result); findTopWindowInNode(*this, result);
group.tab_bar->target_window = result.window; group.tab_bar->target_window = result.window;
if (result.window != nullptr) group.tab_bar->workspace_id = result.window->m_iWorkspaceID; if (result.window != nullptr) group.tab_bar->workspace = result.window->m_pWorkspace;
} else if (group.tab_bar != nullptr) { } else if (group.tab_bar != nullptr) {
group.tab_bar->bar.beginDestroy(); group.tab_bar->bar.beginDestroy();
group.tab_bar = nullptr; group.tab_bar = nullptr;
@ -771,7 +770,7 @@ Hy3Node* Hy3Node::intoGroup(Hy3GroupLayout layout, GroupEphemeralityOption ephem
this->layout->nodes.push_back({ this->layout->nodes.push_back({
.parent = this, .parent = this,
.data = layout, .data = layout,
.workspace_id = this->workspace_id, .workspace = this->workspace,
.layout = this->layout, .layout = this->layout,
}); });

View file

@ -87,7 +87,7 @@ struct Hy3Node {
Vector2D gap_topleft_offset; Vector2D gap_topleft_offset;
Vector2D gap_bottomright_offset; Vector2D gap_bottomright_offset;
float size_ratio = 1.0; float size_ratio = 1.0;
int workspace_id = -1; PHLWORKSPACE workspace = nullptr;
bool hidden = false; bool hidden = false;
Hy3Layout* layout = nullptr; Hy3Layout* layout = nullptr;

View file

@ -444,12 +444,11 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) {
void Hy3TabGroup::tick() { void Hy3TabGroup::tick() {
static const auto enter_from_top = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:from_top"); static const auto enter_from_top = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:from_top");
static const auto padding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:padding"); static const auto padding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:padding");
auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id);
this->bar.tick(); this->bar.tick();
if (workspace != nullptr) { if (valid(this->workspace)) {
if (workspace->m_bHasFullscreenWindow) { if (this->workspace->m_bHasFullscreenWindow) {
if (this->bar.fade_opacity.goal() != 0.0) this->bar.fade_opacity = 0.0; if (this->bar.fade_opacity.goal() != 0.0) this->bar.fade_opacity = 0.0;
} else { } else {
if (this->bar.fade_opacity.goal() != 1.0) this->bar.fade_opacity = 1.0; if (this->bar.fade_opacity.goal() != 1.0) this->bar.fade_opacity = 1.0;
@ -489,15 +488,14 @@ void Hy3TabGroup::renderTabBar() {
static const auto padding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:padding"); static const auto padding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:padding");
auto* monitor = g_pHyprOpenGL->m_RenderData.pMonitor; auto* monitor = g_pHyprOpenGL->m_RenderData.pMonitor;
auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id);
auto scale = monitor->scale; auto scale = monitor->scale;
auto monitor_size = monitor->vecSize; auto monitor_size = monitor->vecSize;
auto pos = this->pos.value() - monitor->vecPosition; auto pos = this->pos.value() - monitor->vecPosition;
auto size = this->size.value(); auto size = this->size.value();
if (workspace != nullptr) { if (valid(this->workspace)) {
pos = pos + workspace->m_vRenderOffset.value(); pos = pos + this->workspace->m_vRenderOffset.value();
} }
auto scaled_pos = Vector2D(std::round(pos.x * scale), std::round(pos.y * scale)); auto scaled_pos = Vector2D(std::round(pos.x * scale), std::round(pos.y * scale));
@ -563,7 +561,7 @@ void Hy3TabGroup::renderTabBar() {
} }
auto fade_opacity = auto fade_opacity =
this->bar.fade_opacity.value() * (workspace == nullptr ? 1.0 : workspace->m_fAlpha.value()); this->bar.fade_opacity.value() * (valid(this->workspace) ? this->workspace->m_fAlpha.value() : 1.0);
auto render_entry = [&](Hy3TabBarEntry& entry) { auto render_entry = [&](Hy3TabBarEntry& entry) {
Vector2D entry_pos = { Vector2D entry_pos = {

View file

@ -86,7 +86,7 @@ private:
class Hy3TabGroup { class Hy3TabGroup {
public: public:
CWindow* target_window = nullptr; CWindow* target_window = nullptr;
int workspace_id = -1; PHLWORKSPACE workspace = nullptr;
bool hidden = false; bool hidden = false;
Hy3TabBar bar; Hy3TabBar bar;
CAnimatedVariable<Vector2D> pos; CAnimatedVariable<Vector2D> pos;

View file

@ -1,27 +1,26 @@
#include <optional> #include <optional>
#include <hyprland/src/Compositor.hpp> #include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/DesktopTypes.hpp>
#include <hyprland/src/plugins/PluginAPI.hpp> #include <hyprland/src/plugins/PluginAPI.hpp>
#include "dispatchers.hpp" #include "dispatchers.hpp"
#include "globals.hpp" #include "globals.hpp"
int workspace_for_action(bool allow_fullscreen = false) { PHLWORKSPACE workspace_for_action(bool allow_fullscreen = false) {
if (g_pLayoutManager->getCurrentLayout() != g_Hy3Layout.get()) return -1; if (g_pLayoutManager->getCurrentLayout() != g_Hy3Layout.get()) return nullptr;
int workspace_id = g_pCompositor->m_pLastMonitor->activeWorkspace; auto workspace = g_pCompositor->m_pLastMonitor->activeWorkspace;
if (workspace_id == -1) return -1; if (!valid(workspace)) return nullptr;
auto* workspace = g_pCompositor->getWorkspaceByID(workspace_id); if (!allow_fullscreen && workspace->m_bHasFullscreenWindow) return nullptr;
if (workspace == nullptr) return -1;
if (!allow_fullscreen && workspace->m_bHasFullscreenWindow) return -1;
return workspace_id; return workspace;
} }
void dispatch_makegroup(std::string value) { void dispatch_makegroup(std::string value) {
int workspace = workspace_for_action(); auto workspace = workspace_for_action();
if (workspace == -1) return; if (!valid(workspace)) return;
auto args = CVarList(value); auto args = CVarList(value);
@ -44,8 +43,8 @@ void dispatch_makegroup(std::string value) {
} }
void dispatch_changegroup(std::string value) { void dispatch_changegroup(std::string value) {
int workspace = workspace_for_action(); auto workspace = workspace_for_action();
if (workspace == -1) return; if (!valid(workspace)) return;
auto args = CVarList(value); auto args = CVarList(value);
@ -65,8 +64,8 @@ void dispatch_changegroup(std::string value) {
} }
void dispatch_setephemeral(std::string value) { void dispatch_setephemeral(std::string value) {
int workspace = workspace_for_action(); auto workspace = workspace_for_action();
if (workspace == -1) return; if (!valid(workspace)) return;
auto args = CVarList(value); auto args = CVarList(value);
@ -84,8 +83,8 @@ std::optional<ShiftDirection> parseShiftArg(std::string arg) {
} }
void dispatch_movewindow(std::string value) { void dispatch_movewindow(std::string value) {
int workspace = workspace_for_action(); auto workspace = workspace_for_action();
if (workspace == -1) return; if (!valid(workspace)) return;
auto args = CVarList(value); auto args = CVarList(value);
@ -109,8 +108,8 @@ void dispatch_movewindow(std::string value) {
} }
void dispatch_movefocus(std::string value) { void dispatch_movefocus(std::string value) {
int workspace = workspace_for_action(); auto workspace = workspace_for_action();
if (workspace == -1) return; if (!valid(workspace)) return;
auto args = CVarList(value); auto args = CVarList(value);
@ -120,8 +119,8 @@ void dispatch_movefocus(std::string value) {
} }
void dispatch_move_to_workspace(std::string value) { void dispatch_move_to_workspace(std::string value) {
int origin_workspace = workspace_for_action(true); auto origin_workspace = workspace_for_action(true);
if (origin_workspace == -1) return; if (!valid(origin_workspace)) return;
auto args = CVarList(value); auto args = CVarList(value);
@ -134,8 +133,8 @@ void dispatch_move_to_workspace(std::string value) {
} }
void dispatch_changefocus(std::string arg) { void dispatch_changefocus(std::string arg) {
int workspace = workspace_for_action(); auto workspace = workspace_for_action();
if (workspace == -1) return; if (!valid(workspace)) return;
if (arg == "top") g_Hy3Layout->changeFocus(workspace, FocusShift::Top); if (arg == "top") g_Hy3Layout->changeFocus(workspace, FocusShift::Top);
else if (arg == "bottom") g_Hy3Layout->changeFocus(workspace, FocusShift::Bottom); else if (arg == "bottom") g_Hy3Layout->changeFocus(workspace, FocusShift::Bottom);
@ -146,8 +145,8 @@ void dispatch_changefocus(std::string arg) {
} }
void dispatch_focustab(std::string value) { void dispatch_focustab(std::string value) {
int workspace = workspace_for_action(); auto workspace = workspace_for_action();
if (workspace == -1) return; if (!valid(workspace)) return;
auto i = 0; auto i = 0;
auto args = CVarList(value); auto args = CVarList(value);
@ -186,8 +185,8 @@ void dispatch_focustab(std::string value) {
} }
void dispatch_setswallow(std::string arg) { void dispatch_setswallow(std::string arg) {
int workspace = workspace_for_action(); auto workspace = workspace_for_action();
if (workspace == -1) return; if (!valid(workspace)) return;
SetSwallowOption option; SetSwallowOption option;
if (arg == "true") { if (arg == "true") {
@ -202,15 +201,15 @@ void dispatch_setswallow(std::string arg) {
} }
void dispatch_killactive(std::string value) { void dispatch_killactive(std::string value) {
int workspace = workspace_for_action(true); auto workspace = workspace_for_action(true);
if (workspace == -1) return; if (!valid(workspace)) return;
g_Hy3Layout->killFocusedNode(workspace); g_Hy3Layout->killFocusedNode(workspace);
} }
void dispatch_expand(std::string value) { void dispatch_expand(std::string value) {
int workspace = workspace_for_action(); auto workspace = workspace_for_action();
if (workspace == -1) return; if (!valid(workspace)) return;
auto args = CVarList(value); auto args = CVarList(value);
@ -234,11 +233,10 @@ void dispatch_expand(std::string value) {
} }
void dispatch_debug(std::string arg) { void dispatch_debug(std::string arg) {
int workspace = workspace_for_action(); auto workspace = workspace_for_action();
if (workspace == -1) return;
auto* root = g_Hy3Layout->getWorkspaceRootGroup(workspace); auto* root = g_Hy3Layout->getWorkspaceRootGroup(workspace);
if (workspace == -1) { if (!valid(workspace)) {
hy3_log(LOG, "DEBUG NODES: no nodes on workspace"); hy3_log(LOG, "DEBUG NODES: no nodes on workspace");
} else { } else {
hy3_log(LOG, "DEBUG NODES\n{}", root->debugNode().c_str()); hy3_log(LOG, "DEBUG NODES\n{}", root->debugNode().c_str());

View file

@ -2,6 +2,7 @@
#include <type_traits> #include <type_traits>
#include <hyprland/src/desktop/Workspace.hpp>
#include <hyprland/src/plugins/PluginAPI.hpp> #include <hyprland/src/plugins/PluginAPI.hpp>
#include <hyprlang.hpp> #include <hyprlang.hpp>