conformal / spectrwm

A small dynamic tiling window manager for X11.
ISC License
1.33k stars 97 forks source link

Restarting changes workspaces and reorders windows. #56

Closed egan closed 10 years ago

egan commented 10 years ago

When restarting spectrwm, the current workspace is lost (the first is displayed) and the placement of windows in each workspace is seemingly randomized.

The first part is a minor inconvenience, but it would be nice if it were fixed to give a seamless restart. The second part for me is a little more annoying because I expect my windows to remain in the same place and have the same size lest their interfaces/scrollbacks change or my muscle memory fail me.

egan commented 10 years ago

Looking at the code, I see that the window order is kept in _NET_CLIENT_LIST, updated I think in ewmh_update_client_list(). Checking that with xprop -root, I see that the window id order represented is accurate with what I see. So I feel like there is a bug in grab_windows() where it "tr[ies] to sort windows according to _NET_CLIENT_LIST".

Take my analysis with a grain of salt because I have no experience with programming for X.

LordReg commented 10 years ago

The reason spectrwm 'resets' to ws1 is for consistency. It's possible for config changes to make a restart not so seamless. For example, if workspace_limit is reduced, the current WS may become unavailable.

As for the window sorting via _NET_CLIENT_LIST on restart. It works for me. What version of spectrwm and what OS/distro are you using? I suspect the problem is stacking-related, perhaps due to a race condition.

egan commented 10 years ago

I am using spectrwm version 2.5.1-1 on Arch Linux.

egan commented 10 years ago

So after trying it a bit more it appears that it isn't actually random, but rather that the order gets flipped.

Upon restarting, the oldest window (bottom of stack) is placed as the newest window (master), and the next oldest as the next newest, etc. Restarting twice results in the correct window order, but of course the terminal interfaces are messed up.

LordReg commented 10 years ago

The order reversal bit was the key. The issue reared its head when spawn_position = prev or first in spectrwm.conf. I presume you are using one of those settings. The windows at start were getting stacked according to that option and that shouldn't be the case. It is fixed in the latest commit.

egan commented 10 years ago

You are correct, I was using spawn_position = prev in my configuration. The latest commit fixes the bug for me, thanks!