in reply to Tk screen and monitor size in mm, DPI and scaling

Have you compared these results with what X11 gives you? (I know Windows is not X11 but you can have a simple X11 server by using something like MobaXterm on Windows).

use strict; use warnings; eval { use X11::Protocol; # Screen dimensions my $x11 = X11::Protocol->new (); my $screen = ($ENV{DISPLAY}//":0.0") =~ m/\.(\d+)$/ ? $1 : 0; $x11->choose_screen ($screen); # Root window printf "Screen is %4d x %4d x %2d pixels (%3d x %3d mm) (X11)\n", $x11->{width_in_pixels}, $x11->{height_in_pixels}, $x11->{root +_depth}, $x11->{width_in_millimeters}, $x11->{height_in_millimeters}; }; eval { use Tk; my $mw = Tk::MainWindow->new; printf "Screen is %4d x %4d x %2d pixels (%3d x %3d mm) (Tk)\n", $mw->screenwidth, $mw->screenheight, $mw->depth, $mw->screenmmwidth, $mw->screenmmheight; };
$ screen_size Screen is 3840 x 1200 x 24 pixels (1014 x 317 mm) (X11) Screen is 3840 x 1200 x 24 pixels (1014 x 317 mm) (Tk)

Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: Tk screen and monitor size in mm, DPI and scaling
by Discipulus (Canon) on Mar 12, 2021 at 11:05 UTC
    Hello Tux and thanks,

    do you really have a monitor 1014 x 317 mm? Or you get wrong answers too?

    I tried with MobaXterm and I get other wrong results

    xdpyinfo | grep 'dimensions:' dimensions: 3840x1080 pixels (1016x286 millimeters)

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      I have two monitors where the desktop is stretched over both, so the dimension in pixels is correct. The dimension in mm is per definition wrong, as the pixels are not of the same size for both displays (I need to replace one of them).

      $ inxi | grep res resolution: 1: 1920x1080~60Hz 2: 1920x1200~60Hz $ xdpyinfo | grep dim dimensions: 3840x1200 pixels (1014x317 millimeters)

      Enjoy, Have FUN! H.Merijn