gtkpointerfocus: Add methods to handle implicit grabs on widgets

Just a basic setter/getter, plus a method to obtain the right logical target
in the presence or absence of these.
This commit is contained in:
Carlos Garnacho 2017-03-31 17:57:44 +02:00
parent 3dfab962fa
commit 23d2126729
2 changed files with 34 additions and 0 deletions

View File

@ -78,6 +78,19 @@ gtk_pointer_focus_get_target (GtkPointerFocus *focus)
return focus->target;
}
void
gtk_pointer_focus_set_implicit_grab (GtkPointerFocus *focus,
GtkWidget *grab_widget)
{
focus->grab_widget = grab_widget;
}
GtkWidget *
gtk_pointer_focus_get_implicit_grab (GtkPointerFocus *focus)
{
return focus->grab_widget;
}
void
gtk_pointer_focus_set_coordinates (GtkPointerFocus *focus,
gdouble x,
@ -87,6 +100,21 @@ gtk_pointer_focus_set_coordinates (GtkPointerFocus *focus,
focus->y = y;
}
GtkWidget *
gtk_pointer_focus_get_effective_target (GtkPointerFocus *focus)
{
GtkWidget *target;
target = focus->target;
if (focus->grab_widget &&
focus->grab_widget != target &&
!gtk_widget_is_ancestor (target, focus->grab_widget))
target = focus->grab_widget;
return target;
}
void
gtk_pointer_focus_repick_target (GtkPointerFocus *focus)
{

View File

@ -47,6 +47,12 @@ void gtk_pointer_focus_set_target (GtkPointerFocus *focus,
GtkWidget *target);
GtkWidget * gtk_pointer_focus_get_target (GtkPointerFocus *focus);
void gtk_pointer_focus_set_implicit_grab (GtkPointerFocus *focus,
GtkWidget *grab_widget);
GtkWidget * gtk_pointer_focus_get_implicit_grab (GtkPointerFocus *focus);
GtkWidget * gtk_pointer_focus_get_effective_target (GtkPointerFocus *focus);
void gtk_pointer_focus_repick_target (GtkPointerFocus *focus);
#endif /* _GTK_POINTER_FOCUS_PRIVATE_H_ */