raboof / notion

Tiling tabbed window manager
https://notionwm.net/
GNU Lesser General Public License v2.1
268 stars 63 forks source link

WTiling.unsplit_at #264

Open ThomasLiA opened 4 years ago

ThomasLiA commented 4 years ago

When applying the function WTiling.unsplitat(, _sub) in the case that the workspace is empty and there is only one frame, this frame is removed as well, and what I see is the background image of my display manager. Any application that is subsequently launched will open in a floating window.

Does anybody experience the same undesired effect? It is apparently unrelated to my configuration; when deactivating the entire .notion directory, the same happens.

This behaviour is new in Notion 4. I would definitely appreciate a hint how to solve this problem.

raboof commented 4 years ago

Does anybody experience the same undesired effect?

I see the same, and I agree it'd be neater to either disallowing unsplitting the toplevel frame, or removing the workspace entirely in that case.

This behaviour is new in Notion 4

Unfortunately this logic is pretty complicated and changed a bit in the 'Notion Dark Ages' (the non-LGPL period for which we've thrown away all changes), so I'm afraid comparing the logic in different Notion revisions is probably not going to get us far. I think it'd be better to take a fresh look at what the code looks like right now and how to fit this improvement in.

I would definitely appreciate a hint how to solve this problem.

I'm afraid I don't have a super good overview of how this should work, but perhaps tiling_managed_remove would be one thing to have a look at.

ThomasLiA commented 4 years ago

Thanks a lot for the confirmation and the information!

I conclude that we likely have to live with the changed behaviour of the "unsplit" function. In spite of my practically non-existent knowledge of matters, I have tried a workaround. The program below checks if there is another client window in the present workspace; if yes, it destroys the focussed frame, and if not, it destroys the workspace (provided that there is another one).

I would have preferred to keep focus on the same window as before (if somebody knows how to do this, please let me know!), this was the previous behaviour of "unsplit". But at least, the replacement seems to be acceptable for the daily work ;-) It no longer happens that the last frame of a workspace is destroyed.

function destroy_frame(wt, wmp) local ws = ioncore.find_manager(wmp, 'WGroupWS') if ws ~= nil then ioncore.defer(function() local WsEmpty = true ioncore.clientwin_i(function(cw) if ioncore.find_manager(cw, 'WGroupWS') == ws then WsEmpty = false return false end return true end) if WsEmpty == true then WRegion.rqclose(ws) else WTiling.unsplit_at(wt, wmp) end end) end end

wilhelmy commented 4 years ago

The currently focused window is returned by ioncore.current(), and both obj:goto_focus() as well as obj:goto_() (the underscore is needed because goto is a keyword starting from Lua 5.2) raises (and focuses? Not entirely sure about the difference between goto_focus and goto, to be honest) a WClientWin (or any other subclass of WRegion) object, even if it is elsewhere, like on a different WGroupWS. Does that help?

ThomasLiA commented 4 years ago

Thanks a lot for the hints! Unfortunately, I am unable to restore the old behaviour of the unsplit function. I have modified the above function as follows: I pass to it ioncore.current() as an additional argument clw; then I added obj:gotofocus(clw) [or obj:goto(clw) or WRegion.goto_(clw)] after WTiling.unsplit_at(...). This change does not have any effect.