mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-01-11 14:40:25 +01:00
[PR #1306] [CLOSED] feat(border): cache borders #1313
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/LGUG2Z/komorebi/pull/1306
Author: @alex-ds13
Created: 2/28/2025
Status: ❌ Closed
Base:
master← Head:feat(border)/cache-borders📝 Commits (2)
b0b4292fix(border): update border when moving from admin windows38325f9feat(border): cache borders on all workspaces📊 Changes
11 files changed (+250 additions, -205 deletions)
View changed files
📝
komorebi-client/src/lib.rs(+1 -0)📝
komorebi/src/border_manager/border.rs(+21 -19)📝
komorebi/src/border_manager/mod.rs(+178 -171)📝
komorebi/src/container.rs(+11 -0)📝
komorebi/src/core/mod.rs(+2 -0)📝
komorebi/src/stackbar_manager/stackbar.rs(+2 -2)📝
komorebi/src/window.rs(+21 -6)📝
komorebi/src/window_manager.rs(+2 -2)📝
komorebi/src/windows_api.rs(+1 -1)📝
komorebi/src/windows_callbacks.rs(+8 -4)📝
komorebi/src/workspace.rs(+3 -0)📄 Description
1st Commit:
2nd Commit:
This commit refactors the
border_managerwith the following changes:Rework the way the borders are created and their pointer is sent to the window message handler. Now we also store the same pointer as a
Box<Border>on theborder_manager'sBORDER_STATE. This means that the borders we have are exactly the same ones that the border window itself is accessing so we can now store the border's info inside theBorderstruct and all of it will be accessible by the border window as well. This makes it so the "ACTUAL" border struct is the one created on the thread of theBorder::create()function and when that thread finishes (after the border window closes) it will handle the drop of the border itself. However this means we need to be careful with our own storedBox<Border>since it will point to the same memory we can't let the compiler drop them as usual or otherwise it would create heap corruption errors. So this commit creates a special function calleddestroy_border()to actually close the window border without dropping the border, since it will be later dropped by the thread that created it.Remove
BORDERS_MONITORS,FOCUS_STATEandRENDER_TARGETSarc mutexes, since now this info is stored on the border itself.Change the
BORDER_STATEto now map an id (container or window) to aBox<Border>.Change the
WINDOWS_BORDERSto now map a window hwnd to a border id.Create new struct
BorderInfowhich as the border window hwnd and the border kind. This struct is what is now returned by the functionwindow_border()which checks if some window as a border attached to it and if it does it returns this info. There is no need to clone the entire border. If in the future we need more info we can just add it to this struct.Change the way we clear the
BORDER_STATE. Like mentioned before we need to be sure we don't drop theBox<Border>when removing it, so now we use the.drainfunction to remove all the borders as an iterator and we call thedestroy_border()on each border we are removing.We now check if a border's
tracking_hwndhas changed and if it does we simply update it instead of destroying the border and create a new one.Create function
delete_borderso that we can remove a border properly from outside theborder_manager.Create function
hide_borderwhich spawns a new thread that searches if a window hwnd has a border attached to it and if it does it hides said border window. This function is called on everywindow.hide().Create function
show_borderwhich spawns a new thread that searches if a window hwnd has a border attached to it and if it does it restores said border window. This function is called on everywindow.restore().This commit also changes the previous
window.hide()andwindow.restore()functions to be named:window.hide_with_border(hide_border: bool): this is the same function as before but adds a check at the end in casehide_borderis true it callsborder_manager::hide_border(). A new function was created with the same name as beforewindow.hide()which by default calls this new function withhide_border = true.window.restore_with_border(restore_border: bool): this is the same function as before but adds a check at the end in casehide_borderis true it callsborder_manager::hide_border(). A new function was created with the same name as beforewindow.hide()which by default calls this new function withhide_border = true.This commit creates a new function on
Containercalledload_focused_window_ignore_borders()which performs the same asload_focused_window()but it ignores the borders when hiding and restoring the windows. This function, along with thehide_with_border(false)andrestore_with_border(false)are used on all functions related to changing focus on a stack since if we let the borders be hidden and restored when cycling or changing focus on a stack the border would flicker slightly, this prevents that. (P.S. there might still be other places that I forgot to use these new functions, but if that is the case then what will happen is a simple flicker of the stack border...)The
remove_windowfromWorkspaceneeds to call theborder_manager::delete_border()so that we make sure we remove that windows's border window as well if it exists. This is essential when enforcing workspace rules, otherwise the border would be left behind.Lastly, but not least, now that we hide the borders windows along with their tracking window, we no longer remove the borders when swapping workspaces or when toggling monocle, etc. Instead we keep all borders of all workspaces cached and simply hide them. They are only removed when their tracking window is closed or cloaked on a stack (since on a stack we only keep one border for all the entire stack container). This means that when changing between workspaces we no longer see the borders showing up delayed after the windows show up. Now both the window and it's border show up as if they are one and the same.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.