lv_drivers icon indicating copy to clipboard operation
lv_drivers copied to clipboard

Windows: create a window which fits selected resolution better

Open danie1kr opened this issue 1 year ago • 3 comments

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

danie1kr avatar Feb 12 '24 09:02 danie1kr

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

kisvegabor avatar Feb 12 '24 19:02 kisvegabor

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

danie1kr avatar Feb 12 '24 21:02 danie1kr

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

https://github.com/lvgl/lv_drivers/blob/451e659cf68d65a7ce13ec7f6a1df16d1c678872/win32drv/win32drv.c#L905-L941

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

MouriNaruto avatar Feb 12 '24 23:02 MouriNaruto