mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-15 10:43:40 +01:00
Add clang-format and editorconfig
This commit is contained in:
parent
45fb1698c1
commit
37e3f273d1
11 changed files with 628 additions and 355 deletions
72
.clang-format
Normal file
72
.clang-format
Normal file
|
@ -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
|
11
.editorconfig
Normal file
11
.editorconfig
Normal file
|
@ -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
|
|
@ -42,7 +42,7 @@
|
|||
name = "hy3";
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
clang-tools_15
|
||||
clang-tools_16
|
||||
bear
|
||||
];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "globals.hpp"
|
||||
#include "Hy3Layout.hpp"
|
||||
#include "globals.hpp"
|
||||
#include "SelectionHook.hpp"
|
||||
|
||||
#include <hyprland/src/Compositor.hpp>
|
||||
|
@ -8,12 +8,15 @@
|
|||
#include <sstream>
|
||||
|
||||
void errorNotif() {
|
||||
HyprlandAPI::addNotificationV2(PHANDLE, {
|
||||
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) {}
|
||||
|
@ -34,9 +37,7 @@ Hy3GroupData::~Hy3GroupData() {
|
|||
|
||||
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));
|
||||
|
@ -46,8 +47,7 @@ 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,17 +185,15 @@ 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) {
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
// 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* 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;
|
||||
// clang-format on
|
||||
|
||||
if (!g_pCompositor->windowExists(window) || !window->m_bIsMapped) {
|
||||
Debug::log(ERR, "Node %p holding invalid window %p!!", node, window);
|
||||
|
@ -704,8 +705,9 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) {
|
|||
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))
|
||||
) {
|
||||
&& 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
|
||||
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) {
|
||||
|
@ -800,7 +809,14 @@ 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({
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -969,7 +998,12 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) {
|
|||
.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,
|
||||
|
@ -979,14 +1013,23 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -1234,8 +1289,7 @@ std::any Hy3Layout::layoutMessage(SLayoutMessageHeader header, std::string conte
|
|||
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<HOOK_CALLBACK_FN> renderHookPtr = std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::renderHook);
|
||||
std::unique_ptr<HOOK_CALLBACK_FN> windowTitleHookPtr = std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::windowTitleHook);
|
||||
std::unique_ptr<HOOK_CALLBACK_FN> tickHookPtr = std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::tickHook);
|
||||
std::unique_ptr<HOOK_CALLBACK_FN> renderHookPtr
|
||||
= std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::renderHook);
|
||||
std::unique_ptr<HOOK_CALLBACK_FN> windowTitleHookPtr
|
||||
= std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::windowTitleHook);
|
||||
std::unique_ptr<HOOK_CALLBACK_FN> tickHookPtr
|
||||
= std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::tickHook);
|
||||
|
||||
void Hy3Layout::onEnable() {
|
||||
for (auto& window: g_pCompositor->m_vWindows) {
|
||||
if (window->isHidden()
|
||||
|| !window->m_bIsMapped
|
||||
|| window->m_bFadingOut
|
||||
|| window->m_bIsFloating)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1376,13 +1424,15 @@ bool shiftMatchesLayout(Hy3GroupLayout layout, ShiftDirection 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,12 +1459,12 @@ 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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1658,15 +1732,15 @@ 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()
|
||||
) {
|
||||
&& std::find(rendered_groups.begin(), rendered_groups.end(), &entry)
|
||||
== rendered_groups.end())
|
||||
{
|
||||
entry.renderTabBar();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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: ";
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <hyprland/src/layout/IHyprLayout.hpp>
|
||||
#include <list>
|
||||
|
||||
struct Hy3Node;
|
||||
#include "TabGroup.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <hyprland/src/layout/IHyprLayout.hpp>
|
||||
|
||||
class Hy3Layout;
|
||||
struct Hy3Node;
|
||||
|
||||
|
@ -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<Hy3Node> nodes;
|
||||
std::list<Hy3TabGroup> 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;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "globals.hpp"
|
||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||
#include <hyprland/src/Compositor.hpp>
|
||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||
|
||||
namespace selection_hook {
|
||||
inline CFunctionHook* g_LastSelectionHook = nullptr;
|
||||
|
@ -22,21 +22,36 @@ namespace selection_hook {
|
|||
}
|
||||
|
||||
void init() {
|
||||
static const auto decoUpdateCandidates = HyprlandAPI::findFunctionsByName(PHANDLE, "updateWindowAnimatedDecorationValues");
|
||||
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\""},
|
||||
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);
|
||||
g_LastSelectionHook = HyprlandAPI::createFunctionHook(
|
||||
PHANDLE,
|
||||
decoUpdateCandidates[0].address,
|
||||
(void*) &hook_updateDecos
|
||||
);
|
||||
}
|
||||
|
||||
void enable() {
|
||||
|
@ -50,4 +65,4 @@ namespace selection_hook {
|
|||
g_LastSelectionHook->unhook();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace selection_hook
|
||||
|
|
|
@ -4,4 +4,4 @@ namespace selection_hook {
|
|||
void init();
|
||||
void enable();
|
||||
void disable();
|
||||
}
|
||||
} // namespace selection_hook
|
||||
|
|
138
src/TabGroup.cpp
138
src/TabGroup.cpp
|
@ -1,18 +1,31 @@
|
|||
#include "globals.hpp"
|
||||
#include "TabGroup.hpp"
|
||||
#include "globals.hpp"
|
||||
#include "Hy3Layout.hpp"
|
||||
|
||||
#include <hyprland/src/Compositor.hpp>
|
||||
#include <cairo/cairo.h>
|
||||
#include <pango/pangocairo.h>
|
||||
#include <hyprland/src/Compositor.hpp>
|
||||
#include <hyprland/src/helpers/Color.hpp>
|
||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||
#include <hyprland/src/render/OpenGL.hpp>
|
||||
#include <pango/pangocairo.h>
|
||||
#include <pixman.h>
|
||||
|
||||
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,6 +87,7 @@ 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
|
||||
|
@ -89,7 +103,9 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
|
|||
|| 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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -256,12 +293,17 @@ void Hy3TabBar::updateNodeList(std::list<Hy3Node*>& 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<Hy3Node*>& 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) {
|
||||
|
@ -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;
|
||||
|
@ -427,16 +491,23 @@ void Hy3TabGroup::renderTabBar() {
|
|||
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};
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -465,7 +536,8 @@ void Hy3TabGroup::renderTabBar() {
|
|||
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,10 +547,12 @@ 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_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;
|
||||
|
||||
|
@ -514,9 +588,7 @@ void Hy3TabGroup::renderTabBar() {
|
|||
|
||||
void findOverlappingWindows(Hy3Node& node, float height, std::vector<CWindow*>& 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;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <hyprland/src/helpers/AnimatedVariable.hpp>
|
||||
#include <hyprland/src/helpers/Vector2D.hpp>
|
||||
#include <hyprland/src/Compositor.hpp>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
@ -10,7 +9,6 @@ class Hy3TabGroup;
|
|||
class Hy3TabBar;
|
||||
|
||||
#include "Hy3Layout.hpp"
|
||||
#include <hyprland/src/render/Texture.hpp>
|
||||
|
||||
struct Hy3TabBarEntry {
|
||||
std::string window_title;
|
||||
|
@ -68,6 +66,7 @@ public:
|
|||
void setSize(Vector2D);
|
||||
|
||||
std::list<Hy3TabBarEntry> entries;
|
||||
|
||||
private:
|
||||
Hy3Node* focused_node = nullptr;
|
||||
Vector2D size;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||
#include "Hy3Layout.hpp"
|
||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||
|
||||
inline HANDLE PHANDLE = nullptr;
|
||||
inline std::unique_ptr<Hy3Layout> g_Hy3Layout;
|
||||
|
|
60
src/main.cpp
60
src/main.cpp
|
@ -1,14 +1,12 @@
|
|||
#include <optional>
|
||||
|
||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||
#include <hyprland/src/Compositor.hpp>
|
||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||
|
||||
#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: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_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: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<Hy3Layout>();
|
||||
HyprlandAPI::addLayout(PHANDLE, "hy3", g_Hy3Layout.get());
|
||||
|
|
Loading…
Add table
Reference in a new issue