From cb0371dab120bbaa7ec4d72f98c259986f9263d8 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 23 Dec 2021 10:06:48 +0100 Subject: [PATCH] fix floating top and cursor warping --- src/KeybindManager.cpp | 2 ++ src/window.cpp | 4 ++++ src/windowManager.cpp | 13 +++++-------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/KeybindManager.cpp b/src/KeybindManager.cpp index eec507c..00fccf6 100644 --- a/src/KeybindManager.cpp +++ b/src/KeybindManager.cpp @@ -189,5 +189,7 @@ void KeybindManager::toggleActiveWindowFloating(std::string unusedArg) { EWMH::updateClientList(); EWMH::updateWindow(PWINDOW->getDrawable()); + + g_pWindowManager->setAllFloatingWindowsTop(); } } \ No newline at end of file diff --git a/src/window.cpp b/src/window.cpp index 24297fb..928ae26 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -52,6 +52,10 @@ void CWindow::bringTopRecursiveTransients() { if (ConfigManager::getInt("intelligent_transients") != 1) return; + // if this is a floating window, top + if (m_bIsFloating && m_iDrawable > 0) + g_pWindowManager->setAWindowTop(m_iDrawable); + // first top all the children if floating for (auto& c : m_vecChildren) { if (const auto PWINDOW = g_pWindowManager->getWindowFromDrawable(c); PWINDOW) { diff --git a/src/windowManager.cpp b/src/windowManager.cpp index 7d6c950..8d37edf 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -1249,9 +1249,6 @@ CWindow* CWindowManager::getNeighborInDir(char dir) { return nullptr; } -// I don't know if this works, it might be an issue with my nested Xorg session I am using rn to test this. -// Will check later. -// TODO: void CWindowManager::warpCursorTo(Vector2D to) { const auto POINTERCOOKIE = xcb_query_pointer(DisplayConnection, Screen->root); @@ -1262,7 +1259,7 @@ void CWindowManager::warpCursorTo(Vector2D to) { return; } - xcb_warp_pointer(DisplayConnection, XCB_NONE, Screen->root, 0, 0, 0, 0, (int)to.x, (int)to.y); + xcb_warp_pointer(DisplayConnection, XCB_NONE, Screen->root, 0, 0, Screen->width_in_pixels, Screen->height_in_pixels, (int)to.x, (int)to.y); free(pointerreply); } @@ -1343,7 +1340,7 @@ void CWindowManager::moveActiveWindowTo(char dir) { CURRENTWINDOW->setDirty(true); neighbor->setDirty(true); - // finish by moving the cursor to the current window + // finish by moving the cursor to the new current window warpCursorTo(CURRENTWINDOW->getPosition() + CURRENTWINDOW->getSize() / 2.f); } @@ -1375,8 +1372,8 @@ void CWindowManager::moveActiveFocusTo(char dir) { // move the focus setFocusedWindow(NEIGHBOR->getDrawable()); - // finish by moving the cursor to the current window - warpCursorTo(CURRENTWINDOW->getPosition() + CURRENTWINDOW->getSize() / 2.f); + // finish by moving the cursor to the neighbor window + warpCursorTo(NEIGHBOR->getPosition() + (NEIGHBOR->getSize() / 2.f)); } void CWindowManager::changeWorkspaceByID(int ID) { @@ -1609,7 +1606,7 @@ void CWindowManager::setAllFloatingWindowsTop() { xcb_configure_window(g_pWindowManager->DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_STACK_MODE, Values); window.bringTopRecursiveTransients(); - } else if (window.getChildren().size() > 0) { + } else { window.bringTopRecursiveTransients(); } }