Adobe-Runtime-Support icon indicating copy to clipboard operation
Adobe-Runtime-Support copied to clipboard

issues with moving windows and reported window size of spark WindowedApplications or Windows in Mac OS X 10.15 and above

Open bishpatrik opened this issue 3 years ago • 2 comments

Problem Description

I have an application that remembers the last position and size on shut down, and restores that position on restart. I noticed this had stopped working properly on later versions of Mac OS X (10.15 and above), but was intermittent. After some investigations I noticed I was getting a resize event, but didn't always get a windowMove or moving event triggered in my code, so it would work if the last action was a resize, but not if the last action was a move.

Reproduced at different levels with AIR SDK 33.1.1.633 on Mac OS X 10.15, 11.6 and 12.4 but not on Mac OS X 10.11.

On resizing a window using the mouse, all OS trigger the resize event and then some trigger a windowMove event after stopping resizing (if x and y have changed) and when I read back NativeWindow.x and y I find the values have updated.

On dragging a window using the mouse, 10.11 triggers a moving event as well as a windowMove event and as far as I can tell both are updating NativeWindow x and y

In Mac OS X 10.15 however, I only get a moving event, which doesn't update NativeWindow.x and y.

In Mac OS X 11 and 12, I don't get any events triggered on dragging a window (or at least none that I am monitoring).

On Windows, we haven't had this issue reported (we support Windows 7-11) so I haven't run the test app on those systems. We don't support other OS.

I added a couple of buttons to my test app one that halves the NativeWindow x and y and one that halves the NativeWindow width and height. The one that repositions triggers a windowMove on all OS whilst the one that resizes triggers a resize on all OS.

Sample Code Start

<?xml version="1.0"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       initialize="updatePositions(0)"
                       windowMove="updatePositions(1)"
                       moving="updatePositions(2)"
                       windowResize="updatePositions(3)">
    <fx:Script><![CDATA[
        private function updatePositions(index:int):void {
            xLabel.text = "" + nativeWindow.x;
            yLabel.text = "" + nativeWindow.y;
            wLabel.text = "" + nativeWindow.width;
            hLabel.text = "" + nativeWindow.height;
            switch (index) {
                case 0: lastActionLabel.text = "initialize"; break;
                case 1: lastActionLabel.text = "windowMove"; break;
                case 2: lastActionLabel.text = "moving"; break;
                case 3: lastActionLabel.text = "resize"; break;
                default: lastActionLabel.text = ""; break;
            }
        }

        private function moveWindow(resize:Boolean):void {
            if (resize) {
                nativeWindow.width = nativeWindow.width / 2;
                nativeWindow.height = nativeWindow.height / 2;
            } else {
                nativeWindow.x = nativeWindow.x / 2;
                nativeWindow.y = nativeWindow.y / 2;
            }
        }
        ]]></fx:Script>
    <s:VGroup horizontalCenter="0" verticalCenter="0">
        <s:Label text="Native Window Move/Resize Test"/>
        <s:Label id="xLabel"/>
        <s:Label id="yLabel"/>
        <s:Label id="wLabel"/>
        <s:Label id="hLabel"/>
        <s:Label id="lastActionLabel"/>
        <s:Button label="Reposition" click="moveWindow(false)"/>
        <s:Button label="Resize" click="moveWindow(true)"/>
        <s:Button label="Clear" click="updatePositions(4)"/>
    </s:VGroup>
</s:WindowedApplication>

Sample Code End

Untidy Workaround is to get a customer to resize window after a move, but I am either looking for a fix, or another event to monitor that will be triggered in all OS on a move, and will have updated NativeWindow x and y on move.

I didn't see this reported anywhere, but I will upgrade my Development machine to use the latest AIR SDK just in case it gives different results.

bishpatrik avatar Jun 17 '22 12:06 bishpatrik

Took me a while to get round to it, as I had to move on to fixing something else, and I always have issues merging the Apache Flex and Harman AIR SDKs on the Mac, but I finally got a working SDK that I could test with, and I don't see any major differences in working between 633 and 889, so it is still a bug with the latest version

bishpatrik avatar Jun 29 '22 12:06 bishpatrik