Add clang-format and editorconfig

This commit is contained in:
outfoxxed 2023-06-07 03:22:17 -07:00
parent 45fb1698c1
commit 37e3f273d1
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
11 changed files with 628 additions and 355 deletions

72
.clang-format Normal file
View 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
View 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

View file

@ -42,7 +42,7 @@
name = "hy3";
nativeBuildInputs = with pkgs; [
clang-tools_15
clang-tools_16
bear
];

File diff suppressed because it is too large Load diff

View file

@ -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;
@ -58,7 +58,7 @@ public:
Hy3NodeData& operator=(CWindow*);
Hy3NodeData& operator=(Hy3GroupLayout);
//private: - I give up, C++ wins
// private: - I give up, C++ wins
Hy3NodeData(Hy3GroupData);
Hy3NodeData(Hy3NodeData&&);
Hy3NodeData& operator=(Hy3NodeData&&);
@ -98,7 +98,8 @@ struct Hy3Node {
// Attempt to swallow a group. returns true if swallowed
static bool swallowGroups(Hy3Node*);
// Remove this node from its parent, deleting the parent if it was
// the only child and recursing if the parent was the only child of it's parent.
// the only child and recursing if the parent was the only child of it's
// parent.
Hy3Node* removeFromParentRecursive();
// Replace this node with a group, returning this node's new address.
@ -149,6 +150,7 @@ public:
std::list<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;

View file

@ -1,53 +1,68 @@
#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;
inline CFunctionHook* g_LastSelectionHook = nullptr;
void hook_updateDecos(void* thisptr, CWindow* window) {
bool explicitly_selected = g_Hy3Layout->shouldRenderSelected(window);
Debug::log(LOG, "update decos for %p - selected: %d", window, explicitly_selected);
void hook_updateDecos(void* thisptr, CWindow* window) {
bool explicitly_selected = g_Hy3Layout->shouldRenderSelected(window);
Debug::log(LOG, "update decos for %p - selected: %d", window, explicitly_selected);
auto* lastWindow = g_pCompositor->m_pLastWindow;
if (explicitly_selected) {
g_pCompositor->m_pLastWindow = window;
}
((void (*)(void*, CWindow*)) g_LastSelectionHook->m_pOriginal)(thisptr, window);
if (explicitly_selected) {
g_pCompositor->m_pLastWindow = lastWindow;
}
auto* lastWindow = g_pCompositor->m_pLastWindow;
if (explicitly_selected) {
g_pCompositor->m_pLastWindow = window;
}
void init() {
static const auto decoUpdateCandidates = HyprlandAPI::findFunctionsByName(PHANDLE, "updateWindowAnimatedDecorationValues");
((void (*)(void*, CWindow*)) g_LastSelectionHook->m_pOriginal)(thisptr, window);
if (decoUpdateCandidates.size() != 1) {
g_LastSelectionHook = nullptr;
Debug::log(ERR, "Expected one matching function to hook for \"updateWindowAnimatedDecorationValues\", found %d", decoUpdateCandidates.size());
HyprlandAPI::addNotificationV2(PHANDLE, {
{"text", "Failed to load function hooks: \"updateWindowAnimatedDecorationValues\""},
{"time", (uint64_t)10000},
{"color", CColor(1.0, 0.0, 0.0, 1.0)},
{"icon", ICON_ERROR},
});
return;
}
g_LastSelectionHook = HyprlandAPI::createFunctionHook(PHANDLE, decoUpdateCandidates[0].address, (void*)&hook_updateDecos);
}
void enable() {
if (g_LastSelectionHook != nullptr) {
g_LastSelectionHook->hook();
}
}
void disable() {
if (g_LastSelectionHook != nullptr) {
g_LastSelectionHook->unhook();
}
if (explicitly_selected) {
g_pCompositor->m_pLastWindow = lastWindow;
}
}
void init() {
static const auto decoUpdateCandidates
= HyprlandAPI::findFunctionsByName(PHANDLE, "updateWindowAnimatedDecorationValues");
if (decoUpdateCandidates.size() != 1) {
g_LastSelectionHook = nullptr;
Debug::log(
ERR,
"Expected one matching function to hook for "
"\"updateWindowAnimatedDecorationValues\", found %d",
decoUpdateCandidates.size()
);
HyprlandAPI::addNotificationV2(
PHANDLE,
{
{"text",
"Failed to load function hooks: "
"\"updateWindowAnimatedDecorationValues\""},
{"time", (uint64_t) 10000},
{"color", CColor(1.0, 0.0, 0.0, 1.0)},
{"icon", ICON_ERROR},
}
);
return;
}
g_LastSelectionHook = HyprlandAPI::createFunctionHook(
PHANDLE,
decoUpdateCandidates[0].address,
(void*) &hook_updateDecos
);
}
void enable() {
if (g_LastSelectionHook != nullptr) {
g_LastSelectionHook->hook();
}
}
void disable() {
if (g_LastSelectionHook != nullptr) {
g_LastSelectionHook->unhook();
}
}
} // namespace selection_hook

View file

@ -1,7 +1,7 @@
#pragma once
namespace selection_hook {
void init();
void enable();
void disable();
}
void init();
void enable();
void disable();
} // namespace selection_hook

View file

@ -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,22 +87,25 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
auto rounding = std::min((double) *s_rounding, std::min(width * 0.5, height * 0.5));
if (this->texture.m_iTexID == 0
// clang-format off
|| this->last_render.x != box.x
|| this->last_render.y != box.y
|| this->last_render.focused != this->focused
|| this->last_render.focused != this->focused
|| this->last_render.urgent != this->urgent
|| this->last_render.window_title != this->window_title
|| this->last_render.rounding != rounding
|| this->last_render.window_title != this->window_title
|| this->last_render.rounding != rounding
|| this->last_render.text_font != *text_font
|| this->last_render.text_height != *text_height
|| this->last_render.text_padding != *text_padding
|| this->last_render.col_active != *col_active
|| this->last_render.text_height != *text_height
|| this->last_render.text_padding != *text_padding
|| this->last_render.col_active != *col_active
|| this->last_render.col_urgent != *col_urgent
|| this->last_render.col_inactive != *col_inactive
|| this->last_render.col_text_active != *col_text_active
|| this->last_render.col_text_urgent != *col_text_urgent
|| this->last_render.col_text_inactive != *col_text_inactive
) {
|| this->last_render.col_inactive != *col_inactive
|| this->last_render.col_text_active != *col_text_active
|| this->last_render.col_text_urgent != *col_text_urgent
|| this->last_render.col_text_inactive != *col_text_inactive
// clang-format on
)
{
this->last_render.x = box.x;
this->last_render.y = box.y;
this->last_render.focused = this->focused;
@ -135,7 +151,14 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
cairo_line_to(cairo, width, height - rounding);
cairo_arc(cairo, width - rounding, height - rounding, rounding, 0.0, 90.0 * (M_PI / 180.0));
cairo_line_to(cairo, rounding, height);
cairo_arc(cairo, rounding, height - rounding, rounding, -270.0 * (M_PI / 180.0), -180.0 * (M_PI / 180.0));
cairo_arc(
cairo,
rounding,
height - rounding,
rounding,
-270.0 * (M_PI / 180.0),
-180.0 * (M_PI / 180.0)
);
cairo_close_path(cairo);
// draw
@ -171,7 +194,7 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
int layout_width, layout_height;
pango_layout_get_size(layout, &layout_width, &layout_height);
auto y_offset = (height / 2.0) - (((double)layout_height / PANGO_SCALE) / 2.0);
auto y_offset = (height / 2.0) - (((double) layout_height / PANGO_SCALE) / 2.0);
cairo_move_to(cairo, padding, y_offset);
pango_cairo_show_layout(cairo, layout);
g_object_unref(layout);
@ -187,10 +210,10 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#ifdef GLES32
#ifdef GLES32
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
#endif
#endif
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
@ -202,8 +225,22 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
}
Hy3TabBar::Hy3TabBar() {
this->vertical_pos.create(AVARTYPE_FLOAT, 1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE);
this->fade_opacity.create(AVARTYPE_FLOAT, 0.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), nullptr, AVARDAMAGE_NONE);
this->vertical_pos.create(
AVARTYPE_FLOAT,
1.0f,
g_pConfigManager->getAnimationPropertyConfig("windowsMove"),
nullptr,
AVARDAMAGE_NONE
);
this->fade_opacity.create(
AVARTYPE_FLOAT,
0.0f,
g_pConfigManager->getAnimationPropertyConfig("windowsMove"),
nullptr,
AVARDAMAGE_NONE
);
this->vertical_pos.registerVar();
this->fade_opacity.registerVar();
@ -242,7 +279,7 @@ void Hy3TabBar::updateNodeList(std::list<Hy3Node*>& nodes) {
entry = std::next(entry);
}
exitloop:
exitloop:
// move any extra entries to removed_entries
while (entry != this->entries.end()) {
@ -256,12 +293,17 @@ void Hy3TabBar::updateNodeList(std::list<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) {
@ -388,7 +450,7 @@ void Hy3TabGroup::tick() {
pos.y += (this->bar.vertical_pos.fl() * size.y) * (*enter_from_top ? -1 : 1);
if (this->last_pos != pos || this->last_size != size) {
wlr_box damage_box = { this->last_pos.x, this->last_pos.y, this->last_size.x, this->last_size.y };
wlr_box damage_box = {this->last_pos.x, this->last_pos.y, this->last_size.x, this->last_size.y};
g_pHyprRenderer->damageBox(&damage_box);
this->bar.damaged = true;
@ -397,7 +459,7 @@ void Hy3TabGroup::tick() {
}
if (this->bar.destroy || this->bar.dirty) {
wlr_box damage_box = { pos.x, pos.y, size.x, size.y };
wlr_box damage_box = {pos.x, pos.y, size.x, size.y};
g_pHyprRenderer->damageBox(&damage_box);
this->bar.damaged = true;
@ -406,8 +468,10 @@ void Hy3TabGroup::tick() {
}
void Hy3TabGroup::renderTabBar() {
static const auto* window_rounding = &HyprlandAPI::getConfigValue(PHANDLE, "decoration:rounding")->intValue;
static const auto* enter_from_top = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:from_top")->intValue;
static const auto* window_rounding
= &HyprlandAPI::getConfigValue(PHANDLE, "decoration:rounding")->intValue;
static const auto* enter_from_top
= &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:from_top")->intValue;
static const auto* padding = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
auto* monitor = g_pHyprOpenGL->m_RenderData.pMonitor;
@ -425,18 +489,25 @@ void Hy3TabGroup::renderTabBar() {
auto scaled_pos = Vector2D(std::round(pos.x * scale), std::round(pos.y * scale));
auto scaled_size = Vector2D(std::round(size.x * scale), std::round(size.y * scale));
wlr_box box = { scaled_pos.x, scaled_pos.y, scaled_size.x, scaled_size.y };
wlr_box box = {scaled_pos.x, scaled_pos.y, scaled_size.x, scaled_size.y};
if (scaled_pos.x > monitor_size.x
|| scaled_pos.y > monitor_size.y
|| scaled_pos.x + scaled_size.x < 0
|| scaled_pos.y + scaled_size.y < 0)
if (scaled_pos.x > monitor_size.x || scaled_pos.y > monitor_size.y
|| scaled_pos.x + scaled_size.x < 0 || scaled_pos.y + scaled_size.y < 0)
return;
if (!this->bar.damaged) {
pixman_region32 damage;
pixman_region32_init(&damage);
pixman_region32_intersect_rect(&damage, g_pHyprOpenGL->m_RenderData.pDamage, box.x, box.y, box.width, box.height);
pixman_region32_intersect_rect(
&damage,
g_pHyprOpenGL->m_RenderData.pDamage,
box.x,
box.y,
box.width,
box.height
);
this->bar.damaged = pixman_region32_not_empty(&damage);
pixman_region32_fini(&damage);
}
@ -462,10 +533,11 @@ void Hy3TabGroup::renderTabBar() {
auto wpos = window->m_vRealPosition.vec() - monitor->vecPosition;
auto wsize = window->m_vRealSize.vec();
wlr_box window_box = { wpos.x, wpos.y, wsize.x, wsize.y };
wlr_box window_box = {wpos.x, wpos.y, wsize.x, wsize.y};
scaleBox(&window_box, scale);
if (window_box.width > 0 && window_box.height > 0) g_pHyprOpenGL->renderRect(&window_box, CColor(0, 0, 0, 0), *window_rounding);
if (window_box.width > 0 && window_box.height > 0)
g_pHyprOpenGL->renderRect(&window_box, CColor(0, 0, 0, 0), *window_rounding);
}
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@ -475,18 +547,20 @@ void Hy3TabGroup::renderTabBar() {
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
}
auto fade_opacity = this->bar.fade_opacity.fl() * (workspace == nullptr ? 1.0 : workspace->m_fAlpha.fl());
auto fade_opacity
= this->bar.fade_opacity.fl() * (workspace == nullptr ? 1.0 : workspace->m_fAlpha.fl());
auto render_entry = [&](Hy3TabBarEntry& entry) {
Vector2D entry_pos = { (pos.x + (entry.offset.fl() * size.x) + (*padding * 0.5)) * scale, scaled_pos.y };
Vector2D entry_size = { ((entry.width.fl() * size.x) - *padding) * scale, scaled_size.y };
Vector2D entry_pos
= {(pos.x + (entry.offset.fl() * size.x) + (*padding * 0.5)) * scale, scaled_pos.y};
Vector2D entry_size = {((entry.width.fl() * size.x) - *padding) * scale, scaled_size.y};
if (entry_size.x < 0 || entry_size.y < 0 || fade_opacity == 0.0) return;
wlr_box box = {
entry_pos.x,
entry_pos.y,
entry_size.x,
entry_size.y,
entry_pos.x,
entry_pos.y,
entry_size.x,
entry_size.y,
};
entry.prepareTexture(scale, box);
@ -514,9 +588,7 @@ void Hy3TabGroup::renderTabBar() {
void findOverlappingWindows(Hy3Node& node, float height, std::vector<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;

View file

@ -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;
@ -18,7 +16,7 @@ struct Hy3TabBarEntry {
bool urgent = false;
CTexture texture;
CAnimatedVariable offset; // offset 0, 0.0-1.0 of total bar
CAnimatedVariable width; // 0.0-1.0 of total bar
CAnimatedVariable width; // 0.0-1.0 of total bar
Hy3TabBar& tab_bar;
Hy3Node& node; // only used for comparioson. do not deref.
@ -68,6 +66,7 @@ public:
void setSize(Vector2D);
std::list<Hy3TabBarEntry> entries;
private:
Hy3Node* focused_node = nullptr;
Vector2D size;

View file

@ -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;

View file

@ -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:group_inset", SConfigValue{.intValue = 10});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:height", SConfigValue{.intValue = 15});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:padding", SConfigValue{.intValue = 5});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:from_top", SConfigValue{.intValue = 0});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:rounding", SConfigValue{.intValue = 3});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:render_text", SConfigValue{.intValue = 1});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:text_font", SConfigValue{.strValue = "Sans"});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:text_height", SConfigValue{.intValue = 8});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:text_padding", SConfigValue{.intValue = 3});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.active", SConfigValue{.intValue = 0xff32b4ff});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.urgent", SConfigValue{.intValue = 0xffff4f4f});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.inactive", SConfigValue{.intValue = 0x80808080});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.text.active", SConfigValue{.intValue = 0xff000000});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.text.urgent", SConfigValue{.intValue = 0xff000000});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.text.inactive", SConfigValue{.intValue = 0xff000000});
HyprlandAPI::addConfigValue(
PHANDLE,
"plugin:hy3:no_gaps_when_only",
SConfigValue {.intValue = 0}
);
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:group_inset", SConfigValue {.intValue = 10});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:height", SConfigValue {.intValue = 15});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:padding", SConfigValue {.intValue = 5});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:from_top", SConfigValue {.intValue = 0});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:rounding", SConfigValue {.intValue = 3});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:render_text", SConfigValue {.intValue = 1});
HyprlandAPI::addConfigValue(
PHANDLE,
"plugin:hy3:tabs:text_font",
SConfigValue {.strValue = "Sans"}
);
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:text_height", SConfigValue {.intValue = 8});
HyprlandAPI::addConfigValue(
PHANDLE,
"plugin:hy3:tabs:text_padding",
SConfigValue {.intValue = 3}
);
HyprlandAPI::addConfigValue(
PHANDLE,
"plugin:hy3:tabs:col.active",
SConfigValue {.intValue = 0xff32b4ff}
);
HyprlandAPI::addConfigValue(
PHANDLE,
"plugin:hy3:tabs:col.urgent",
SConfigValue {.intValue = 0xffff4f4f}
);
HyprlandAPI::addConfigValue(
PHANDLE,
"plugin:hy3:tabs:col.inactive",
SConfigValue {.intValue = 0x80808080}
);
HyprlandAPI::addConfigValue(
PHANDLE,
"plugin:hy3:tabs:col.text.active",
SConfigValue {.intValue = 0xff000000}
);
HyprlandAPI::addConfigValue(
PHANDLE,
"plugin:hy3:tabs:col.text.urgent",
SConfigValue {.intValue = 0xff000000}
);
HyprlandAPI::addConfigValue(
PHANDLE,
"plugin:hy3:tabs:col.text.inactive",
SConfigValue {.intValue = 0xff000000}
);
g_Hy3Layout = std::make_unique<Hy3Layout>();
HyprlandAPI::addLayout(PHANDLE, "hy3", g_Hy3Layout.get());