Bug in NSViewComponentPeer::constrainRect()?


I found that the ComponentBoundsConstrainer doesn’t always work. I have a custom subclass of ComponentBoundsConstrainer and the checkBounds() method is not always called with the proper values for the isStretching* parameters. The problem is because these are set by comparing changes to the window bounds only the first time that NSViewComponentPeer::constrainRect() is called. So, if you click on the bottom/right corner of the window but happen to only size the width on the first mouse drag then the isStretchingBottom will never be true for the duration.

A potential fix that seems to work for me is to change this line as follows in NSViewComponentPeer::constrainRect:
- if (! inLiveResize || isFirstLiveResize)
+ if (true || ! inLiveResize || isFirstLiveResize)

However, perhaps there would be a bad side effect of making this always calculate which side is being changed? If so then maybe there is a more appropriate fix.

Thanks for taking a look!


Btw, I see that this was changed fairly recently (2016) in commit with ID 437cb4e9a4960be332f0e9bf7ae82a1dc559fa1e. Not sure what the motivation for the change was.