06ecd58399f8e3dcb20a7dd256c97b2b6e77c107

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

Message

Move newly tiled windows into place in the window's workspace

Usually the window workspace differs from the monitor workspace when
moving a window to a background workspace.
Previously onWindowCreatedTiling acted on the monitor active workspace
which caused windows to always appear at the end of the outermost node
on the target workspace. Now they appear relative to the last selected node.

Diff

 1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 2index 6ad2d070562c0c555883fca42845b5e5a1f8af1d..d29d801ff7cd0845f594a0c0866d1b1971316b4b 100644
 3--- a/src/Hy3Layout.cpp
 4+++ b/src/Hy3Layout.cpp
 5@@ -73,11 +73,14 @@ void Hy3Layout::onWindowCreated(CWindow* window, eDirection direction) {
 6 
 7 void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) {
 8 	hy3_log(
 9-	    TRACE,
10-	    "onWindowCreatedTiling called with window {:x} (floating: {})",
11+	    LOG,
12+	    "onWindowCreatedTiling called with window {:x} (floating: {}, monitor: {}, workspace: {})",
13 	    (uintptr_t) window,
14-	    window->m_bIsFloating
15+	    window->m_bIsFloating,
16+	    window->m_iMonitorID,
17+	    window->m_iWorkspaceID
18 	);
19+
20 	if (window->m_bIsFloating) return;
21 
22 	auto* existing = this->getNodeFromWindow(window);
23@@ -96,17 +99,15 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) {
24 	Hy3Node* opening_into;
25 	Hy3Node* opening_after = nullptr;
26 
27-	if (monitor->activeWorkspace != -1) {
28-		auto* root = this->getWorkspaceRootGroup(monitor->activeWorkspace);
29+	auto* root = this->getWorkspaceRootGroup(window->m_iWorkspaceID);
30 
31-		if (root != nullptr) {
32-			opening_after = root->getFocusedNode();
33+	if (root != nullptr) {
34+		opening_after = root->getFocusedNode();
35 
36-			// opening_after->parent cannot be nullptr
37-			if (opening_after == root) {
38-				opening_after =
39-				    opening_after->intoGroup(Hy3GroupLayout::SplitH, GroupEphemeralityOption::Standard);
40-			}
41+		// opening_after->parent cannot be nullptr
42+		if (opening_after == root) {
43+			opening_after =
44+			    opening_after->intoGroup(Hy3GroupLayout::SplitH, GroupEphemeralityOption::Standard);
45 		}
46 	}
47 
48diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp
49index 788898497abff53721e9fac5883009cb710caafb..af2d989c02a33b612546ab0dc1e73cc660aaa06b 100644
50--- a/src/TabGroup.cpp
51+++ b/src/TabGroup.cpp
52@@ -225,8 +225,7 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) {
53 			PangoLayout* layout = pango_cairo_create_layout(cairo);
54 			pango_layout_set_text(layout, this->window_title.c_str(), -1);
55 
56-			if (*text_center)
57-				pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
58+			if (*text_center) pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
59 
60 			PangoFontDescription* font_desc = pango_font_description_from_string(text_font->c_str());
61 			pango_font_description_set_size(font_desc, *text_height * scale * PANGO_SCALE);