Diff
1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
2index 3fbb063863c2902c68a8163a73c15010d766cfd6..97e41e823a8f2c00cf54a44f8d2c4cb74e9d5876 100644
3--- a/src/Hy3Layout.cpp
4+++ b/src/Hy3Layout.cpp
5@@ -426,6 +426,12 @@ Hy3Node* Hy3Layout::getWorkspaceRootGroup(const int& id) {
6 return nullptr;
7 }
8
9+Hy3Node* Hy3Layout::getWorkspaceFocusedNode(const int& id) {
10+ auto* rootNode = this->getWorkspaceRootGroup(id);
11+ if (rootNode == nullptr) return nullptr;
12+ return rootNode->getFocusedNode();
13+}
14+
15 void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) {
16 if (node->data.type != Hy3NodeData::Window) return;
17 CWindow* window = node->data.as_window;
18@@ -648,10 +654,7 @@ void Hy3Layout::onWindowRemovedTiling(CWindow* window) {
19 }
20
21 CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) {
22- auto* node = this->getWorkspaceRootGroup(window->m_iWorkspaceID);
23- if (node == nullptr) return nullptr;
24-
25- node = node->getFocusedNode();
26+ auto* node = this->getWorkspaceFocusedNode(window->m_iWorkspaceID);
27
28 switch (node->data.type) {
29 case Hy3NodeData::Window:
30@@ -1057,7 +1060,7 @@ void Hy3Layout::onDisable() {
31 }
32
33 void Hy3Layout::makeGroupOn(int workspace, Hy3GroupLayout layout) {
34- auto* node = this->getWorkspaceRootGroup(workspace)->getFocusedNode();
35+ auto* node = this->getWorkspaceFocusedNode(workspace);
36 if (node == nullptr) return;
37
38 if (node->parent->data.as_group.children.size() == 1
39@@ -1087,9 +1090,7 @@ void Hy3Layout::makeGroupOn(int workspace, Hy3GroupLayout layout) {
40 Hy3Node* shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, bool shift);
41
42 void Hy3Layout::shiftFocus(int workspace, ShiftDirection direction) {
43- auto* root = this->getWorkspaceRootGroup(workspace);
44- if (root == nullptr) return;
45- auto* node = root->getFocusedNode();
46+ auto* node = this->getWorkspaceFocusedNode(workspace);
47 Debug::log(LOG, "ShiftFocus %p %d", node, direction);
48 if (node == nullptr) return;
49
50@@ -1100,9 +1101,7 @@ void Hy3Layout::shiftFocus(int workspace, ShiftDirection direction) {
51 }
52
53 void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction) {
54- auto* root = this->getWorkspaceRootGroup(workspace);
55- if (root == nullptr) return;
56- auto* node = root->getFocusedNode();
57+ auto* node = this->getWorkspaceFocusedNode(workspace);
58 Debug::log(LOG, "ShiftWindow %p %d", node, direction);
59 if (node == nullptr) return;
60
61@@ -1279,9 +1278,8 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, boo
62 }
63
64 void Hy3Layout::raiseFocus(int workspace) {
65- auto* root = this->getWorkspaceRootGroup(workspace);
66- if (root == nullptr) return;
67- auto* node = root->getFocusedNode();
68+ auto* node = this->getWorkspaceFocusedNode(workspace);
69+ if (node == nullptr) return;
70
71 if (node->parent != nullptr && node->parent->parent != nullptr) {
72 node->parent->focus();
73diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp
74index 6e9dc3c8013016ab98ccde038e431b2e22126954..a40e8033f98761d7e26a029ef1f87ee8ed90d8cf 100644
75--- a/src/Hy3Layout.hpp
76+++ b/src/Hy3Layout.hpp
77@@ -118,6 +118,7 @@ public:
78 bool shouldRenderSelected(CWindow*);
79
80 Hy3Node* getWorkspaceRootGroup(const int&);
81+ Hy3Node* getWorkspaceFocusedNode(const int&);
82
83 std::list<Hy3Node> nodes;
84 private: