Commit 88250391 authored by Michael Natterer's avatar Michael Natterer 😴

app: fix keyboard focus navigation in overlay children

Implement GtkWidget::focus() and override GtkContainer's focus()
implementation which would always give focus to the canvas because it
is focussable. Instead, try navigating in the focussed overlay child
first, and use GtkContainer's default implementation only if that
fails (which happens when focus navigation leaves the overlay child).
parent 5da660a1
......@@ -64,6 +64,8 @@ static gboolean gimp_canvas_focus_in_event (GtkWidget *widget,
GdkEventFocus *event);
static gboolean gimp_canvas_focus_out_event (GtkWidget *widget,
GdkEventFocus *event);
static gboolean gimp_canvas_focus (GtkWidget *widget,
GtkDirectionType direction);
static GdkGC * gimp_canvas_gc_new (GimpCanvas *canvas,
GimpCanvasStyle style);
......@@ -173,6 +175,7 @@ gimp_canvas_class_init (GimpCanvasClass *klass)
widget_class->style_set = gimp_canvas_style_set;
widget_class->focus_in_event = gimp_canvas_focus_in_event;
widget_class->focus_out_event = gimp_canvas_focus_out_event;
widget_class->focus = gimp_canvas_focus;
g_object_class_install_property (object_class, PROP_CONFIG,
g_param_spec_object ("config", NULL, NULL,
......@@ -316,6 +319,26 @@ gimp_canvas_focus_out_event (GtkWidget *widget,
return FALSE;
}
static gboolean
gimp_canvas_focus (GtkWidget *widget,
GtkDirectionType direction)
{
GtkWidget *focus = gtk_container_get_focus_child (GTK_CONTAINER (widget));
/* override GtkContainer's focus() implementation which would always
* give focus to the canvas because it is focussable. Instead, try
* navigating in the focussed overlay child first, and use
* GtkContainer's default implementation only if that fails (which
* happens when cursor navigation leaves the overlay child's
* widget).
*/
if (focus && gtk_widget_child_focus (focus, direction))
return TRUE;
return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction);
}
/* Returns: %TRUE if the XOR color is not white */
static gboolean
gimp_canvas_get_xor_color (GimpCanvas *canvas,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment