76551a40ef55781413ef3827b76f91fe1d0a21f3

Author
outfoxxed <outfoxxed@outfoxxed.me>
Committer
outfoxxed <outfoxxed@outfoxxed.me>
Date

Message

Hide inactive tab group windows

Diff

This diff is truncated to protect this page.

  1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
  2index 7371b891e510a5051983a521fb3173465f318f82..bbe12d6dc62cac3c9baeeb7f750a1eae93db42be 100644
  3--- a/src/Hy3Layout.cpp
  4+++ b/src/Hy3Layout.cpp
  5@@ -130,10 +130,13 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
  6 			errorNotif();
  7 		}
  8 
  9+		if (child->data.type == Hy3NodeData::Window) {
 10+			child->data.as_window->setHidden(false);
 11+		}
 12+
 13 		double distort_out;
 14 		double distort_in;
 15 
 16-
 17 		if (gaps_in > gaps_out) {
 18 			distort_out = *gaps_out - 1.0;
 19 		} else {
 20@@ -187,7 +190,13 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
 21 
 22 	double offset = 0;
 23 
 24-	for(auto child: group->children) {
 25+	if (group->layout == Hy3GroupLayout::Tabbed && group->focused_child != nullptr) {
 26+		group->focused_child->setHidden(false);
 27+	}
 28+
 29+	bool hid_focused = false;
 30+
 31+	for(auto* child: group->children) {
 32 		switch (group->layout) {
 33 		case Hy3GroupLayout::SplitH:
 34 			child->position.x = this->position.x + offset;
 35@@ -195,7 +204,8 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
 36 			offset += child->size.x;
 37 			child->position.y = this->position.y;
 38 			child->size.y = this->size.y;
 39-			//child->setHidden(false);
 40+			child->setHidden(false);
 41+			child->recalcSizePosRecursive(force);
 42 			break;
 43 		case Hy3GroupLayout::SplitV:
 44 			child->position.y = this->position.y + offset;
 45@@ -203,19 +213,22 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
 46 			offset += child->size.y;
 47 			child->position.x = this->position.x;
 48 			child->size.x = this->size.x;
 49-			//child->setHidden(false);
 50+			child->setHidden(false);
 51+			child->recalcSizePosRecursive(force);
 52 			break;
 53 		case Hy3GroupLayout::Tabbed:
 54 			child->position.y = this->position.y + tab_height_offset;
 55 			child->size.y = this->size.y - tab_height_offset;
 56 			child->position.x = this->position.x;
 57 			child->size.x = this->size.x;
 58-			//child->setHidden(group->focused_child != child);
 59+			bool hidden = group->focused_child != child;
 60+			Debug::log(LOG, "set %p hidden: %d", child, hidden);
 61+			if (child->isIndirectlyFocused()) hid_focused = true;
 62+			child->setHidden(hidden);
 63+			if (!hidden) child->recalcSizePosRecursive(force);
 64 			break;
 65-		}
 66-
 67-		child->recalcSizePosRecursive(force);
 68-	}
 69+    }
 70+  }
 71 
 72 	this->updateTabBar();
 73 }
 74@@ -332,6 +345,7 @@ void Hy3Node::focus() {
 75 
 76 	switch (this->data.type) {
 77 	case Hy3NodeData::Window:
 78+		this->data.as_window->setHidden(false);
 79 		g_pCompositor->focusWindow(this->data.as_window);
 80 		break;
 81 	case Hy3NodeData::Group:
 82@@ -341,6 +355,28 @@ void Hy3Node::focus() {
 83 	}
 84 }
 85 
 86+bool Hy3Node::focusWindow() {
 87+	switch (this->data.type) {
 88+	case Hy3NodeData::Window:
 89+	  this->markFocused();
 90+		g_pCompositor->focusWindow(this->data.as_window);
 91+
 92+		return true;
 93+	case Hy3NodeData::Group:
 94+		if (this->data.as_group.layout == Hy3GroupLayout::Tabbed) {
 95+			if (this->data.as_group.focused_child != nullptr) {
 96+				return this->data.as_group.focused_child->focusWindow();
 97+			}
 98+		} else {
 99+			for (auto* node: this->data.as_group.children) {
100+				if (node->focusWindow()) break;
101+			}
102+		}
103+
104+		return false;
105diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp
106index d065d06d4b3726400694231cbf515e7206185e5b..515875a77c49b7f77c1c94c26f0489080bd4c962 100644
107--- a/src/Hy3Layout.hpp
108+++ b/src/Hy3Layout.hpp
109@@ -78,6 +78,7 @@ struct Hy3Node {
110 	std::string debugNode();
111 	void markFocused();
112 	void focus();
113+	bool focusWindow();
114 	void raiseToTop();
115 	Hy3Node* getFocusedNode();
116 	void updateDecos();