From b93f3dbf0362d87b93995e2ddc02f5f387069443 Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Tue, 21 May 2024 09:47:26 +0300 Subject: [PATCH 1/2] call ChangeClientBounds() --- MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs | 5 ++--- MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs b/MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs index 0058b80e82b..daa50236e75 100644 --- a/MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs +++ b/MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs @@ -289,10 +289,9 @@ void ProcessStateResumed() { ConcreteGraphicsDevice gd = (ConcreteGraphicsDevice)((IPlatformGraphicsDevice)gdm.GraphicsDevice).Strategy; gd.Android_UpdateBackBufferBounds(this.Width, this.Height); - - _gameWindow.ChangeClientBounds(new Rectangle(0, 0, this.Width, this.Height)); } } + _gameWindow.ChangeClientBounds(new Rectangle(0, 0, this.Width, this.Height)); } if (_isGLContextLost) @@ -322,9 +321,9 @@ void ProcessStateResumed() ConcreteGraphicsDevice gd = (ConcreteGraphicsDevice)((IPlatformGraphicsDevice)gdm.GraphicsDevice).Strategy; gd.Android_UpdateBackBufferBounds(this.Width, this.Height); - _gameWindow.ChangeClientBounds(new Rectangle(0, 0, this.Width, this.Height)); } } + _gameWindow.ChangeClientBounds(new Rectangle(0, 0, this.Width, this.Height)); } // check if app wants to exit diff --git a/MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs b/MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs index f14e4439178..16fd29b5a53 100644 --- a/MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs +++ b/MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs @@ -238,10 +238,9 @@ void ProcessStateResumed() { ConcreteGraphicsDevice gd = (ConcreteGraphicsDevice)((IPlatformGraphicsDevice)gdm.GraphicsDevice).Strategy; gd.Android_UpdateBackBufferBounds(this.Width, this.Height); - - _gameWindow.ChangeClientBounds(new Rectangle(0, 0, this.Width, this.Height)); } } + _gameWindow.ChangeClientBounds(new Rectangle(0, 0, this.Width, this.Height)); } if (_isGLContextLost) @@ -275,9 +274,9 @@ void ProcessStateResumed() ConcreteGraphicsDevice gd = (ConcreteGraphicsDevice)((IPlatformGraphicsDevice)gdm.GraphicsDevice).Strategy; gd.Android_UpdateBackBufferBounds(this.Width, this.Height); - _gameWindow.ChangeClientBounds(new Rectangle(0, 0, this.Width, this.Height)); } } + _gameWindow.ChangeClientBounds(new Rectangle(0, 0, this.Width, this.Height)); } // check if app wants to exit From 60d92c318050f7b26257601c02fd673bbdb30409 Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Tue, 21 May 2024 09:49:59 +0300 Subject: [PATCH 2/2] update TouchPanel only when _clientBounds changed --- MonoGame.Framework/Platform/Android/AndroidGameWindow.cs | 7 ++++--- .../Platform/Cardboard/AndroidGameWindow.cs | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/MonoGame.Framework/Platform/Android/AndroidGameWindow.cs b/MonoGame.Framework/Platform/Android/AndroidGameWindow.cs index 431f70ce281..8d5079198f7 100644 --- a/MonoGame.Framework/Platform/Android/AndroidGameWindow.cs +++ b/MonoGame.Framework/Platform/Android/AndroidGameWindow.cs @@ -244,11 +244,12 @@ internal void ChangeClientBounds(Rectangle bounds) { _clientBounds = bounds; OnClientSizeChanged(); + + Android.Util.Log.Debug("Kni", "GameWindow.ChangeClientBounds: newClientBounds=" + this.ClientBounds.Width + "," + this.ClientBounds.Height); + TouchPanel.DisplayWidth = this.ClientBounds.Width; + TouchPanel.DisplayHeight = this.ClientBounds.Height; } - Android.Util.Log.Debug("Kni", "GameWindow.ChangeClientBounds: newClientBounds=" + this.ClientBounds.Width + "," + this.ClientBounds.Height); - TouchPanel.DisplayWidth = this.ClientBounds.Width; - TouchPanel.DisplayHeight = this.ClientBounds.Height; } public override bool AllowUserResizing diff --git a/MonoGame.Framework/Platform/Cardboard/AndroidGameWindow.cs b/MonoGame.Framework/Platform/Cardboard/AndroidGameWindow.cs index 50a0c42267e..a284ed40e1a 100644 --- a/MonoGame.Framework/Platform/Cardboard/AndroidGameWindow.cs +++ b/MonoGame.Framework/Platform/Cardboard/AndroidGameWindow.cs @@ -244,11 +244,11 @@ internal void ChangeClientBounds(Rectangle bounds) { _clientBounds = bounds; OnClientSizeChanged(); - } - Android.Util.Log.Debug("Kni", "GameWindow.ChangeClientBounds: newClientBounds=" + this.ClientBounds.Width + "," + this.ClientBounds.Height); - TouchPanel.DisplayWidth = this.ClientBounds.Width; - TouchPanel.DisplayHeight = this.ClientBounds.Height; + Android.Util.Log.Debug("Kni", "GameWindow.ChangeClientBounds: newClientBounds=" + this.ClientBounds.Width + "," + this.ClientBounds.Height); + TouchPanel.DisplayWidth = this.ClientBounds.Width; + TouchPanel.DisplayHeight = this.ClientBounds.Height; + } } public override bool AllowUserResizing