Skip to content

Commit

Permalink
ChangeClientBounds (#1588)
Browse files Browse the repository at this point in the history
* call ChangeClientBounds()

* update TouchPanel only when _clientBounds changed
  • Loading branch information
nkast authored May 21, 2024
1 parent 28462ff commit 3775024
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
7 changes: 4 additions & 3 deletions MonoGame.Framework/Platform/Android/AndroidGameWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions MonoGame.Framework/Platform/Cardboard/AndroidGameWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3775024

Please sign in to comment.