mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-15 18:53: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";
|
name = "hy3";
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
clang-tools_15
|
clang-tools_16
|
||||||
bear
|
bear
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "globals.hpp"
|
|
||||||
#include "Hy3Layout.hpp"
|
#include "Hy3Layout.hpp"
|
||||||
|
#include "globals.hpp"
|
||||||
#include "SelectionHook.hpp"
|
#include "SelectionHook.hpp"
|
||||||
|
|
||||||
#include <hyprland/src/Compositor.hpp>
|
#include <hyprland/src/Compositor.hpp>
|
||||||
|
@ -8,12 +8,15 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
void errorNotif() {
|
void errorNotif() {
|
||||||
HyprlandAPI::addNotificationV2(PHANDLE, {
|
HyprlandAPI::addNotificationV2(
|
||||||
|
PHANDLE,
|
||||||
|
{
|
||||||
{"text", "Something has gone very wrong. Check the log for details."},
|
{"text", "Something has gone very wrong. Check the log for details."},
|
||||||
{"time", (uint64_t) 10000},
|
{"time", (uint64_t) 10000},
|
||||||
{"color", CColor(1.0, 0.0, 0.0, 1.0)},
|
{"color", CColor(1.0, 0.0, 0.0, 1.0)},
|
||||||
{"icon", ICON_ERROR},
|
{"icon", ICON_ERROR},
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Hy3GroupData::Hy3GroupData(Hy3GroupLayout layout): layout(layout) {}
|
Hy3GroupData::Hy3GroupData(Hy3GroupLayout layout): layout(layout) {}
|
||||||
|
@ -34,9 +37,7 @@ Hy3GroupData::~Hy3GroupData() {
|
||||||
|
|
||||||
Hy3NodeData::Hy3NodeData(): Hy3NodeData((CWindow*) nullptr) {}
|
Hy3NodeData::Hy3NodeData(): Hy3NodeData((CWindow*) nullptr) {}
|
||||||
|
|
||||||
Hy3NodeData::Hy3NodeData(CWindow *window): type(Hy3NodeData::Window) {
|
Hy3NodeData::Hy3NodeData(CWindow* window): type(Hy3NodeData::Window) { this->as_window = window; }
|
||||||
this->as_window = window;
|
|
||||||
}
|
|
||||||
|
|
||||||
Hy3NodeData::Hy3NodeData(Hy3GroupData group): type(Hy3NodeData::Group) {
|
Hy3NodeData::Hy3NodeData(Hy3GroupData group): type(Hy3NodeData::Group) {
|
||||||
new (&this->as_group) Hy3GroupData(std::move(group));
|
new (&this->as_group) Hy3GroupData(std::move(group));
|
||||||
|
@ -46,8 +47,7 @@ Hy3NodeData::Hy3NodeData(Hy3GroupLayout layout): Hy3NodeData(Hy3GroupData(layout
|
||||||
|
|
||||||
Hy3NodeData::~Hy3NodeData() {
|
Hy3NodeData::~Hy3NodeData() {
|
||||||
switch (this->type) {
|
switch (this->type) {
|
||||||
case Hy3NodeData::Window:
|
case Hy3NodeData::Window: break;
|
||||||
break;
|
|
||||||
case Hy3NodeData::Group:
|
case Hy3NodeData::Group:
|
||||||
this->as_group.~Hy3GroupData();
|
this->as_group.~Hy3GroupData();
|
||||||
|
|
||||||
|
@ -58,19 +58,27 @@ Hy3NodeData::~Hy3NodeData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Hy3NodeData::Hy3NodeData(Hy3NodeData&& from): type(from.type) {
|
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) {
|
switch (from.type) {
|
||||||
case Hy3NodeData::Window:
|
case Hy3NodeData::Window: this->as_window = from.as_window; break;
|
||||||
this->as_window = from.as_window;
|
case Hy3NodeData::Group: new (&this->as_group) Hy3GroupData(std::move(from.as_group)); break;
|
||||||
break;
|
|
||||||
case Hy3NodeData::Group:
|
|
||||||
new(&this->as_group) Hy3GroupData(std::move(from.as_group));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Hy3NodeData& Hy3NodeData::operator=(Hy3NodeData&& from) {
|
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) {
|
if (this->type == Hy3NodeData::Group) {
|
||||||
this->as_group.~Hy3GroupData();
|
this->as_group.~Hy3GroupData();
|
||||||
}
|
}
|
||||||
|
@ -78,12 +86,8 @@ Hy3NodeData& Hy3NodeData::operator=(Hy3NodeData&& from) {
|
||||||
this->type = from.type;
|
this->type = from.type;
|
||||||
|
|
||||||
switch (this->type) {
|
switch (this->type) {
|
||||||
case Hy3NodeData::Window:
|
case Hy3NodeData::Window: this->as_window = from.as_window; break;
|
||||||
this->as_window = from.as_window;
|
case Hy3NodeData::Group: new (&this->as_group) Hy3GroupData(std::move(from.as_group)); break;
|
||||||
break;
|
|
||||||
case Hy3NodeData::Group:
|
|
||||||
new(&this->as_group) Hy3GroupData(std::move(from.as_group));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -101,18 +105,18 @@ Hy3NodeData& Hy3NodeData::operator=(Hy3GroupLayout layout) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Hy3NodeData::operator==(const Hy3NodeData& rhs) const {
|
bool Hy3NodeData::operator==(const Hy3NodeData& rhs) const { return this == &rhs; }
|
||||||
return this == &rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Hy3Node::operator==(const Hy3Node& rhs) const {
|
bool Hy3Node::operator==(const Hy3Node& rhs) const { return this->data == rhs.data; }
|
||||||
return this->data == rhs.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Hy3Node::recalcSizePosRecursive(bool force) {
|
void Hy3Node::recalcSizePosRecursive(bool force) {
|
||||||
|
// clang-format off
|
||||||
static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->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* 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* 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;
|
int outer_gaps = 0;
|
||||||
Vector2D gap_pos_offset;
|
Vector2D gap_pos_offset;
|
||||||
|
@ -130,8 +134,6 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
|
||||||
auto tpos = this->position;
|
auto tpos = this->position;
|
||||||
auto tsize = this->size;
|
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;
|
double tab_height_offset = *tab_bar_height + *tab_bar_padding;
|
||||||
|
|
||||||
if (this->data.type != Hy3NodeData::Group) {
|
if (this->data.type != Hy3NodeData::Group) {
|
||||||
|
@ -183,17 +185,15 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
|
||||||
|
|
||||||
int constraint;
|
int constraint;
|
||||||
switch (group->layout) {
|
switch (group->layout) {
|
||||||
case Hy3GroupLayout::SplitH:
|
case Hy3GroupLayout::SplitH: constraint = tsize.x; break;
|
||||||
constraint = tsize.x;
|
case Hy3GroupLayout::SplitV: constraint = tsize.y; break;
|
||||||
break;
|
case Hy3GroupLayout::Tabbed: 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;
|
double offset = 0;
|
||||||
|
|
||||||
if (group->layout == Hy3GroupLayout::Tabbed && group->focused_child != nullptr) {
|
if (group->layout == Hy3GroupLayout::Tabbed && group->focused_child != nullptr) {
|
||||||
|
@ -250,8 +250,7 @@ void Hy3Node::setHidden(bool hidden) {
|
||||||
|
|
||||||
bool Hy3Node::isUrgent() {
|
bool Hy3Node::isUrgent() {
|
||||||
switch (this->data.type) {
|
switch (this->data.type) {
|
||||||
case Hy3NodeData::Window:
|
case Hy3NodeData::Window: return this->data.as_window->m_bIsUrgent;
|
||||||
return this->data.as_window->m_bIsUrgent;
|
|
||||||
case Hy3NodeData::Group:
|
case Hy3NodeData::Group:
|
||||||
for (auto* child: this->data.as_group.children) {
|
for (auto* child: this->data.as_group.children) {
|
||||||
if (child->isUrgent()) return true;
|
if (child->isUrgent()) return true;
|
||||||
|
@ -274,21 +273,14 @@ bool Hy3Node::isIndirectlyFocused() {
|
||||||
|
|
||||||
std::string Hy3Node::getTitle() {
|
std::string Hy3Node::getTitle() {
|
||||||
switch (this->data.type) {
|
switch (this->data.type) {
|
||||||
case Hy3NodeData::Window:
|
case Hy3NodeData::Window: return this->data.as_window->m_szTitle;
|
||||||
return this->data.as_window->m_szTitle;
|
|
||||||
case Hy3NodeData::Group:
|
case Hy3NodeData::Group:
|
||||||
std::string title;
|
std::string title;
|
||||||
|
|
||||||
switch (this->data.as_group.layout) {
|
switch (this->data.as_group.layout) {
|
||||||
case Hy3GroupLayout::SplitH:
|
case Hy3GroupLayout::SplitH: title = "[H] "; break;
|
||||||
title = "[H] ";
|
case Hy3GroupLayout::SplitV: title = "[V] "; break;
|
||||||
break;
|
case Hy3GroupLayout::Tabbed: title = "[T] "; break;
|
||||||
case Hy3GroupLayout::SplitV:
|
|
||||||
title = "[V] ";
|
|
||||||
break;
|
|
||||||
case Hy3GroupLayout::Tabbed:
|
|
||||||
title = "[T] ";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->data.as_group.focused_child == nullptr) {
|
if (this->data.as_group.focused_child == nullptr) {
|
||||||
|
@ -327,6 +319,7 @@ void Hy3Node::markFocused() {
|
||||||
node->parent->updateTabBar();
|
node->parent->updateTabBar();
|
||||||
node = node->parent;
|
node = node->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (node2->parent != nullptr) {
|
while (node2->parent != nullptr) {
|
||||||
node2->parent->data.as_group.focused_child = node2;
|
node2->parent->data.as_group.focused_child = node2;
|
||||||
node2->parent->data.as_group.group_focused = false;
|
node2->parent->data.as_group.group_focused = false;
|
||||||
|
@ -336,6 +329,7 @@ void Hy3Node::markFocused() {
|
||||||
|
|
||||||
if (oldfocus != nullptr) {
|
if (oldfocus != nullptr) {
|
||||||
oldfocus->updateDecos();
|
oldfocus->updateDecos();
|
||||||
|
|
||||||
while (oldfocus != nullptr) {
|
while (oldfocus != nullptr) {
|
||||||
oldfocus->updateTabBar();
|
oldfocus->updateTabBar();
|
||||||
oldfocus = oldfocus->parent;
|
oldfocus = oldfocus->parent;
|
||||||
|
@ -382,9 +376,7 @@ bool Hy3Node::focusWindow() {
|
||||||
|
|
||||||
void Hy3Node::raiseToTop() {
|
void Hy3Node::raiseToTop() {
|
||||||
switch (this->data.type) {
|
switch (this->data.type) {
|
||||||
case Hy3NodeData::Window:
|
case Hy3NodeData::Window: g_pCompositor->moveWindowToTop(this->data.as_window); break;
|
||||||
g_pCompositor->moveWindowToTop(this->data.as_window);
|
|
||||||
break;
|
|
||||||
case Hy3NodeData::Group:
|
case Hy3NodeData::Group:
|
||||||
for (auto* child: this->data.as_group.children) {
|
for (auto* child: this->data.as_group.children) {
|
||||||
child->raiseToTop();
|
child->raiseToTop();
|
||||||
|
@ -395,8 +387,7 @@ void Hy3Node::raiseToTop() {
|
||||||
|
|
||||||
Hy3Node* Hy3Node::getFocusedNode() {
|
Hy3Node* Hy3Node::getFocusedNode() {
|
||||||
switch (this->data.type) {
|
switch (this->data.type) {
|
||||||
case Hy3NodeData::Window:
|
case Hy3NodeData::Window: return this;
|
||||||
return this;
|
|
||||||
case Hy3NodeData::Group:
|
case Hy3NodeData::Group:
|
||||||
if (this->data.as_group.focused_child == nullptr || this->data.as_group.group_focused) {
|
if (this->data.as_group.focused_child == nullptr || this->data.as_group.group_focused) {
|
||||||
return this;
|
return this;
|
||||||
|
@ -407,14 +398,14 @@ Hy3Node* Hy3Node::getFocusedNode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Hy3Node::swallowGroups(Hy3Node* into) {
|
bool Hy3Node::swallowGroups(Hy3Node* into) {
|
||||||
if (into == nullptr
|
if (into == nullptr || into->data.type != Hy3NodeData::Group
|
||||||
|| into->data.type != Hy3NodeData::Group
|
|
||||||
|| into->data.as_group.children.size() != 1)
|
|| into->data.as_group.children.size() != 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto* child = into->data.as_group.children.front();
|
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;
|
if (into->parent == nullptr && child->data.type != Hy3NodeData::Group) return false;
|
||||||
|
|
||||||
Debug::log(LOG, "Swallowing %p into %p", child, into);
|
Debug::log(LOG, "Swallowing %p into %p", child, into);
|
||||||
|
@ -458,7 +449,14 @@ Hy3Node* Hy3Node::removeFromParentRecursive() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!group.children.remove(child)) {
|
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();
|
errorNotif();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -670,7 +668,9 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
if (monitor == nullptr) {
|
||||||
|
@ -679,10 +679,11 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
static const auto* border_size = &HyprlandAPI::getConfigValue(PHANDLE, "general:border_size")->intValue;
|
static const auto* border_size = &HyprlandAPI::getConfigValue(PHANDLE, "general:border_size")->intValue;
|
||||||
static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
|
static const auto* gaps_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;
|
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) {
|
if (!g_pCompositor->windowExists(window) || !window->m_bIsMapped) {
|
||||||
Debug::log(ERR, "Node %p holding invalid window %p!!", node, window);
|
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)
|
if (!g_pCompositor->isWorkspaceSpecial(window->m_iWorkspaceID)
|
||||||
&& ((*single_window_no_gaps && only_node)
|
&& ((*single_window_no_gaps && only_node)
|
||||||
|| (window->m_bIsFullscreen
|
|| (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_vRealPosition = window->m_vPosition;
|
||||||
window->m_vRealSize = window->m_vSize;
|
window->m_vRealSize = window->m_vSize;
|
||||||
|
|
||||||
|
@ -753,7 +755,13 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) {
|
||||||
|
|
||||||
auto* existing = this->getNodeFromWindow(window);
|
auto* existing = this->getNodeFromWindow(window);
|
||||||
if (existing != nullptr) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,15 +770,16 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) {
|
||||||
Hy3Node* opening_into;
|
Hy3Node* opening_into;
|
||||||
Hy3Node* opening_after;
|
Hy3Node* opening_after;
|
||||||
|
|
||||||
if (g_pCompositor->m_pLastWindow != nullptr
|
if (g_pCompositor->m_pLastWindow != nullptr && !g_pCompositor->m_pLastWindow->m_bIsFloating
|
||||||
&& !g_pCompositor->m_pLastWindow->m_bIsFloating
|
|
||||||
&& g_pCompositor->m_pLastWindow != window
|
&& g_pCompositor->m_pLastWindow != window
|
||||||
&& g_pCompositor->m_pLastWindow->m_iWorkspaceID == window->m_iWorkspaceID
|
&& g_pCompositor->m_pLastWindow->m_iWorkspaceID == window->m_iWorkspaceID
|
||||||
&& g_pCompositor->m_pLastWindow->m_bIsMapped)
|
&& g_pCompositor->m_pLastWindow->m_bIsMapped)
|
||||||
{
|
{
|
||||||
opening_after = this->getNodeFromWindow(g_pCompositor->m_pLastWindow);
|
opening_after = this->getNodeFromWindow(g_pCompositor->m_pLastWindow);
|
||||||
} else {
|
} 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) {
|
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) {
|
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({
|
this->nodes.push_back({
|
||||||
|
@ -820,11 +836,25 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) {
|
||||||
auto iter2 = std::next(iter);
|
auto iter2 = std::next(iter);
|
||||||
children.insert(iter2, &node);
|
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();
|
node.markFocused();
|
||||||
opening_into->recalcSizePosRecursive();
|
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) {
|
void Hy3Layout::onWindowRemovedTiling(CWindow* window) {
|
||||||
|
@ -862,7 +892,6 @@ void Hy3Layout::onWindowRemovedTiling(CWindow* window) {
|
||||||
target_parent->recalcSizePosRecursive();
|
target_parent->recalcSizePosRecursive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) {
|
CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) {
|
||||||
|
@ -870,10 +899,8 @@ CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) {
|
||||||
if (node == nullptr) return nullptr;
|
if (node == nullptr) return nullptr;
|
||||||
|
|
||||||
switch (node->data.type) {
|
switch (node->data.type) {
|
||||||
case Hy3NodeData::Window:
|
case Hy3NodeData::Window: return node->data.as_window;
|
||||||
return node->data.as_window;
|
case Hy3NodeData::Group: return nullptr;
|
||||||
case Hy3NodeData::Group:
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -906,7 +933,8 @@ void Hy3Layout::recalculateMonitor(const int& monitor_id) {
|
||||||
|
|
||||||
if (top_node != nullptr) {
|
if (top_node != nullptr) {
|
||||||
top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft;
|
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();
|
top_node->recalcSizePosRecursive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -934,7 +962,8 @@ void Hy3Layout::recalculateMonitor(const int& monitor_id) {
|
||||||
|
|
||||||
if (top_node != nullptr) {
|
if (top_node != nullptr) {
|
||||||
top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft;
|
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();
|
top_node->recalcSizePosRecursive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -969,7 +998,12 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) {
|
||||||
.yExtent = mouse_offset.y > window->m_vSize.y / 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 {
|
} else {
|
||||||
this->drag_flags = {
|
this->drag_flags = {
|
||||||
.started = false,
|
.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);
|
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_left
|
||||||
const bool display_right = STICKS(node->position.x + node->size.x, monitor->vecPosition.x + monitor->vecSize.x - monitor->vecReservedBottomRight.x);
|
= STICKS(node->position.x, monitor->vecPosition.x + monitor->vecReservedTopLeft.x);
|
||||||
const bool display_top = STICKS(node->position.y, monitor->vecPosition.y + monitor->vecReservedTopLeft.y);
|
const bool display_right = STICKS(
|
||||||
const bool display_bottom = STICKS(node->position.y + node->size.y, monitor->vecPosition.y + monitor->vecSize.y - monitor->vecReservedBottomRight.y);
|
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;
|
Vector2D allowed_movement = delta;
|
||||||
if (display_left && display_right) allowed_movement.x = 0;
|
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;
|
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) {
|
while (inner_node->parent != nullptr) {
|
||||||
auto& group = inner_node->parent->data.as_group;
|
auto& group = inner_node->parent->data.as_group;
|
||||||
|
|
||||||
|
@ -1004,13 +1048,15 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) {
|
||||||
goto cont;
|
goto cont;
|
||||||
case Hy3GroupLayout::SplitH:
|
case Hy3GroupLayout::SplitH:
|
||||||
if ((this->drag_flags.xExtent && group.children.back() == inner_node)
|
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;
|
goto cont;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Hy3GroupLayout::SplitV:
|
case Hy3GroupLayout::SplitV:
|
||||||
if ((this->drag_flags.yExtent && group.children.back() == inner_node)
|
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;
|
goto cont;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1026,8 +1072,8 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) {
|
||||||
|
|
||||||
auto* outer_node = inner_node;
|
auto* outer_node = inner_node;
|
||||||
|
|
||||||
// break into parent groups when encountering a corner we're dragging in, a tab group,
|
// break into parent groups when encountering a corner we're dragging in, a
|
||||||
// or a layout matching the inner_parent.
|
// tab group, or a layout matching the inner_parent.
|
||||||
while (outer_node->parent != nullptr) {
|
while (outer_node->parent != nullptr) {
|
||||||
auto& group = outer_node->parent->data.as_group;
|
auto& group = outer_node->parent->data.as_group;
|
||||||
|
|
||||||
|
@ -1040,13 +1086,15 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) {
|
||||||
goto cont2;
|
goto cont2;
|
||||||
case Hy3GroupLayout::SplitH:
|
case Hy3GroupLayout::SplitH:
|
||||||
if ((this->drag_flags.xExtent && group.children.back() == outer_node)
|
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;
|
goto cont2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Hy3GroupLayout::SplitV:
|
case Hy3GroupLayout::SplitV:
|
||||||
if ((this->drag_flags.yExtent && group.children.back() == outer_node)
|
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;
|
goto cont2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1063,7 +1111,8 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) {
|
||||||
// adjust the inner node
|
// adjust the inner node
|
||||||
switch (inner_group.layout) {
|
switch (inner_group.layout) {
|
||||||
case Hy3GroupLayout::SplitH: {
|
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);
|
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;
|
neighbor->size_ratio -= ratio_mod;
|
||||||
} break;
|
} break;
|
||||||
case Hy3GroupLayout::SplitV: {
|
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);
|
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;
|
inner_node->size_ratio += ratio_mod;
|
||||||
neighbor->size_ratio -= ratio_mod;
|
neighbor->size_ratio -= ratio_mod;
|
||||||
} break;
|
} break;
|
||||||
case Hy3GroupLayout::Tabbed:
|
case Hy3GroupLayout::Tabbed: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inner_parent->recalcSizePosRecursive(*animate == 0);
|
inner_parent->recalcSizePosRecursive(*animate == 0);
|
||||||
|
@ -1112,7 +1161,8 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) {
|
||||||
// adjust the outer node
|
// adjust the outer node
|
||||||
switch (outer_group.layout) {
|
switch (outer_group.layout) {
|
||||||
case Hy3GroupLayout::SplitH: {
|
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);
|
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;
|
neighbor->size_ratio -= ratio_mod;
|
||||||
} break;
|
} break;
|
||||||
case Hy3GroupLayout::SplitV: {
|
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);
|
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;
|
outer_node->size_ratio += ratio_mod;
|
||||||
neighbor->size_ratio -= ratio_mod;
|
neighbor->size_ratio -= ratio_mod;
|
||||||
} break;
|
} break;
|
||||||
case Hy3GroupLayout::Tabbed:
|
case Hy3GroupLayout::Tabbed: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outer_parent->recalcSizePosRecursive(*animate == 0);
|
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 (!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 monitor = g_pCompositor->getMonitorFromID(window->m_iMonitorID);
|
||||||
const auto workspace = g_pCompositor->getWorkspaceByID(window->m_iWorkspaceID);
|
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;
|
layout = Hy3GroupLayout::SplitH;
|
||||||
node->parent->recalcSizePosRecursive();
|
node->parent->recalcSizePosRecursive();
|
||||||
break;
|
break;
|
||||||
case Hy3GroupLayout::Tabbed:
|
case Hy3GroupLayout::Tabbed: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1243,9 +1297,7 @@ std::any Hy3Layout::layoutMessage(SLayoutMessageHeader header, std::string conte
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
SWindowRenderLayoutHints Hy3Layout::requestRenderHints(CWindow* window) {
|
SWindowRenderLayoutHints Hy3Layout::requestRenderHints(CWindow* window) { return {}; }
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
void Hy3Layout::switchWindows(CWindow* pWindowA, CWindow* pWindowB) {
|
void Hy3Layout::switchWindows(CWindow* pWindowA, CWindow* pWindowB) {
|
||||||
// todo
|
// todo
|
||||||
|
@ -1255,9 +1307,7 @@ void Hy3Layout::alterSplitRatio(CWindow* pWindow, float delta, bool exact) {
|
||||||
// todo
|
// todo
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Hy3Layout::getLayoutName() {
|
std::string Hy3Layout::getLayoutName() { return "hy3"; }
|
||||||
return "hy3";
|
|
||||||
}
|
|
||||||
|
|
||||||
void Hy3Layout::replaceWindowDataWith(CWindow* from, CWindow* to) {
|
void Hy3Layout::replaceWindowDataWith(CWindow* from, CWindow* to) {
|
||||||
auto* node = this->getNodeFromWindow(from);
|
auto* node = this->getNodeFromWindow(from);
|
||||||
|
@ -1267,16 +1317,16 @@ void Hy3Layout::replaceWindowDataWith(CWindow* from, CWindow* to) {
|
||||||
this->applyNodeDataToWindow(node);
|
this->applyNodeDataToWindow(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<HOOK_CALLBACK_FN> renderHookPtr = std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::renderHook);
|
std::unique_ptr<HOOK_CALLBACK_FN> renderHookPtr
|
||||||
std::unique_ptr<HOOK_CALLBACK_FN> windowTitleHookPtr = std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::windowTitleHook);
|
= std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::renderHook);
|
||||||
std::unique_ptr<HOOK_CALLBACK_FN> tickHookPtr = std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::tickHook);
|
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() {
|
void Hy3Layout::onEnable() {
|
||||||
for (auto& window: g_pCompositor->m_vWindows) {
|
for (auto& window: g_pCompositor->m_vWindows) {
|
||||||
if (window->isHidden()
|
if (window->isHidden() || !window->m_bIsMapped || window->m_bFadingOut || window->m_bIsFloating)
|
||||||
|| !window->m_bIsMapped
|
|
||||||
|| window->m_bFadingOut
|
|
||||||
|| window->m_bIsFloating)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
this->onWindowCreatedTiling(window.get());
|
this->onWindowCreatedTiling(window.get());
|
||||||
|
@ -1328,9 +1378,8 @@ void Hy3Layout::makeOppositeGroupOn(Hy3Node* node) {
|
||||||
node->intoGroup(Hy3GroupLayout::SplitH);
|
node->intoGroup(Hy3GroupLayout::SplitH);
|
||||||
} else {
|
} else {
|
||||||
auto& group = node->parent->data.as_group;
|
auto& group = node->parent->data.as_group;
|
||||||
auto layout = group.layout == Hy3GroupLayout::SplitH
|
auto layout
|
||||||
? Hy3GroupLayout::SplitV
|
= group.layout == Hy3GroupLayout::SplitH ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH;
|
||||||
: Hy3GroupLayout::SplitH;
|
|
||||||
|
|
||||||
if (group.children.size() == 1) {
|
if (group.children.size() == 1) {
|
||||||
group.layout = layout;
|
group.layout = layout;
|
||||||
|
@ -1359,7 +1408,6 @@ void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction, bool once)
|
||||||
Debug::log(LOG, "ShiftWindow %p %d", node, direction);
|
Debug::log(LOG, "ShiftWindow %p %d", node, direction);
|
||||||
if (node == nullptr) return;
|
if (node == nullptr) return;
|
||||||
|
|
||||||
|
|
||||||
this->shiftOrGetFocus(*node, direction, true, once);
|
this->shiftOrGetFocus(*node, direction, true, once);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1376,13 +1424,15 @@ bool shiftMatchesLayout(Hy3GroupLayout layout, ShiftDirection 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_origin = &node;
|
||||||
auto* break_parent = break_origin->parent;
|
auto* break_parent = break_origin->parent;
|
||||||
|
|
||||||
auto has_broken_once = false;
|
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) {
|
while (true) {
|
||||||
if (break_parent == nullptr) return nullptr;
|
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 (once && shift && has_broken_once) break;
|
||||||
if (break_origin != &node) has_broken_once = true;
|
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)
|
// if this movement would break out of the group, continue the break loop
|
||||||
// otherwise break.
|
// (do not enter this if) otherwise break.
|
||||||
if ((has_broken_once && once && shift)
|
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;
|
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
|
// 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.
|
// 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
|
if (group.layout != Hy3GroupLayout::Tabbed && group.children.size() == 2
|
||||||
&& group.children.size() == 2
|
&& std::find(group.children.begin(), group.children.end(), &node) != group.children.end())
|
||||||
&& std::find(group.children.begin(), group.children.end(), &node) != group.children.end()
|
{
|
||||||
) {
|
|
||||||
group.layout = shiftIsVertical(direction) ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH;
|
group.layout = shiftIsVertical(direction) ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH;
|
||||||
} else {
|
} else {
|
||||||
// wrap the root group in another group
|
// wrap the root group in another group
|
||||||
|
@ -1477,11 +1529,17 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, boo
|
||||||
|
|
||||||
bool shift_after = false;
|
bool shift_after = false;
|
||||||
|
|
||||||
if (!shift && group_data.layout == Hy3GroupLayout::Tabbed && group_data.focused_child != nullptr) {
|
if (!shift && group_data.layout == Hy3GroupLayout::Tabbed
|
||||||
iter = std::find(group_data.children.begin(), group_data.children.end(), group_data.focused_child);
|
&& 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)) {
|
} else if (shiftMatchesLayout(group_data.layout, direction)) {
|
||||||
// if the group has the same orientation as movement pick the last/first child based
|
// if the group has the same orientation as movement pick the
|
||||||
// on movement direction
|
// last/first child based on movement direction
|
||||||
if (shiftIsForward(direction)) iter = group_data.children.begin();
|
if (shiftIsForward(direction)) iter = group_data.children.begin();
|
||||||
else {
|
else {
|
||||||
iter = std::prev(group_data.children.end());
|
iter = std::prev(group_data.children.end());
|
||||||
|
@ -1489,7 +1547,11 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, boo
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (group_data.focused_child != nullptr) {
|
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;
|
shift_after = true;
|
||||||
} else {
|
} else {
|
||||||
iter = group_data.children.begin();
|
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;
|
auto& group_data = target_group->data.as_group;
|
||||||
|
|
||||||
if (target_group == node.parent) {
|
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);
|
auto iter = std::find(group_data.children.begin(), group_data.children.end(), &node);
|
||||||
*iter = nullptr;
|
*iter = nullptr;
|
||||||
target_group->data.as_group.children.insert(insert, &node);
|
target_group->data.as_group.children.insert(insert, &node);
|
||||||
|
@ -1588,7 +1651,17 @@ void Hy3Layout::focusTab(int workspace) {
|
||||||
auto size = tab_group.size.vec();
|
auto size = tab_group.size.vec();
|
||||||
if (pos.x + size.x < mouse_pos.x || pos.y + size.y < mouse_pos.y) continue;
|
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);
|
auto* group = node->findNodeForTabGroup(tab_group);
|
||||||
if (group == nullptr) continue;
|
if (group == nullptr) continue;
|
||||||
|
|
||||||
|
@ -1600,7 +1673,9 @@ void Hy3Layout::focusTab(int workspace) {
|
||||||
for (auto& tab: tab_group.bar.entries) {
|
for (auto& tab: tab_group.bar.entries) {
|
||||||
if (node_iter == node_list.end()) break;
|
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();
|
(*node_iter)->focus();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1618,8 +1693,7 @@ bool Hy3Layout::shouldRenderSelected(CWindow* window) {
|
||||||
if (focused == nullptr) return false;
|
if (focused == nullptr) return false;
|
||||||
|
|
||||||
switch (focused->data.type) {
|
switch (focused->data.type) {
|
||||||
case Hy3NodeData::Window:
|
case Hy3NodeData::Window: return false;
|
||||||
return false;
|
|
||||||
case Hy3NodeData::Group:
|
case Hy3NodeData::Group:
|
||||||
auto* node = this->getNodeFromWindow(window);
|
auto* node = this->getNodeFromWindow(window);
|
||||||
if (node == nullptr) return false;
|
if (node == nullptr) return false;
|
||||||
|
@ -1642,10 +1716,10 @@ void Hy3Layout::renderHook(void*, std::any data) {
|
||||||
if (!rendering_normally) break;
|
if (!rendering_normally) break;
|
||||||
|
|
||||||
for (auto& entry: g_Hy3Layout->tab_groups) {
|
for (auto& entry: g_Hy3Layout->tab_groups) {
|
||||||
if (!entry.hidden
|
if (!entry.hidden && entry.target_window == g_pHyprOpenGL->m_pCurrentWindow
|
||||||
&& entry.target_window == g_pHyprOpenGL->m_pCurrentWindow
|
&& std::find(rendered_groups.begin(), rendered_groups.end(), &entry)
|
||||||
&& std::find(rendered_groups.begin(), rendered_groups.end(), &entry) == rendered_groups.end()
|
== rendered_groups.end())
|
||||||
) {
|
{
|
||||||
entry.renderTabBar();
|
entry.renderTabBar();
|
||||||
rendered_groups.push_back(&entry);
|
rendered_groups.push_back(&entry);
|
||||||
}
|
}
|
||||||
|
@ -1658,15 +1732,15 @@ void Hy3Layout::renderHook(void*, std::any data) {
|
||||||
for (auto& entry: g_Hy3Layout->tab_groups) {
|
for (auto& entry: g_Hy3Layout->tab_groups) {
|
||||||
if (!entry.hidden
|
if (!entry.hidden
|
||||||
&& entry.target_window->m_iMonitorID == g_pHyprOpenGL->m_RenderData.pMonitor->ID
|
&& 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();
|
entry.renderTabBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1708,15 +1782,9 @@ std::string Hy3Node::debugNode() {
|
||||||
buf << ") [";
|
buf << ") [";
|
||||||
|
|
||||||
switch (this->data.as_group.layout) {
|
switch (this->data.as_group.layout) {
|
||||||
case Hy3GroupLayout::SplitH:
|
case Hy3GroupLayout::SplitH: buf << "splith"; break;
|
||||||
buf << "splith";
|
case Hy3GroupLayout::SplitV: buf << "splitv"; break;
|
||||||
break;
|
case Hy3GroupLayout::Tabbed: buf << "tabs"; break;
|
||||||
case Hy3GroupLayout::SplitV:
|
|
||||||
buf << "splitv";
|
|
||||||
break;
|
|
||||||
case Hy3GroupLayout::Tabbed:
|
|
||||||
buf << "tabs";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buf << "] size ratio: ";
|
buf << "] size ratio: ";
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <hyprland/src/layout/IHyprLayout.hpp>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
struct Hy3Node;
|
struct Hy3Node;
|
||||||
#include "TabGroup.hpp"
|
#include "TabGroup.hpp"
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <hyprland/src/layout/IHyprLayout.hpp>
|
|
||||||
|
|
||||||
class Hy3Layout;
|
class Hy3Layout;
|
||||||
struct Hy3Node;
|
struct Hy3Node;
|
||||||
|
|
||||||
|
@ -98,7 +98,8 @@ struct Hy3Node {
|
||||||
// Attempt to swallow a group. returns true if swallowed
|
// Attempt to swallow a group. returns true if swallowed
|
||||||
static bool swallowGroups(Hy3Node*);
|
static bool swallowGroups(Hy3Node*);
|
||||||
// Remove this node from its parent, deleting the parent if it was
|
// 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();
|
Hy3Node* removeFromParentRecursive();
|
||||||
|
|
||||||
// Replace this node with a group, returning this node's new address.
|
// Replace this node with a group, returning this node's new address.
|
||||||
|
@ -149,6 +150,7 @@ public:
|
||||||
|
|
||||||
std::list<Hy3Node> nodes;
|
std::list<Hy3Node> nodes;
|
||||||
std::list<Hy3TabGroup> tab_groups;
|
std::list<Hy3TabGroup> tab_groups;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct {
|
struct {
|
||||||
bool started = false;
|
bool started = false;
|
||||||
|
@ -160,9 +162,9 @@ private:
|
||||||
Hy3Node* getNodeFromWindow(CWindow*);
|
Hy3Node* getNodeFromWindow(CWindow*);
|
||||||
void applyNodeDataToWindow(Hy3Node*, bool force = false);
|
void applyNodeDataToWindow(Hy3Node*, bool force = false);
|
||||||
|
|
||||||
// if shift is true, shift the window in the given direction, returning nullptr,
|
// if shift is true, shift the window in the given direction, returning
|
||||||
// if shift is false, return the window in the given direction or nullptr.
|
// nullptr, if shift is false, return the window in the given direction or
|
||||||
// if once is true, only one group will be broken out of / into
|
// nullptr. if once is true, only one group will be broken out of / into
|
||||||
Hy3Node* shiftOrGetFocus(Hy3Node&, ShiftDirection, bool, bool);
|
Hy3Node* shiftOrGetFocus(Hy3Node&, ShiftDirection, bool, bool);
|
||||||
|
|
||||||
friend struct Hy3Node;
|
friend struct Hy3Node;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "globals.hpp"
|
#include "globals.hpp"
|
||||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
|
||||||
#include <hyprland/src/Compositor.hpp>
|
#include <hyprland/src/Compositor.hpp>
|
||||||
|
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||||
|
|
||||||
namespace selection_hook {
|
namespace selection_hook {
|
||||||
inline CFunctionHook* g_LastSelectionHook = nullptr;
|
inline CFunctionHook* g_LastSelectionHook = nullptr;
|
||||||
|
@ -22,21 +22,36 @@ namespace selection_hook {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
static const auto decoUpdateCandidates = HyprlandAPI::findFunctionsByName(PHANDLE, "updateWindowAnimatedDecorationValues");
|
static const auto decoUpdateCandidates
|
||||||
|
= HyprlandAPI::findFunctionsByName(PHANDLE, "updateWindowAnimatedDecorationValues");
|
||||||
|
|
||||||
if (decoUpdateCandidates.size() != 1) {
|
if (decoUpdateCandidates.size() != 1) {
|
||||||
g_LastSelectionHook = nullptr;
|
g_LastSelectionHook = nullptr;
|
||||||
Debug::log(ERR, "Expected one matching function to hook for \"updateWindowAnimatedDecorationValues\", found %d", decoUpdateCandidates.size());
|
Debug::log(
|
||||||
HyprlandAPI::addNotificationV2(PHANDLE, {
|
ERR,
|
||||||
{"text", "Failed to load function hooks: \"updateWindowAnimatedDecorationValues\""},
|
"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},
|
{"time", (uint64_t) 10000},
|
||||||
{"color", CColor(1.0, 0.0, 0.0, 1.0)},
|
{"color", CColor(1.0, 0.0, 0.0, 1.0)},
|
||||||
{"icon", ICON_ERROR},
|
{"icon", ICON_ERROR},
|
||||||
});
|
}
|
||||||
|
);
|
||||||
return;
|
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() {
|
void enable() {
|
||||||
|
@ -50,4 +65,4 @@ namespace selection_hook {
|
||||||
g_LastSelectionHook->unhook();
|
g_LastSelectionHook->unhook();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace selection_hook
|
||||||
|
|
|
@ -4,4 +4,4 @@ namespace selection_hook {
|
||||||
void init();
|
void init();
|
||||||
void enable();
|
void enable();
|
||||||
void disable();
|
void disable();
|
||||||
}
|
} // namespace selection_hook
|
||||||
|
|
138
src/TabGroup.cpp
138
src/TabGroup.cpp
|
@ -1,18 +1,31 @@
|
||||||
#include "globals.hpp"
|
|
||||||
#include "TabGroup.hpp"
|
#include "TabGroup.hpp"
|
||||||
|
#include "globals.hpp"
|
||||||
#include "Hy3Layout.hpp"
|
#include "Hy3Layout.hpp"
|
||||||
|
|
||||||
#include <hyprland/src/Compositor.hpp>
|
|
||||||
#include <cairo/cairo.h>
|
#include <cairo/cairo.h>
|
||||||
#include <pango/pangocairo.h>
|
#include <hyprland/src/Compositor.hpp>
|
||||||
#include <hyprland/src/helpers/Color.hpp>
|
#include <hyprland/src/helpers/Color.hpp>
|
||||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||||
#include <hyprland/src/render/OpenGL.hpp>
|
#include <hyprland/src/render/OpenGL.hpp>
|
||||||
|
#include <pango/pangocairo.h>
|
||||||
#include <pixman.h>
|
#include <pixman.h>
|
||||||
|
|
||||||
Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_bar), node(node) {
|
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->offset.create(
|
||||||
this->width.create(AVARTYPE_FLOAT, -1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE);
|
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->offset.registerVar();
|
||||||
this->width.registerVar();
|
this->width.registerVar();
|
||||||
|
@ -26,9 +39,7 @@ Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_b
|
||||||
this->urgent = node.isUrgent();
|
this->urgent = node.isUrgent();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Hy3TabBarEntry::operator==(const Hy3Node& node) const {
|
bool Hy3TabBarEntry::operator==(const Hy3Node& node) const { return this->node == node; }
|
||||||
return this->node == node;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Hy3TabBarEntry::operator==(const Hy3TabBarEntry& entry) const {
|
bool Hy3TabBarEntry::operator==(const Hy3TabBarEntry& entry) const {
|
||||||
return this->node == entry.node;
|
return this->node == entry.node;
|
||||||
|
@ -56,6 +67,7 @@ void Hy3TabBarEntry::setWindowTitle(std::string title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
|
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* 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* 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;
|
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_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_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;
|
static const auto* col_text_inactive = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:col.text.inactive")->intValue;
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
auto width = box.width;
|
auto width = box.width;
|
||||||
auto height = box.height;
|
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));
|
auto rounding = std::min((double) *s_rounding, std::min(width * 0.5, height * 0.5));
|
||||||
|
|
||||||
if (this->texture.m_iTexID == 0
|
if (this->texture.m_iTexID == 0
|
||||||
|
// clang-format off
|
||||||
|| this->last_render.x != box.x
|
|| this->last_render.x != box.x
|
||||||
|| this->last_render.y != box.y
|
|| this->last_render.y != box.y
|
||||||
|| this->last_render.focused != this->focused
|
|| 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_active != *col_text_active
|
||||||
|| this->last_render.col_text_urgent != *col_text_urgent
|
|| this->last_render.col_text_urgent != *col_text_urgent
|
||||||
|| this->last_render.col_text_inactive != *col_text_inactive
|
|| this->last_render.col_text_inactive != *col_text_inactive
|
||||||
) {
|
// clang-format on
|
||||||
|
)
|
||||||
|
{
|
||||||
this->last_render.x = box.x;
|
this->last_render.x = box.x;
|
||||||
this->last_render.y = box.y;
|
this->last_render.y = box.y;
|
||||||
this->last_render.focused = this->focused;
|
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_line_to(cairo, width, height - rounding);
|
||||||
cairo_arc(cairo, width - rounding, height - rounding, rounding, 0.0, 90.0 * (M_PI / 180.0));
|
cairo_arc(cairo, width - rounding, height - rounding, rounding, 0.0, 90.0 * (M_PI / 180.0));
|
||||||
cairo_line_to(cairo, rounding, height);
|
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);
|
cairo_close_path(cairo);
|
||||||
|
|
||||||
// draw
|
// draw
|
||||||
|
@ -202,8 +225,22 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Hy3TabBar::Hy3TabBar() {
|
Hy3TabBar::Hy3TabBar() {
|
||||||
this->vertical_pos.create(AVARTYPE_FLOAT, 1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE);
|
this->vertical_pos.create(
|
||||||
this->fade_opacity.create(AVARTYPE_FLOAT, 0.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE);
|
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->vertical_pos.registerVar();
|
||||||
this->fade_opacity.registerVar();
|
this->fade_opacity.registerVar();
|
||||||
|
|
||||||
|
@ -256,12 +293,17 @@ void Hy3TabBar::updateNodeList(std::list<Hy3Node*>& nodes) {
|
||||||
// add missing entries, taking first from removed_entries
|
// add missing entries, taking first from removed_entries
|
||||||
while (node != nodes.end()) {
|
while (node != nodes.end()) {
|
||||||
if (entry == this->entries.end() || *entry != **node) {
|
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);
|
entry = std::next(entry);
|
||||||
continue;
|
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()) {
|
if (moved != removed_entries.end()) {
|
||||||
this->entries.splice(entry, this->entries, *moved);
|
this->entries.splice(entry, this->entries, *moved);
|
||||||
entry = *moved;
|
entry = *moved;
|
||||||
|
@ -279,7 +321,12 @@ void Hy3TabBar::updateNodeList(std::list<Hy3Node*>& nodes) {
|
||||||
// set stats from node data
|
// set stats from node data
|
||||||
auto* parent = (*node)->parent;
|
auto* parent = (*node)->parent;
|
||||||
auto& parent_group = parent->data.as_group;
|
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->setUrgent((*node)->isUrgent());
|
||||||
entry->setWindowTitle((*node)->getTitle());
|
entry->setWindowTitle((*node)->getTitle());
|
||||||
|
|
||||||
|
@ -323,7 +370,8 @@ void Hy3TabBar::updateAnimations(bool warp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->offset.goalf() != offset) entry->offset = offset;
|
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();
|
offset += entry->width.goalf();
|
||||||
|
@ -338,8 +386,20 @@ void Hy3TabBar::setSize(Vector2D size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Hy3TabGroup::Hy3TabGroup(Hy3Node& node) {
|
Hy3TabGroup::Hy3TabGroup(Hy3Node& node) {
|
||||||
this->pos.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE);
|
this->pos.create(
|
||||||
this->size.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE);
|
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->pos.registerVar();
|
||||||
this->size.registerVar();
|
this->size.registerVar();
|
||||||
|
|
||||||
|
@ -353,7 +413,8 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node) {
|
||||||
Debug::log(LOG, "updated tab bar for %p", &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_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
|
||||||
static const auto* gaps_out = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_out")->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 gaps = node.parent == nullptr ? *gaps_out : *gaps_in;
|
||||||
auto tpos = node.position + Vector2D(gaps, gaps) + node.gap_pos_offset;
|
auto tpos = node.position + Vector2D(gaps, gaps) + node.gap_pos_offset;
|
||||||
|
@ -372,7 +433,8 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hy3TabGroup::tick() {
|
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);
|
auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id);
|
||||||
|
|
||||||
if (!this->bar.destroying && workspace != nullptr) {
|
if (!this->bar.destroying && workspace != nullptr) {
|
||||||
|
@ -406,8 +468,10 @@ void Hy3TabGroup::tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hy3TabGroup::renderTabBar() {
|
void Hy3TabGroup::renderTabBar() {
|
||||||
static const auto* window_rounding = &HyprlandAPI::getConfigValue(PHANDLE, "decoration:rounding")->intValue;
|
static const auto* window_rounding
|
||||||
static const auto* enter_from_top = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:from_top")->intValue;
|
= &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;
|
static const auto* padding = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
|
||||||
|
|
||||||
auto* monitor = g_pHyprOpenGL->m_RenderData.pMonitor;
|
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));
|
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
|
if (scaled_pos.x > monitor_size.x || scaled_pos.y > monitor_size.y
|
||||||
|| scaled_pos.y > monitor_size.y
|
|| scaled_pos.x + scaled_size.x < 0 || scaled_pos.y + scaled_size.y < 0)
|
||||||
|| scaled_pos.x + scaled_size.x < 0
|
|
||||||
|| scaled_pos.y + scaled_size.y < 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!this->bar.damaged) {
|
if (!this->bar.damaged) {
|
||||||
pixman_region32 damage;
|
pixman_region32 damage;
|
||||||
pixman_region32_init(&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);
|
this->bar.damaged = pixman_region32_not_empty(&damage);
|
||||||
pixman_region32_fini(&damage);
|
pixman_region32_fini(&damage);
|
||||||
}
|
}
|
||||||
|
@ -465,7 +536,8 @@ void Hy3TabGroup::renderTabBar() {
|
||||||
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);
|
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);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
|
@ -475,10 +547,12 @@ void Hy3TabGroup::renderTabBar() {
|
||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
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) {
|
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};
|
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;
|
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) {
|
void findOverlappingWindows(Hy3Node& node, float height, std::vector<CWindow*>& windows) {
|
||||||
switch (node.data.type) {
|
switch (node.data.type) {
|
||||||
case Hy3NodeData::Window:
|
case Hy3NodeData::Window: windows.push_back(node.data.as_window); break;
|
||||||
windows.push_back(node.data.as_window);
|
|
||||||
break;
|
|
||||||
case Hy3NodeData::Group:
|
case Hy3NodeData::Group:
|
||||||
auto& group = node.data.as_group;
|
auto& group = node.data.as_group;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hyprland/src/helpers/AnimatedVariable.hpp>
|
#include <hyprland/src/Compositor.hpp>
|
||||||
#include <hyprland/src/helpers/Vector2D.hpp>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -10,7 +9,6 @@ class Hy3TabGroup;
|
||||||
class Hy3TabBar;
|
class Hy3TabBar;
|
||||||
|
|
||||||
#include "Hy3Layout.hpp"
|
#include "Hy3Layout.hpp"
|
||||||
#include <hyprland/src/render/Texture.hpp>
|
|
||||||
|
|
||||||
struct Hy3TabBarEntry {
|
struct Hy3TabBarEntry {
|
||||||
std::string window_title;
|
std::string window_title;
|
||||||
|
@ -68,6 +66,7 @@ public:
|
||||||
void setSize(Vector2D);
|
void setSize(Vector2D);
|
||||||
|
|
||||||
std::list<Hy3TabBarEntry> entries;
|
std::list<Hy3TabBarEntry> entries;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Hy3Node* focused_node = nullptr;
|
Hy3Node* focused_node = nullptr;
|
||||||
Vector2D size;
|
Vector2D size;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
|
||||||
#include "Hy3Layout.hpp"
|
#include "Hy3Layout.hpp"
|
||||||
|
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||||
|
|
||||||
inline HANDLE PHANDLE = nullptr;
|
inline HANDLE PHANDLE = nullptr;
|
||||||
inline std::unique_ptr<Hy3Layout> g_Hy3Layout;
|
inline std::unique_ptr<Hy3Layout> g_Hy3Layout;
|
||||||
|
|
60
src/main.cpp
60
src/main.cpp
|
@ -1,14 +1,12 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
|
||||||
#include <hyprland/src/Compositor.hpp>
|
#include <hyprland/src/Compositor.hpp>
|
||||||
|
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||||
|
|
||||||
#include "globals.hpp"
|
#include "globals.hpp"
|
||||||
#include "SelectionHook.hpp"
|
#include "SelectionHook.hpp"
|
||||||
|
|
||||||
APICALL EXPORT std::string PLUGIN_API_VERSION() {
|
APICALL EXPORT std::string PLUGIN_API_VERSION() { return HYPRLAND_API_VERSION; }
|
||||||
return HYPRLAND_API_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a window if a window action makes sense now
|
// return a window if a window action makes sense now
|
||||||
CWindow* window_for_action() {
|
CWindow* window_for_action() {
|
||||||
|
@ -112,22 +110,58 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||||
|
|
||||||
selection_hook::init();
|
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:group_inset", SConfigValue {.intValue = 10});
|
||||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:height", SConfigValue {.intValue = 15});
|
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:padding", SConfigValue {.intValue = 5});
|
||||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:from_top", SConfigValue {.intValue = 0});
|
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:rounding", SConfigValue {.intValue = 3});
|
||||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:render_text", SConfigValue {.intValue = 1});
|
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_height", SConfigValue {.intValue = 8});
|
||||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:text_padding", SConfigValue{.intValue = 3});
|
HyprlandAPI::addConfigValue(
|
||||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.active", SConfigValue{.intValue = 0xff32b4ff});
|
PHANDLE,
|
||||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.urgent", SConfigValue{.intValue = 0xffff4f4f});
|
"plugin:hy3:tabs:text_padding",
|
||||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.inactive", SConfigValue{.intValue = 0x80808080});
|
SConfigValue {.intValue = 3}
|
||||||
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(
|
||||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.text.inactive", SConfigValue{.intValue = 0xff000000});
|
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>();
|
g_Hy3Layout = std::make_unique<Hy3Layout>();
|
||||||
HyprlandAPI::addLayout(PHANDLE, "hy3", g_Hy3Layout.get());
|
HyprlandAPI::addLayout(PHANDLE, "hy3", g_Hy3Layout.get());
|
||||||
|
|
Loading…
Add table
Reference in a new issue