From 993334c48a5ff9dff0c8112cc38bb9da3974d05a Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Tue, 12 Mar 2019 10:11:20 -0700 Subject: [PATCH] Avoid clipping wxCheckBox focus indicator on GTK3 GtkCheckButton "outline" is drawn outside of widget's allocation with Adwaita theme See #18353, #18043 --- src/gtk/window.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 991c245fd7..375912170f 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2220,10 +2220,28 @@ size_allocate(GtkWidget* WXUNUSED_IN_GTK2(widget), GtkAllocation* alloc, wxWindo #if GTK_CHECK_VERSION(3,14,0) if (wx_is_at_least_gtk3(14)) { + // Prevent under-allocated widgets from drawing outside their allocation GtkAllocation clip; gtk_widget_get_clip(widget, &clip); if (clip.width > w || clip.height > h) - gtk_widget_set_clip(widget, alloc); + { + GtkStyleContext* sc = gtk_widget_get_style_context(widget); + int outline_offset, outline_width; + gtk_style_context_get(sc, gtk_style_context_get_state(sc), + "outline-offset", &outline_offset, "outline-width", &outline_width, NULL); + const int outline = outline_offset + outline_width; + GtkAllocation a = *alloc; + if (outline > 0) + { + // Allow enough room for focus indicator "outline", it's drawn + // outside of GtkCheckButton allocation with Adwaita theme + a.x -= outline; + a.y -= outline; + a.width += outline + outline; + a.height += outline + outline; + } + gtk_widget_set_clip(widget, &a); + } } #endif if (win->m_wxwindow)