terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Opening a new terminal window does not restore the previous window's size and position on the screen

Open Poopooracoocoo opened this issue 3 years ago • 16 comments

Windows Terminal version

1.13.10395.0

Windows build number

10.0.19044

Other Software

No response

Steps to reproduce

  1. Open Terminal
  2. Resize and reposition window
  3. Close window
  4. Open Terminal again

Expected Behavior

Terminal would open the window in the same position and size

Actual Behavior

The position and size are reset.

Note: I am not referring to session restore on start-up like you'd find in a web browser that can be enabled optionally. I'm referring to regular behaviour that people expect on desktop operating systems. And in particular, this makes it easier to use on smaller screens such as laptops.

Poopooracoocoo avatar Mar 06 '22 06:03 Poopooracoocoo

Do you have window layout saving enabled? In Settings -> Startup -> "When Terminal starts" select the "Open windows from a previous session" option.

image

https://docs.microsoft.com/en-us/windows/terminal/customize-settings/startup#behavior-when-starting-a-new-terminal-session

Rosefield avatar Mar 06 '22 19:03 Rosefield

Do you have window layout saving enabled? In Settings -> Startup -> "When Terminal starts" select the "Open windows from a previous session" option.

I don't want that, nor should I need that enabled to have this.

Edit: I even explicitly mentioned that option in my issue. No edits.

Poopooracoocoo avatar Mar 06 '22 21:03 Poopooracoocoo

Alright so this is a new feature request - a setting to use the initialPosition, initialSize in state.json instead of the ones in the settings file. I suppose that could be a checkbox within the Launch Size expander. Ah, but then we've got the trick that we'd want one checkbox for "use previous position" and another for "use previous size". (admittedly, initialPosition isn't in the SUI yet, #9075). Then there's also the complicating factor that enabling "Open windows from a previous session" would spooky-action-at-a-distance check and disable those boxes.

So then it makes more sense to put this as another radio option in "When Terminal starts...". Or like, a checkbox under the "Open a tab with the default profile", that only ~reveals~enables itself when that radio button is selected? (hiding itself would be terrible discoverability)

zadjii-msft avatar Mar 07 '22 12:03 zadjii-msft

An option doesn't really make sense to me. I don't really want anything complicated. I just want the default windowing behaviour I've come to expect from other apps. 🤷

Poopooracoocoo avatar Mar 07 '22 12:03 Poopooracoocoo

We already have some other settings to control where the window is positioned and how big it is, so already we're off the rails of "other apps". I'm of the strong opinion that user preference is king - I'd love to give everyone as many knobs to control the Terminal as possible, to make it work exactly like they'd like.

zadjii-msft avatar Mar 07 '22 13:03 zadjii-msft

Good defaults are always nice tho :)

Poopooracoocoo avatar Mar 07 '22 20:03 Poopooracoocoo

I agree, it should just work its standard windows behaviour. Should respect the monitor it was on as well. Let people override if required but please follow principle of least surprises.

SteveALee avatar Mar 09 '22 13:03 SteveALee

Discussion outcome: This probably needs a miniature spec (AKA: we agree on it in the issue, and check in a quick markdown document about it) as the team couldn't come to consensus on whether this is a firstWindowPreference or a launchPosition, and whether this is part of or not a part of the session restoration code.

DHowett avatar Mar 14 '22 21:03 DHowett

Thanks for bringing the outcome here!

SteveALee avatar Mar 15 '22 07:03 SteveALee

Hah just came here to report this, I was thinking of two suggestions:

  1. Option to always spawn at a set of coordinates OR at the center of the screen
  2. Remember position properly

Stanzilla avatar Mar 24 '22 20:03 Stanzilla

FWIW:

Option to always spawn at a set of coordinates OR at the center of the screen are already settings.

Unifying those two with bullet point 2 is the one that this issue is tracking - finding a good way of exposing that setting to the user both as a UI and in json is the hard part.

zadjii-msft avatar Mar 24 '22 21:03 zadjii-msft

FWIW:

Option to always spawn at a set of coordinates OR at the center of the screen are already settings.

Unifying those two with bullet point 2 is the one that this issue is tracking - finding a good way of exposing that setting to the user both as a UI and in json is the hard part.

Oh my bad, sorry. I didn't see it in the UI options.

Stanzilla avatar Mar 24 '22 21:03 Stanzilla

Any updates here?

I do use the subscribe button but I'm the author of this issue so I receive notifications by default. People have bumped other issues in Microsoft repos that were forgotten and that seemed to work for some of those issues. Doing so here isn't such a stretch.

Poopooracoocoo avatar Jan 24 '23 20:01 Poopooracoocoo

Nope. We'll make sure to update this thread when there is. In the meantime, might I recommend the Subscribe button? image That way you'll be notified of any updates to this thread, without needlessly pinging everyone on this thread ☺️

As it stands, this issue remains at:

Discussion outcome: This probably needs a miniature spec (AKA: we agree on it in the issue, and check in a quick markdown document about it) as the team couldn't come to consensus on whether this is a firstWindowPreference or a launchPosition, and whether this is part of or not a part of the session restoration code.

If someone wants to sort out how exactly this should be implemented, we'd be more than happy to review a writeup ☺️


Some notes, march 2023:

  • On my branch
  • You delete tabLayout entirely (is null) -> right size & pos, but explodes
  • you set tabLayout to [] -> Right size & pos, and uses the default profile

around 434abc247 (during #14825), this was actually almost trivially easy. We made the logic concerning the number of tabs persisted a bit more strict, but honestly, I think we could undo that easily. Commit 1b59eb923 was the one to enforce the "we must have tabs" thing

zadjii-msft avatar Jan 24 '23 20:01 zadjii-msft

If someone wants to sort out how exactly this should be implemented, we'd be more than happy to review a writeup ☺️

FWIW, and when it comes to the implementation specifically, I believe this should use the GetWindowPlacement and SetWindowPlacement APIs. Those have been in use by other HWND applications for this purpose since forever.

lhecker avatar Mar 20 '24 16:03 lhecker