Skip to content

Commit

Permalink
Fix special workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Rehan committed Aug 21, 2023
1 parent 0cc5af9 commit 1709de2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ plugin {
# offset from group split direction when only one window is in a group
group_inset = <int> # default: 10
# scale factor of windows on the special workspace
special_scale_factor = <float> # default: 0.8
# tab group settings
tabs {
# height of the tab bar
Expand Down
10 changes: 9 additions & 1 deletion src/Hy3Layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) {
);
}

if (monitor == nullptr) {
if (!g_pCompositor->isWorkspaceSpecial(node->workspace_id) && monitor == nullptr) {
Debug::log(ERR, "Orphaned Node %x (workspace ID: %i)!!", node, node->workspace_id);
errorNotif();
return;
Expand Down Expand Up @@ -1426,6 +1426,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;
}

window->m_vRealPosition = calcPos;
window->m_vRealSize = calcSize;
Debug::log(LOG, "Set size (%f %f)", calcSize.x, calcSize.y);
Expand Down
5 changes: 3 additions & 2 deletions src/dispatchers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,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);
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

// tabs
CONF("tabs:height", int, 15);
Expand Down

0 comments on commit 1709de2

Please sign in to comment.