Skip to content

Remove boolean trap in Workspace::stackBelow()

Boolean traps are a code smell that makes code harder to read and it also usually makes the api more difficult.

The force == false is used by two places:

  • in Workspace::restackWindowUnderActive()
  • and in X11Window::restackWindow()

Technically, the restackWindow() function doesn't need the force == false behavior because the stackBelow() function is used in code paths where an explicit sibling is provided.

The restackWindowUnderActive() function is trickier, it is used in the case when kwin rejects to raise a newly mapped window, so for that purpose, I changed the function so it picks the lowest window that belongs to the same application as m_activeWindow.

The result of this change is that the stackBelow() is simpler and its behavior is much more predictable, which is important when analyzing the code that updates the stack.

Edited by Vlad Zahorodnii

Merge request reports