Subject: bug#75936: monitor width reporting

From: Po Lu <[email-masked]>
Date: Thu, 30 Jan 2025 15:24:43 +0800

Eli Zaretskii <[email-masked]> writes:

>> 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.
>
> Can you tell more about the differences between these two builds?  Are
> they builds of the same Emacs version with the same configure-time
> switches/options and the same versions of the development tools, or
> are any of those factors different between the builds (and if so,
> which ones)?
>
>> 
>> 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.
>
> Looks like one of the outputs reports two separate screens, whereas
> the other reports a combined screen?  If so, aren't the differences
> expected?  Or what am I missing?

The latter Emacs build was configured on a system without XRandr
headers, XRandr being the X server extension that provides detailed
monitor information.