TCustomForm.WindowState is always wsNormal
Original Reporter info from Mantis: zpeterson @boramis
-
Reporter name: Zoë Peterson
Original Reporter info from Mantis: zpeterson @boramis
- Reporter name: Zoë Peterson
Description:
This patch fixes an issue where TForm's WindowState property was always wsNormal regardless of the actual state of the window. There were two different bugs involved:
-
When resizing a form, TLCLCommonCallback's boundsDidChange called lclWindowState on the TCocoaWindowContent object, rather than TCocoaWindow. Adding an override to call the window's lclWindowState fixes that. It's possible this could be simplified by just moving the TCocoaWindow.lclWindowState code down to TCocoaWindowContent.
-
Minimizing/restoring the window does not change its bounds, so the boundsDidChange method never runs. Fixed by adding a call to LCLSendSizeMsg when the window receives the windowDidMiniaturize and windowDidDeminiaturize messages.This could instead be redirected through the existing TLCLWindowCallback.resize and TLCLCommonCallback.boundsDidChange functions, but TLCLCommonCallback.boundsDidChange would need a way to check whether the TCustomForm Target's WindowState had changed since neither Resized nor ClientResized are true in this case.
Steps to reproduce:
Extract/compile the attached sample project and run it from the command line or put breakpoints in the FormResize and FormWindowStateChange events. It will write out when those functions are called and what the form's WindowState property is at that point. Prior to the patch, WindowState is always wsNormal, and neither FormResize nor FormWindowStateChange are called when minimize or de-minimizing a window.