Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to set an initial position for the terminal #1043

Closed
patriksvensson opened this issue May 28, 2019 · 13 comments · Fixed by #2817
Closed

Be able to set an initial position for the terminal #1043

patriksvensson opened this issue May 28, 2019 · 13 comments · Fixed by #2817
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@patriksvensson
Copy link

Environment

Windows build number: Microsoft Windows [Version 10.0.18362.86]
Windows Terminal version (if applicable): commit bbbd3e0323a82548416f40ddba

Steps to reproduce

  1. Start Windows Terminal
  2. Move the Windows Terminal window
  3. Close Windows Terminal
  4. Start Windows Terminal

Expected behavior

Window position is restored to were it was in step 3 above.

Actual behavior

Window is opened at a default location.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels May 28, 2019
@DHowett-MSFT
Copy link
Contributor

What if you have more than one window?

@patriksvensson
Copy link
Author

@DHowett-MSFT Good question and I realize my expectations what somewhat flawed. Currently the Windows Terminal window is opened so that half the terminal is outside of my screen bounds (I've changed the initialRows and initialCols)

When I think about it, I would want a way of setting the default window position somehow (like I can with the old fashion terminal).

@zadjii-msft
Copy link
Member

There's already #766, which deals with restoring general state from the previous session. I'd say much of this issue fits under that umbrella, save for:

I would want a way of setting the default window position somehow (like I can with the old fashion terminal).

Shockingly, I don't think we have an issue tracking that particular feature request quite yet. This is now the thread tracking that feature request.

@zadjii-msft zadjii-msft changed the title Restore window position from last session Be able to set an initial position for the terminal May 29, 2019
@zadjii-msft zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels May 29, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 29, 2019
@zadjii-msft zadjii-msft added this to the Terminal v1.0 milestone May 29, 2019
@DHowett-MSFT DHowett-MSFT removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label May 30, 2019
@UweKeim
Copy link

UweKeim commented Jun 22, 2019

Personally, I prefer even having multiple instances being restored to the very same pixel position and size rather than stacking them pseudo-randomly over my desktop.

Tastes are different, so why not add an option like:

{
    "windowRestoreMode": "lastPositionAndSize"
}

With windowRestoreMode being an enum of values like:

@lllopo
Copy link

lllopo commented Jun 23, 2019

Personally, I prefer even having multiple instances being restored to the very same pixel position and size rather than stacking them pseudo-randomly over my desktop.

Tastes are different, so why not add an option like:

{
    "windowRestoreMode": "lastPositionAndSize"
}

With windowRestoreMode being an enum of values like:

"Possibly more modes" should also include a predefined position on screen in pixels, imho.

@UweKeim
Copy link

UweKeim commented Jun 23, 2019

Sounds very good, @lllopo.

For your defindedPositionAndSize mode, one could enhance this like e.g.:

{
    "windowRestoreMode": "definedPositionAndSize",
    "windowPos": 
    {
        "x": 100,
        "y": 120,
        "width": 400,
        "height": 800
    }
}

One could even enhance this for multiple intances of Terminal to each use another set of positions/sizes like:

{
    "windowRestoreMode": "definedPositionAndSize",
    "windowPos": 
    [
        {
            "isDefault": true,
            "x": 100,
            "y": 120,
            "width": 400,
            "height": 800
        },
        {
            "x": 500,
            "y": 120,
            "width": 400,
            "height": 800
        },
        {
            "x": 900,
            "y": 120,
            "width": 400,
            "height": 800
        }
    ]
}

I.e. the first instance use the first object of position and size in the windowPos array, the second instance of Terminal uses the second object in the array, and so on.

For following instances with no representation in the windowPos array, an entry with "isDefault": true is searched, or if none is found, the first entry is being used.

@UweKeim
Copy link

UweKeim commented Sep 27, 2019

Just one more discovery:

Visual Studio Code starts the first instance pixel-perfect as it was closed before. When starting a second instance, it starts it as some default position and size.

Not as advanced as my suggestion, but way better than Terminal doing now.

@carlos-zamora carlos-zamora added the In-PR This issue has a related PR label Oct 16, 2019
@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Oct 17, 2019
DHowett-MSFT pushed a commit that referenced this issue Oct 17, 2019
This PR includes the code changes that enable users to set an initial position
(top left corner) and launch maximized. There are some corner cases:

1. Multiple monitors. The user should be able to set the initial position to
any monitors attached. For the monitors on the left side of the major monitor,
the initial position values are negative.

2. If the initial position is larger than the screen resolution and the window
is off-screen, the current solution is to check if the top left corner of the
window intersect with any monitors. If it is not, we set the initial position
to the top left corner of the nearest monitor.

3. If the user wants to launch maximized and provides an initial position, we
launch the maximized window on the monitor where the position is located.

# Testing

To test:
1. Check-out this branch and build on VS2019
2. Launch Terminal, and open Settings. Then close the terminal.
3. Add the following setting into Json settings file as part of "globals", just
after "initialRows":
  "initialPosition": "1000, 1000",
  "launchMode": "default"

My test data:
I have already tested with the following variables:
  1. showTabsInTitlebar true or false
  2. The initial position of the top left corner of the window
  3. Whether to launch maximized
  4. The DPI of the monitor

Test data combination:

Non-client island window (showTabsInTitlebar true)

1. Three monitors with the same DPI (100%), left, middle and right, with the
middle one as the primary, resolution: 1980 * 1200, 1920 * 1200, 1920 * 1080
    launchMode: default
      In-Screen test: (0, 0), (1000, 500), (2000, 300), (-1000, 400),
        (-100, 200), (-2000, 100), (0, 1119)
      out-of-screen:
        (200, -200): initialize to (0, 0)
        (200, 1500): initialize to (0, 0)
        (2000, -200): initialize to (1920, 0)
        (2500, 2000): initialize to (1920, 0)
        (4000 100): initialize to (1920, 0)
        (-1000, -100): initialize to (-1920, 0)
        (-3000, 100): initialize to (-1920, 0)
        (10000, -10000): initialize to (1920, 0)
        (-10000, 10000): initialize to (-1920, 0)
        (0, -10000): initialize to (0, 0)
        (0, -1):  initialize to (0, 0)
        (0, 1200):  initialize to (0, 0)
    launch mode: maximize
        (100, 100)
        (-1000, 100): On the left monitor
        (0, -2000): On the primary monitor
        (10000, 10000): On the primary monitor


2. Left monitor 200% DPI, primary monitor 100% DPI
    In screen: (-1900, 100), (-3000, 100), (-1000, 100)
    our-of-screen: (-8000, 100): initialize at (-1920, 0)
    launch Maximized:  (-100, 100): launch maximized on the left monitor
      correctly

3. Left monitor 100% DPI, primary monitor 200% DPI
    In-screen: (-1900, 100), (300, 100), (-800, 100), (-200, 100)
    out-of-screen: (-3000, 100): initialize at (-1920, 0)
    launch maximized: (100, 100), (-1000, 100)

For client island window, the test data is the same as above.

Issues:

1. If we set the initial position on the monitor with a different DPI as the
primary monitor, and the window "lays" across two monitors, then the window
still renders as it is on the primary monitor. The size of the window is
correct.

Closes #1043
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Oct 17, 2019
@ghost
Copy link

ghost commented Oct 23, 2019

🎉This issue was addressed in #2817, which has now been successfully released as Windows Terminal Preview v0.6.2951.0.:tada:

Handy links:

@Seefer
Copy link

Seefer commented Aug 6, 2020

What if you have more than one window?

More than one window is great in multiple monitor arrangements and I'd still like to have control over where they open and the their size on each display. For multiple terminals on one display I'd prefer to have a tab feature in one window or use WTs splitPane function rather than separate windows.

@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Aug 6, 2020
@escalonn
Copy link

escalonn commented Nov 4, 2021

this is still an issue in the present released version.

@zadjii-msft
Copy link
Member

@escalonn This feature was merged two years ago, can you file a new issue to track whatever you're seeing? Please make sure to include your settings.json, your Terminal version, etc.

There's also #766 which merged into 1.12, which will restore the window positions automatically, which is part of what this thread was discussion originally.

@UweKeim
Copy link

UweKeim commented Nov 4, 2021

For me, it is still not working pixel-perfect, too, when being docked to either side of the screen.

I gave up, bought DisplayFusion Pro and created a trigger therein to position the Terminal window correctly after it start.

@patriksvensson
Copy link
Author

@zadjii-msft I think you should lock this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants