Realize the window widget before trying to center it, as we need the monitor it is displayed on.

[GB.GTK]
* BUG: Realize the window widget before trying to center it, as we need the monitor it is displayed on.

[GB.GTK3]
* BUG: Realize the window widget before trying to center it, as we need the monitor it is displayed on.
This commit is contained in:
gambas 2021-08-21 01:02:17 +02:00
parent 6ffcf98d76
commit 588e192a05

View file

@ -998,22 +998,19 @@ void gMainWindow::center()
if (MAIN_platform_is_wayland)
gtk_window_set_position(GTK_WINDOW(border), GTK_WIN_POS_CENTER_ON_PARENT);
else
gtk_window_set_position(GTK_WINDOW(border), GTK_WIN_POS_CENTER_ALWAYS);
#else
#endif
GdkRectangle rect;
int x, y;
gtk_widget_realize(border);
gDesktop::availableGeometry(screen(), &rect);
x = rect.x + (rect.width - width()) / 2;
y = rect.y + (rect.height - height()) / 2;
move(x, y);
#endif
}
bool gMainWindow::isModal() const