Bug 1807825 Comment 11 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

(In reply to Markus Stange [:mstange] from comment #7)
> [...]
> So it detects the screen based on the window's rectangle. It would probably be better to override this method in `nsCocoaWindow` by calling `-[NSWindow screen]`, i.e. asking macOS which screen it thinks the window is on.

It looks to me like the screen manager is queried for the screen for a particular rect that was previously "made" in [`MakeScreen`]((https://searchfox.org/mozilla-central/source/widget/cocoa/ScreenHelperCocoa.mm#79-132)), which does use `-[NSWindow screen]` indirectly via [`ScreenHelperCocoa::RefreshScreens`](https://searchfox.org/mozilla-central/source/widget/cocoa/ScreenHelperCocoa.mm#134-152). If I had to guess I'd say there is some kind of rounding error due to the backing scale factor which causes `ScreenManager::ScreenForRect` to return the wrong screen, but I haven't been able to isolate this yet.
(In reply to Markus Stange [:mstange] from comment #7)
> [...]
> So it detects the screen based on the window's rectangle. It would probably be better to override this method in `nsCocoaWindow` by calling `-[NSWindow screen]`, i.e. asking macOS which screen it thinks the window is on.

It looks to me like the screen manager is queried for the screen for a particular rect that was previously "made" in [`MakeScreen`]((https://searchfox.org/mozilla-central/source/widget/cocoa/ScreenHelperCocoa.mm#79-132)), which does use `-[NSWindow screen]` indirectly via [`ScreenHelperCocoa::RefreshScreens`](https://searchfox.org/mozilla-central/source/widget/cocoa/ScreenHelperCocoa.mm#134-152). If I had to guess I'd say there is some kind of rounding error due to the backing scale factor which causes [`ScreenManager::ScreenForRect`](https://searchfox.org/mozilla-central/source/widget/ScreenManager.cpp#118) to return the wrong screen, but I haven't been able to isolate this yet.
(In reply to Markus Stange [:mstange] from comment #7)
> [...]
> So it detects the screen based on the window's rectangle. It would probably be better to override this method in `nsCocoaWindow` by calling `-[NSWindow screen]`, i.e. asking macOS which screen it thinks the window is on.

It looks to me like the screen manager is queried for the screen for a particular rect that was previously "made" in [`MakeScreen`]((https://searchfox.org/mozilla-central/source/widget/cocoa/ScreenHelperCocoa.mm#79-132)), which does use `-[NSWindow screen]` indirectly via [`ScreenHelperCocoa::RefreshScreens`](https://searchfox.org/mozilla-central/source/widget/cocoa/ScreenHelperCocoa.mm#134-152). If I had to guess I'd say there is some kind of rounding error due to the backing scale factor which causes [`ScreenManager::ScreenForRect`](https://searchfox.org/mozilla-central/source/widget/ScreenManager.cpp#118) to return the wrong screen, but I haven't been able to isolate this yet. We seem to look for the screen with the largest intersection with the window, which should prevent rounding errors from being a factor. I'll try to take another look today.
(In reply to Markus Stange [:mstange] from comment #7)
> [...]
> So it detects the screen based on the window's rectangle. It would probably be better to override this method in `nsCocoaWindow` by calling `-[NSWindow screen]`, i.e. asking macOS which screen it thinks the window is on.

It looks to me like the screen manager is queried for the screen for a particular rect that was previously "made" in [`MakeScreen`]((https://searchfox.org/mozilla-central/source/widget/cocoa/ScreenHelperCocoa.mm#79-132)), which does use `-[NSWindow screen]` indirectly via [`ScreenHelperCocoa::RefreshScreens`](https://searchfox.org/mozilla-central/source/widget/cocoa/ScreenHelperCocoa.mm#134-152). If I had to guess I'd say there is some kind of error due to the backing scale factor which causes [`ScreenManager::ScreenForRect`](https://searchfox.org/mozilla-central/source/widget/ScreenManager.cpp#118) to return the wrong screen, but I haven't been able to isolate this yet. We seem to look for the screen with the largest intersection with the window, which should prevent rounding errors from being a factor. I'll try to take another look today.

Back to Bug 1807825 Comment 11