Skip to content

Commit df3c836

Browse files
committed
Bump core: one logical screen space on Windows across mixed scale factors; spec the screen coordinates
1 parent 24eafb2 commit df3c836

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎bindings/dart/nativeapi/CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
on Windows and Linux as well, and ends the process on Linux, as documented.
1818
On Windows it destroys the windows before the loop ends, so a Flutter app's
1919
engine shuts down cleanly instead of crashing in its teardown.
20+
* Windows: screen coordinates are one logical space across monitors with
21+
different scale factors, laid out side by side as Chromium does. A window's
22+
position and bounds survive being saved and restored on any monitor, and
23+
moving a window onto a monitor with another factor keeps the size asked for.
24+
Display positions change where monitors have different factors (they
25+
overlapped before); `TrayIcon.bounds` and menu positions are logical now,
26+
like everything else, instead of physical pixels.
2027
* `Application.show()`, `Application.hide()` and `Application.isVisible()`:
2128
application-level hiding on macOS (`-[NSApplication hide:]`), which the Dock
2229
understands, unlike hiding every window. They return false on other

‎specs/api-style.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,25 @@ C 没有重载,codegen 给重载方法加参数后缀:`Run(window)` →
175175
8. 不出现:裸指针(`void*` 原生对象与 `const char*` 除外)、输出参数、`std::pair` /
176176
`std::tuple`、模板方法、运算符。多值返回就定义一个值 struct。
177177

178+
### 2.1 屏幕坐标
179+
180+
凡是「screen coordinates」——窗口的位置与 bounds、显示器的位置与工作区、光标位置、
181+
托盘图标的 bounds、`PositioningStrategy` 的绝对点与矩形——都在**同一个逻辑像素空间**里,
182+
原点在主显示器左上角,y 向下。同一个值能在这些 API 之间互传:拿托盘图标的 bounds
183+
去摆窗口、拿窗口的 bounds 去弹菜单,不需要调用方换算。尺寸(宽高、最小 / 最大尺寸)
184+
按所在显示器的缩放系数换算;相对坐标(View、内容区内的点)按窗口的系数换算。
185+
186+
各平台怎么落地:
187+
188+
- macOS:AppKit 的点本来就是这个空间(翻转 y 由 `coordinate_utils` 做)。
189+
- Linux:GDK 的逻辑坐标。
190+
- Windows:系统的屏幕坐标是物理像素,每块显示器一个系数,**不能**用「除以所在显示器的
191+
系数」得到逻辑空间——系数不同时显示器会在逻辑空间里重叠或出现空隙,一个逻辑点对应两个
192+
物理点。做法同 Chromium:主显示器为根,物理上相邻的显示器在逻辑空间里也贴边摆放,
193+
显示器内部只差它自己的系数(`platform/windows/screen_layout_windows.h`,换算入口在
194+
`dpi_utils_windows.h`)。所有显示器系数相同时,结果就是物理坐标除以该系数。
195+
新增任何进出屏幕坐标的 Windows 代码都走这些入口,不自己乘除系数。
196+
178197
## 3. 类型定义
179198

180199
### 3.1 枚举

0 commit comments

Comments
 (0)