handle OS window size changes

main
cosmonaut 2022-07-28 16:06:50 -07:00
parent 40a2b31e90
commit 5a5fbc0c77
2 changed files with 19 additions and 1 deletions

View File

@ -213,10 +213,22 @@ namespace MoonWorks
case SDL.SDL_EventType.SDL_CONTROLLERDEVICEREMOVED:
HandleControllerRemoved(_event);
break;
case SDL.SDL_EventType.SDL_WINDOWEVENT:
HandleWindowEvent(_event);
break;
}
}
}
private void HandleWindowEvent(SDL.SDL_Event evt)
{
if (evt.window.windowEvent == SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED)
{
Window.SizeChanged((uint) evt.window.data1, (uint) evt.window.data2);
}
}
private void HandleTextInput(SDL.SDL_Event evt)
{
// Based on the SDL2# LPUtf8StrMarshaler

View File

@ -1,4 +1,4 @@
using System;
using System;
using SDL2;
namespace MoonWorks
@ -81,6 +81,12 @@ namespace MoonWorks
Height = height;
}
internal void SizeChanged(uint width, uint height)
{
Width = width;
Height = height;
}
protected virtual void Dispose(bool disposing)
{
if (!IsDisposed)