Automatic placement on mac works correctly now so remove the hack to
replace the window. This should fix placement on both Windows and
Mac so the dialogs are correctly centred.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=9012
This commit is contained in:
Alan McGovern 2013-01-03 12:56:00 +00:00
Родитель 22f350f7fd
Коммит 8c2667b85e
1 изменённых файлов: 0 добавлений и 35 удалений

Просмотреть файл

@ -72,7 +72,6 @@ namespace Xwt.GtkBackend
}
dialog.TransientFor = parent;
dialog.DestroyWithParent = true;
PlaceDialog (dialog, parent);
return GtkWorkarounds.RunDialogWithNotification (dialog);
}
@ -96,39 +95,5 @@ namespace Xwt.GtkBackend
return w;
return RootWindow;
}
/// <summary>
/// Positions a dialog relative to its parent on platforms where default placement is known to be poor.
/// </summary>
public static void PlaceDialog (Gtk.Window child, Gtk.Window parent)
{
//HACK: Mac GTK automatic window placement is broken
if (Platform.IsMac) {
if (parent == null) {
parent = GetDefaultParent (child);
}
if (parent != null) {
CenterWindow (child, parent);
}
}
}
/// <summary>Centers a window relative to its parent.</summary>
static void CenterWindow (Gtk.Window child, Gtk.Window parent)
{
child.Child.Show ();
int w, h, winw, winh, x, y, winx, winy;
if (child.Visible)
child.GetSize (out w, out h);
else {
w = child.DefaultSize.Width;
h = child.DefaultSize.Height;
}
parent.GetSize (out winw, out winh);
parent.GetPosition (out winx, out winy);
x = Math.Max (0, (winw - w) /2) + winx;
y = Math.Max (0, (winh - h) /2) + winy;
child.Move (x, y);
}
}
}