Repository: microsoft/terminal (language: cpp)

Issue:
Settings / Startup / Launch Parameters / Launch Position doesn't allow Negative values
# Description of the new feature/enhancement
Currently, the Launch Position doesn't allow negative values.
I have a 3 monitor setup with the middle monitor as monitor 1.
I have "cmd" setup with defaults to set Left (X) as -1924, which works great as the window comes up on my left monitor all they way to the edge.

Please allow negative values for X in Launch Position.



Discussion / hints:
Methinks this is #15656:

> I don't think this needs to be a feature request - this is probably just a bug report 😜 `--pos` with a negative number absolutely _should_ work! Our psychic debugging guess is that the arg parser we're using is treating `--pos -100,-200` as a different option entirely, rather than a value for the `--pos` arg.
@zadjii-msft But, as far as I understand it, this issue is about the settings UI not supporting negative numbers. There, it doesn't work either (= separate issue).
Ho boy it doesn't work in the SUI either? Jeez 🤦 

> **Note**
> ## Walkthrough

Yep, these guys:
https://github.com/microsoft/terminal/blob/b556594793006ba49934d9e5291cbf235e18b4b3/src/cascadia/TerminalSettingsEditor/Launch.xaml#L239-L254

use this style

https://github.com/microsoft/terminal/blob/b556594793006ba49934d9e5291cbf235e18b4b3/src/cascadia/TerminalSettingsEditor/Launch.xaml#L26-L32

and that's got a minimum of 1. 

Should be easy enough to make a duplicate of that style, but for `LaunchPositionNumberBoxStyle`, and with a different minimum.
Hello @zadjii-msft , @lhecker , I would like to work on this.

A few questions:
1) We have to implement two things, One is a new style `LaunchPositionNumberBoxStyle` in the settings UI. Another is allowing negative x and y in the argument parser so that it allows negative numbers in the `--pos` argument. **Is my understanding correct?**
2) What should be the minimum value in the new `LaunchPositionNumberBoxStyle`..? 

Thank you.
> 1. We have to implement two things, One is a new style LaunchPositionNumberBoxStyle in the settings UI. Another is allowing negative x and y in the argument parser so that it allows negative numbers in the --pos argument. Is my understanding correct?

Yes, but `--pos` already allows negative coordinates as far as I know. It doesn't need to be fixed. 🙂

> 2. What should be the minimum value in the new `LaunchPositionNumberBoxStyle`..?

I doesn't necessarily need a minimum value, because the min. is just as large as the max. value. Technically speaking, window coordinates are limited to INT32_MIN and INT32_MAX, so you can use this if you'd like:
```
     <Setter Property="Minimum" Value="-2147483648" /> 
     <Setter Property="Maximum" Value="2147483647" /> 
```

---

@zadjii-msft BTW I noticed that `InitialPosition` struct uses `IReference<Int32>`. I think we should progressively replace all those integer coordinates with `float`s in DIPs in the coming ~year to make our lives with HiDPI a bit better. We can use NAN to indicate a field not being set.
@codecruisedor 

1. Yea, there's two parts, but for the sake of _this_ thread, I'd just focus on the Settings UI bit. #15656 is tracking the commandline parsing one, and that seems... well quite a bit weirder. 
2. I agree with lhecker. INT_MAX for all I know. I'm sure there's _technically_ a smarter value out there to use for "the largest/smallest possible window coordinate", but I'm not sure we _need_ to be that precise. 

Fix patch:
diff --git a/src/cascadia/TerminalSettingsEditor/Launch.xaml b/src/cascadia/TerminalSettingsEditor/Launch.xaml
index a76d78cacec..71d0827e2b3 100644
--- a/src/cascadia/TerminalSettingsEditor/Launch.xaml
+++ b/src/cascadia/TerminalSettingsEditor/Launch.xaml
@@ -30,6 +30,14 @@
                 <Setter Property="LargeChange" Value="10" />
                 <Setter Property="Minimum" Value="1" />
             </Style>
+            <Style x:Key="LaunchPositionNumberBoxStyle"
+                   BasedOn="{StaticResource NumberBoxSettingStyle}"
+                   TargetType="muxc:NumberBox">
+                <Setter Property="SmallChange" Value="1" />
+                <Setter Property="LargeChange" Value="10" />
+                <Setter Property="Minimum" Value="-2147483648" />
+                <Setter Property="Maximum" Value="2147483647" />
+            </Style>
         </ResourceDictionary>
     </Page.Resources>
 
@@ -242,7 +250,7 @@
                                             Grid.Column="0"
                                             Width="118"
                                             IsEnabled="{x:Bind local:Converters.InvertBoolean(ViewModel.UseDefaultLaunchPosition), Mode=OneWay}"
-                                            Style="{StaticResource LaunchSizeNumberBoxStyle}"
+                                            Style="{StaticResource LaunchPositionNumberBoxStyle}"
                                             Value="{x:Bind ViewModel.InitialPosX, Mode=TwoWay}" />
                             <muxc:NumberBox x:Name="PosYBox"
                                             x:Uid="Globals_InitialPosYBox"
@@ -250,7 +258,7 @@
                                             Grid.Column="1"
                                             Width="118"
                                             IsEnabled="{x:Bind local:Converters.InvertBoolean(ViewModel.UseDefaultLaunchPosition), Mode=OneWay}"
-                                            Style="{StaticResource LaunchSizeNumberBoxStyle}"
+                                            Style="{StaticResource LaunchPositionNumberBoxStyle}"
                                             Value="{x:Bind ViewModel.InitialPosY, Mode=TwoWay}" />
                             <CheckBox x:Name="UseDefaultLaunchPositionCheckbox"
                                       x:Uid="Globals_DefaultLaunchPositionCheckbox"


Test patch: