Nothing Special   »   [go: up one dir, main page]

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

The Window size (client area) is incorrect when using Windows display driver. #6679

Open
sliang951753 opened this issue Aug 14, 2024 · 9 comments

Comments

@sliang951753
Copy link

LVGL version

v9.0.0

What happened?

When using lv_windows_create_display() to create LVGL display, the Window's client area always smaller than the specified screen resolution.
for example, lv_windows_create_display(L"LVGL Window", 1024, 600, 100, true, false);
then, the created window is at the resolution of 1024*600, however, its client area is smaller and about to 1000 * 550.

This is because the specified display resolution does not consider the window caption and client edge size.

Here's a possible fix for this issue.
In lv_windows_display_thread_entrypoint() function, calling AdjustWindowRectEx before CreateWindowExW.

` RECT rc = {0, 0, data->hor_res, data->ver_res};
AdjustWindowRectEx(&rc, window_style, FALSE, WS_EX_CLIENTEDGE);

HWND window_handle = CreateWindowExW(
                         WS_EX_CLIENTEDGE,
                         L"LVGL.Window",
                         data->title,
                         window_style,
                         CW_USEDEFAULT,
                         0,
                         rc.right - rc.left,
                         rc.bottom - rc.top,
                         NULL,
                         NULL,
                         NULL,
                         data);`

How to reproduce?

No response

@sliang951753 sliang951753 changed the title The Window size (client area) is incorrected when using Windows display driver. The Window size (client area) is incorrect when using Windows display driver. Aug 14, 2024
@lvgl-bot
Copy link

We need some feedback on this issue.

Now we mark this as "stale" because there was no activity here for 14 days.

Remove the "stale" label or comment else this will be closed in 7 days.

@lvgl-bot lvgl-bot added the stale label Aug 29, 2024
@kisvegabor
Copy link
Member

Thank you for reporting it!

@MouriNaruto could you take look at this issue?

@vwheeler63
Copy link
Contributor
vwheeler63 commented Aug 29, 2024
> HWND window_handle = CreateWindowExW(
>                          WS_EX_CLIENTEDGE,
>                          L"LVGL.Window",
>                          data->title,
>                          window_style,
>                          CW_USEDEFAULT,
>                          0,
>                          rc.right - rc.left,
>                          rc.bottom - rc.top,
>                          NULL,
>                          NULL,
>                          NULL,
>                          data);

I believe there are also 2 one-off errors in this call. Specifically:

width should be = rc.right - rc.left + 1 + (2 * edge_width);
height should be = rc.bottom - rc.top + 1 + (2 * edge_width) + title_bar_height;

or

width should be = rc.right - rc.left + 1 + (edge_width << 1);
height should be = rc.bottom - rc.top + 1 + (edge_width << 1) + title_bar_height;

if your compiler doesn't optimize multiplying by 2.

I am a little rusty on CreateWindowExW(), but what I remember about Win32 is that (using Win32 data):

Width = Right - Left
Height = Bottom - Top

and I am 100% certain that:

Right = 1 pixel PAST right edge, and
Bottom = 1 pixel PAST bottom edge.

Note: There are ways to create a window where the width and height passed are for the CLIENT AREA, which is what is wanted. This question/answer on stackexchange.com covers one way to do that.

Kind regards,
Vic

@MouriNaruto
Copy link
Contributor

I will try to fix that.

Kenji Mouri

@lvgl-bot lvgl-bot removed the stale label Sep 1, 2024
@lvgl-bot
Copy link

We need some feedback on this issue.

Now we mark this as "stale" because there was no activity here for 14 days.

Remove the "stale" label or comment else this will be closed in 7 days.

@lvgl-bot lvgl-bot added the stale label Sep 16, 2024
@kisvegabor
Copy link
Member

@MouriNaruto did you have time to look into this?

@MouriNaruto
Copy link
Contributor

I will look into this issue in the recent days.

Kenji Mouri

@lvgl-bot lvgl-bot removed the stale label Sep 18, 2024
@lvgl-bot
Copy link
lvgl-bot commented Oct 3, 2024

We need some feedback on this issue.

Now we mark this as "Abandoned" because there was no activity here for 14 days.

Remove the "Stale" label or comment else this will be closed in 7 days.

@lvgl-bot lvgl-bot added the stale label Oct 3, 2024
@MouriNaruto
Copy link
Contributor

not stale

@lvgl-bot lvgl-bot removed the stale label Oct 5, 2024
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

5 participants