[X11] Improved WindowBorder.Fixed detection

This now works even without having to map the window first.
This commit is contained in:
thefiddler 2014-05-19 09:22:27 +02:00
parent d6426f20bd
commit cfb2d45b8b

View file

@ -194,9 +194,6 @@ namespace OpenTK.Platform.X11
Functions.XStoreName(window.Display, window.Handle, title); Functions.XStoreName(window.Display, window.Handle, title);
} }
// Set the window hints
SetWindowMinMax(_min_width, _min_height, -1, -1);
XSizeHints hints = new XSizeHints(); XSizeHints hints = new XSizeHints();
hints.base_width = width; hints.base_width = width;
hints.base_height = height; hints.base_height = height;
@ -217,6 +214,8 @@ namespace OpenTK.Platform.X11
Functions.XSetClassHint(window.Display, window.Handle, ref class_hint); Functions.XSetClassHint(window.Display, window.Handle, ref class_hint);
} }
SetWindowMinMax(_min_width, _min_height, -1, -1);
// Set the initial window size to ensure X, Y, Width, Height and the rest // Set the initial window size to ensure X, Y, Width, Height and the rest
// return the correct values inside the constructor and the Load event. // return the correct values inside the constructor and the Load event.
XEvent e = new XEvent(); XEvent e = new XEvent();
@ -395,33 +394,15 @@ namespace OpenTK.Platform.X11
{ {
get get
{ {
IntPtr actual_atom;
int actual_format;
IntPtr nitems;
IntPtr bytes_after;
IntPtr prop = IntPtr.Zero;
IntPtr atom;
//XWindowAttributes attributes;
using (new XLock(window.Display)) using (new XLock(window.Display))
{ {
Functions.XGetWindowProperty(window.Display, window.Handle, XSizeHints hints = new XSizeHints();
_atom_net_wm_allowed_actions, IntPtr.Zero, new IntPtr(256), false, IntPtr dummy;
IntPtr.Zero, out actual_atom, out actual_format, out nitems, if (Functions.XGetWMNormalHints(window.Display, window.Handle, ref hints, out dummy) != 0)
out bytes_after, ref prop);
if ((long)nitems > 0 && prop != IntPtr.Zero)
{ {
for (int i = 0; i < (long)nitems; i++) return hints.min_width != hints.max_width || hints.min_height != hints.max_height;
{
atom = (IntPtr)Marshal.ReadIntPtr(prop, i * IntPtr.Size);
if (atom == _atom_net_wm_action_resize)
return true;
}
Functions.XFree(prop);
} }
} }
return false; return false;
} }
} }