[CmdPal] Added recenter window support.
Summary of the Pull Request
Added a new setting option to Command Palette that allows users to choose whether the window should be recentered on every launch or remember its last position. This enhancement improves user experience by maintaining window positioning preferences across sessions.
PR Checklist
- [x] Closes: #38310
- [x] Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
- [ ] Tests: Added/updated and all pass
- [ ] Localization: All end user facing strings can be localized
- [ ] Dev docs: Added/updated
- [ ] New binaries: Added on the required places
- [ ] JSON for signing for new binaries
- [ ] WXS for installer for new binaries and localization folder
- [ ] YML for CI pipeline for new test projects
- [ ] YML for signed pipeline
- [ ] Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx
Detailed Description of the Pull Request / Additional comments
This PR adds a "Recenter window on launch" setting to Command Palette with the following changes:
- Added a new
RecenterWindowproperty toSettingsModel(default is true for backward compatibility) - Added corresponding property to
SettingsViewModelfor binding - Created a new
WindowPositionclass to track window position and size - Modified
MainWindow.xaml.csto:- Track window position and size changes
- Update position memory when window is modified or dismissed
- Respect the recenter setting when showing the window
- Added UI controls in the settings page with proper localization strings
This feature allows users who prefer to have the Command Palette appear in a specific screen location to maintain that preference, while others can continue using the centered window behavior.
Validation Steps Performed
- Manually verified that with the setting enabled (default), the window centers on launch
- Verified that with the setting disabled, the window appears at its last position
Can we move the new setting nearby the monitor selection setting? Would make sense
Can we move the new setting nearby the monitor selection setting? Would make sense
Done.
Ok, fine. Let me summarize:
currently, we will always open cmdpal in the center right?
After this change, we can:
- Open cmdpal in the center.
- Open cmdpal in the last position.
I think the config text is wired. We have one behaviour as default (open in the center), so we need to add a settings for another behaviour, right?
I think "Always Open in the center" or "Open in the last position" is better. We don't need to mix the two behaviour in one description.
Ok, fine. Let me summarize:
currently, we will always open cmdpal in the center right?
After this change, we can:
- Open cmdpal in the center.
- Open cmdpal in the last position.
I think the config text is wired. We have one behaviour as default (open in the center), so we need to add a settings for another behaviour, right?
I think "Always Open in the center" or "Open in the last position" is better. We don't need to mix the two behaviour in one description.
We do not have any setting to control the window open position. After adding this setting, user can control the window open position, and by default it will always be opened in center of screen, if user want to open the window at the place where it was closed last time, they can disable this setting.
/azp run
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.
/azp run
Azure Pipelines successfully started running 1 pipeline(s).
Okay I just checked this branch out. My immediate thought is that if this setting overrides the setting from SummonOn, then it should just be another enum value of MonitorBehavior, it shouldn't be a separate boolean
Okay I just checked this branch out. My immediate thought is that if this setting overrides the setting from
SummonOn, then it should just be another enum value ofMonitorBehavior, it shouldn't be a separate boolean
Looks like it need more thinking and time for this PR.
The PR current implementation doesn't persist the "position" to disk, i.e. there is still need a behavior on "new launch" Moreover, there will be still plug and unplug new monitor scenario which it need fallback setting.
The perfect case should be it remember my common monitors setting up to X, and remember the position per a given monitors setting even on relaunch.
Yea I concur. Let's pull this one from 0.91 and get this early in 0.92
Hiya @shuaiyuanxx, looks like we're still needing:
- Persist location to disk
- Set location on startup
Is that it?
Hiya @shuaiyuanxx, looks like we're still needing:
- Persist location to disk
- Set location on startup
Is that it?
I think so.