Fix getNextWindowCandidate returning null if a group is focused

This commit is contained in:
outfoxxed 2023-07-31 20:38:58 -07:00
parent 84317d3d2a
commit f08c7ff2e4
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
4 changed files with 10 additions and 8 deletions

View file

@ -641,7 +641,7 @@ void Hy3Layout::alterSplitRatio(CWindow* pWindow, float delta, bool exact) {
std::string Hy3Layout::getLayoutName() { return "hy3"; }
CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) {
auto* node = this->getWorkspaceFocusedNode(window->m_iWorkspaceID);
auto* node = this->getWorkspaceFocusedNode(window->m_iWorkspaceID, true);
if (node == nullptr) return nullptr;
switch (node->data.type) {
@ -1051,10 +1051,10 @@ Hy3Node* Hy3Layout::getWorkspaceRootGroup(const int& workspace) {
return nullptr;
}
Hy3Node* Hy3Layout::getWorkspaceFocusedNode(const int& workspace) {
Hy3Node* Hy3Layout::getWorkspaceFocusedNode(const int& workspace, bool ignore_group_focus) {
auto* rootNode = this->getWorkspaceRootGroup(workspace);
if (rootNode == nullptr) return nullptr;
return rootNode->getFocusedNode();
return rootNode->getFocusedNode(ignore_group_focus);
}
void Hy3Layout::renderHook(void*, std::any data) {

View file

@ -88,7 +88,7 @@ public:
bool shouldRenderSelected(CWindow*);
Hy3Node* getWorkspaceRootGroup(const int& workspace);
Hy3Node* getWorkspaceFocusedNode(const int& workspace);
Hy3Node* getWorkspaceFocusedNode(const int& workspace, bool ignore_group_focus = false);
static void renderHook(void*, std::any);
static void windowGroupUrgentHook(void*, std::any);

View file

@ -191,14 +191,16 @@ void Hy3Node::raiseToTop() {
}
}
Hy3Node* Hy3Node::getFocusedNode() {
Hy3Node* Hy3Node::getFocusedNode(bool ignore_group_focus) {
switch (this->data.type) {
case Hy3NodeType::Window: return this;
case Hy3NodeType::Group:
if (this->data.as_group.focused_child == nullptr || this->data.as_group.group_focused) {
if (this->data.as_group.focused_child == nullptr
|| (!ignore_group_focus && this->data.as_group.group_focused))
{
return this;
} else {
return this->data.as_group.focused_child->getFocusedNode();
return this->data.as_group.focused_child->getFocusedNode(ignore_group_focus);
}
}
}

View file

@ -84,7 +84,7 @@ struct Hy3Node {
bool focusWindow();
void markFocused();
void raiseToTop();
Hy3Node* getFocusedNode();
Hy3Node* getFocusedNode(bool ignore_group_focus = false);
bool isIndirectlyFocused();
void recalcSizePosRecursive(bool no_animation = false);