From da91c54ef43a6ce26060e564fb9663087425deea Mon Sep 17 00:00:00 2001 From: Kaley Fischer Date: Sat, 2 Dec 2023 12:52:00 +0100 Subject: [PATCH] pull: Added some good pull requests --- README.md | 3 +++ src/Hy3Layout.cpp | 17 ++++++++++++++--- src/dispatchers.cpp | 4 +++- src/main.cpp | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0867132..a789c9b 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,9 @@ plugin { # offset from group split direction when only one window is in a group group_inset = # default: 10 + # scale factor of windows on the special workspace + special_scale_factor = # default: 0.8 + # if a tab group will automatically be created for the first window spawned in a workspace tab_first_window = diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 1406272..45a67b6 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -95,8 +95,11 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) { Hy3Node* opening_into; Hy3Node* opening_after = nullptr; - if (monitor->activeWorkspace != -1) { - auto* root = this->getWorkspaceRootGroup(monitor->activeWorkspace); + int specialWorkspaceID = monitor->specialWorkspaceID; + int workspace_id = specialWorkspaceID ? specialWorkspaceID : monitor->activeWorkspace; + + if (workspace_id != -1) { + auto* root = this->getWorkspaceRootGroup(workspace_id); if (root != nullptr) { opening_after = root->getFocusedNode(); @@ -1390,7 +1393,7 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { ); } - if (monitor == nullptr) { + if (!g_pCompositor->isWorkspaceSpecial(node->workspace_id) && monitor == nullptr) { hy3_log( ERR, "node {:x}'s workspace has no associated monitor, cannot apply node data", @@ -1462,6 +1465,14 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) { calcPos = calcPos + reserved_area.topLeft; calcSize = calcSize - (reserved_area.topLeft - reserved_area.bottomRight); + if (g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)) { + // adjust for special workspaces + static const auto* scalefactor + = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:special_scale_factor")->floatValue; + calcPos = calcPos + (calcSize - calcSize * *scalefactor) / 2.f; + calcSize = calcSize * *scalefactor; + } + CBox wb = {calcPos, calcSize}; wb.round(); diff --git a/src/dispatchers.cpp b/src/dispatchers.cpp index f4d663c..046631d 100644 --- a/src/dispatchers.cpp +++ b/src/dispatchers.cpp @@ -9,7 +9,9 @@ int workspace_for_action() { if (g_pLayoutManager->getCurrentLayout() != g_Hy3Layout.get()) return -1; - int workspace_id = g_pCompositor->m_pLastMonitor->activeWorkspace; + int specialWorkspaceID = g_pCompositor->m_pLastMonitor->specialWorkspaceID; + int workspace_id + = specialWorkspaceID ? specialWorkspaceID : g_pCompositor->m_pLastMonitor->activeWorkspace; if (workspace_id == -1) return -1; auto* workspace = g_pCompositor->getWorkspaceByID(workspace_id); diff --git a/src/main.cpp b/src/main.cpp index f4e9c9e..cbfb8ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { CONF("no_gaps_when_only", int, 0); CONF("node_collapse_policy", int, 2); CONF("group_inset", int, 10); + CONF("special_scale_factor", float, 0.8); CONF("tab_first_window", int, 0); // tabs