Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeWindow::resizeToScreen() cause deformated fullscreen #3241

Open
itlancer opened this issue May 12, 2024 · 1 comment
Open

NativeWindow::resizeToScreen() cause deformated fullscreen #3241

itlancer opened this issue May 12, 2024 · 1 comment
Labels

Comments

@itlancer
Copy link

Problem Description

NativeWindow::resizeToScreen() call cause deformated fullscreen afterward.
It critical when you try to turn AIR application window to fullscreen on specific Screen.

Reproduced with multiple AIR versions, even with AIR 50.2.4.4, 50.2.4.5, 50.2.5.1 and latest 51.0.1.1 with multiple different Windows devices with different applications.
Same issue in all cases.
Adding timeout after NativeWindow::resizeToScreen() didn't help.
Didn't test with macOS and Linux.

Related issues:
#3239
#3203
#3177
#3176
#2549
#2497
#2495
#2241
#1840
#1669
#1425
#1200
#1123
#528

Steps to Reproduce

Launch application with code below. It just set stage color to green, draw red rectangle little smaller than fullscreen Stage (just to better show issue), resize application window to main Screen and change display state to fullscreen.

Application example with sources attached.
resizetoscreen_fullscreen_bug.zip

package {
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.display.Shape;
	import flash.display.StageDisplayState;
	import flash.display.Screen;
	import flash.events.Event;
	import flash.display.NativeWindow;
	import flash.events.NativeWindowDisplayStateEvent;
	import flash.display.NativeWindowDisplayState;
	
	public class ResizeToScreenFullscreenBug extends Sprite {
		private var window:NativeWindow;
		
		public function ResizeToScreenFullscreenBug() {
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.color = 0x00ff00;//Set stage color to green
			
			//Draw red rectangle little smaller than whole fullscreen stage
			var shape:Shape = new Shape();
			shape.graphics.beginFill(0xff0000);
			shape.graphics.drawRect(0, 0, stage.fullScreenWidth - 10, stage.fullScreenHeight - 10);
			shape.graphics.endFill();
			addChild(shape);
			
			addEventListener(Event.ADDED_TO_STAGE, addedToStage);
		}
		
		private function addedToStage(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
			
			window = stage.nativeWindow;
			if (window.active){
				//Main window is active
				window_activate();
			} else {
				//Wait for window to be activated
				window.addEventListener(Event.ACTIVATE, window_activate);
			}
		}
		
		private function window_activate(e:Event = null):void {
			window.removeEventListener(Event.ACTIVATE, window_activate);
			
			window.resizeToScreen(Screen.mainScreen);//Fit (resize) window to whole main screen
			
			stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
			
			//For workaround comment line above and uncomment 2 lines below
			//window.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE, window_displayStateChange);
			//window.maximize();
		}
	
		private function window_displayStateChange(e:NativeWindowDisplayStateEvent):void {
			trace("window_displayStateChange");
			if (e.afterDisplayState == NativeWindowDisplayState.MAXIMIZED){//Window maximized
				window.removeEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE, window_displayStateChange);
				
				stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
			}
		}
	}
}

Actual Result:
All stage looks red (without green borders). In real complex applications also you can see that content inside stage deformed (aspect ratio wrong).
image

Expected Result:
You can see green border at right and bottom. No content deformation.
image

Known Workarounds

After NativeWindow::resizeToScreen() call NativeWindow::maximize().
See code above.

@itlancer itlancer added the Bug label May 12, 2024
@ajwfrost
Copy link
Collaborator

Seems like this is related to the render mode i.e. in CPU rendering, it works, but with Direct mode, it doesn't.

Testing here:

  • stage has full screen width/height as 1920x1200
  • resize after that resizeToScreen call gives a stage size of 1904x1161
  • final result after setting display state gives a stage size of 1920x1200
  • if we do the "maximise" step, stage size is 1920x1096

We can try to investigate this one...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants