diff options
| author | Alan Third | 2025-05-26 20:27:39 +0100 |
|---|---|---|
| committer | Alan Third | 2025-06-02 18:34:10 +0100 |
| commit | 50e3bce315eb499917c1d208f87f84315f1a8b4e (patch) | |
| tree | 47431d7680652f0bc1f4a95f3509f3e259f8c932 /src | |
| parent | 9cc5f1c697c1a47470651ff4293f335eaa10ea9a (diff) | |
| download | emacs-50e3bce315eb499917c1d208f87f84315f1a8b4e.tar.gz emacs-50e3bce315eb499917c1d208f87f84315f1a8b4e.zip | |
Fix NS port screen geometry report (bug#76051)
* src/nsfns.m (Fns_display_monitor_attributes_list): Fix the arithmetic
to calculate the origin of the visible frame.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsfns.m | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/src/nsfns.m b/src/nsfns.m index b219064cdd1..41400e8883f 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -2692,41 +2692,28 @@ Internal use only, use `display-monitor-attributes-list' instead. */) | |||
| 2692 | struct MonitorInfo *m = &monitors[i]; | 2692 | struct MonitorInfo *m = &monitors[i]; |
| 2693 | NSRect fr = [s frame]; | 2693 | NSRect fr = [s frame]; |
| 2694 | NSRect vfr = [s visibleFrame]; | 2694 | NSRect vfr = [s visibleFrame]; |
| 2695 | short y, vy; | ||
| 2696 | 2695 | ||
| 2697 | #ifdef NS_IMPL_COCOA | 2696 | #ifdef NS_IMPL_COCOA |
| 2698 | NSDictionary *dict = [s deviceDescription]; | 2697 | NSDictionary *dict = [s deviceDescription]; |
| 2699 | NSNumber *nid = [dict objectForKey:@"NSScreenNumber"]; | 2698 | NSNumber *nid = [dict objectForKey:@"NSScreenNumber"]; |
| 2700 | CGDirectDisplayID did = [nid unsignedIntValue]; | 2699 | CGDirectDisplayID did = [nid unsignedIntValue]; |
| 2701 | #endif | 2700 | #endif |
| 2701 | |||
| 2702 | /* The primary display is always the first in the array. */ | ||
| 2702 | if (i == 0) | 2703 | if (i == 0) |
| 2703 | { | 2704 | primary_display_height = fr.size.height; |
| 2704 | primary_display_height = fr.size.height; | 2705 | |
| 2705 | y = (short) fr.origin.y; | 2706 | /* Flip y coordinate as NS screen coordinates originate from |
| 2706 | vy = (short) vfr.origin.y; | 2707 | the bottom. */ |
| 2707 | } | ||
| 2708 | else | ||
| 2709 | { | ||
| 2710 | /* Flip y coordinate as NS screen coordinates originate from | ||
| 2711 | the bottom. */ | ||
| 2712 | y = (short) (primary_display_height - fr.size.height - fr.origin.y); | ||
| 2713 | vy = (short) (primary_display_height - | ||
| 2714 | vfr.size.height - vfr.origin.y); | ||
| 2715 | } | ||
| 2716 | 2708 | ||
| 2717 | m->geom.x = (short) fr.origin.x; | 2709 | m->geom.x = (short) fr.origin.x; |
| 2718 | m->geom.y = y; | 2710 | m->geom.y = (short) (primary_display_height - NSMaxY(fr)); |
| 2719 | m->geom.width = (unsigned short) fr.size.width; | 2711 | m->geom.width = (unsigned short) fr.size.width; |
| 2720 | m->geom.height = (unsigned short) fr.size.height; | 2712 | m->geom.height = (unsigned short) fr.size.height; |
| 2721 | 2713 | ||
| 2714 | /* The work area excludes the menu bar and the dock. */ | ||
| 2722 | m->work.x = (short) vfr.origin.x; | 2715 | m->work.x = (short) vfr.origin.x; |
| 2723 | /* y is flipped on NS, so vy - y are pixels missing at the | 2716 | m->work.y = (short) (primary_display_height - NSMaxY(vfr)); |
| 2724 | bottom, and fr.size.height - vfr.size.height are pixels | ||
| 2725 | missing in total. | ||
| 2726 | |||
| 2727 | Pixels missing at top are fr.size.height - vfr.size.height - | ||
| 2728 | vy + y. work.y is then pixels missing at top + y. */ | ||
| 2729 | m->work.y = (short) (fr.size.height - vfr.size.height) - vy + y + y; | ||
| 2730 | m->work.width = (unsigned short) vfr.size.width; | 2717 | m->work.width = (unsigned short) vfr.size.width; |
| 2731 | m->work.height = (unsigned short) vfr.size.height; | 2718 | m->work.height = (unsigned short) vfr.size.height; |
| 2732 | 2719 | ||