Skip to content

Commit

Permalink
Add no_gaps_when_only
Browse files Browse the repository at this point in the history
  • Loading branch information
outfoxxed committed May 27, 2023
1 parent 4439352 commit b5df837
Showing 2 changed files with 22 additions and 11 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -31,6 +31,16 @@ In your hyprland config replace the following dispatchers:

You can use `hy3:makegroup` to create a new split.

### Config fields
```conf
plugin {
hy3 {
# disable gaps when only one window is onscreen
no_gaps_when_only = <bool>
}
}
```

### Dispatcher list
- `hy3:makegroup, <h | v | opposite>` - make a vertical or horizontal split
- `hy3:movefocus, <l | u | d | r | left | down | up | right>` - move the focus left, up, down, or right
23 changes: 12 additions & 11 deletions src/Hy3Layout.cpp
Original file line number Diff line number Diff line change
@@ -480,10 +480,10 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) {
const bool display_top = STICKS(node->position.y, monitor->vecPosition.y + monitor->vecReservedTopLeft.y);
const bool display_bottom = STICKS(node->position.y + node->size.y, monitor->vecPosition.y + monitor->vecSize.y - monitor->vecReservedBottomRight.y);

const auto* border_size = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
const auto* gaps_in = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
const auto* gaps_out = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
static auto* const single_window_no_gaps = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:no_gaps_when_only")->intValue;
static const auto* border_size = &HyprlandAPI::getConfigValue(PHANDLE, "general:border_size")->intValue;
static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
static const auto* gaps_out = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_out")->intValue;
static const auto* single_window_no_gaps = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:no_gaps_when_only")->intValue;

if (!g_pCompositor->windowExists(window) || !window->m_bIsMapped) {
Debug::log(ERR, "Node %p holding invalid window %p!!", node, window);
@@ -498,14 +498,15 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) {
auto calcPos = window->m_vPosition + Vector2D(*border_size, *border_size);
auto calcSize = window->m_vSize - Vector2D(2 * *border_size, 2 * *border_size);

const auto workspace_node_count = this->getWorkspaceNodeCount(window->m_iWorkspaceID);
auto root_node = this->getWorkspaceRootGroup(window->m_iWorkspaceID);
auto only_node = root_node->data.as_group.children.size() == 1
&& root_node->data.as_group.children.front()->data.type == Hy3NodeData::Window;

if (*single_window_no_gaps
&& !g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)
&& (workspace_node_count == 1
|| (window->m_bIsFullscreen
&& g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED)))
{
if (!g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)
&& ((*single_window_no_gaps && only_node)
|| (window->m_bIsFullscreen
&& g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_FULL))
) {
window->m_vRealPosition = window->m_vPosition;
window->m_vRealSize = window->m_vSize;

0 comments on commit b5df837

Please sign in to comment.