GTK4 doesn't respect size changes from `WM_WINDOWPOSCHANGED` events on Windows
Steps to reproduce
- Spawn a GTK4 window on Windows.
- Either from the application itself, or from an external source, try to programmatically change the window resolution with
SetWindowPos
,MoveWindow
, or some other mechanism.
Current behavior
WM_WINDOWPOSCHANGED
events cannot cause a change in size, only position, Z-order, and other attributes. Something in GTK is suppressing size changes.
Expected outcome
GTK windows should resize in response to matching WM_WINDOWPOSCHANGED
events. I believe those are the only events being sent for resizes since GTK suppresses the WM_MOVE
and WM_RESIZE
events
Version information
GTK 4.6.2, Windows 10 (msvc), using vcpkg
Additional information
I was porting my application to Windows and noticed it wasn't reacting properly to resize events, whether originating from my application directly using SetWindowPos
/MoveWindow
or using external scripts to set it. The position, Z-order, and attributes change but the size does not, and it's only GTK applications that are affected.
I added a hook myself to log the events, here are two sample WINDOWPOS
structs from WM_WINDOWPOSCHANGED
from running my script once:
- WINDOWPOS { hwnd: HWND(17041336), hwndInsertAfter: HWND(0), x: 228, y: 228, cx: 2000, cy: 1000, flags: SET_WINDOW_POS_FLAGS(4118) }
- WINDOWPOS { hwnd: HWND(17041336), hwndInsertAfter: HWND(0), x: 228, y: 228, cx: 928, cy: 629, flags: SET_WINDOW_POS_FLAGS(4118) }
The first one was caused by me directly entering "2000" for width and "1000" for height in my AHK script. The second event followed the first almost instantly and I do not know what caused it, but its cx
and cy
match the current resolution of the window, which did not change. The values and flags are the same even use SetWindowPos
from within the application.
- Sample application that only opens a window: gtk4.c
- Simple AHK script to change window sizes (win + =)resize.ahk, this works for all non-GTK windows I've tested it on.