Subject: bug#75936: monitor width reporting

From: "david" <[email-masked]>
Date: Wed, 29 Jan 2025 17:03:39 -0700

This is a bug that caused me some trouble; but mainly it is FYI.  The physical
arrangement is a laptop, which has a 4K screen, driving a single 4K screen.  I
get (still and always) the different results below from two different Emacs
builds.

The items below are:

A: code from a startup file; the messages are debug stuff, normally absent, the
   intention behind the code is to compute the aspect ratio of a single monitor.

B and C: output from two different Emacs builds, see ned and nut directories.
         The different widths matter to me because I am computing a ratio that
         later wreak havoc 8-(  The creation dates probably matter to you.
         Other than the dates I see no way to differentiate between the builds.

 A
  ;; Probably this is not the aspect ratio of the full screen, probably the window manager will keep
  ;; some of the screen for itself.
  (defconst  .emacs-monitor-aspect-ratio
    (let  ((geometry  (assoc  'geometry  (frame-monitor-attributes  (selected-frame))) ))
      (message  (format  "geometry   %s"  geometry))
      (message  (format  "width      %s" (float  (nth  3  geometry))))
      (message  (format  "height     %s" (nth  4  geometry)))
      (message  (format  "pix width  %s" (display-pixel-width)))
      (message  (format  "pix height %s" (display-pixel-height)))
      (message  (format  "mm width   %s" (display-mm-width)))
      (message  (format  "mm height  %s" (display-mm-height)))
      (message  (format  "screens    %s" (display-screens)))
      (message  (format  "attributes %s" (display-monitor-attributes-list)))
      (message  (format  "frame atts  %s" (frame-monitor-attributes)))
      (/  (float  (nth  3  geometry))
          (nth  4  geometry)))
    "*The ratio width/height for the current display screen, calculated in screen pixels.")

 B
    .emacs-emacs-directory:  /home/dajo/ned/emacs-29.3/
geometry   (geometry 0 0 3840 2160)
width      3840.0
height     2160
pix width  7680
pix height 2160
mm width   2032
mm height  572
screens    1
attributes (((name . DP-1) (geometry 0 0 3840 2160) (workarea 0 72 3840 2088) (mm-size 597 336) (frames #<frame *scratch* - GNU Emacs at Aglaea 0x559619a129a8>) (source . XRandR 1.5)) ((name . eDP-1) (geometry 3840 0 3840 2160) (workarea 3840 0 3840 2160) (mm-size 309 173) (frames) (source . XRandR 1.5)))
frame atts  ((name . DP-1) (geometry 0 0 3840 2160) (workarea 0 72 3840 2088) (mm-size 597 336) (frames #<frame *scratch* - GNU Emacs at Aglaea 0x559619a129a8>) (source . XRandR 1.5))

Nepenthes .emacs loading in GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
 of 2024-07-18.

 C
    .emacs-emacs-directory:  /home/dajo/nut/emacs-29.3/
geometry   (geometry 0 0 7680 2160)
width      7680.0
height     2160
pix width  7680
pix height 2160
mm width   2032
mm height  572
screens    1
attributes (((name . combined screen) (geometry 0 0 7680 2160) (workarea 0 72 7680 2088) (mm-size 2032 572) (frames #<frame *scratch* - GNU Emacs at Aglaea 0x5620435c10a8>) (source . fallback)))
frame atts  ((name . combined screen) (geometry 0 0 7680 2160) (workarea 0 72 7680 2088) (mm-size 2032 572) (frames #<frame *scratch* - GNU Emacs at Aglaea 0x5620435c10a8>) (source . fallback))

Nepenthes .emacs loading in GNU Emacs 29.3 (build 3, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
 of 2025-01-29.