Do not crash if expanded widgets change during arrangement. Fix GTK+ window centering method.
[GB.GTK] * BUG: Do not crash if expanded widgets change during arrangement. [GB.GTK3] * BUG: Remove platform-specific window centering method. * BUG: Do not crash if expanded widgets change during arrangement. [GB.QT4] * BUG: Do not crash if expanded widgets change during arrangement. [GB.QT5] * BUG: Do not crash if expanded widgets change during arrangement.
This commit is contained in:
parent
cf8abc4639
commit
ab307322bf
5 changed files with 35 additions and 46 deletions
|
@ -958,19 +958,22 @@ void gMainWindow::center()
|
||||||
{
|
{
|
||||||
if (!isTopLevel()) return;
|
if (!isTopLevel()) return;
|
||||||
|
|
||||||
|
GdkRectangle rect;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
if (!isTopLevel()) return;
|
||||||
|
|
||||||
#ifdef GTK3
|
#ifdef GTK3
|
||||||
PLATFORM.Window.Center(GTK_WINDOW(border));
|
if (MAIN_platform_is_wayland)
|
||||||
#else
|
gtk_window_set_position(GTK_WINDOW(border), GTK_WIN_POS_CENTER_ON_PARENT);
|
||||||
GdkRectangle rect;
|
|
||||||
int x, y;
|
|
||||||
|
|
||||||
gDesktop::availableGeometry(screen(), &rect);
|
|
||||||
|
|
||||||
x = rect.x + (rect.width - width()) / 2;
|
|
||||||
y = rect.y + (rect.height - height()) / 2;
|
|
||||||
|
|
||||||
move(x, y);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gDesktop::availableGeometry(screen(), &rect);
|
||||||
|
|
||||||
|
x = rect.x + (rect.width - width()) / 2;
|
||||||
|
y = rect.y + (rect.height - height()) / 2;
|
||||||
|
|
||||||
|
move(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gMainWindow::isModal() const
|
bool gMainWindow::isModal() const
|
||||||
|
@ -991,13 +994,13 @@ void gMainWindow::showModal()
|
||||||
setType(GTK_WINDOW_TOPLEVEL);
|
setType(GTK_WINDOW_TOPLEVEL);
|
||||||
|
|
||||||
gtk_window_set_modal(GTK_WINDOW(border), true);
|
gtk_window_set_modal(GTK_WINDOW(border), true);
|
||||||
center();
|
|
||||||
setTransientFor();
|
setTransientFor();
|
||||||
|
|
||||||
save = _current;
|
save = _current;
|
||||||
_current = this;
|
_current = this;
|
||||||
|
|
||||||
show();
|
show();
|
||||||
|
center();
|
||||||
gtk_grab_add(border);
|
gtk_grab_add(border);
|
||||||
gApplication::enterLoop(this);
|
gApplication::enterLoop(this);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ typedef
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
long (*GetId)(GdkWindow *);
|
long (*GetId)(GdkWindow *);
|
||||||
void (*Center)(GtkWindow *);
|
|
||||||
} Window;
|
} Window;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -47,12 +47,6 @@ static long window_get_id(GdkWindow *window)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_center(GtkWindow *window)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "window_center\n");
|
|
||||||
gtk_window_set_position(window, GTK_WIN_POS_CENTER_ON_PARENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
bool desktop_has_system_tray()
|
bool desktop_has_system_tray()
|
||||||
|
|
|
@ -58,26 +58,6 @@ static long window_get_id(GdkWindow *window)
|
||||||
return window ? GDK_WINDOW_XID(window) : 0;
|
return window ? GDK_WINDOW_XID(window) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_center(GtkWindow *window)
|
|
||||||
{
|
|
||||||
GdkRectangle rect;
|
|
||||||
int x, y;
|
|
||||||
int screen;
|
|
||||||
|
|
||||||
screen = gdk_screen_get_number(gtk_window_get_screen(window));
|
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION(3, 22, 0)
|
|
||||||
gdk_monitor_get_workarea(gdk_display_get_monitor(gdk_display_get_default(), screen), &rect);
|
|
||||||
#else
|
|
||||||
gdk_screen_get_monitor_workarea(gdk_screen_get_default(), screen, &rect);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
x = rect.x + (rect.width - width()) / 2;
|
|
||||||
y = rect.y + (rect.height - height()) / 2;
|
|
||||||
|
|
||||||
gtk_window_move(window, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
static bool desktop_has_system_tray()
|
static bool desktop_has_system_tray()
|
||||||
|
@ -134,7 +114,6 @@ void *GB_GTK3_X11_1[] EXPORT = {
|
||||||
(void *)platform_create_plug,
|
(void *)platform_create_plug,
|
||||||
|
|
||||||
(void *)window_get_id,
|
(void *)window_get_id,
|
||||||
(void *)window_center,
|
|
||||||
|
|
||||||
(void *)desktop_has_system_tray,
|
(void *)desktop_has_system_tray,
|
||||||
(void *)desktop_show_tray_icon,
|
(void *)desktop_show_tray_icon,
|
||||||
|
|
|
@ -393,9 +393,15 @@ void FUNCTION_NAME(void *_object) //(QFrame *cont)
|
||||||
{
|
{
|
||||||
if (IS_EXPAND(ob)) // && !autoresize)
|
if (IS_EXPAND(ob)) // && !autoresize)
|
||||||
{
|
{
|
||||||
h = sexp / nexp;
|
if (nexp == 0) // the list of expanded widget may change
|
||||||
sexp -= h;
|
h = 0;
|
||||||
nexp--;
|
else
|
||||||
|
{
|
||||||
|
h = sexp / nexp;
|
||||||
|
sexp -= h;
|
||||||
|
nexp--;
|
||||||
|
}
|
||||||
|
|
||||||
if (h <= 0)
|
if (h <= 0)
|
||||||
MOVE_WIDGET(ob, wid, -GET_WIDGET_W(wid), GET_WIDGET_Y(wid));
|
MOVE_WIDGET(ob, wid, -GET_WIDGET_W(wid), GET_WIDGET_Y(wid));
|
||||||
}
|
}
|
||||||
|
@ -426,9 +432,17 @@ void FUNCTION_NAME(void *_object) //(QFrame *cont)
|
||||||
{
|
{
|
||||||
if (IS_EXPAND(ob)) // && !autoresize)
|
if (IS_EXPAND(ob)) // && !autoresize)
|
||||||
{
|
{
|
||||||
w = sexp / nexp;
|
if (nexp == 0) // the list of expanded widget may change
|
||||||
sexp -= w;
|
{
|
||||||
nexp--;
|
w = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
w = sexp / nexp;
|
||||||
|
sexp -= w;
|
||||||
|
nexp--;
|
||||||
|
}
|
||||||
|
|
||||||
if (w <= 0)
|
if (w <= 0)
|
||||||
MOVE_WIDGET(ob, wid, GET_WIDGET_X(wid), -GET_WIDGET_H(wid));
|
MOVE_WIDGET(ob, wid, GET_WIDGET_X(wid), -GET_WIDGET_H(wid));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue