internal static Rectangle TranslateClientRectangleToQuartzClientRectangle (Hwnd hwnd, Control ctrl) {
/* From XplatUIX11
* If this is a form with no window manager, X is handling all the border and caption painting
* so remove that from the area (since the area we set of the window here is the part of the window
* we're painting in only)
*/
Rectangle rect = hwnd.ClientRect;
Form form = ctrl as Form;
CreateParams cp = null;
if (form != null)
cp = form.GetCreateParams ();
if (form != null && (form.window_manager == null || cp.IsSet (WindowExStyles.WS_EX_TOOLWINDOW))) {
Hwnd.Borders borders = Hwnd.GetBorders (cp, null);
Rectangle qrect = rect;
qrect.Y -= borders.top;
qrect.X -= borders.left;
qrect.Width += borders.left + borders.right;
qrect.Height += borders.top + borders.bottom;
rect = qrect;
}
if (rect.Width < 1 || rect.Height < 1) {
rect.Width = 1;
rect.Height = 1;
rect.X = -5;
rect.Y = -5;
}
return rect;
}