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.
This commit is contained in:
outfoxxed 2024-01-12 03:14:31 -08:00
parent 66ef532537
commit 06ecd58399
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
2 changed files with 14 additions and 14 deletions

View file

@ -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);
}
}

View file

@ -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);