lvgl / lv_port_pc_visual_studio

Visual Studio projects for LVGL embedded graphics library. Recommended on Windows. Linux support with Wayland is work in progress.
MIT License
552 stars 282 forks source link

Size of the screen is not perfect. #63

Open Kirbyrawr opened 6 months ago

Kirbyrawr commented 6 months ago

Problem

When you specify 800x480 for example, the size of the content screen is less than that since is taking space from the title bar.

Potential Solution

When initializing the screen in the wind32drv.c, we can modify the CreateWindowExW in this way:

HWND display_window_handle = CreateWindowExW(
    NULL,
    LVGL_SIMULATOR_WINDOW_CLASS,
    window_title,
    WS_POPUP,
    CW_USEDEFAULT,
    0,
    hor_res,
    ver_res,
    NULL,
    NULL,
    instance_handle,
    NULL);

Basically we change

This way the screen wont have title bar but the content size will be the exact one. imagen

MouriNaruto commented 6 months ago

When you specify 800x480 for example, the size of the content screen is less than that since is taking space from the title bar.

If you have read the implementation, you will know the implementation will adjust to the correct content resolution. So, it won’t affect.

https://github.com/lvgl/lv_port_pc_visual_studio/blob/c042c669ba4881fd273890e0c2aeff843bc4e53a/LvglWindowsSimulator/win32drv.c#L1518-L1523

https://github.com/lvgl/lv_port_pc_visual_studio/blob/c042c669ba4881fd273890e0c2aeff843bc4e53a/LvglWindowsSimulator/win32drv.c#L1585-L1627

Kenji Mouri

Kirbyrawr commented 6 months ago

When you specify 800x480 for example, the size of the content screen is less than that since is taking space from the title bar.

If you have read the implementation, you will know the implementation will adjust to the correct content resolution. So, it won’t affect.

https://github.com/lvgl/lv_port_pc_visual_studio/blob/c042c669ba4881fd273890e0c2aeff843bc4e53a/LvglWindowsSimulator/win32drv.c#L1518-L1523

https://github.com/lvgl/lv_port_pc_visual_studio/blob/c042c669ba4881fd273890e0c2aeff843bc4e53a/LvglWindowsSimulator/win32drv.c#L1585-L1627

Kenji Mouri

Hi Kenji, that looks like it should do the trick, however, when i tested it, i took several screenshots with different sizes, etc... they were all having less because of the title bar, i'm not sure if it was a bug on my side or what.

Kirbyrawr commented 5 months ago

Hi, regarding this problem, it looks like it's related to the DPI of 125% from Windows of my screen, 400 x 300 is 320 x 240 * 1.25 that is my scale. I tried to put the overrideDPI as false and true and nothing changes there.

Kirbyrawr commented 5 months ago

Even in the latest commit is still like that, i'm not sure if i'm doing something wrong.

MouriNaruto commented 5 months ago

Hi, regarding this problem, it looks like it's related to the DPI of 125% from Windows of my screen, 400 x 300 is 320 x 240 * 1.25 that is my scale.

https://docs.lvgl.io/master/integration/driver/windows.html

Maybe this doc will do some help.

Kenji Mouri

Kirbyrawr commented 5 months ago

Hi there @MouriNaruto thanks for the link, sadly it doesn't work. Let me explain the situation...

If i run LVGLSimulator project with DPI 100% in Windows, it works. ✅ If i run LVGLSimulator project with DPI 125% in Windows, it doesn't work. ❌

I tried both simulator and desktop mode, also i tried to change DPI Override etc..., it doesn't work.

Kirbyrawr commented 5 months ago

320 x 240 pixels.

DPI 100% Simulator Mode ✅ imagen

DPI 125% Simulator Mode ❌ imagen

You can check that the size is different, changing the desktop and dpi in code doesn't work.

MouriNaruto commented 5 months ago

Got it. I will try to do some fix.

Kenji Mouri

19e2k67 commented 1 week ago

Snipaste_2024-06-29_13-09-17 my computer DPI = 125%, I change LvglWindowsSimulator.cpp 26 line

bool simulator_mode = false;

it present 100% Snipaste_2024-06-29_12-56-08 Default is true, display 125%, font is blurry Snipaste_2024-06-29_12-56-22