diff options
author | Matthias Clasen <mclasen@redhat.com> | 2011-08-10 16:00:38 +0200 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2011-08-10 16:34:20 +0200 |
commit | 2ba9c4b4a7d9ffc3161e2db1774743182a365d99 (patch) | |
tree | 71eafdf29308d8cf5b2adba4df97461ee9b5568a /gtk/gtkbutton.c | |
parent | 6596dbff312ecdc65681c37f3de21217d7731388 (diff) | |
download | gtk+-2ba9c4b4a7d9ffc3161e2db1774743182a365d99.tar.gz |
Make focus rectangles optional
This commit introduces a new setting, gtk-visible-focus, backed
by the Gtk/VisibleFocus X setting. Its three values control how
focus rectangles are displayed.
'always' is equivalent to the traditional GTK+ behaviour of always
rendering focus rectangles.
'never' does what it says, and is intended for keyboardless
situations, e.g. tablets.
'automatic' hides focus rectangles initially, until the user
interacts with the keyboard, at which point focus rectangles
become visible.
https://bugzilla.gnome.org/show_bug.cgi?id=649567
Diffstat (limited to 'gtk/gtkbutton.c')
-rw-r--r-- | gtk/gtkbutton.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 6b967846fb..aa3fe63b18 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -1570,6 +1570,7 @@ _gtk_button_paint (GtkButton *button, gint focus_pad; GtkAllocation allocation; GtkStyleContext *context; + gboolean draw_focus; widget = GTK_WIDGET (button); context = gtk_widget_get_style_context (widget); @@ -1605,8 +1606,11 @@ _gtk_button_paint (GtkButton *button, width -= default_outside_border.left + default_outside_border.right; height -= default_outside_border.top + default_outside_border.bottom; } - - if (!interior_focus && gtk_widget_has_focus (widget)) + + draw_focus = gtk_widget_has_visible_focus (widget); + + + if (!interior_focus && draw_focus) { x += focus_width + focus_pad; y += focus_width + focus_pad; @@ -1623,7 +1627,7 @@ _gtk_button_paint (GtkButton *button, x, y, width, height); } - if (gtk_widget_has_focus (widget)) + if (draw_focus) { gint child_displacement_x; gint child_displacement_y; @@ -1658,8 +1662,7 @@ _gtk_button_paint (GtkButton *button, y += child_displacement_y; } - gtk_render_focus (context, cr, - x, y, width, height); + gtk_render_focus (context, cr, x, y, width, height); } gtk_style_context_restore (context); |