If I switch between clients within a one view, returned Array of recent clients keeps an order where last client is pushed into the head (ie. at 0 index) and remaining are shifted to the right (ie. their index is increased by 1).

However if I switch between clients on different views (within a one screen), order 'sometimes' gets lost:

I'm in view named "terms", launch two xterms, set left gravity for the first, right for the second.

Set focus on right xterm and run an irb session from within: irb(main):008:0> Subtlext::Client.recent.collect {|c| c.instance} => ["xterm", "xterm", "xterm", "xterm", "xterm"]

Now I switch to view named "www" and back to "terms" (by ViewSwitch action) and check how result of .recent has changed irb(main):009:0> Subtlext::Client.recent.collect {|c| c.instance} => ["xterm", "xterm", "xterm", "Navigator", "xterm"]

EDIT: what a coincidence, even attached screenshots placed carefully by each step lost their order07.png -> 26.png -> 39.png (starting with focus on right xterm)58.png -> 04.png -> 10.png (starting with focus on left xterm)

I've discovered the issue is caused by multiple re-focusing of a client.

Let's have two windows in one view. Left covers 66% of a view, right covers remaining 34%.

Focus right window with a keyboard or a mouse. If focused with a keyboard, mouse cursor reappears in the centre of the focused window.

Now switch to other view (by keyboard) with only one window covering whole area. Mouse cursor is placed in the centre.

Now switch back to the original view (by keyboard). The right (smaller) window gets focus, but then unintentionaly gets focus the left (larger) window and then again back the right. Thus list of recent focused windows is updated 3 times.

You can check it out by implementing client_focus hook with debugging output: