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

优化主窗口位置 #762

Merged
merged 2 commits into from
Nov 26, 2023
Merged

优化主窗口位置 #762

merged 2 commits into from
Nov 26, 2023

Conversation

Blinue
Copy link
Owner

@Blinue Blinue commented Nov 26, 2023

  1. 保存的窗口尺寸改为和 DPI 无关,在启动时根据当前屏幕的 DPI 调整窗口大小。
  2. 启动时主窗口不会跨越多个屏幕,且将完全位于屏幕的工作区,也就是说不会和任务栏、Copilot 等重叠。这也是 UWP 窗口和文件资源管理器的行为。

关于 1 有一些微妙的地方:

  1. 旧版本配置文件将尽可能转换为新版本,但在一种情况下可能会出错:由于旧版本配置保存窗口的绝对位置,如果用户更改了多屏幕,导致原始窗口位置不存在屏幕了,将无法获取 DPI。这种情况下将假设和主屏幕相同,如果猜错了,就无法还原窗口的尺寸。
  2. 根据我的测试,创建窗口时 Windows 根据窗口中心点确定 DPI 缩放,这使我们可以在创建窗口前知晓 DPI。因此配置文件保存了窗口中心点,而不是左上角的坐标。
  3. 第一次打开 Magpie 时窗口尺寸也会根据 DPI 正确缩放,而之前是固定尺寸。
  4. 用户可能修改了多屏幕配置,这种情况也能完美处理。如果启动时中心点位置不存在屏幕,则由 Windows 决定位置,一般是正在使用的屏幕的左上角。如果 DPI 缩放后窗口太大无法被屏幕的工作区域容纳,则会将窗口调整为默认尺寸,就如同第一次打开 Magpie 一样。
  5. 如果由 Windows 决定位置,便无法在窗口显示前获取 DPI 了,在这种情况下先以零尺寸创建窗口,然后获取窗口 DPI 并设置 DPI 缩放后的尺寸。

@Blinue Blinue added enhancement New feature or request area: UI labels Nov 26, 2023
@Blinue Blinue merged commit e753069 into dev Nov 26, 2023
2 checks passed
@Blinue Blinue deleted the window-pos branch November 26, 2023 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: UI enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant