Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Conversation

@danie1kr
Copy link

try to get a window which is closer to the selected resolution. Still 2 pixels off horizontally, but better than what windows creates.

try to get a window which is closer to the selected resolution. Still 2 pixels off horizontally, but better than what windows creates.
@danie1kr danie1kr changed the title Update win32drv.c Windows: create a window which fits selected resolution better Feb 12, 2024
@kisvegabor
Copy link
Member

As it might affect existing projects I wouldn't touch this part.
However I would be happy to merge lvgl/lvgl#5639 if it's approved by @MouriNaruto.

@danie1kr
Copy link
Author

Sure, I understand. Actually, I moved from lv_drivers to pure lvgl when I fixed this.

@MouriNaruto
Copy link
Contributor

I don't think you have read the implementation carefully. The current 8.x implementation will apply the real size in WM_CREATE message.

RECT calculated_window_size;
calculated_window_size.left = 0;
calculated_window_size.right = MulDiv(
context->display_hor_res * WIN32DRV_MONITOR_ZOOM,
context->display_dpi,
USER_DEFAULT_SCREEN_DPI);
calculated_window_size.top = 0;
calculated_window_size.bottom = MulDiv(
context->display_ver_res * WIN32DRV_MONITOR_ZOOM,
context->display_dpi,
USER_DEFAULT_SCREEN_DPI);
AdjustWindowRectEx(
&calculated_window_size,
WINDOW_STYLE,
FALSE,
WINDOW_EX_STYLE);
OffsetRect(
&calculated_window_size,
-calculated_window_size.left,
-calculated_window_size.top);
SetWindowPos(
hWnd,
NULL,
0,
0,
calculated_window_size.right,
calculated_window_size.bottom,
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
lv_win32_register_touch_window(hWnd, 0);
lv_win32_enable_child_window_dpi_message(hWnd);
break;

I don't use AdjustWindowRect when creating window because it's not reliable.

image
First, AdjustWindowRect document said that to specify an extended window style, use the AdjustWindowRectEx function.

image
Second, AdjustWindowRectEx document said that this API is not DPI aware, and should not be used if the calling thread is per-monitor DPI aware. For the DPI-aware version of this API, see AdjustWindowsRectExForDPI.

Also, AdjustWindowsRectExForDPI is not reliable for enabling the DWM composition which is forced beginning with Windows 8. Especially the Windows 10 frameless-style window which is the DWM hacking.

So, this is why I chose only to pass the raw window size before. Because we need to let WM_CREATE message know the raw value for postprocessing. But for 8.x implementation is simplified because 8.x's driver only provides the simulator mode.

Kenji Mouri

@stale
Copy link

stale bot commented May 19, 2025

This issue or pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants