mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-15 18:53:40 +01:00
Visual indication for single-window groups & more
- Fix being able to create multiple levels of groups around a single window - Destroy single-member groups when they loose focus
This commit is contained in:
parent
b171721e66
commit
0e854287ff
3 changed files with 75 additions and 1 deletions
|
@ -20,7 +20,6 @@ pkg_check_modules(DEPS REQUIRED pixman-1 libdrm)
|
||||||
add_library(hy3 SHARED
|
add_library(hy3 SHARED
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
src/Hy3Layout.cpp
|
src/Hy3Layout.cpp
|
||||||
src/Hy3SpawnLocDecoration.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(hy3 PRIVATE
|
target_include_directories(hy3 PRIVATE
|
||||||
|
|
|
@ -103,6 +103,47 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* group = &this->data.as_group;
|
auto* group = &this->data.as_group;
|
||||||
|
|
||||||
|
if (group->children.size() == 1 && this->parent != nullptr) {
|
||||||
|
auto& child = group->children.front();
|
||||||
|
|
||||||
|
double distortOut;
|
||||||
|
double distortIn;
|
||||||
|
|
||||||
|
const auto* gaps_in = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
||||||
|
const auto* gaps_out = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
||||||
|
|
||||||
|
if (gaps_in > gaps_out) {
|
||||||
|
distortOut = *gaps_out - 1.0;
|
||||||
|
} else {
|
||||||
|
distortOut = *gaps_in - 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (distortOut < 0) distortOut = 0.0;
|
||||||
|
|
||||||
|
distortIn = *gaps_in * 2;
|
||||||
|
|
||||||
|
switch (group->layout) {
|
||||||
|
case Hy3GroupLayout::SplitH:
|
||||||
|
child->position.x = this->position.x - distortOut;
|
||||||
|
child->size.x = this->size.x - distortIn;
|
||||||
|
child->position.y = this->position.y;
|
||||||
|
child->size.y = this->size.y;
|
||||||
|
break;
|
||||||
|
case Hy3GroupLayout::SplitV:
|
||||||
|
child->position.y = this->position.y - distortOut;
|
||||||
|
child->size.y = this->size.y - distortIn;
|
||||||
|
child->position.x = this->position.x;
|
||||||
|
child->size.x = this->size.x;
|
||||||
|
case Hy3GroupLayout::Tabbed:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
child->recalcSizePosRecursive();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int constraint;
|
int constraint;
|
||||||
switch (group->layout) {
|
switch (group->layout) {
|
||||||
case Hy3GroupLayout::SplitH:
|
case Hy3GroupLayout::SplitH:
|
||||||
|
@ -371,6 +412,28 @@ void Hy3Layout::onWindowRemovedTiling(CWindow* window) {
|
||||||
if (parent != nullptr) parent->recalcSizePosRecursive();
|
if (parent != nullptr) parent->recalcSizePosRecursive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Hy3Layout::onWindowFocusChange(CWindow* window) {
|
||||||
|
Debug::log(LOG, "Switched windows from %p to %p", this->lastActiveWindow, window);
|
||||||
|
auto* node = this->getNodeFromWindow(this->lastActiveWindow);
|
||||||
|
|
||||||
|
while (node != nullptr
|
||||||
|
&& node->parent != nullptr
|
||||||
|
&& node->parent->parent != nullptr
|
||||||
|
&& node->parent->data.as_group.children.size() == 1)
|
||||||
|
{
|
||||||
|
auto parent = node->parent;
|
||||||
|
std::swap(parent->data, node->data);
|
||||||
|
this->nodes.remove(*node);
|
||||||
|
node = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node != nullptr) {
|
||||||
|
node->recalcSizePosRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
this->lastActiveWindow = window;
|
||||||
|
}
|
||||||
|
|
||||||
bool Hy3Layout::isWindowTiled(CWindow* window) {
|
bool Hy3Layout::isWindowTiled(CWindow* window) {
|
||||||
return this->getNodeFromWindow(window) != nullptr;
|
return this->getNodeFromWindow(window) != nullptr;
|
||||||
}
|
}
|
||||||
|
@ -402,6 +465,16 @@ std::any Hy3Layout::layoutMessage(SLayoutMessageHeader header, std::string conte
|
||||||
layout = Hy3GroupLayout::SplitV;
|
layout = Hy3GroupLayout::SplitV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node->parent != nullptr
|
||||||
|
&& node->parent->data.as_group.children.size() == 1
|
||||||
|
&& (node->parent->data.as_group.layout == Hy3GroupLayout::SplitH
|
||||||
|
|| node->parent->data.as_group.layout == Hy3GroupLayout::SplitV))
|
||||||
|
{
|
||||||
|
node->parent->data.as_group.layout = layout;
|
||||||
|
node->parent->recalcSizePosRecursive();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
Hy3NodeData node_data = Hy3NodeData(Hy3GroupData(layout));
|
Hy3NodeData node_data = Hy3NodeData(Hy3GroupData(layout));
|
||||||
std::swap(node->data, node_data);
|
std::swap(node->data, node_data);
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ class Hy3Layout: public IHyprLayout {
|
||||||
public:
|
public:
|
||||||
virtual void onWindowCreatedTiling(CWindow*);
|
virtual void onWindowCreatedTiling(CWindow*);
|
||||||
virtual void onWindowRemovedTiling(CWindow*);
|
virtual void onWindowRemovedTiling(CWindow*);
|
||||||
|
virtual void onWindowFocusChange(CWindow*);
|
||||||
virtual bool isWindowTiled(CWindow*);
|
virtual bool isWindowTiled(CWindow*);
|
||||||
virtual void recalculateMonitor(const int&);
|
virtual void recalculateMonitor(const int&);
|
||||||
virtual void recalculateWindow(CWindow*);
|
virtual void recalculateWindow(CWindow*);
|
||||||
|
@ -75,6 +76,7 @@ private:
|
||||||
// std::list is used over std::vector because it does not invalidate references
|
// std::list is used over std::vector because it does not invalidate references
|
||||||
// when mutated.
|
// when mutated.
|
||||||
std::list<Hy3Node> nodes;
|
std::list<Hy3Node> nodes;
|
||||||
|
CWindow* lastActiveWindow = nullptr;
|
||||||
|
|
||||||
int getWorkspaceNodeCount(const int&);
|
int getWorkspaceNodeCount(const int&);
|
||||||
Hy3Node* getNodeFromWindow(CWindow*);
|
Hy3Node* getNodeFromWindow(CWindow*);
|
||||||
|
|
Loading…
Add table
Reference in a new issue