Assign a GtkConstraintSolver to each GtkRoot

Constraints need to work across different parents, so it's better to
have a single constraint solver per top level.
This commit is contained in:
Emmanuele Bassi 2019-04-09 14:20:54 +01:00
parent c694dd6049
commit 98a21bf498
2 changed files with 25 additions and 0 deletions

View File

@ -50,10 +50,18 @@ gtk_root_default_get_display (GtkRoot *self)
return gdk_display_get_default ();
}
static GtkConstraintSolver *
gtk_root_default_get_constraint_solver (GtkRoot *self)
{
return NULL;
}
static void
gtk_root_default_init (GtkRootInterface *iface)
{
iface->get_display = gtk_root_default_get_display;
iface->get_constraint_solver = gtk_root_default_get_constraint_solver;
g_object_interface_install_property (iface,
g_param_spec_object ("focus-widget",
@ -82,6 +90,17 @@ gtk_root_get_display (GtkRoot *self)
return iface->get_display (self);
}
GtkConstraintSolver *
gtk_root_get_constraint_solver (GtkRoot *self)
{
GtkRootInterface *iface;
g_return_val_if_fail (GTK_IS_ROOT (self), NULL);
iface = GTK_ROOT_GET_IFACE (self);
return iface->get_constraint_solver (self);
}
/**
* gtk_root_set_focus:
* @self: a #GtkRoot

View File

@ -3,6 +3,8 @@
#include "gtkroot.h"
#include "gtkconstraintsolverprivate.h"
G_BEGIN_DECLS
/**
@ -17,8 +19,12 @@ struct _GtkRootInterface
/*< public >*/
GdkDisplay * (* get_display) (GtkRoot *self);
GtkConstraintSolver * (* get_constraint_solver) (GtkRoot *self);
};
GtkConstraintSolver * gtk_root_get_constraint_solver (GtkRoot *self);
enum {
GTK_ROOT_PROP_FOCUS_WIDGET,
GTK_ROOT_NUM_PROPERTIES