View Ticket
Not logged in
Ticket Hash: 0c7dac6fccdf5eb668b2073c6cc7777712944c29
Title: [tk scaling] on undroidwish gives different results than on wish, on the same machine
Status: Closed Type: Code_Defect
Severity: Minor Priority: Medium
Subsystem: Resolution: Works_As_Designed
Last Modified: 2019-05-18 04:15:23
Version Found In:
User Comments:
anonymous added on 2019-05-15 09:42:10: (text/x-fossil-plain)
Testing on an AMD64 running Kubuntu 16.04, using wish:

% tk scaling
1.3333333333333333

Testing on the same PC using undroidwish:

% tk scaling
1.0006771314250538

As a result, content on undroidwish looks smaller when using density dependent units.

chw added on 2019-05-15 20:15:48: (text/x-fossil-plain)
Works as designed and was documentent about 3 years ago, see [427535dec3571d4d8afb52c0d0ae6c20e7835afa]

anonymous added on 2019-05-16 13:50:49: (text/x-fossil-plain)
It seems I forgot to RTFM. Thanks!

anonymous added on 2019-05-17 11:38:04: (text/html)
More on this issue:
<br><br>
My goal is to present an sdltk window on a desktop PC that accurately emulates the screen of a mobile phone/tablet device. To achieve this I do the following:
<ol>
<li>Write down the target device's densitydpi and density, as returned by the command `borg displaymetrics` run on androwish on the mobile device. An example of such result from an actual device is: `densitydpi 240 density 1.5`</li>
<li>On the PC, run `undroidwish -sdlxdpi <densitydpi>`, where <densitydpi> is the value returned by the above `borg displaymetrics` command.</li>
<li>Inside undroidwish, run the following code:</li>
<code><pre>
% tk scaling
3.344855967078189
# set `tk scaling` to the <density> value return by `borg displaymetrics`
% tk scaling 1.5
# create a shape with specs dependent on device dpi:
% pack [frame .f -width 20m -height 20m -bg red] -padx 20m -pady 20m 
<pre><code>
<li>Measure the red rectangular representing the specified tk frame widget. Result: It measures exactly the specified 20mm.</li>
</ol>
So I conclude that this method gives an adequate solution to the set goal. Now the problem:
<br><br>
While tk seems to be correctly set to display the content, the sdltk window borders are scaled by the -sdlxdpi value given at the command line, which seems to be approx. 240.0/72 = 3.333.., in the above example. <a href='https://github.com/dzach/awemu/blob/master/issues/sdltk_border.png'>See this screenshot</a>. The size of the font in the console is not a problem; it will resize properly once the console is redrawn by Tk. But...
<br><br>
I have not found a way to set sdltk's window borders. Tk commands for toplevel windows do not seem to influence sdltk's window decoration in undroidwish. I can make them disappear, e.g. by running `wm overrideredirect`, but then the ability to move the windows around is lost. 
<br><br>
How can one change window decoration sizes in sdltk? It seems they should be tied to the `tk scaling` that undroidwish comes up with initially.

chw added on 2019-05-17 17:43:53: (text/x-fossil-plain)
There are some hard coded steps in which the window manager decorations
are adapted to the dpi ratio of the screen. This was needed especially
on Android devices which have a great bandwidth of dpis (140 ... 550).

There's certainly room for improvement but I have no time for it. If you'd
like to contribute a patch, I'll gladly integrate it.

anonymous added on 2019-05-17 21:48:44: (text/x-fossil-plain)
What would be a location to start looking?

chw added on 2019-05-18 04:15:23: (text/x-fossil-plain)
[b65fa01ff47e67b9ff62e3e404ee97fbdf3397f9]

[6586a4973f3eebf82fb9487f2221554a5f0a48c3]

search for "dpi" and "dec_frame_height"