Hide and show all children of a container when it is mapped, to workaround GTK+3 bugs with widget stacking.

[GB.GTK3]
* BUG: Hide and show all children of a container when it is mapped, to workaround GTK+3 bugs with widget stacking.
This commit is contained in:
gambas 2021-12-12 00:53:38 +01:00
parent 93613f517a
commit ab885aabd4
3 changed files with 33 additions and 7 deletions

View file

@ -70,6 +70,26 @@ static void cb_map(GtkWidget *widget, gContainer *sender)
sender->arrangeLater();
}
#if GTK3
static void cb_remap_children(GtkWidget *widget, GdkEvent *event, gContainer *sender)
{
int i;
gControl *child;
//fprintf(stderr, "cb_remap_children: %s\n", sender->name());
for (i = 0; i < sender->childCount(); i++)
{
child = sender->child(i);
if (gtk_widget_get_visible(child->border))
{
child->hideButKeepFocus();
child->showButKeepFocus();
}
}
}
#endif
static void cb_unmap(GtkWidget *widget, gContainer *sender)
{
sender->setShown(false);
@ -750,6 +770,9 @@ void gContainer::connectBorder()
{
g_signal_connect_after(G_OBJECT(border), "map", G_CALLBACK(cb_map), (gpointer)this);
g_signal_connect_after(G_OBJECT(border), "unmap", G_CALLBACK(cb_unmap), (gpointer)this);
#if GTK3
g_signal_connect_after(G_OBJECT(border), "map-event", G_CALLBACK(cb_remap_children), (gpointer)this);
#endif
}
bool gContainer::resize(int w, int h, bool no_decide)

View file

@ -154,7 +154,7 @@ public:
virtual void reparent(gContainer *newpr, int x, int y);
void hideHiddenChildren();
virtual GtkWidget *getContainer();
void setShown(bool v) { _shown = v; }
bool isShown() const { return _shown; }
void arrangeLater();

View file

@ -712,11 +712,14 @@ void gControl::hideButKeepFocus()
{
//fprintf(stderr, "gControl::hideButKeepFocus: %s\n", gApplication::_active_control ? gApplication::_active_control->name() : "NULL");
gApplication::_keep_focus = true;
gApplication::_disable_mapping_events = true;
gtk_widget_hide(border);
gApplication::_disable_mapping_events = false;
gApplication::_keep_focus = false;
if (gtk_widget_get_visible(border))
{
gApplication::_keep_focus = true;
gApplication::_disable_mapping_events = true;
gtk_widget_hide(border);
gApplication::_disable_mapping_events = false;
gApplication::_keep_focus = false;
}
}
void gControl::showButKeepFocus()
@ -725,7 +728,7 @@ void gControl::showButKeepFocus()
//fprintf(stderr, "gControl::showButKeepFocus: %s\n", gApplication::_active_control ? gApplication::_active_control->name() : "NULL");
if (_allow_show)
if (_allow_show && !gtk_widget_get_visible(border))
{
gApplication::_disable_mapping_events = true;
gtk_widget_show(border);