mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-15 18:53:40 +01:00
Fix gaps config being read as an int (it is now a customtype)
Fixes breakage introduced in hyprland/ddf022d61c63fb36b4abba392682772690c06b5c
This commit is contained in:
parent
1a4847456b
commit
f5fc457d6b
5 changed files with 84 additions and 51 deletions
14
flake.lock
generated
14
flake.lock
generated
|
@ -10,11 +10,11 @@
|
||||||
"xdph": "xdph"
|
"xdph": "xdph"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1708272248,
|
"lastModified": 1708650152,
|
||||||
"narHash": "sha256-EMGPzNg9422NEoFJUfidRHPokX2+UWErX9qSghpfS/g=",
|
"narHash": "sha256-OZUS5FED7KKAPpNaJYQr4BPGXQzGrDFgkKVg9U2aZh8=",
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "Hyprland",
|
"repo": "Hyprland",
|
||||||
"rev": "301b48b74087cc59753ffa144b215540e6f82831",
|
"rev": "8c3613632a6ccebf9fb797ec756ecfce99514eec",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -131,18 +131,18 @@
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"host": "gitlab.freedesktop.org",
|
"host": "gitlab.freedesktop.org",
|
||||||
"lastModified": 1706359063,
|
"lastModified": 1708558866,
|
||||||
"narHash": "sha256-5HUTG0p+nCJv3cn73AmFHRZdfRV5AD5N43g8xAePSKM=",
|
"narHash": "sha256-Mz6hCtommq7RQfcPnxLINigO4RYSNt23HeJHC6mVmWI=",
|
||||||
"owner": "wlroots",
|
"owner": "wlroots",
|
||||||
"repo": "wlroots",
|
"repo": "wlroots",
|
||||||
"rev": "00b869c1a96f300a8f25da95d624524895e0ddf2",
|
"rev": "0cb091f1a2d345f37d2ee445f4ffd04f7f4ec9e5",
|
||||||
"type": "gitlab"
|
"type": "gitlab"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"host": "gitlab.freedesktop.org",
|
"host": "gitlab.freedesktop.org",
|
||||||
"owner": "wlroots",
|
"owner": "wlroots",
|
||||||
"repo": "wlroots",
|
"repo": "wlroots",
|
||||||
"rev": "00b869c1a96f300a8f25da95d624524895e0ddf2",
|
"rev": "0cb091f1a2d345f37d2ee445f4ffd04f7f4ec9e5",
|
||||||
"type": "gitlab"
|
"type": "gitlab"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -543,13 +543,21 @@ void Hy3Layout::fullscreenRequestForWindow(
|
||||||
// Copy of vaxry's massive hack
|
// Copy of vaxry's massive hack
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const auto gaps_in = ConfigValue<Hyprlang::INT>("general:gaps_in");
|
static const auto gaps_in = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_in");
|
||||||
static const auto gaps_out = ConfigValue<Hyprlang::INT>("general:gaps_out");
|
static const auto gaps_out = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_out");
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
int outer_gaps = -(*gaps_in - *gaps_out);
|
// clang-format off
|
||||||
auto gap_pos_offset = Vector2D(outer_gaps, outer_gaps);
|
auto gap_pos_offset = Vector2D(
|
||||||
auto gap_size_offset = Vector2D(outer_gaps * 2, outer_gaps * 2);
|
-(gaps_in->left - gaps_out->left),
|
||||||
|
-(gaps_in->top - gaps_out->top)
|
||||||
|
);
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
auto gap_size_offset = Vector2D(
|
||||||
|
-(gaps_in->left - gaps_out->left) + -(gaps_in->right - gaps_out->right),
|
||||||
|
-(gaps_in->top - gaps_out->top) + -(gaps_in->bottom - gaps_out->bottom)
|
||||||
|
);
|
||||||
|
|
||||||
Hy3Node fakeNode = {
|
Hy3Node fakeNode = {
|
||||||
.data = window,
|
.data = window,
|
||||||
|
@ -1049,8 +1057,8 @@ bottom:
|
||||||
|
|
||||||
Hy3Node* findTabBarAt(Hy3Node& node, Vector2D pos, Hy3Node** focused_node) {
|
Hy3Node* findTabBarAt(Hy3Node& node, Vector2D pos, Hy3Node** focused_node) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const auto gaps_in = ConfigValue<Hyprlang::INT>("general:gaps_in");
|
static const auto gaps_in = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_in");
|
||||||
static const auto gaps_out = ConfigValue<Hyprlang::INT>("general:gaps_out");
|
static const auto gaps_out = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_out");
|
||||||
static const auto tab_bar_height = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:height");
|
static const auto tab_bar_height = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:height");
|
||||||
static const auto tab_bar_padding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:padding");
|
static const auto tab_bar_padding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:padding");
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -1058,9 +1066,9 @@ Hy3Node* findTabBarAt(Hy3Node& node, Vector2D pos, Hy3Node** focused_node) {
|
||||||
auto inset = *tab_bar_height + *tab_bar_padding;
|
auto inset = *tab_bar_height + *tab_bar_padding;
|
||||||
|
|
||||||
if (node.parent == nullptr) {
|
if (node.parent == nullptr) {
|
||||||
inset += *gaps_out;
|
inset += gaps_out->left;
|
||||||
} else {
|
} else {
|
||||||
inset += *gaps_in;
|
inset += gaps_in->left;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.data.type == Hy3NodeType::Group) {
|
if (node.data.type == Hy3NodeType::Group) {
|
||||||
|
@ -1468,7 +1476,7 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const auto gaps_in = ConfigValue<Hyprlang::INT>("general:gaps_in");
|
static const auto gaps_in = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_in");
|
||||||
static const auto single_window_no_gaps = ConfigValue<Hyprlang::INT>("plugin:hy3:no_gaps_when_only");
|
static const auto single_window_no_gaps = ConfigValue<Hyprlang::INT>("plugin:hy3:no_gaps_when_only");
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -1517,9 +1525,10 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) {
|
||||||
auto calcPos = window->m_vPosition;
|
auto calcPos = window->m_vPosition;
|
||||||
auto calcSize = window->m_vSize;
|
auto calcSize = window->m_vSize;
|
||||||
|
|
||||||
auto gaps_offset_topleft = Vector2D(*gaps_in, *gaps_in) + node->gap_topleft_offset;
|
auto gaps_offset_topleft = Vector2D(gaps_in->left, gaps_in->top) + node->gap_topleft_offset;
|
||||||
auto gaps_offset_bottomright = Vector2D(*gaps_in * 2, *gaps_in * 2)
|
auto gaps_offset_bottomright =
|
||||||
+ node->gap_bottomright_offset + node->gap_topleft_offset;
|
Vector2D(gaps_in->left + gaps_in->right, gaps_in->top + gaps_in->bottom)
|
||||||
|
+ node->gap_bottomright_offset + node->gap_topleft_offset;
|
||||||
|
|
||||||
calcPos = calcPos + gaps_offset_topleft;
|
calcPos = calcPos + gaps_offset_topleft;
|
||||||
calcSize = calcSize - gaps_offset_bottomright;
|
calcSize = calcSize - gaps_offset_bottomright;
|
||||||
|
|
|
@ -270,13 +270,25 @@ Hy3Node& Hy3Node::getExpandActor() {
|
||||||
|
|
||||||
void Hy3Node::recalcSizePosRecursive(bool no_animation) {
|
void Hy3Node::recalcSizePosRecursive(bool no_animation) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const auto gaps_in = ConfigValue<Hyprlang::INT>("general:gaps_in");
|
static const auto gaps_in = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_in");
|
||||||
static const auto gaps_out = ConfigValue<Hyprlang::INT>("general:gaps_out");
|
static const auto gaps_out = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_out");
|
||||||
static const auto group_inset = ConfigValue<Hyprlang::INT>("plugin:hy3:group_inset");
|
static const auto group_inset = ConfigValue<Hyprlang::INT>("plugin:hy3:group_inset");
|
||||||
static const auto tab_bar_height = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:height");
|
static const auto tab_bar_height = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:height");
|
||||||
static const auto tab_bar_padding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:padding");
|
static const auto tab_bar_padding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:padding");
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
auto gap_topleft_offset = Vector2D(
|
||||||
|
-(gaps_in->left - gaps_out->left),
|
||||||
|
-(gaps_in->top - gaps_out->top)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto gap_bottomright_offset = Vector2D(
|
||||||
|
-(gaps_in->right - gaps_out->right),
|
||||||
|
-(gaps_in->bottom - gaps_out->bottom)
|
||||||
|
);
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
if (this->data.type == Hy3NodeType::Window && this->data.as_window->m_bIsFullscreen) {
|
if (this->data.type == Hy3NodeType::Window && this->data.as_window->m_bIsFullscreen) {
|
||||||
auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id);
|
auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id);
|
||||||
auto* monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID);
|
auto* monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID);
|
||||||
|
@ -287,11 +299,6 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int outer_gaps = -(*gaps_in - *gaps_out);
|
|
||||||
|
|
||||||
auto gap_topleft_offset = Vector2D(outer_gaps, outer_gaps);
|
|
||||||
auto gap_bottomright_offset = Vector2D(outer_gaps, outer_gaps);
|
|
||||||
|
|
||||||
Hy3Node fake_node = {
|
Hy3Node fake_node = {
|
||||||
.data = this->data.as_window,
|
.data = this->data.as_window,
|
||||||
.position = monitor->vecPosition + monitor->vecReservedTopLeft,
|
.position = monitor->vecPosition + monitor->vecReservedTopLeft,
|
||||||
|
@ -305,15 +312,7 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int outer_gaps = 0;
|
if (this->parent != nullptr) {
|
||||||
Vector2D gap_topleft_offset;
|
|
||||||
Vector2D gap_bottomright_offset;
|
|
||||||
if (this->parent == nullptr) {
|
|
||||||
outer_gaps = -(*gaps_in - *gaps_out);
|
|
||||||
|
|
||||||
gap_topleft_offset = Vector2D(outer_gaps, outer_gaps);
|
|
||||||
gap_bottomright_offset = Vector2D(outer_gaps, outer_gaps);
|
|
||||||
} else {
|
|
||||||
gap_topleft_offset = this->gap_topleft_offset;
|
gap_topleft_offset = this->gap_topleft_offset;
|
||||||
gap_bottomright_offset = this->gap_bottomright_offset;
|
gap_bottomright_offset = this->gap_bottomright_offset;
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,16 +452,19 @@ Hy3TabGroup::Hy3TabGroup(Hy3Node& node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) {
|
void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) {
|
||||||
static const auto gaps_in = ConfigValue<Hyprlang::INT>("general:gaps_in");
|
static const auto gaps_in = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_in");
|
||||||
static const auto gaps_out = ConfigValue<Hyprlang::INT>("general:gaps_out");
|
static const auto gaps_out = ConfigValue<Hyprlang::CUSTOMTYPE, CCssGapData>("general:gaps_out");
|
||||||
static const auto bar_height = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:height");
|
static const auto bar_height = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:height");
|
||||||
|
|
||||||
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_topleft_offset;
|
auto tpos = node.position + Vector2D(gaps->left, gaps->top) + node.gap_topleft_offset;
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
auto tsize = Vector2D(
|
auto tsize = Vector2D(
|
||||||
node.size.x - node.gap_bottomright_offset.x - node.gap_topleft_offset.x - gaps * 2,
|
node.size.x - node.gap_bottomright_offset.x - node.gap_topleft_offset.x - (gaps->left + gaps->right),
|
||||||
*bar_height
|
*bar_height
|
||||||
);
|
);
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
this->hidden = node.hidden;
|
this->hidden = node.hidden;
|
||||||
if (this->pos.goalv() != tpos) {
|
if (this->pos.goalv() != tpos) {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||||
#include <hyprlang.hpp>
|
#include <hyprlang.hpp>
|
||||||
|
|
||||||
|
@ -21,23 +23,43 @@ inline void errorNotif() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
class HyprlangUnspecifiedCustomType {};
|
||||||
|
|
||||||
|
// abandon hope all ye who enter here
|
||||||
|
template <typename T, typename V = HyprlangUnspecifiedCustomType>
|
||||||
class ConfigValue {
|
class ConfigValue {
|
||||||
public:
|
public:
|
||||||
ConfigValue(const std::string& option) {
|
ConfigValue(const std::string& option) {
|
||||||
this->static_data_ptr = HyprlandAPI::getConfigValue(PHANDLE, option)->getDataStaticPtr();
|
this->static_data_ptr = HyprlandAPI::getConfigValue(PHANDLE, option)->getDataStaticPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
const T& get() const { return *(T*) *this->static_data_ptr; }
|
template <typename U = T>
|
||||||
|
typename std::enable_if<std::is_same<U, Hyprlang::CUSTOMTYPE>::value, const V&>::type
|
||||||
|
operator*() const {
|
||||||
|
return *(V*) ((Hyprlang::CUSTOMTYPE*) *this->static_data_ptr)->getData();
|
||||||
|
}
|
||||||
|
|
||||||
const T& operator*() const { return this->get(); }
|
template <typename U = T>
|
||||||
|
typename std::enable_if<std::is_same<U, Hyprlang::CUSTOMTYPE>::value, const V*>::type
|
||||||
|
operator->() const {
|
||||||
|
return &**this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bullshit microptimization case for strings
|
||||||
|
template <typename U = T>
|
||||||
|
typename std::enable_if<std::is_same<U, Hyprlang::STRING>::value, const char*>::type
|
||||||
|
operator*() const {
|
||||||
|
return *(const char**) this->static_data_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U = T>
|
||||||
|
typename std::enable_if<
|
||||||
|
!std::is_same<U, Hyprlang::CUSTOMTYPE>::value && !std::is_same<U, Hyprlang::STRING>::value,
|
||||||
|
const T&>::type
|
||||||
|
operator*() const {
|
||||||
|
return *(T*) *this->static_data_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void* const* static_data_ptr;
|
void* const* static_data_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Bullshit undocumented microptimization case for strings
|
|
||||||
template <>
|
|
||||||
inline const Hyprlang::STRING& ConfigValue<Hyprlang::STRING>::get() const {
|
|
||||||
return *(char* const*) this->static_data_ptr;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue