[PR #2817] [MERGED] Enable setting an initial position and maximization launch for Terminal #25090

Open
opened 2026-01-31 09:07:13 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/2817
Author: @KaiyuWang16
Created: 9/19/2019
Status: Merged
Merged: 10/17/2019
Merged by: @DHowett-MSFT

Base: masterHead: dev/kawa/1043-set-initial-position-for-the-terminal-spec-and-implementation


📝 Commits (10+)

  • 9e85571 Spec version 1 for set terminal initial position
  • dbbba4e Fix the spec title
  • 5a919c7 Add a new function to read initial position properties
  • 5e8dc81 Merge branch 'master' into dev/kawa/1043-set-initial-position-for-the-terminal
  • 5e947ac Test version - 9-6
  • 8fbe307 spec for code review updates
  • f5926f8 Code change 9-11
  • 6c59f37 temporary changes 9 12
  • e2999b1 Enable setting an initial position for terminal and maximization launch
  • 6206ecb remove empty lines

📊 Changes

12 files changed (+380 additions, -64 deletions)

View changed files

📝 src/cascadia/TerminalApp/App.cpp (+54 -0)
📝 src/cascadia/TerminalApp/App.h (+2 -0)
📝 src/cascadia/TerminalApp/App.idl (+9 -1)
📝 src/cascadia/TerminalApp/GlobalAppSettings.cpp (+153 -3)
📝 src/cascadia/TerminalApp/GlobalAppSettings.h (+22 -0)
📝 src/cascadia/WindowsTerminal/AppHost.cpp (+107 -53)
📝 src/cascadia/WindowsTerminal/AppHost.h (+1 -1)
📝 src/cascadia/WindowsTerminal/BaseWindow.h (+9 -0)
📝 src/cascadia/WindowsTerminal/IslandWindow.cpp (+19 -3)
📝 src/cascadia/WindowsTerminal/IslandWindow.h (+3 -2)
📝 src/cascadia/WindowsTerminal/NonClientIslandWindow.h (+0 -1)
📝 src/cascadia/WindowsTerminal/pch.h (+1 -0)

📄 Description

This PR is for code changes as well as a spec for https://github.com/microsoft/terminal/issues/1043

No

PR Checklist

  • Closes Set the social media image for the project ... (#1043)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/2817 **Author:** [@KaiyuWang16](https://github.com/KaiyuWang16) **Created:** 9/19/2019 **Status:** ✅ Merged **Merged:** 10/17/2019 **Merged by:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Base:** `master` ← **Head:** `dev/kawa/1043-set-initial-position-for-the-terminal-spec-and-implementation` --- ### 📝 Commits (10+) - [`9e85571`](https://github.com/microsoft/terminal/commit/9e85571ac4d4c53963fc051c035ffb9230e09f68) Spec version 1 for set terminal initial position - [`dbbba4e`](https://github.com/microsoft/terminal/commit/dbbba4e9c817564a62370a81ca1422d66bcbd2f7) Fix the spec title - [`5a919c7`](https://github.com/microsoft/terminal/commit/5a919c7af46baef97c48b75fd66bf966c0b83ef0) Add a new function to read initial position properties - [`5e8dc81`](https://github.com/microsoft/terminal/commit/5e8dc8106a1321119bbf20fbcff143b604ffdd5c) Merge branch 'master' into dev/kawa/1043-set-initial-position-for-the-terminal - [`5e947ac`](https://github.com/microsoft/terminal/commit/5e947ac9bba357146a3e958f1c669f4bc0da9b40) Test version - 9-6 - [`8fbe307`](https://github.com/microsoft/terminal/commit/8fbe307db22e5a44e5fa7ee589b05d1df6aa934d) spec for code review updates - [`f5926f8`](https://github.com/microsoft/terminal/commit/f5926f8ad761a553590c58295cf759e11beb2340) Code change 9-11 - [`6c59f37`](https://github.com/microsoft/terminal/commit/6c59f375704b127c08ab0db440205ebd80ad53ff) temporary changes 9 12 - [`e2999b1`](https://github.com/microsoft/terminal/commit/e2999b1e87517996ca60cd3be62f49ab91245ef6) Enable setting an initial position for terminal and maximization launch - [`6206ecb`](https://github.com/microsoft/terminal/commit/6206ecb547c3d5a7c11af6ed4855a60a8421fe59) remove empty lines ### 📊 Changes **12 files changed** (+380 additions, -64 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalApp/App.cpp` (+54 -0) 📝 `src/cascadia/TerminalApp/App.h` (+2 -0) 📝 `src/cascadia/TerminalApp/App.idl` (+9 -1) 📝 `src/cascadia/TerminalApp/GlobalAppSettings.cpp` (+153 -3) 📝 `src/cascadia/TerminalApp/GlobalAppSettings.h` (+22 -0) 📝 `src/cascadia/WindowsTerminal/AppHost.cpp` (+107 -53) 📝 `src/cascadia/WindowsTerminal/AppHost.h` (+1 -1) 📝 `src/cascadia/WindowsTerminal/BaseWindow.h` (+9 -0) 📝 `src/cascadia/WindowsTerminal/IslandWindow.cpp` (+19 -3) 📝 `src/cascadia/WindowsTerminal/IslandWindow.h` (+3 -2) 📝 `src/cascadia/WindowsTerminal/NonClientIslandWindow.h` (+0 -1) 📝 `src/cascadia/WindowsTerminal/pch.h` (+1 -0) </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> This PR is for code changes as well as a spec for https://github.com/microsoft/terminal/issues/1043 <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> No <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #1043 * [ ] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Requires documentation to be updated * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> 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. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:07:13 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25090