diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..89917c2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,72 @@ +--- +AlignArrayOfStructures: None +AlignAfterOpenBracket: BlockIndent +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: AllIfsAndElse +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +BinPackArguments: false +BinPackParameters: false +Cpp11BracedListStyle: true +LambdaBodyIndentation: Signature +UseCRLF: false +UseTab: ForIndentation +SpacesInSquareBrackets: false +SpacesInParentheses: false +SpacesInCStyleCastParentheses: false +SpacesInAngles: Never +SpaceInEmptyParentheses: false +SpaceInEmptyBlock: false +SpaceBeforeSquareBrackets: false +SpaceBeforeRangeBasedForLoopColon: false +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: false +SpaceBeforeInheritanceColon: false +SpaceBeforeParens: ControlStatementsExceptControlMacros +SortIncludes: CaseInsensitive +PointerAlignment: Left +PackConstructorInitializers: CurrentLine +LineEnding: LF +InsertBraces: false +BreakConstructorInitializers: AfterColon +BreakBeforeBraces: Custom +BreakInheritanceList: AfterColon +AllowAllParametersOfDeclarationOnNextLine: false +AllowAllArgumentsOnNextLine: false +AlwaysBreakTemplateDeclarations: Yes +BraceWrapping: + AfterClass: false + AfterFunction: false + AfterCaseLabel: false + AfterEnum: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: false + SplitEmptyNamespace: false + AfterControlStatement: MultiLine +BreakBeforeBinaryOperators: All +BreakBeforeTernaryOperators: true +AlignOperands: AlignAfterOperator +InsertTrailingCommas: Wrapped +MaxEmptyLinesToKeep: 1 +ExperimentalAutoDetectBinPacking: false +ColumnLimit: 100 +IndentWidth: 2 +TabWidth: 2 +AllowAllConstructorInitializersOnNextLine: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0b09ad2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = tab + +[*.nix] +indent_style = space +indent_size = 2 \ No newline at end of file diff --git a/flake.nix b/flake.nix index f0b4a93..6cfab11 100644 --- a/flake.nix +++ b/flake.nix @@ -42,7 +42,7 @@ name = "hy3"; nativeBuildInputs = with pkgs; [ - clang-tools_15 + clang-tools_16 bear ]; diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 780e0a7..f3704b0 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -1,5 +1,5 @@ -#include "globals.hpp" #include "Hy3Layout.hpp" +#include "globals.hpp" #include "SelectionHook.hpp" #include @@ -8,12 +8,15 @@ #include void errorNotif() { - HyprlandAPI::addNotificationV2(PHANDLE, { - {"text", "Something has gone very wrong. Check the log for details."}, - {"time", (uint64_t)10000}, - {"color", CColor(1.0, 0.0, 0.0, 1.0)}, - {"icon", ICON_ERROR}, - }); + HyprlandAPI::addNotificationV2( + PHANDLE, + { + {"text", "Something has gone very wrong. Check the log for details."}, + {"time", (uint64_t) 10000}, + {"color", CColor(1.0, 0.0, 0.0, 1.0)}, + {"icon", ICON_ERROR}, + } + ); } Hy3GroupData::Hy3GroupData(Hy3GroupLayout layout): layout(layout) {} @@ -32,22 +35,19 @@ Hy3GroupData::~Hy3GroupData() { if (this->tab_bar != nullptr) this->tab_bar->bar.beginDestroy(); } -Hy3NodeData::Hy3NodeData(): Hy3NodeData((CWindow*)nullptr) {} +Hy3NodeData::Hy3NodeData(): Hy3NodeData((CWindow*) nullptr) {} -Hy3NodeData::Hy3NodeData(CWindow *window): type(Hy3NodeData::Window) { - this->as_window = window; -} +Hy3NodeData::Hy3NodeData(CWindow* window): type(Hy3NodeData::Window) { this->as_window = window; } Hy3NodeData::Hy3NodeData(Hy3GroupData group): type(Hy3NodeData::Group) { - new(&this->as_group) Hy3GroupData(std::move(group)); + new (&this->as_group) Hy3GroupData(std::move(group)); } Hy3NodeData::Hy3NodeData(Hy3GroupLayout layout): Hy3NodeData(Hy3GroupData(layout)) {} Hy3NodeData::~Hy3NodeData() { switch (this->type) { - case Hy3NodeData::Window: - break; + case Hy3NodeData::Window: break; case Hy3NodeData::Group: this->as_group.~Hy3GroupData(); @@ -58,19 +58,27 @@ Hy3NodeData::~Hy3NodeData() { } Hy3NodeData::Hy3NodeData(Hy3NodeData&& from): type(from.type) { - Debug::log(LOG, "Move CTor type matches? %d is group? %d", this->type == from.type, this->type == Hy3NodeData::Group); + Debug::log( + LOG, + "Move CTor type matches? %d is group? %d", + this->type == from.type, + this->type == Hy3NodeData::Group + ); + switch (from.type) { - case Hy3NodeData::Window: - this->as_window = from.as_window; - break; - case Hy3NodeData::Group: - new(&this->as_group) Hy3GroupData(std::move(from.as_group)); - break; + case Hy3NodeData::Window: this->as_window = from.as_window; break; + case Hy3NodeData::Group: new (&this->as_group) Hy3GroupData(std::move(from.as_group)); break; } } Hy3NodeData& Hy3NodeData::operator=(Hy3NodeData&& from) { - Debug::log(LOG, "operator= type matches? %d is group? %d", this->type == from.type, this->type == Hy3NodeData::Group); + Debug::log( + LOG, + "operator= type matches? %d is group? %d", + this->type == from.type, + this->type == Hy3NodeData::Group + ); + if (this->type == Hy3NodeData::Group) { this->as_group.~Hy3GroupData(); } @@ -78,12 +86,8 @@ Hy3NodeData& Hy3NodeData::operator=(Hy3NodeData&& from) { this->type = from.type; switch (this->type) { - case Hy3NodeData::Window: - this->as_window = from.as_window; - break; - case Hy3NodeData::Group: - new(&this->as_group) Hy3GroupData(std::move(from.as_group)); - break; + case Hy3NodeData::Window: this->as_window = from.as_window; break; + case Hy3NodeData::Group: new (&this->as_group) Hy3GroupData(std::move(from.as_group)); break; } return *this; @@ -101,18 +105,18 @@ Hy3NodeData& Hy3NodeData::operator=(Hy3GroupLayout layout) { return *this; } -bool Hy3NodeData::operator==(const Hy3NodeData& rhs) const { - return this == &rhs; -} +bool Hy3NodeData::operator==(const Hy3NodeData& rhs) const { return this == &rhs; } -bool Hy3Node::operator==(const Hy3Node& rhs) const { - return this->data == rhs.data; -} +bool Hy3Node::operator==(const Hy3Node& rhs) const { return this->data == rhs.data; } void Hy3Node::recalcSizePosRecursive(bool force) { + // clang-format off 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* group_inset = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:group_inset")->intValue; + static const auto* tab_bar_height = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:height")->intValue; + static const auto* tab_bar_padding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:padding")->intValue; + // clang-format on int outer_gaps = 0; Vector2D gap_pos_offset; @@ -130,8 +134,6 @@ void Hy3Node::recalcSizePosRecursive(bool force) { auto tpos = this->position; auto tsize = this->size; - static const auto* tab_bar_height = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:height")->intValue; - static const auto* tab_bar_padding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:padding")->intValue; double tab_height_offset = *tab_bar_height + *tab_bar_padding; if (this->data.type != Hy3NodeData::Group) { @@ -183,24 +185,22 @@ void Hy3Node::recalcSizePosRecursive(bool force) { int constraint; switch (group->layout) { - case Hy3GroupLayout::SplitH: - constraint = tsize.x; - break; - case Hy3GroupLayout::SplitV: - constraint = tsize.y; - break; - case Hy3GroupLayout::Tabbed: - break; + case Hy3GroupLayout::SplitH: constraint = tsize.x; break; + case Hy3GroupLayout::SplitV: constraint = tsize.y; break; + case Hy3GroupLayout::Tabbed: break; } - double ratio_mul = group->layout != Hy3GroupLayout::Tabbed ? group->children.empty() ? 0 : constraint / group->children.size() : 0; + double ratio_mul = group->layout != Hy3GroupLayout::Tabbed + ? group->children.empty() ? 0 : constraint / group->children.size() + : 0; + double offset = 0; if (group->layout == Hy3GroupLayout::Tabbed && group->focused_child != nullptr) { group->focused_child->setHidden(false); } - for(auto* child: group->children) { + for (auto* child: group->children) { switch (group->layout) { case Hy3GroupLayout::SplitH: child->position.x = tpos.x + offset; @@ -229,11 +229,11 @@ void Hy3Node::recalcSizePosRecursive(bool force) { child->setHidden(hidden); child->recalcSizePosRecursive(force); break; - } + } child->gap_pos_offset = gap_pos_offset; child->gap_size_offset = gap_pos_offset; - } + } this->updateTabBar(); } @@ -250,8 +250,7 @@ void Hy3Node::setHidden(bool hidden) { bool Hy3Node::isUrgent() { switch (this->data.type) { - case Hy3NodeData::Window: - return this->data.as_window->m_bIsUrgent; + case Hy3NodeData::Window: return this->data.as_window->m_bIsUrgent; case Hy3NodeData::Group: for (auto* child: this->data.as_group.children) { if (child->isUrgent()) return true; @@ -274,21 +273,14 @@ bool Hy3Node::isIndirectlyFocused() { std::string Hy3Node::getTitle() { switch (this->data.type) { - case Hy3NodeData::Window: - return this->data.as_window->m_szTitle; + case Hy3NodeData::Window: return this->data.as_window->m_szTitle; case Hy3NodeData::Group: std::string title; switch (this->data.as_group.layout) { - case Hy3GroupLayout::SplitH: - title = "[H] "; - break; - case Hy3GroupLayout::SplitV: - title = "[V] "; - break; - case Hy3GroupLayout::Tabbed: - title = "[T] "; - break; + case Hy3GroupLayout::SplitH: title = "[H] "; break; + case Hy3GroupLayout::SplitV: title = "[V] "; break; + case Hy3GroupLayout::Tabbed: title = "[T] "; break; } if (this->data.as_group.focused_child == nullptr) { @@ -327,6 +319,7 @@ void Hy3Node::markFocused() { node->parent->updateTabBar(); node = node->parent; } + while (node2->parent != nullptr) { node2->parent->data.as_group.focused_child = node2; node2->parent->data.as_group.group_focused = false; @@ -336,6 +329,7 @@ void Hy3Node::markFocused() { if (oldfocus != nullptr) { oldfocus->updateDecos(); + while (oldfocus != nullptr) { oldfocus->updateTabBar(); oldfocus = oldfocus->parent; @@ -361,7 +355,7 @@ void Hy3Node::focus() { bool Hy3Node::focusWindow() { switch (this->data.type) { case Hy3NodeData::Window: - this->markFocused(); + this->markFocused(); g_pCompositor->focusWindow(this->data.as_window); return true; @@ -382,9 +376,7 @@ bool Hy3Node::focusWindow() { void Hy3Node::raiseToTop() { switch (this->data.type) { - case Hy3NodeData::Window: - g_pCompositor->moveWindowToTop(this->data.as_window); - break; + case Hy3NodeData::Window: g_pCompositor->moveWindowToTop(this->data.as_window); break; case Hy3NodeData::Group: for (auto* child: this->data.as_group.children) { child->raiseToTop(); @@ -395,8 +387,7 @@ void Hy3Node::raiseToTop() { Hy3Node* Hy3Node::getFocusedNode() { switch (this->data.type) { - case Hy3NodeData::Window: - return this; + case Hy3NodeData::Window: return this; case Hy3NodeData::Group: if (this->data.as_group.focused_child == nullptr || this->data.as_group.group_focused) { return this; @@ -407,14 +398,14 @@ Hy3Node* Hy3Node::getFocusedNode() { } bool Hy3Node::swallowGroups(Hy3Node* into) { - if (into == nullptr - || into->data.type != Hy3NodeData::Group - || into->data.as_group.children.size() != 1) + if (into == nullptr || into->data.type != Hy3NodeData::Group + || into->data.as_group.children.size() != 1) return false; auto* child = into->data.as_group.children.front(); - // a lot of segfaulting happens once the assumption that the root node is a group is wrong. + // a lot of segfaulting happens once the assumption that the root node is a + // group is wrong. if (into->parent == nullptr && child->data.type != Hy3NodeData::Group) return false; Debug::log(LOG, "Swallowing %p into %p", child, into); @@ -458,7 +449,14 @@ Hy3Node* Hy3Node::removeFromParentRecursive() { } if (!group.children.remove(child)) { - Debug::log(ERR, "Was unable to remove child node %p from parent %p. Child likely has a false parent pointer.", child, parent); + Debug::log( + ERR, + "Was unable to remove child node %p from parent %p. Child likely has " + "a false parent pointer.", + child, + parent + ); + errorNotif(); return nullptr; } @@ -496,10 +494,10 @@ Hy3Node* Hy3Node::removeFromParentRecursive() { Hy3Node* Hy3Node::intoGroup(Hy3GroupLayout layout) { this->layout->nodes.push_back({ - .parent = this, - .data = layout, - .workspace_id = this->workspace_id, - .layout = this->layout, + .parent = this, + .data = layout, + .workspace_id = this->workspace_id, + .layout = this->layout, }); auto* node = &this->layout->nodes.back(); @@ -552,7 +550,7 @@ struct FindTopWindowInNodeResult { }; void findTopWindowInNode(Hy3Node& node, FindTopWindowInNodeResult& result) { - switch(node.data.type) { + switch (node.data.type) { case Hy3NodeData::Window: { auto* window = node.data.as_window; auto& windows = g_pCompositor->m_vWindows; @@ -614,7 +612,7 @@ void Hy3Node::updateDecos() { g_pCompositor->updateWindowAnimatedDecorationValues(this->data.as_window); break; case Hy3NodeData::Group: - for (auto* child: this->data.as_group.children) { + for (auto* child: this->data.as_group.children) { child->updateDecos(); } } @@ -670,7 +668,9 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) { } } } else { - monitor = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(node->workspace_id)->m_iMonitorID); + monitor = g_pCompositor->getMonitorFromID( + g_pCompositor->getWorkspaceByID(node->workspace_id)->m_iMonitorID + ); } if (monitor == nullptr) { @@ -679,10 +679,11 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) { return; } - 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; + // clang-format off + 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* single_window_no_gaps = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:no_gaps_when_only")->intValue; + // clang-format on if (!g_pCompositor->windowExists(window) || !window->m_bIsMapped) { Debug::log(ERR, "Node %p holding invalid window %p!!", node, window); @@ -699,13 +700,14 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) { 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; + && root_node->data.as_group.children.front()->data.type == Hy3NodeData::Window; 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)) - ) { + && ((*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; @@ -753,7 +755,13 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) { auto* existing = this->getNodeFromWindow(window); if (existing != nullptr) { - Debug::log(WARN, "Attempted to add a window(%p) that is already tiled(as %p) to the layout", window, existing); + Debug::log( + WARN, + "Attempted to add a window(%p) that is already tiled(as %p) to the " + "layout", + window, + existing + ); return; } @@ -762,15 +770,16 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) { Hy3Node* opening_into; Hy3Node* opening_after; - if (g_pCompositor->m_pLastWindow != nullptr - && !g_pCompositor->m_pLastWindow->m_bIsFloating - && g_pCompositor->m_pLastWindow != window - && g_pCompositor->m_pLastWindow->m_iWorkspaceID == window->m_iWorkspaceID - && g_pCompositor->m_pLastWindow->m_bIsMapped) + if (g_pCompositor->m_pLastWindow != nullptr && !g_pCompositor->m_pLastWindow->m_bIsFloating + && g_pCompositor->m_pLastWindow != window + && g_pCompositor->m_pLastWindow->m_iWorkspaceID == window->m_iWorkspaceID + && g_pCompositor->m_pLastWindow->m_bIsMapped) { opening_after = this->getNodeFromWindow(g_pCompositor->m_pLastWindow); } else { - opening_after = this->getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal())); + opening_after = this->getNodeFromWindow( + g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()) + ); } if (opening_after != nullptr && opening_after->workspace_id != window->m_iWorkspaceID) { @@ -782,11 +791,11 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) { } else { if ((opening_into = this->getWorkspaceRootGroup(window->m_iWorkspaceID)) == nullptr) { this->nodes.push_back({ - .data = Hy3GroupLayout::SplitH, - .position = monitor->vecPosition + monitor->vecReservedTopLeft, - .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, - .workspace_id = window->m_iWorkspaceID, - .layout = this, + .data = Hy3GroupLayout::SplitH, + .position = monitor->vecPosition + monitor->vecReservedTopLeft, + .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, + .workspace_id = window->m_iWorkspaceID, + .layout = this, }); opening_into = &this->nodes.back(); @@ -800,14 +809,21 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) { } if (opening_into->workspace_id != window->m_iWorkspaceID) { - Debug::log(WARN, "opening_into node %p has workspace %d which does not match the opening window (workspace %d)", opening_into, opening_into->workspace_id, window->m_iWorkspaceID); + Debug::log( + WARN, + "opening_into node %p has workspace %d which does not match the " + "opening window (workspace %d)", + opening_into, + opening_into->workspace_id, + window->m_iWorkspaceID + ); } this->nodes.push_back({ - .parent = opening_into, - .data = window, - .workspace_id = window->m_iWorkspaceID, - .layout = this, + .parent = opening_into, + .data = window, + .workspace_id = window->m_iWorkspaceID, + .layout = this, }); auto& node = this->nodes.back(); @@ -820,11 +836,25 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) { auto iter2 = std::next(iter); children.insert(iter2, &node); } - Debug::log(LOG, "opened new window %p(node: %p) on window %p in %p", window, &node, opening_after, opening_into); + + Debug::log( + LOG, + "opened new window %p(node: %p) on window %p in %p", + window, + &node, + opening_after, + opening_into + ); node.markFocused(); opening_into->recalcSizePosRecursive(); - Debug::log(LOG, "opening_into (%p) contains new child (%p)? %d", opening_into, &node, opening_into->data.as_group.hasChild(&node)); + Debug::log( + LOG, + "opening_into (%p) contains new child (%p)? %d", + opening_into, + &node, + opening_into->data.as_group.hasChild(&node) + ); } void Hy3Layout::onWindowRemovedTiling(CWindow* window) { @@ -851,7 +881,7 @@ void Hy3Layout::onWindowRemovedTiling(CWindow* window) { parent->recalcSizePosRecursive(); if (parent->data.as_group.children.size() == 1 - && parent->data.as_group.children.front()->data.type == Hy3NodeData::Group) + && parent->data.as_group.children.front()->data.type == Hy3NodeData::Group) { auto* target_parent = parent; while (target_parent != nullptr && Hy3Node::swallowGroups(target_parent)) { @@ -862,7 +892,6 @@ void Hy3Layout::onWindowRemovedTiling(CWindow* window) { target_parent->recalcSizePosRecursive(); } } - } CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) { @@ -870,10 +899,8 @@ CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) { if (node == nullptr) return nullptr; switch (node->data.type) { - case Hy3NodeData::Window: - return node->data.as_window; - case Hy3NodeData::Group: - return nullptr; + case Hy3NodeData::Window: return node->data.as_window; + case Hy3NodeData::Group: return nullptr; } } @@ -906,7 +933,8 @@ void Hy3Layout::recalculateMonitor(const int& monitor_id) { if (top_node != nullptr) { top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft; - top_node->size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight; + top_node->size + = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight; top_node->recalcSizePosRecursive(); } } @@ -921,10 +949,10 @@ void Hy3Layout::recalculateMonitor(const int& monitor_id) { // Vaxry's hack from below, but again Hy3Node fakeNode = { - .data = window, - .position = monitor->vecPosition + monitor->vecReservedTopLeft, - .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, - .workspace_id = window->m_iWorkspaceID, + .data = window, + .position = monitor->vecPosition + monitor->vecReservedTopLeft, + .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, + .workspace_id = window->m_iWorkspaceID, }; this->applyNodeDataToWindow(&fakeNode); @@ -934,7 +962,8 @@ void Hy3Layout::recalculateMonitor(const int& monitor_id) { if (top_node != nullptr) { top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft; - top_node->size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight; + top_node->size + = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight; top_node->recalcSizePosRecursive(); } } @@ -964,29 +993,43 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { auto mouse_offset = mouse - window->m_vPosition; this->drag_flags = { - .started = true, - .xExtent = mouse_offset.x > window->m_vSize.x / 2, - .yExtent = mouse_offset.y > window->m_vSize.y / 2, + .started = true, + .xExtent = mouse_offset.x > window->m_vSize.x / 2, + .yExtent = mouse_offset.y > window->m_vSize.y / 2, }; - Debug::log(LOG, "Positive offsets - x: %d, y: %d", this->drag_flags.xExtent, this->drag_flags.yExtent); + Debug::log( + LOG, + "Positive offsets - x: %d, y: %d", + this->drag_flags.xExtent, + this->drag_flags.yExtent + ); } else { this->drag_flags = { - .started = false, - .xExtent = delta.x > 0, - .yExtent = delta.y > 0, + .started = false, + .xExtent = delta.x > 0, + .yExtent = delta.y > 0, }; } } - const auto animate = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue; + const auto animate + = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue; auto monitor = g_pCompositor->getMonitorFromID(window->m_iMonitorID); - const bool display_left = STICKS(node->position.x, monitor->vecPosition.x + monitor->vecReservedTopLeft.x); - const bool display_right = STICKS(node->position.x + node->size.x, monitor->vecPosition.x + monitor->vecSize.x - monitor->vecReservedBottomRight.x); - 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 bool display_left + = STICKS(node->position.x, monitor->vecPosition.x + monitor->vecReservedTopLeft.x); + const bool display_right = STICKS( + node->position.x + node->size.x, + monitor->vecPosition.x + monitor->vecSize.x - monitor->vecReservedBottomRight.x + ); + 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 + ); Vector2D allowed_movement = delta; if (display_left && display_right) allowed_movement.x = 0; @@ -994,7 +1037,8 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { auto* inner_node = node; - // break into parent groups when encountering a corner we're dragging in or a tab group + // break into parent groups when encountering a corner we're dragging in or a + // tab group while (inner_node->parent != nullptr) { auto& group = inner_node->parent->data.as_group; @@ -1004,13 +1048,15 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { goto cont; case Hy3GroupLayout::SplitH: if ((this->drag_flags.xExtent && group.children.back() == inner_node) - || (!this->drag_flags.xExtent && group.children.front() == inner_node)) { + || (!this->drag_flags.xExtent && group.children.front() == inner_node)) + { goto cont; } break; case Hy3GroupLayout::SplitV: if ((this->drag_flags.yExtent && group.children.back() == inner_node) - || (!this->drag_flags.yExtent && group.children.front() == inner_node)) { + || (!this->drag_flags.yExtent && group.children.front() == inner_node)) + { goto cont; } break; @@ -1026,8 +1072,8 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { auto* outer_node = inner_node; - // break into parent groups when encountering a corner we're dragging in, a tab group, - // or a layout matching the inner_parent. + // break into parent groups when encountering a corner we're dragging in, a + // tab group, or a layout matching the inner_parent. while (outer_node->parent != nullptr) { auto& group = outer_node->parent->data.as_group; @@ -1040,13 +1086,15 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { goto cont2; case Hy3GroupLayout::SplitH: if ((this->drag_flags.xExtent && group.children.back() == outer_node) - || (!this->drag_flags.xExtent && group.children.front() == outer_node)) { + || (!this->drag_flags.xExtent && group.children.front() == outer_node)) + { goto cont2; } break; case Hy3GroupLayout::SplitV: if ((this->drag_flags.yExtent && group.children.back() == outer_node) - || (!this->drag_flags.yExtent && group.children.front() == outer_node)) { + || (!this->drag_flags.yExtent && group.children.front() == outer_node)) + { goto cont2; } break; @@ -1063,7 +1111,8 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { // adjust the inner node switch (inner_group.layout) { case Hy3GroupLayout::SplitH: { - auto ratio_mod = allowed_movement.x * (float) inner_group.children.size() / inner_parent->size.x; + auto ratio_mod + = allowed_movement.x * (float) inner_group.children.size() / inner_parent->size.x; auto iter = std::find(inner_group.children.begin(), inner_group.children.end(), inner_node); @@ -1082,7 +1131,8 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { neighbor->size_ratio -= ratio_mod; } break; case Hy3GroupLayout::SplitV: { - auto ratio_mod = allowed_movement.y * (float) inner_parent->data.as_group.children.size() / inner_parent->size.y; + auto ratio_mod = allowed_movement.y * (float) inner_parent->data.as_group.children.size() + / inner_parent->size.y; auto iter = std::find(inner_group.children.begin(), inner_group.children.end(), inner_node); @@ -1100,8 +1150,7 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { inner_node->size_ratio += ratio_mod; neighbor->size_ratio -= ratio_mod; } break; - case Hy3GroupLayout::Tabbed: - break; + case Hy3GroupLayout::Tabbed: break; } inner_parent->recalcSizePosRecursive(*animate == 0); @@ -1112,7 +1161,8 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { // adjust the outer node switch (outer_group.layout) { case Hy3GroupLayout::SplitH: { - auto ratio_mod = allowed_movement.x * (float) outer_group.children.size() / outer_parent->size.x; + auto ratio_mod + = allowed_movement.x * (float) outer_group.children.size() / outer_parent->size.x; auto iter = std::find(outer_group.children.begin(), outer_group.children.end(), outer_node); @@ -1131,7 +1181,8 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { neighbor->size_ratio -= ratio_mod; } break; case Hy3GroupLayout::SplitV: { - auto ratio_mod = allowed_movement.y * (float) outer_parent->data.as_group.children.size() / outer_parent->size.y; + auto ratio_mod = allowed_movement.y * (float) outer_parent->data.as_group.children.size() + / outer_parent->size.y; auto iter = std::find(outer_group.children.begin(), outer_group.children.end(), outer_node); @@ -1149,17 +1200,21 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { outer_node->size_ratio += ratio_mod; neighbor->size_ratio -= ratio_mod; } break; - case Hy3GroupLayout::Tabbed: - break; + case Hy3GroupLayout::Tabbed: break; } outer_parent->recalcSizePosRecursive(*animate == 0); } } -void Hy3Layout::fullscreenRequestForWindow(CWindow* window, eFullscreenMode fullscreen_mode, bool on) { +void Hy3Layout::fullscreenRequestForWindow( + CWindow* window, + eFullscreenMode fullscreen_mode, + bool on +) { if (!g_pCompositor->windowValidMapped(window)) return; - if (on == window->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)) return; + if (on == window->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)) + return; const auto monitor = g_pCompositor->getMonitorFromID(window->m_iMonitorID); const auto workspace = g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID); @@ -1203,10 +1258,10 @@ void Hy3Layout::fullscreenRequestForWindow(CWindow* window, eFullscreenMode full // Copy of vaxry's massive hack Hy3Node fakeNode = { - .data = window, - .position = monitor->vecPosition + monitor->vecReservedTopLeft, - .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, - .workspace_id = window->m_iWorkspaceID, + .data = window, + .position = monitor->vecPosition + monitor->vecReservedTopLeft, + .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight, + .workspace_id = window->m_iWorkspaceID, }; this->applyNodeDataToWindow(&fakeNode); @@ -1227,15 +1282,14 @@ std::any Hy3Layout::layoutMessage(SLayoutMessageHeader header, std::string conte switch (layout) { case Hy3GroupLayout::SplitH: - layout = Hy3GroupLayout::SplitV; + layout = Hy3GroupLayout::SplitV; node->parent->recalcSizePosRecursive(); break; case Hy3GroupLayout::SplitV: layout = Hy3GroupLayout::SplitH; node->parent->recalcSizePosRecursive(); break; - case Hy3GroupLayout::Tabbed: - break; + case Hy3GroupLayout::Tabbed: break; } } } @@ -1243,9 +1297,7 @@ std::any Hy3Layout::layoutMessage(SLayoutMessageHeader header, std::string conte return ""; } -SWindowRenderLayoutHints Hy3Layout::requestRenderHints(CWindow* window) { - return {}; -} +SWindowRenderLayoutHints Hy3Layout::requestRenderHints(CWindow* window) { return {}; } void Hy3Layout::switchWindows(CWindow* pWindowA, CWindow* pWindowB) { // todo @@ -1255,9 +1307,7 @@ void Hy3Layout::alterSplitRatio(CWindow* pWindow, float delta, bool exact) { // todo } -std::string Hy3Layout::getLayoutName() { - return "hy3"; -} +std::string Hy3Layout::getLayoutName() { return "hy3"; } void Hy3Layout::replaceWindowDataWith(CWindow* from, CWindow* to) { auto* node = this->getNodeFromWindow(from); @@ -1267,16 +1317,16 @@ void Hy3Layout::replaceWindowDataWith(CWindow* from, CWindow* to) { this->applyNodeDataToWindow(node); } -std::unique_ptr renderHookPtr = std::make_unique(Hy3Layout::renderHook); -std::unique_ptr windowTitleHookPtr = std::make_unique(Hy3Layout::windowTitleHook); -std::unique_ptr tickHookPtr = std::make_unique(Hy3Layout::tickHook); +std::unique_ptr renderHookPtr + = std::make_unique(Hy3Layout::renderHook); +std::unique_ptr windowTitleHookPtr + = std::make_unique(Hy3Layout::windowTitleHook); +std::unique_ptr tickHookPtr + = std::make_unique(Hy3Layout::tickHook); void Hy3Layout::onEnable() { - for (auto &window : g_pCompositor->m_vWindows) { - if (window->isHidden() - || !window->m_bIsMapped - || window->m_bFadingOut - || window->m_bIsFloating) + for (auto& window: g_pCompositor->m_vWindows) { + if (window->isHidden() || !window->m_bIsMapped || window->m_bFadingOut || window->m_bIsFloating) continue; this->onWindowCreatedTiling(window.get()); @@ -1328,9 +1378,8 @@ void Hy3Layout::makeOppositeGroupOn(Hy3Node* node) { node->intoGroup(Hy3GroupLayout::SplitH); } else { auto& group = node->parent->data.as_group; - auto layout = group.layout == Hy3GroupLayout::SplitH - ? Hy3GroupLayout::SplitV - : Hy3GroupLayout::SplitH; + auto layout + = group.layout == Hy3GroupLayout::SplitH ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH; if (group.children.size() == 1) { group.layout = layout; @@ -1359,7 +1408,6 @@ void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction, bool once) Debug::log(LOG, "ShiftWindow %p %d", node, direction); if (node == nullptr) return; - this->shiftOrGetFocus(*node, direction, true, once); } @@ -1373,16 +1421,18 @@ bool shiftIsVertical(ShiftDirection direction) { bool shiftMatchesLayout(Hy3GroupLayout layout, ShiftDirection direction) { return (layout == Hy3GroupLayout::SplitV && shiftIsVertical(direction)) - || (layout != Hy3GroupLayout::SplitV && !shiftIsVertical(direction)); + || (layout != Hy3GroupLayout::SplitV && !shiftIsVertical(direction)); } -Hy3Node* Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, bool shift, bool once) { +Hy3Node* +Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, bool shift, bool once) { auto* break_origin = &node; auto* break_parent = break_origin->parent; auto has_broken_once = false; - // break parents until we hit a container oriented the same way as the shift direction + // break parents until we hit a container oriented the same way as the shift + // direction while (true) { if (break_parent == nullptr) return nullptr; @@ -1394,11 +1444,13 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, boo if (once && shift && has_broken_once) break; if (break_origin != &node) has_broken_once = true; - // if this movement would break out of the group, continue the break loop (do not enter this if) - // otherwise break. + // if this movement would break out of the group, continue the break loop + // (do not enter this if) otherwise break. if ((has_broken_once && once && shift) - || !((!shiftIsForward(direction) && group.children.front() == break_origin) - || (shiftIsForward(direction) && group.children.back() == break_origin))) + || !( + (!shiftIsForward(direction) && group.children.front() == break_origin) + || (shiftIsForward(direction) && group.children.back() == break_origin) + )) break; } @@ -1407,22 +1459,22 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, boo // if we haven't gone up any levels and the group is in the same direction // there's no reason to wrap the root group. - if (group.layout != Hy3GroupLayout::Tabbed && shiftMatchesLayout(group.layout, direction)) break; + if (group.layout != Hy3GroupLayout::Tabbed && shiftMatchesLayout(group.layout, direction)) + break; - if (group.layout != Hy3GroupLayout::Tabbed - && group.children.size() == 2 - && std::find(group.children.begin(), group.children.end(), &node) != group.children.end() - ) { + if (group.layout != Hy3GroupLayout::Tabbed && group.children.size() == 2 + && std::find(group.children.begin(), group.children.end(), &node) != group.children.end()) + { group.layout = shiftIsVertical(direction) ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH; } else { // wrap the root group in another group this->nodes.push_back({ - .parent = break_parent, - .data = shiftIsVertical(direction) ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH, - .position = break_parent->position, - .size = break_parent->size, - .workspace_id = break_parent->workspace_id, - .layout = this, + .parent = break_parent, + .data = shiftIsVertical(direction) ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH, + .position = break_parent->position, + .size = break_parent->size, + .workspace_id = break_parent->workspace_id, + .layout = this, }); auto* newChild = &this->nodes.back(); @@ -1477,11 +1529,17 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, boo bool shift_after = false; - if (!shift && group_data.layout == Hy3GroupLayout::Tabbed && group_data.focused_child != nullptr) { - iter = std::find(group_data.children.begin(), group_data.children.end(), group_data.focused_child); + if (!shift && group_data.layout == Hy3GroupLayout::Tabbed + && group_data.focused_child != nullptr) + { + iter = std::find( + group_data.children.begin(), + group_data.children.end(), + group_data.focused_child + ); } else if (shiftMatchesLayout(group_data.layout, direction)) { - // if the group has the same orientation as movement pick the last/first child based - // on movement direction + // if the group has the same orientation as movement pick the + // last/first child based on movement direction if (shiftIsForward(direction)) iter = group_data.children.begin(); else { iter = std::prev(group_data.children.end()); @@ -1489,7 +1547,11 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, boo } } else { if (group_data.focused_child != nullptr) { - iter = std::find(group_data.children.begin(), group_data.children.end(), group_data.focused_child); + iter = std::find( + group_data.children.begin(), + group_data.children.end(), + group_data.focused_child + ); shift_after = true; } else { iter = group_data.children.begin(); @@ -1518,7 +1580,8 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, boo auto& group_data = target_group->data.as_group; if (target_group == node.parent) { - // nullptr is used as a signal value instead of removing it first to avoid iterator invalidation. + // nullptr is used as a signal value instead of removing it first to avoid + // iterator invalidation. auto iter = std::find(group_data.children.begin(), group_data.children.end(), &node); *iter = nullptr; target_group->data.as_group.children.insert(insert, &node); @@ -1588,7 +1651,17 @@ void Hy3Layout::focusTab(int workspace) { auto size = tab_group.size.vec(); if (pos.x + size.x < mouse_pos.x || pos.y + size.y < mouse_pos.y) continue; - Debug::log(LOG, "!!! tab group clicked: %f %f, %f %f [%f %f]", pos.x, pos.y, size.x, size.y, mouse_pos.x, mouse_pos.y); + Debug::log( + LOG, + "!!! tab group clicked: %f %f, %f %f [%f %f]", + pos.x, + pos.y, + size.x, + size.y, + mouse_pos.x, + mouse_pos.y + ); + auto* group = node->findNodeForTabGroup(tab_group); if (group == nullptr) continue; @@ -1600,7 +1673,9 @@ void Hy3Layout::focusTab(int workspace) { for (auto& tab: tab_group.bar.entries) { if (node_iter == node_list.end()) break; - if (delta.x > tab.offset.fl() * size.x && delta.x < (tab.offset.fl() + tab.width.fl()) * size.x) { + if (delta.x > tab.offset.fl() * size.x + && delta.x < (tab.offset.fl() + tab.width.fl()) * size.x) + { (*node_iter)->focus(); break; } @@ -1618,8 +1693,7 @@ bool Hy3Layout::shouldRenderSelected(CWindow* window) { if (focused == nullptr) return false; switch (focused->data.type) { - case Hy3NodeData::Window: - return false; + case Hy3NodeData::Window: return false; case Hy3NodeData::Group: auto* node = this->getNodeFromWindow(window); if (node == nullptr) return false; @@ -1642,10 +1716,10 @@ void Hy3Layout::renderHook(void*, std::any data) { if (!rendering_normally) break; for (auto& entry: g_Hy3Layout->tab_groups) { - if (!entry.hidden - && entry.target_window == g_pHyprOpenGL->m_pCurrentWindow - && std::find(rendered_groups.begin(), rendered_groups.end(), &entry) == rendered_groups.end() - ) { + if (!entry.hidden && entry.target_window == g_pHyprOpenGL->m_pCurrentWindow + && std::find(rendered_groups.begin(), rendered_groups.end(), &entry) + == rendered_groups.end()) + { entry.renderTabBar(); rendered_groups.push_back(&entry); } @@ -1657,16 +1731,16 @@ void Hy3Layout::renderHook(void*, std::any data) { for (auto& entry: g_Hy3Layout->tab_groups) { if (!entry.hidden - && entry.target_window->m_iMonitorID == g_pHyprOpenGL->m_RenderData.pMonitor->ID - && std::find(rendered_groups.begin(), rendered_groups.end(), &entry) == rendered_groups.end() - ) { + && entry.target_window->m_iMonitorID == g_pHyprOpenGL->m_RenderData.pMonitor->ID + && std::find(rendered_groups.begin(), rendered_groups.end(), &entry) + == rendered_groups.end()) + { entry.renderTabBar(); } } break; - default: - break; + default: break; } } @@ -1692,7 +1766,7 @@ void Hy3Layout::tickHook(void*, std::any) { std::string Hy3Node::debugNode() { std::stringstream buf; - std::string addr = "0x" + std::to_string((size_t)this); + std::string addr = "0x" + std::to_string((size_t) this); switch (this->data.type) { case Hy3NodeData::Window: buf << "window("; @@ -1708,15 +1782,9 @@ std::string Hy3Node::debugNode() { buf << ") ["; switch (this->data.as_group.layout) { - case Hy3GroupLayout::SplitH: - buf << "splith"; - break; - case Hy3GroupLayout::SplitV: - buf << "splitv"; - break; - case Hy3GroupLayout::Tabbed: - buf << "tabs"; - break; + case Hy3GroupLayout::SplitH: buf << "splith"; break; + case Hy3GroupLayout::SplitV: buf << "splitv"; break; + case Hy3GroupLayout::Tabbed: buf << "tabs"; break; } buf << "] size ratio: "; diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index 3545c66..7f06632 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -1,11 +1,11 @@ #pragma once +#include +#include + struct Hy3Node; #include "TabGroup.hpp" -#include -#include - class Hy3Layout; struct Hy3Node; @@ -58,7 +58,7 @@ public: Hy3NodeData& operator=(CWindow*); Hy3NodeData& operator=(Hy3GroupLayout); - //private: - I give up, C++ wins + // private: - I give up, C++ wins Hy3NodeData(Hy3GroupData); Hy3NodeData(Hy3NodeData&&); Hy3NodeData& operator=(Hy3NodeData&&); @@ -98,7 +98,8 @@ struct Hy3Node { // Attempt to swallow a group. returns true if swallowed static bool swallowGroups(Hy3Node*); // Remove this node from its parent, deleting the parent if it was - // the only child and recursing if the parent was the only child of it's parent. + // the only child and recursing if the parent was the only child of it's + // parent. Hy3Node* removeFromParentRecursive(); // Replace this node with a group, returning this node's new address. @@ -149,6 +150,7 @@ public: std::list nodes; std::list tab_groups; + private: struct { bool started = false; @@ -160,9 +162,9 @@ private: Hy3Node* getNodeFromWindow(CWindow*); void applyNodeDataToWindow(Hy3Node*, bool force = false); - // if shift is true, shift the window in the given direction, returning nullptr, - // if shift is false, return the window in the given direction or nullptr. - // if once is true, only one group will be broken out of / into + // if shift is true, shift the window in the given direction, returning + // nullptr, if shift is false, return the window in the given direction or + // nullptr. if once is true, only one group will be broken out of / into Hy3Node* shiftOrGetFocus(Hy3Node&, ShiftDirection, bool, bool); friend struct Hy3Node; diff --git a/src/SelectionHook.cpp b/src/SelectionHook.cpp index 2441fe4..bbf63ae 100644 --- a/src/SelectionHook.cpp +++ b/src/SelectionHook.cpp @@ -1,53 +1,68 @@ #include "globals.hpp" -#include #include +#include namespace selection_hook { - inline CFunctionHook* g_LastSelectionHook = nullptr; +inline CFunctionHook* g_LastSelectionHook = nullptr; - void hook_updateDecos(void* thisptr, CWindow* window) { - bool explicitly_selected = g_Hy3Layout->shouldRenderSelected(window); - Debug::log(LOG, "update decos for %p - selected: %d", window, explicitly_selected); +void hook_updateDecos(void* thisptr, CWindow* window) { + bool explicitly_selected = g_Hy3Layout->shouldRenderSelected(window); + Debug::log(LOG, "update decos for %p - selected: %d", window, explicitly_selected); - auto* lastWindow = g_pCompositor->m_pLastWindow; - if (explicitly_selected) { - g_pCompositor->m_pLastWindow = window; - } - - ((void (*)(void*, CWindow*)) g_LastSelectionHook->m_pOriginal)(thisptr, window); - - if (explicitly_selected) { - g_pCompositor->m_pLastWindow = lastWindow; - } + auto* lastWindow = g_pCompositor->m_pLastWindow; + if (explicitly_selected) { + g_pCompositor->m_pLastWindow = window; } - void init() { - static const auto decoUpdateCandidates = HyprlandAPI::findFunctionsByName(PHANDLE, "updateWindowAnimatedDecorationValues"); + ((void (*)(void*, CWindow*)) g_LastSelectionHook->m_pOriginal)(thisptr, window); - if (decoUpdateCandidates.size() != 1) { - g_LastSelectionHook = nullptr; - Debug::log(ERR, "Expected one matching function to hook for \"updateWindowAnimatedDecorationValues\", found %d", decoUpdateCandidates.size()); - HyprlandAPI::addNotificationV2(PHANDLE, { - {"text", "Failed to load function hooks: \"updateWindowAnimatedDecorationValues\""}, - {"time", (uint64_t)10000}, - {"color", CColor(1.0, 0.0, 0.0, 1.0)}, - {"icon", ICON_ERROR}, - }); - return; - } - - g_LastSelectionHook = HyprlandAPI::createFunctionHook(PHANDLE, decoUpdateCandidates[0].address, (void*)&hook_updateDecos); - } - - void enable() { - if (g_LastSelectionHook != nullptr) { - g_LastSelectionHook->hook(); - } - } - - void disable() { - if (g_LastSelectionHook != nullptr) { - g_LastSelectionHook->unhook(); - } + if (explicitly_selected) { + g_pCompositor->m_pLastWindow = lastWindow; } } + +void init() { + static const auto decoUpdateCandidates + = HyprlandAPI::findFunctionsByName(PHANDLE, "updateWindowAnimatedDecorationValues"); + + if (decoUpdateCandidates.size() != 1) { + g_LastSelectionHook = nullptr; + Debug::log( + ERR, + "Expected one matching function to hook for " + "\"updateWindowAnimatedDecorationValues\", found %d", + decoUpdateCandidates.size() + ); + HyprlandAPI::addNotificationV2( + PHANDLE, + { + {"text", + "Failed to load function hooks: " + "\"updateWindowAnimatedDecorationValues\""}, + {"time", (uint64_t) 10000}, + {"color", CColor(1.0, 0.0, 0.0, 1.0)}, + {"icon", ICON_ERROR}, + } + ); + return; + } + + g_LastSelectionHook = HyprlandAPI::createFunctionHook( + PHANDLE, + decoUpdateCandidates[0].address, + (void*) &hook_updateDecos + ); +} + +void enable() { + if (g_LastSelectionHook != nullptr) { + g_LastSelectionHook->hook(); + } +} + +void disable() { + if (g_LastSelectionHook != nullptr) { + g_LastSelectionHook->unhook(); + } +} +} // namespace selection_hook diff --git a/src/SelectionHook.hpp b/src/SelectionHook.hpp index 3f38e53..6040bdb 100644 --- a/src/SelectionHook.hpp +++ b/src/SelectionHook.hpp @@ -1,7 +1,7 @@ #pragma once namespace selection_hook { - void init(); - void enable(); - void disable(); -} +void init(); +void enable(); +void disable(); +} // namespace selection_hook diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 2e0e52e..eb8d7f9 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -1,18 +1,31 @@ -#include "globals.hpp" #include "TabGroup.hpp" +#include "globals.hpp" #include "Hy3Layout.hpp" -#include #include -#include +#include #include #include #include +#include #include Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_bar), node(node) { - this->offset.create(AVARTYPE_FLOAT, -1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE); - this->width.create(AVARTYPE_FLOAT, -1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE); + this->offset.create( + AVARTYPE_FLOAT, + -1.0f, + g_pConfigManager->getAnimationPropertyConfig("windowsMove"), + nullptr, + AVARDAMAGE_NONE + ); + + this->width.create( + AVARTYPE_FLOAT, + -1.0f, + g_pConfigManager->getAnimationPropertyConfig("windowsMove"), + nullptr, + AVARDAMAGE_NONE + ); this->offset.registerVar(); this->width.registerVar(); @@ -26,9 +39,7 @@ Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_b this->urgent = node.isUrgent(); } -bool Hy3TabBarEntry::operator==(const Hy3Node& node) const { - return this->node == node; -} +bool Hy3TabBarEntry::operator==(const Hy3Node& node) const { return this->node == node; } bool Hy3TabBarEntry::operator==(const Hy3TabBarEntry& entry) const { return this->node == entry.node; @@ -56,6 +67,7 @@ void Hy3TabBarEntry::setWindowTitle(std::string title) { } void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) { + // clang-format off static const auto* s_rounding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:rounding")->intValue; static const auto* render_text = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:render_text")->intValue; static const auto* text_font = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_font")->strValue; @@ -67,6 +79,7 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) { static const auto* col_text_active = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:col.text.active")->intValue; static const auto* col_text_urgent = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:col.text.urgent")->intValue; static const auto* col_text_inactive = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:col.text.inactive")->intValue; + // clang-format on auto width = box.width; auto height = box.height; @@ -74,22 +87,25 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) { auto rounding = std::min((double) *s_rounding, std::min(width * 0.5, height * 0.5)); if (this->texture.m_iTexID == 0 + // clang-format off || this->last_render.x != box.x || this->last_render.y != box.y - || this->last_render.focused != this->focused + || this->last_render.focused != this->focused || this->last_render.urgent != this->urgent - || this->last_render.window_title != this->window_title - || this->last_render.rounding != rounding + || this->last_render.window_title != this->window_title + || this->last_render.rounding != rounding || this->last_render.text_font != *text_font - || this->last_render.text_height != *text_height - || this->last_render.text_padding != *text_padding - || this->last_render.col_active != *col_active + || this->last_render.text_height != *text_height + || this->last_render.text_padding != *text_padding + || this->last_render.col_active != *col_active || this->last_render.col_urgent != *col_urgent - || this->last_render.col_inactive != *col_inactive - || this->last_render.col_text_active != *col_text_active - || this->last_render.col_text_urgent != *col_text_urgent - || this->last_render.col_text_inactive != *col_text_inactive - ) { + || this->last_render.col_inactive != *col_inactive + || this->last_render.col_text_active != *col_text_active + || this->last_render.col_text_urgent != *col_text_urgent + || this->last_render.col_text_inactive != *col_text_inactive + // clang-format on + ) + { this->last_render.x = box.x; this->last_render.y = box.y; this->last_render.focused = this->focused; @@ -135,7 +151,14 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) { cairo_line_to(cairo, width, height - rounding); cairo_arc(cairo, width - rounding, height - rounding, rounding, 0.0, 90.0 * (M_PI / 180.0)); cairo_line_to(cairo, rounding, height); - cairo_arc(cairo, rounding, height - rounding, rounding, -270.0 * (M_PI / 180.0), -180.0 * (M_PI / 180.0)); + cairo_arc( + cairo, + rounding, + height - rounding, + rounding, + -270.0 * (M_PI / 180.0), + -180.0 * (M_PI / 180.0) + ); cairo_close_path(cairo); // draw @@ -171,7 +194,7 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) { int layout_width, layout_height; pango_layout_get_size(layout, &layout_width, &layout_height); - auto y_offset = (height / 2.0) - (((double)layout_height / PANGO_SCALE) / 2.0); + auto y_offset = (height / 2.0) - (((double) layout_height / PANGO_SCALE) / 2.0); cairo_move_to(cairo, padding, y_offset); pango_cairo_show_layout(cairo, layout); g_object_unref(layout); @@ -187,10 +210,10 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - #ifdef GLES32 +#ifdef GLES32 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); - #endif +#endif glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); @@ -202,8 +225,22 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) { } Hy3TabBar::Hy3TabBar() { - this->vertical_pos.create(AVARTYPE_FLOAT, 1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE); - this->fade_opacity.create(AVARTYPE_FLOAT, 0.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE); + this->vertical_pos.create( + AVARTYPE_FLOAT, + 1.0f, + g_pConfigManager->getAnimationPropertyConfig("windowsMove"), + nullptr, + AVARDAMAGE_NONE + ); + + this->fade_opacity.create( + AVARTYPE_FLOAT, + 0.0f, + g_pConfigManager->getAnimationPropertyConfig("windowsMove"), + nullptr, + AVARDAMAGE_NONE + ); + this->vertical_pos.registerVar(); this->fade_opacity.registerVar(); @@ -242,7 +279,7 @@ void Hy3TabBar::updateNodeList(std::list& nodes) { entry = std::next(entry); } - exitloop: +exitloop: // move any extra entries to removed_entries while (entry != this->entries.end()) { @@ -256,12 +293,17 @@ void Hy3TabBar::updateNodeList(std::list& nodes) { // add missing entries, taking first from removed_entries while (node != nodes.end()) { if (entry == this->entries.end() || *entry != **node) { - if (std::find(removed_entries.begin(), removed_entries.end(), entry) != removed_entries.end()) { + if (std::find(removed_entries.begin(), removed_entries.end(), entry) != removed_entries.end()) + { entry = std::next(entry); continue; } - auto moved = std::find_if(removed_entries.begin(), removed_entries.end(), [&node](auto entry) { return **node == *entry; }); + auto moved + = std::find_if(removed_entries.begin(), removed_entries.end(), [&node](auto entry) { + return **node == *entry; + }); + if (moved != removed_entries.end()) { this->entries.splice(entry, this->entries, *moved); entry = *moved; @@ -279,7 +321,12 @@ void Hy3TabBar::updateNodeList(std::list& nodes) { // set stats from node data auto* parent = (*node)->parent; auto& parent_group = parent->data.as_group; - entry->setFocused(parent_group.focused_child == *node || (parent_group.group_focused && parent->isIndirectlyFocused())); + + entry->setFocused( + parent_group.focused_child == *node + || (parent_group.group_focused && parent->isIndirectlyFocused()) + ); + entry->setUrgent((*node)->isUrgent()); entry->setWindowTitle((*node)->getTitle()); @@ -323,7 +370,8 @@ void Hy3TabBar::updateAnimations(bool warp) { } if (entry->offset.goalf() != offset) entry->offset = offset; - if ((warp_init || entry->width.goalf() != 0.0) && entry->width.goalf() != entry_width) entry->width = entry_width; + if ((warp_init || entry->width.goalf() != 0.0) && entry->width.goalf() != entry_width) + entry->width = entry_width; } offset += entry->width.goalf(); @@ -338,8 +386,20 @@ void Hy3TabBar::setSize(Vector2D size) { } Hy3TabGroup::Hy3TabGroup(Hy3Node& node) { - this->pos.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE); - this->size.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE); + this->pos.create( + AVARTYPE_VECTOR, + g_pConfigManager->getAnimationPropertyConfig("windowsMove"), + nullptr, + AVARDAMAGE_NONE + ); + + this->size.create( + AVARTYPE_VECTOR, + g_pConfigManager->getAnimationPropertyConfig("windowsMove"), + nullptr, + AVARDAMAGE_NONE + ); + this->pos.registerVar(); this->size.registerVar(); @@ -353,7 +413,8 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node) { Debug::log(LOG, "updated tab bar for %p", &node); 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* bar_height = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:height")->intValue; + static const auto* bar_height + = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:height")->intValue; auto gaps = node.parent == nullptr ? *gaps_out : *gaps_in; auto tpos = node.position + Vector2D(gaps, gaps) + node.gap_pos_offset; @@ -372,7 +433,8 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node) { } void Hy3TabGroup::tick() { - static const auto* enter_from_top = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:from_top")->intValue; + static const auto* enter_from_top + = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:from_top")->intValue; auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id); if (!this->bar.destroying && workspace != nullptr) { @@ -388,7 +450,7 @@ void Hy3TabGroup::tick() { pos.y += (this->bar.vertical_pos.fl() * size.y) * (*enter_from_top ? -1 : 1); if (this->last_pos != pos || this->last_size != size) { - wlr_box damage_box = { this->last_pos.x, this->last_pos.y, this->last_size.x, this->last_size.y }; + wlr_box damage_box = {this->last_pos.x, this->last_pos.y, this->last_size.x, this->last_size.y}; g_pHyprRenderer->damageBox(&damage_box); this->bar.damaged = true; @@ -397,7 +459,7 @@ void Hy3TabGroup::tick() { } if (this->bar.destroy || this->bar.dirty) { - wlr_box damage_box = { pos.x, pos.y, size.x, size.y }; + wlr_box damage_box = {pos.x, pos.y, size.x, size.y}; g_pHyprRenderer->damageBox(&damage_box); this->bar.damaged = true; @@ -406,8 +468,10 @@ void Hy3TabGroup::tick() { } void Hy3TabGroup::renderTabBar() { - static const auto* window_rounding = &HyprlandAPI::getConfigValue(PHANDLE, "decoration:rounding")->intValue; - static const auto* enter_from_top = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:from_top")->intValue; + static const auto* window_rounding + = &HyprlandAPI::getConfigValue(PHANDLE, "decoration:rounding")->intValue; + static const auto* enter_from_top + = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:from_top")->intValue; static const auto* padding = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue; auto* monitor = g_pHyprOpenGL->m_RenderData.pMonitor; @@ -425,18 +489,25 @@ void Hy3TabGroup::renderTabBar() { auto scaled_pos = Vector2D(std::round(pos.x * scale), std::round(pos.y * scale)); auto scaled_size = Vector2D(std::round(size.x * scale), std::round(size.y * scale)); - wlr_box box = { scaled_pos.x, scaled_pos.y, scaled_size.x, scaled_size.y }; + wlr_box box = {scaled_pos.x, scaled_pos.y, scaled_size.x, scaled_size.y}; - if (scaled_pos.x > monitor_size.x - || scaled_pos.y > monitor_size.y - || scaled_pos.x + scaled_size.x < 0 - || scaled_pos.y + scaled_size.y < 0) + if (scaled_pos.x > monitor_size.x || scaled_pos.y > monitor_size.y + || scaled_pos.x + scaled_size.x < 0 || scaled_pos.y + scaled_size.y < 0) return; if (!this->bar.damaged) { pixman_region32 damage; pixman_region32_init(&damage); - pixman_region32_intersect_rect(&damage, g_pHyprOpenGL->m_RenderData.pDamage, box.x, box.y, box.width, box.height); + + pixman_region32_intersect_rect( + &damage, + g_pHyprOpenGL->m_RenderData.pDamage, + box.x, + box.y, + box.width, + box.height + ); + this->bar.damaged = pixman_region32_not_empty(&damage); pixman_region32_fini(&damage); } @@ -462,10 +533,11 @@ void Hy3TabGroup::renderTabBar() { auto wpos = window->m_vRealPosition.vec() - monitor->vecPosition; auto wsize = window->m_vRealSize.vec(); - wlr_box window_box = { wpos.x, wpos.y, wsize.x, wsize.y }; + wlr_box window_box = {wpos.x, wpos.y, wsize.x, wsize.y}; scaleBox(&window_box, scale); - if (window_box.width > 0 && window_box.height > 0) g_pHyprOpenGL->renderRect(&window_box, CColor(0, 0, 0, 0), *window_rounding); + if (window_box.width > 0 && window_box.height > 0) + g_pHyprOpenGL->renderRect(&window_box, CColor(0, 0, 0, 0), *window_rounding); } glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); @@ -475,18 +547,20 @@ void Hy3TabGroup::renderTabBar() { glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); } - auto fade_opacity = this->bar.fade_opacity.fl() * (workspace == nullptr ? 1.0 : workspace->m_fAlpha.fl()); + auto fade_opacity + = this->bar.fade_opacity.fl() * (workspace == nullptr ? 1.0 : workspace->m_fAlpha.fl()); auto render_entry = [&](Hy3TabBarEntry& entry) { - Vector2D entry_pos = { (pos.x + (entry.offset.fl() * size.x) + (*padding * 0.5)) * scale, scaled_pos.y }; - Vector2D entry_size = { ((entry.width.fl() * size.x) - *padding) * scale, scaled_size.y }; + Vector2D entry_pos + = {(pos.x + (entry.offset.fl() * size.x) + (*padding * 0.5)) * scale, scaled_pos.y}; + Vector2D entry_size = {((entry.width.fl() * size.x) - *padding) * scale, scaled_size.y}; if (entry_size.x < 0 || entry_size.y < 0 || fade_opacity == 0.0) return; wlr_box box = { - entry_pos.x, - entry_pos.y, - entry_size.x, - entry_size.y, + entry_pos.x, + entry_pos.y, + entry_size.x, + entry_size.y, }; entry.prepareTexture(scale, box); @@ -514,9 +588,7 @@ void Hy3TabGroup::renderTabBar() { void findOverlappingWindows(Hy3Node& node, float height, std::vector& windows) { switch (node.data.type) { - case Hy3NodeData::Window: - windows.push_back(node.data.as_window); - break; + case Hy3NodeData::Window: windows.push_back(node.data.as_window); break; case Hy3NodeData::Group: auto& group = node.data.as_group; diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index e463f92..dc12a00 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -1,7 +1,6 @@ #pragma once -#include -#include +#include #include #include #include @@ -10,7 +9,6 @@ class Hy3TabGroup; class Hy3TabBar; #include "Hy3Layout.hpp" -#include struct Hy3TabBarEntry { std::string window_title; @@ -18,7 +16,7 @@ struct Hy3TabBarEntry { bool urgent = false; CTexture texture; CAnimatedVariable offset; // offset 0, 0.0-1.0 of total bar - CAnimatedVariable width; // 0.0-1.0 of total bar + CAnimatedVariable width; // 0.0-1.0 of total bar Hy3TabBar& tab_bar; Hy3Node& node; // only used for comparioson. do not deref. @@ -68,6 +66,7 @@ public: void setSize(Vector2D); std::list entries; + private: Hy3Node* focused_node = nullptr; Vector2D size; diff --git a/src/globals.hpp b/src/globals.hpp index c955ee3..ed7522f 100644 --- a/src/globals.hpp +++ b/src/globals.hpp @@ -1,5 +1,5 @@ -#include #include "Hy3Layout.hpp" +#include inline HANDLE PHANDLE = nullptr; inline std::unique_ptr g_Hy3Layout; diff --git a/src/main.cpp b/src/main.cpp index e92fac1..3c4374a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,14 +1,12 @@ #include -#include #include +#include #include "globals.hpp" #include "SelectionHook.hpp" -APICALL EXPORT std::string PLUGIN_API_VERSION() { - return HYPRLAND_API_VERSION; -} +APICALL EXPORT std::string PLUGIN_API_VERSION() { return HYPRLAND_API_VERSION; } // return a window if a window action makes sense now CWindow* window_for_action() { @@ -112,22 +110,58 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { selection_hook::init(); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:no_gaps_when_only", SConfigValue{.intValue = 0}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:group_inset", SConfigValue{.intValue = 10}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:height", SConfigValue{.intValue = 15}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:padding", SConfigValue{.intValue = 5}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:from_top", SConfigValue{.intValue = 0}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:rounding", SConfigValue{.intValue = 3}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:render_text", SConfigValue{.intValue = 1}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:text_font", SConfigValue{.strValue = "Sans"}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:text_height", SConfigValue{.intValue = 8}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:text_padding", SConfigValue{.intValue = 3}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.active", SConfigValue{.intValue = 0xff32b4ff}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.urgent", SConfigValue{.intValue = 0xffff4f4f}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.inactive", SConfigValue{.intValue = 0x80808080}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.text.active", SConfigValue{.intValue = 0xff000000}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.text.urgent", SConfigValue{.intValue = 0xff000000}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.text.inactive", SConfigValue{.intValue = 0xff000000}); + HyprlandAPI::addConfigValue( + PHANDLE, + "plugin:hy3:no_gaps_when_only", + SConfigValue {.intValue = 0} + ); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:group_inset", SConfigValue {.intValue = 10}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:height", SConfigValue {.intValue = 15}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:padding", SConfigValue {.intValue = 5}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:from_top", SConfigValue {.intValue = 0}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:rounding", SConfigValue {.intValue = 3}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:render_text", SConfigValue {.intValue = 1}); + HyprlandAPI::addConfigValue( + PHANDLE, + "plugin:hy3:tabs:text_font", + SConfigValue {.strValue = "Sans"} + ); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:text_height", SConfigValue {.intValue = 8}); + HyprlandAPI::addConfigValue( + PHANDLE, + "plugin:hy3:tabs:text_padding", + SConfigValue {.intValue = 3} + ); + HyprlandAPI::addConfigValue( + PHANDLE, + "plugin:hy3:tabs:col.active", + SConfigValue {.intValue = 0xff32b4ff} + ); + HyprlandAPI::addConfigValue( + PHANDLE, + "plugin:hy3:tabs:col.urgent", + SConfigValue {.intValue = 0xffff4f4f} + ); + HyprlandAPI::addConfigValue( + PHANDLE, + "plugin:hy3:tabs:col.inactive", + SConfigValue {.intValue = 0x80808080} + ); + HyprlandAPI::addConfigValue( + PHANDLE, + "plugin:hy3:tabs:col.text.active", + SConfigValue {.intValue = 0xff000000} + ); + HyprlandAPI::addConfigValue( + PHANDLE, + "plugin:hy3:tabs:col.text.urgent", + SConfigValue {.intValue = 0xff000000} + ); + HyprlandAPI::addConfigValue( + PHANDLE, + "plugin:hy3:tabs:col.text.inactive", + SConfigValue {.intValue = 0xff000000} + ); g_Hy3Layout = std::make_unique(); HyprlandAPI::addLayout(PHANDLE, "hy3", g_Hy3Layout.get());