From 06ecd58399f8e3dcb20a7dd256c97b2b6e77c107 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 12 Jan 2024 03:14:31 -0800 Subject: [PATCH] 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. --- src/Hy3Layout.cpp | 25 +++++++++++++------------ src/TabGroup.cpp | 3 +-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 6ad2d07..d29d801 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -73,11 +73,14 @@ void Hy3Layout::onWindowCreated(CWindow* window, eDirection direction) { void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) { hy3_log( - TRACE, - "onWindowCreatedTiling called with window {:x} (floating: {})", + LOG, + "onWindowCreatedTiling called with window {:x} (floating: {}, monitor: {}, workspace: {})", (uintptr_t) window, - window->m_bIsFloating + window->m_bIsFloating, + window->m_iMonitorID, + window->m_iWorkspaceID ); + if (window->m_bIsFloating) return; auto* existing = this->getNodeFromWindow(window); @@ -96,17 +99,15 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) { Hy3Node* opening_into; Hy3Node* opening_after = nullptr; - if (monitor->activeWorkspace != -1) { - auto* root = this->getWorkspaceRootGroup(monitor->activeWorkspace); + auto* root = this->getWorkspaceRootGroup(window->m_iWorkspaceID); - if (root != nullptr) { - opening_after = root->getFocusedNode(); + if (root != nullptr) { + opening_after = root->getFocusedNode(); - // opening_after->parent cannot be nullptr - if (opening_after == root) { - opening_after = - opening_after->intoGroup(Hy3GroupLayout::SplitH, GroupEphemeralityOption::Standard); - } + // opening_after->parent cannot be nullptr + if (opening_after == root) { + opening_after = + opening_after->intoGroup(Hy3GroupLayout::SplitH, GroupEphemeralityOption::Standard); } } diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 7888984..af2d989 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -225,8 +225,7 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { PangoLayout* layout = pango_cairo_create_layout(cairo); pango_layout_set_text(layout, this->window_title.c_str(), -1); - if (*text_center) - pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); + if (*text_center) pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); PangoFontDescription* font_desc = pango_font_description_from_string(text_font->c_str()); pango_font_description_set_size(font_desc, *text_height * scale * PANGO_SCALE);