kons-9 icon indicating copy to clipboard operation
kons-9 copied to clipboard

Menu issue on 4k monitors.

Open aykaramba opened this issue 1 year ago • 15 comments

Opening up issue as per request in this ticket: https://github.com/kaveh808/kons-9/discussions/118#discussioncomment-3844190

PROBLEM: Menu boxes render properly but the text is offset by varying amounts on 4k mintor as per screenshot:

194181411-88334ee9-92af-452f-a7ad-75a7b478f355

The issue is still in the latest git pull of the test-engine branch as of posting of this ticket.

System info: Linux 5.10.0-18-amd64 https://github.com/kaveh808/kons-9/pull/1 SMP Debian 5.10.140-1 (2022-09-02) x86_64 GNU/Linux (Debian 11)

When I run this: (glfw:get-monitor-content-scale (glfw:get-primary-monitor))

The result is this: (1.1458334 1.1458334 )

aykaramba avatar Oct 11 '22 02:10 aykaramba

Thanks for the testing @aykaramba

In the file kons-9/src/graphics/glfw/minimal-ui.lisp, in the function show-window at the bottom of the file is this code:

          (setf (monitor-scale *drawing-settings*)
                (first (glfw:get-monitor-content-scale (glfw:get-primary-monitor))))

Try two things and see how they affect the font placement. Change the above expression to the following:

          (setf (monitor-scale *drawing-settings*) 1)
          (setf (monitor-scale *drawing-settings*) 2)

kaveh808 avatar Oct 11 '22 05:10 kaveh808

Well, that worked.

Details:

  1. (setf (monitor-scale drawing-settings) 1) produces this:

good

  1. (setf (monitor-scale drawing-settings) 2) produces this:

bad

For me, this is good enough, I can use this to keep playing around and testing. If you would like to have me do any further testing, please let me know. More than happy to help.

aykaramba avatar Oct 11 '22 05:10 aykaramba

Hmm, I wonder if your monitor is an odd case, or whether I should set the monitor scale to the floor of the specified value...

As far as more testing, please feel free to try out the scenes in demo.lisp and try out variations of your own to see if (a) you get any cool results we can add to our demos, or (b) you find bugs.

kaveh808 avatar Oct 11 '22 20:10 kaveh808

My 4K monitor is setup for 200% (2.0) scaling. The main UI text looks right but the menu draws in the wrong place:

https://user-images.githubusercontent.com/13791/195351519-0a145c0e-2b99-49ab-9b4b-391743756d4e.mp4

In principle I can work around this by changing the scaling factor to 1 though in practice that makes the text too small for me to read :)

How is scaling supposed to happen in the UI? Do all text operations need to be manually scaled? I tried adding some multiply-by-scaling-factor operations to ui-widgets.lisp but didn't stumble upon the right correction.

lukego avatar Oct 12 '22 13:10 lukego

I don't take the monitor-size into account for the GUI, but the text engine does, so this is probably the cause.

And yet everything looks correct on my MacOS external monitor (scale = 1) and my laptop display (scale = 2).

I'll reopen the issue...

kaveh808 avatar Oct 12 '22 19:10 kaveh808

you should be able to set the framebuffer-scale variable to whatever is returned by "get monitor content scale" and that should be a good foundation for tackling the problem. I think it has to be done before ensure-font is called.

On Wed, Oct 12, 2022 at 2:25 PM Kaveh Kardan @.***> wrote:

Reopened #125 https://github.com/kaveh808/kons-9/issues/125.

— Reply to this email directly, view it on GitHub https://github.com/kaveh808/kons-9/issues/125#event-7574700437, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABGMMIRVH7MSROLOKR6NFDWC4GBRANCNFSM6AAAAAARB253B4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

awolven avatar Oct 12 '22 19:10 awolven

right now it just assumes #+darwin and #-darwin framebuffer-scale 2 and 1 respectively, which is severe ignorance apparently.

On Wed, Oct 12, 2022 at 2:50 PM Andrew Wolven @.***> wrote:

you should be able to set the framebuffer-scale variable to whatever is returned by "get monitor content scale" and that should be a good foundation for tackling the problem. I think it has to be done before ensure-font is called.

On Wed, Oct 12, 2022 at 2:25 PM Kaveh Kardan @.***> wrote:

Reopened #125 https://github.com/kaveh808/kons-9/issues/125.

— Reply to this email directly, view it on GitHub https://github.com/kaveh808/kons-9/issues/125#event-7574700437, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABGMMIRVH7MSROLOKR6NFDWC4GBRANCNFSM6AAAAAARB253B4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

awolven avatar Oct 12 '22 20:10 awolven