Skip to content

Commit

Permalink
X11: Fix so ClientSize can resize windows with fixed borders
Browse files Browse the repository at this point in the history
Also fixes issue that NativeWindowBase.Height was setting non-client
height but Width was setting client Width. Both now set client size.

Fixes opentk#259
  • Loading branch information
Frassle committed May 12, 2015
1 parent d6779d9 commit 0fb149f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 2 additions & 4 deletions Source/OpenTK/Platform/NativeWindowBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@ public int Width
}
set
{
Rectangle old = ClientRectangle;
ClientRectangle = new Rectangle(old.X, old.Y, value, old.Height);
ClientSize = new Size(value, ClientSize.Height);
}
}

Expand All @@ -430,8 +429,7 @@ public int Height
}
set
{
Rectangle old = ClientRectangle;
Bounds = new Rectangle(old.X, old.Y, old.Width, value);
ClientSize = new Size(ClientSize.Width, value);
}
}

Expand Down
18 changes: 16 additions & 2 deletions Source/OpenTK/Platform/X11/X11GLNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1072,11 +1072,25 @@ public override Size ClientSize
}
set
{
bool is_size_changed = client_rectangle.Size != value;

int width = value.Width;
int height = value.Height;

if (WindowBorder != WindowBorder.Resizable)
{
SetWindowMinMax(width, height, width, height);
}

using (new XLock(window.Display))
{
Functions.XResizeWindow(window.Display, window.Handle,
value.Width, value.Height);
if (is_size_changed)
{
Functions.XResizeWindow(window.Display, window.Handle,
width, height);
}
}

ProcessEvents();
}
}
Expand Down

0 comments on commit 0fb149f

Please sign in to comment.