Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix special workspaces #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
17 changes: 14 additions & 3 deletions src/Hy3Layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) {
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();
Expand Down Expand Up @@ -1368,7 +1371,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 +1429,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