private void UpdateWindowState()
{
// we should wait until window's not fullscreen to resize
if (updateClientBounds)
{
window.WindowBorder = WindowBorder.Resizable;
updateClientBounds = false;
window.ClientRectangle = new System.Drawing.Rectangle(targetBounds.X,
targetBounds.Y, targetBounds.Width, targetBounds.Height);
// if the window-state is set from the outside (maximized button pressed) we have to update it here.
// if it was set from the inside (.IsFullScreen changed), we have to change the window.
// this code might not cover all corner cases
// window was maximized
if ((windowState == WindowState.Normal && window.WindowState == WindowState.Maximized) ||
(windowState == WindowState.Maximized && window.WindowState == WindowState.Normal))
windowState = window.WindowState; // maximize->normal and normal->maximize are usually set from the outside
else
window.WindowState = windowState; // usually fullscreen-stuff is set from the code
// we need to create a small delay between resizing the window
// and changing the border to avoid OpenTK Linux bug
updateborder = 2;
var context = GraphicsContext.CurrentContext;
if (context != null)
context.Update(window.WindowInfo);
}
}