CodedOre / NewCaw

Development on Cawbird 2.0
GNU General Public License v3.0
97 stars 5 forks source link

Remember window sizes #75

Closed IBBoard closed 1 year ago

IBBoard commented 1 year ago

The default windows are a bit small. You often only see one toot. I normally have Cawbird taking up the entire height of the left-hand section of my 1440p monitor.

Unfortunately, GTK4 takes more account of Wayland, and Wayland doesn't support specifying window positions, so all that we can do is define window sizing.

There's also a boolean flag for whether we show windows, as I plan to add a toggle for that. I generally want my IBBoard account, but may not want my Cawbird and Cawbird Test accounts to show every time.

I've not yet worked out how to make Mutter place the windows separately. It stacks them on startup.

CodedOre commented 1 year ago

I wanted to clear this point from my ToDo-list for some time, but never came around to do this... Anyway, a few points:

First, I would like to keep the concept of the previous client-side session storage, which used a separate structure to store the information about active windows.

Speaking of "active windows": The original concept was to save all open windows on shutdown and restore them when you open them again. I would assume this works well in most cases. If I'm right, most users will only have one window open anyway and switch between their accounts. However, we could discuss if we should add an option to use a configured method with startup accounts, like the old Cawbird uses.

IBBoard commented 1 year ago

I did consider storing it separately. But then there was already the file there, and it tied it closely to the window, and you didn't have to do the mapping of "which shaped window did this account have?"

But we could switch it around and map the window and the account that it's showing. That will also give us flexibility for odd situations where someone has a "big window" and a "little window" and wants to alternate which account is shown in which. Although I'd have to check what happens when we select the same account in two windows!

I don't think "save on shutdown" will work, though. I close things window by window. I don't quit the entire app (I don't know where you'd put that option). And if you close window by window then you can't differentiate "I had two windows open and only want one now" from "I'm closing down the second window and then the first window to close the app entirely".

IBBoard commented 1 year ago

I'm working through this and hitting all sorts of "how do we handle that?" problems.

I'll keep working on it and see if I can get something workable.

IBBoard commented 1 year ago

Okay, I think that's got it working in a sensible way now 🙂

The app (not the Client) now tracks the window dimensions for each session.

On startup, we open all of the accounts that are set with auto_start. That's a Session property so that we can have "auto-start polling", but it also triggers windows. We could potentially break them apart in future and have some accounts polling/streaming in the background, but that's separate functionality.

If there are accounts but none are marked autostart then it picks the first one (which is basically what Cawbird did).

It captures it when the window is closed, so if you have three accounts, open Account 1, switch to Account 2 and switch to Account 3 and close the window then it'll record the size for Account 3 and Account 1 and 2 won't have a size set.

Once it's set, it won't be lost. So if I open a window for Account 2, resize it and close it and the account is not autostart then we'll store the size, not create a window on start, but create a "correct sized" window if someone opens a new window. If they open in the existing window then we don't override, we just leave it at the current dimensions.

If someone opens two windows and switches them both to the same account then we'll track whichever is the last window closed. I don't think we can do much better than that!

Responsibility for creating the local data directory is moved up to the app so that we're consistent between the client and the window sizing information and we don't have both sides checking that the directory exists.

I've now got my IBBoard and Cawbird accounts configured. IBBoard is set to autostart and Cawbird isn't, so I just get the one correctly sized window. If I enable autostart on Cawbird then they both open.