Skip to content

Conversation

@jopamo
Copy link

@jopamo jopamo commented Dec 8, 2025

This patch adds a stacking_node pointer to the ObWindow struct, caching the window's position in the global stacking_list.

Previously, operations like stacking_remove, stacking_raise, and occlusion checks required calling g_list_find or iterating through the list, resulting in O(N) complexity. For setups with many windows, this created unnecessary CPU overhead during focus changes and restacking.

By utilizing the cached GList node:

  1. Window removal becomes O(1) via a new helper stacking_detach_node.
  2. Occlusion checks start iteration immediately from the window's position.
  3. Restacking operations avoid linear scans to find the window.

This patch adds a `stacking_node` pointer to the `ObWindow` struct,
caching the window's position in the global `stacking_list`.

Previously, operations like `stacking_remove`, `stacking_raise`, and
occlusion checks required calling `g_list_find` or iterating through
the list, resulting in O(N) complexity. For setups with many windows,
this created unnecessary CPU overhead during focus changes and restacking.

By utilizing the cached `GList` node:
1. Window removal becomes O(1) via a new helper `stacking_detach_node`.
2. Occlusion checks start iteration immediately from the window's
   position.
3. Restacking operations avoid linear scans to find the window.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant