Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size of the screen is not perfect. #63

Open
Kirbyrawr opened this issue Dec 31, 2023 · 9 comments
Open

Size of the screen is not perfect. #63

Kirbyrawr opened this issue Dec 31, 2023 · 9 comments

Comments

@Kirbyrawr
Copy link

Kirbyrawr commented Dec 31, 2023

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

  • WINDOW_EX_STYLE to NULL
  • WINDOW_STYLE to WS_POPUP

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

@MouriNaruto
Copy link
Collaborator

MouriNaruto commented Jan 2, 2024

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.

RECT request_content_size;
GetWindowRect(hWnd, &request_content_size);
lv_display_set_resolution(
context->display_device_object,
request_content_size.right - request_content_size.left,
request_content_size.bottom - request_content_size.top);

int32_t window_width = lv_windows_dpi_to_physical(
lv_windows_zoom_to_physical(
lv_display_get_horizontal_resolution(
context->display_device_object),
context->zoom_level),
context->window_dpi);
int32_t window_height = lv_windows_dpi_to_physical(
lv_windows_zoom_to_physical(
lv_display_get_vertical_resolution(
context->display_device_object),
context->zoom_level),
context->window_dpi);
RECT window_rect;
GetWindowRect(hWnd, &window_rect);
RECT client_rect;
GetClientRect(hWnd, &client_rect);
int32_t original_window_width =
window_rect.right - window_rect.left;
int32_t original_window_height =
window_rect.bottom - window_rect.top;
int32_t original_client_width =
client_rect.right - client_rect.left;
int32_t original_client_height =
client_rect.bottom - client_rect.top;
int32_t reserved_width =
original_window_width - original_client_width;
int32_t reserved_height =
original_window_height - original_client_height;
SetWindowPos(
hWnd,
NULL,
0,
0,
reserved_width + window_width,
reserved_height + window_height,
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
}

Kenji Mouri

@Kirbyrawr
Copy link
Author

Kirbyrawr commented Jan 3, 2024

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.

RECT request_content_size;
GetWindowRect(hWnd, &request_content_size);
lv_display_set_resolution(
context->display_device_object,
request_content_size.right - request_content_size.left,
request_content_size.bottom - request_content_size.top);

int32_t window_width = lv_windows_dpi_to_physical(
lv_windows_zoom_to_physical(
lv_display_get_horizontal_resolution(
context->display_device_object),
context->zoom_level),
context->window_dpi);
int32_t window_height = lv_windows_dpi_to_physical(
lv_windows_zoom_to_physical(
lv_display_get_vertical_resolution(
context->display_device_object),
context->zoom_level),
context->window_dpi);
RECT window_rect;
GetWindowRect(hWnd, &window_rect);
RECT client_rect;
GetClientRect(hWnd, &client_rect);
int32_t original_window_width =
window_rect.right - window_rect.left;
int32_t original_window_height =
window_rect.bottom - window_rect.top;
int32_t original_client_width =
client_rect.right - client_rect.left;
int32_t original_client_height =
client_rect.bottom - client_rect.top;
int32_t reserved_width =
original_window_width - original_client_width;
int32_t reserved_height =
original_window_height - original_client_height;
SetWindowPos(
hWnd,
NULL,
0,
0,
reserved_width + window_width,
reserved_height + window_height,
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
}

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
Copy link
Author

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
Copy link
Author

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

@MouriNaruto
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Author

Kirbyrawr commented Jan 22, 2024

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
Copy link
Collaborator

Got it. I will try to do some fix.

Kenji Mouri

@Bendikos
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants