Tk Source Code

View Ticket
Login
Ticket UUID: 985607f2406d737a124f6a5b68a8139262c17003
Title: Tk reports wrong physical screen size
Type: Bug Version: 8.6
Submitter: anonymous Created on: 2016-01-16 13:41:53
Subsystem: 67. Unix Window Operations Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Pending Last Modified: 2026-09-23 20:00:00
Resolution: None Closed By: nobody
    Closed on:
Description:

Test code:

% winfo screenwidth .
3840
% winfo screenheight .
1080
% winfo screenmmwidth .
1013
# ^ reports total dual monitor width. Monitors are identical, so for each, screenmmwidth = 506.5mm 
% winfo screenmmheight .
284
However, xrandr gives different values which, after measuring the actual screens, prove to be the correct ones:
$ xrandr
Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 8192 x 8192
VGA-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 477mm x 268mm
   1920x1080      60.0*+
   1680x1050      60.0  
   1400x1050      60.0  
   1600x900       60.0  
   1280x1024      75.0     60.0  
   1440x900       59.9  
   1280x800       59.8  
   1152x864       75.0  
   1280x720       60.0  
   1024x768       75.1     60.0  
   832x624        74.6  
   800x600        75.0     60.3     56.2  
   640x480        75.0     60.0  
   720x400        70.1  
HDMI-0 disconnected (normal left inverted right x axis y axis)
DVI-0 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 477mm x 268mm
   1920x1080      60.0*+
   1680x1050      59.9  
   1280x1024      75.0     60.0  
   1152x864       75.0  
   1024x768       75.1     60.0  
   800x600        75.0     60.3  
   640x480        75.0     60.0  
   720x400        70.1  
Screen geometry reported by xrandr: 3840 x 1080 px (correct).
Physical size reported by xrandr: 477mm x 268mm (per screen, correct)

Horizontal and vertical screen sizes reported by Tk are wrong. Tests have been done with 2x LG FLATRON E2251 and verified on a single LG-22EA53.

The problem is amplified when simulating AndroWish apps on desktop PCs, because it becomes difficult to match font sizes due to the wrong resulting dpi.

dzach

User Comments: serhiy.storchaka added on 2026-09-23 20:00:00:

winfo screenmmwidth does not report a measured size. Since tk scaling writes the millimetre dimensions of the screen back into the X screen structure (generic/tkCmds.c), the value follows Tk's scaling factor. On my display with 9.1b1:

tk scaling 1.998 (scalingPct 150) -> winfo screenmm 452 x 282
tk scaling 1.0                    -> winfo screenmm 903 x 564
xdpyinfo                          -> 677 x 423 mm (96 dpi, nominal)
xrandr eDP-1                      -> 388mm x 242mm (EDID, the real panel)

The server value itself is nominal too: it is the logical screen size at an assumed dpi, which is where the 1013 mm for two 477 mm monitors comes from (3840 px at 96 dpi is about 1016 mm). Only RandR per output carries the physical size, and Tk has no per monitor query: winfo only knows screens, and on Xinerama the two monitors are one screen.

Making winfo screenmm* report EDID data would change every dimension given in millimetres, since the same values drive winfo fpixels . 1m and all mm options. A per monitor query would be a new feature, that is a TIP.


anonymous added on 2016-01-17 10:14:49:

Missing OS info:

Kubuntu 14.04, Linux 3.13.0-39-generic #66-Ubuntu SMP i686 GNU/Linux
dzach