Skip to content
This repository was archived by the owner on Dec 13, 2025. It is now read-only.

Conversation

@kkvark
Copy link
Contributor

@kkvark kkvark commented Aug 20, 2025

Floating nodes in sway change to last place in json-output every time they get focus.
For example, if we have windows 1 and 2, and also floating 3 and 4 . Without sorting, cycling will be: 1>2>3>1>2>4... And backward cycling get stuck between windows 3 and 4.

@kkvark kkvark changed the title add --prev option add --prev option and sort floating_nodes Aug 20, 2025
@kkvark kkvark force-pushed the main branch 2 times, most recently from e9f476c to a466cd7 Compare August 20, 2025 07:13
@TLINDEN
Copy link
Owner

TLINDEN commented Aug 24, 2025

Hi, thanks a lot for the PR, I'll look at it tomorrow. Especially the floating window issue is new to me as I don't use this very often.

@TLINDEN
Copy link
Owner

TLINDEN commented Aug 25, 2025

Interesting... I can't reproduce the underlying problem, that is if I have multiple floating windows, I can reach everyone with swaycycle.

So, the order of floating windows changes indeed every time I switch focus, it doesn't change when I don't do anything. However, even with the order changed, every window is reachable.

I added a little debugging code to show the list of visible windows (unsorted) and tested it. I have a workspace with 4 floating windows. Calling swaycycle 4 times yields this log:

    visibles:
        - 'id: 29, focus: false, name: scip@tripod:~ — Konsole'
        - 'id: 30, focus: false, name: Select items from the list'
        - 'id: 25, focus: false, name: Terminal - scip@tripod:~'
        - 'id: 28, focus:  true, name: About this System  — Info Center'
    visibles:
        - 'id: 30, focus: false, name: Select items from the list'
        - 'id: 25, focus: false, name: Terminal - scip@tripod:~'
        - 'id: 28, focus: false, name: About this System  — Info Center'
        - 'id: 29, focus:  true, name: scip@tripod:~ — Konsole'
    visibles:
        - 'id: 25, focus: false, name: Terminal - scip@tripod:~'
        - 'id: 28, focus: false, name: About this System  — Info Center'
        - 'id: 29, focus: false, name: scip@tripod:~ — Konsole'
        - 'id: 30, focus:  true, name: Select items from the list'
    visibles:
        - 'id: 28, focus: false, name: About this System  — Info Center'
        - 'id: 29, focus: false, name: scip@tripod:~ — Konsole'
        - 'id: 30, focus: false, name: Select items from the list'
        - 'id: 25, focus:  true, name: Terminal - scip@tripod:~'

Although the windows appear in another order each time we get called, it follows a pattern. The current focused window is always the last one in the list. And the overall order of the windows stays the same if you consider the list to be a ring. Then - for example - window 29 always follows window 28, or formulated differently: the order is always 29,30,25,28. And this doesn't change when some windows are floating and some are not.

So, from my point of view, the current code is sufficient. But I'll apply the patch anyway because this may be an issue with sway, which swayfx (which I use) doesn't have.

@kkvark
Copy link
Contributor Author

kkvark commented Aug 25, 2025

The problem appears precisely when there are several windows of both types. They are all reachable but to switch between "neighboring" floating windows, we pass cycle through all non-floating.
To reproduce create 3 non-floating widows and 2 or more floating.

@TLINDEN
Copy link
Owner

TLINDEN commented Aug 25, 2025

Hm, strange. I did so and I could cycle through all windows, however, one of the floating ones is being skipped every two cycles. Great :)

And yes, this odd behavior disappears with the patched version.

Many thanks a lot for finding and patching this!

@TLINDEN TLINDEN merged commit 7a5657b into TLINDEN:main Aug 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants