Skip to content

[Linux] Cannot prevent NativeWindow minimization by NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING #4307

Description

@itlancer

Problem Description

preventDefault() for NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING doesn't work when try to do it on NativeWindow minimization event for Linux.
So you cannot provide proper UX in many cases.

Tested with multiple AIR 51.3.x, even with latest AIR 51.3.4.1 with multiple Ubuntu 22/24 x86_64 devices (VM and physical), X11, with different applications.
The same issue in all cases.
There is no such issue with Windows.

Related issues:
#3976
#3689
#3505
#3241
#3239
#3176
#2497
#2495
#2208
#4119

Steps to Reproduce

Launch application with code below using Linux device and click on minimize icon on window chrome border.

Application example with sources attached.
linux_nativewindowdisplaystateevent_minimize_prevent_bug.zip

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.NativeWindowDisplayStateEvent;
	
	public class LinuxNativeWindowDisplayStateEventMinimizePreventBug extends Sprite {
		
		public function LinuxNativeWindowDisplayStateEventMinimizePreventBug() {
			addEventListener(Event.ADDED_TO_STAGE, addedToStage);
		}
		
		private function addedToStage(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
			
			stage.nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING, windowDisplayStateChanging);
		}
		
		private function windowDisplayStateChanging(e:NativeWindowDisplayStateEvent):void {
			trace("windowDisplayStateChanging", e.afterDisplayState);
			e.preventDefault();
			e.stopImmediatePropagation();
			e.stopPropagation();
		}
	}
}

Actual Result:
Window will be minimized.
In traces you will see:

windowDisplayStateChanging minimized

Expected Result:
Window will not be minimized. Minimization will be prevented.
In traces you will see:

windowDisplayStateChanging minimized

Known Workarounds

none

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions