From 095c4c4b5355f576be9c15ec6be8f3a90fec85ec Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Sun, 13 Nov 2016 21:20:35 -0500 Subject: [PATCH] Fix some sizing problems with GTK3 (#1392102) - Fix non-default window background color with GTK+ >= 3.20 (#1393847) --- wxGTK3-3.0.2-background-color.patch | 32 +++++ wxGTK3-3.0.2-gtk-sizing-problems.patch | 166 +++++++++++++++++++++++++ wxGTK3.spec | 14 ++- 3 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 wxGTK3-3.0.2-background-color.patch create mode 100644 wxGTK3-3.0.2-gtk-sizing-problems.patch diff --git a/wxGTK3-3.0.2-background-color.patch b/wxGTK3-3.0.2-background-color.patch new file mode 100644 index 0000000..830d876 --- /dev/null +++ b/wxGTK3-3.0.2-background-color.patch @@ -0,0 +1,32 @@ +From 553ec7537c30636ddf6cbc157373477fb2e9da41 Mon Sep 17 00:00:00 2001 +From: Paul Cornett +Date: Wed, 9 Nov 2016 20:06:26 -0800 +Subject: [PATCH] Fix non-default window background color with GTK+ >= 3.20 + +GTK+ no longer automatically paints non-default window background. See #17586 + +(cherry picked from commit 9bb5d0435a4cce5bcb7b3956cb730f59c37ea5f6) +--- + src/gtk/window.cpp | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp +index 0826e06..bca5443 100644 +--- a/src/gtk/window.cpp ++++ b/src/gtk/window.cpp +@@ -4238,6 +4238,15 @@ void wxWindowGTK::GTKSendPaintEvents(const GdkRegion* region) + 0, 0, w, h); + #endif // !__WXGTK3__ + } ++#ifdef __WXGTK3__ ++ else if (m_backgroundColour.IsOk() && gtk_check_version(3,20,0) == NULL) ++ { ++ cairo_save(cr); ++ gdk_cairo_set_source_rgba(cr, m_backgroundColour); ++ cairo_paint(cr); ++ cairo_restore(cr); ++ } ++#endif + break; + + case wxBG_STYLE_PAINT: diff --git a/wxGTK3-3.0.2-gtk-sizing-problems.patch b/wxGTK3-3.0.2-gtk-sizing-problems.patch new file mode 100644 index 0000000..8096209 --- /dev/null +++ b/wxGTK3-3.0.2-gtk-sizing-problems.patch @@ -0,0 +1,166 @@ +From 6475376931bf316a4fd791114408f7c1fc2fe836 Mon Sep 17 00:00:00 2001 +From: Paul Cornett +Date: Wed, 2 Nov 2016 10:30:44 -0700 +Subject: [PATCH] Fix some sizing problems with GTK3 + +A change in size-allocate handling with GTK+ 3.20 exposed a flaw in our method for +deferring queue-resize requests. Using an idle callback to process the requests +did not work well with the GdkFrameClock-based system used since GTK+ 3.8. Using +the "check-resize" signal works better. Also with GTK+ >= 3.20, it seems necessary +to manually work the queue-resize up to the TLW, as otherwise the resized widgets +don't get updated without an external size-allocate event. +See #17585 + +(backport of 3b4ee5a031b1c2fa29772b90751a82dd7f1d3de0) +--- + src/gtk/window.cpp | 102 +++++++++++++++++++++++++++++++++++++++-------------- + 1 file changed, 76 insertions(+), 26 deletions(-) + +diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp +index d27f889..ab56baa 100644 +--- a/src/gtk/window.cpp ++++ b/src/gtk/window.cpp +@@ -221,6 +221,8 @@ int g_lastButtonNumber = 0; + + #ifdef __WXGTK3__ + static GList* gs_sizeRevalidateList; ++static GSList* gs_queueResizeList; ++static bool gs_inSizeAllocate; + void wxGTKSizeRevalidate(wxWindow*); + #endif + +@@ -2083,6 +2085,54 @@ static void frame_clock_layout(GdkFrameClock*, wxWindow* win) + } + #endif // GTK_CHECK_VERSION(3,8,0) + ++#ifdef __WXGTK3__ ++//----------------------------------------------------------------------------- ++// "check-resize" ++//----------------------------------------------------------------------------- ++ ++static void check_resize(GtkContainer*, wxWindow*) ++{ ++ gs_inSizeAllocate = true; ++} ++ ++static void check_resize_after(GtkContainer*, wxWindow*) ++{ ++ gs_inSizeAllocate = false; ++ if (gs_queueResizeList) ++ { ++ for (GSList* p = gs_queueResizeList; p; p = p->next) ++ { ++ if (p->data == NULL) ++ continue; ++ ++ wxWindowGTK* w = static_cast(p->data); ++ g_object_remove_weak_pointer(G_OBJECT(w->m_widget), &p->data); ++ gtk_widget_set_size_request(w->m_widget, w->m_width, w->m_height); ++ ++ // in case only the position is changing ++ gtk_widget_queue_resize(w->m_widget); ++ ++ // need to force the queue-resize up to the TLW with GTK >= 3.20 ++ if (gtk_check_version(3,20,0) == NULL) ++ { ++ GtkWidget* widget = w->m_widget; ++ for (;;) ++ { ++ widget = gtk_widget_get_parent(widget); ++ if (widget == NULL) ++ break; ++ gtk_widget_queue_resize(widget); ++ if (gtk_widget_is_toplevel(widget)) ++ break; ++ } ++ } ++ } ++ g_slist_free(gs_queueResizeList); ++ gs_queueResizeList = NULL; ++ } ++} ++#endif // __WXGTK3__ ++ + } // extern "C" + + void wxWindowGTK::GTKHandleRealized() +@@ -2670,6 +2720,13 @@ void wxWindowGTK::PostCreation() + g_signal_connect(m_wxwindow ? m_wxwindow : m_widget, "size_allocate", + G_CALLBACK(size_allocate), this); + } ++#ifdef __WXGTK3__ ++ else ++ { ++ g_signal_connect(m_widget, "check-resize", G_CALLBACK(check_resize), this); ++ g_signal_connect_after(m_widget, "check-resize", G_CALLBACK(check_resize_after), this); ++ } ++#endif + + #if GTK_CHECK_VERSION(2, 8, 0) + #ifndef __WXGTK3__ +@@ -2778,46 +2835,39 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget ) + G_CALLBACK (gtk_window_leave_callback), this); + } + +-static GSList* gs_queueResizeList; +- +-extern "C" { +-static gboolean queue_resize(void*) +-{ +- gdk_threads_enter(); +- for (GSList* p = gs_queueResizeList; p; p = p->next) +- { +- if (p->data) +- { +- gtk_widget_queue_resize(GTK_WIDGET(p->data)); +- g_object_remove_weak_pointer(G_OBJECT(p->data), &p->data); +- } +- } +- g_slist_free(gs_queueResizeList); +- gs_queueResizeList = NULL; +- gdk_threads_leave(); +- return false; +-} +-} +- + void wxWindowGTK::DoMoveWindow(int x, int y, int width, int height) + { +- gtk_widget_set_size_request(m_widget, width, height); + GtkWidget* parent = gtk_widget_get_parent(m_widget); + if (WX_IS_PIZZA(parent)) ++ { + WX_PIZZA(parent)->move(m_widget, x, y, width, height); ++ if ( ++#ifdef __WXGTK3__ ++ !gs_inSizeAllocate && ++#endif ++ gtk_widget_get_visible(m_widget)) ++ { ++ // in case only the position is changing ++ gtk_widget_queue_resize(m_widget); ++ } ++ } + ++#ifdef __WXGTK3__ + // With GTK3, gtk_widget_queue_resize() is ignored while a size-allocate + // is in progress. This situation is common in wxWidgets, since + // size-allocate can generate wxSizeEvent and size event handlers often + // call SetSize(), directly or indirectly. Work around this by deferring + // the queue-resize until after size-allocate processing is finished. +- if (g_slist_find(gs_queueResizeList, m_widget) == NULL) ++ if (!gs_inSizeAllocate || !gtk_widget_get_visible(m_widget)) ++ gtk_widget_set_size_request(m_widget, width, height); ++ else + { +- if (gs_queueResizeList == NULL) +- g_idle_add_full(GTK_PRIORITY_RESIZE, queue_resize, NULL, NULL); +- gs_queueResizeList = g_slist_prepend(gs_queueResizeList, m_widget); ++ gs_queueResizeList = g_slist_prepend(gs_queueResizeList, this); + g_object_add_weak_pointer(G_OBJECT(m_widget), &gs_queueResizeList->data); + } ++#else // !__WXGTK3__ ++ gtk_widget_set_size_request(m_widget, width, height); ++#endif // !__WXGTK3__ + } + + void wxWindowGTK::ConstrainSize() diff --git a/wxGTK3.spec b/wxGTK3.spec index de2238f..c0c9f6f 100644 --- a/wxGTK3.spec +++ b/wxGTK3.spec @@ -11,7 +11,7 @@ Name: %{wxgtkname} Version: 3.0.2 -Release: 28%{?dist} +Release: 29%{?dist} Summary: GTK port of the wxWidgets GUI library License: wxWidgets Group: System Environment/Libraries @@ -96,6 +96,14 @@ Patch19: %{name}-%{version}-fix-percent-dnd2.patch # For more details, see the upstream commit: # https://github.com/wxWidgets/wxWidgets/commit/8d7e0d045250fa78a7e7d5a25cecee43bb75db3a Patch20: %{name}-%{version}-scrolwin-sizing-loop.patch +# Fixes sizing issues on GTK 3.20+ +# For more details, see the upstream commit: +# https://github.com/wxWidgets/wxWidgets/commit/6475376931bf316a4fd791114408f7c1fc2fe836 +Patch21: %{name}-%{version}-gtk-sizing-problems.patch +# Fixes non-default window background color with GTK+ >= 3.20 +# For more details, see the upstream commit: +# https://github.com/wxWidgets/wxWidgets/commit/553ec7537c30636ddf6cbc157373477fb2e9da41 +Patch22: %{name}-%{version}-background-color.patch BuildRequires: gtk%{gtkver}-devel #Note webkitgtk (GTK2) does not appear to be supported @@ -397,6 +405,10 @@ fi %doc docs/doxygen/out/xml/* %changelog +* Mon Nov 14 2016 Scott Talbert - 3.0.2-29 +- Fix some sizing problems with GTK3 (#1392102) +- Fix non-default window background color with GTK+ >= 3.20 (#1393847) + * Mon Oct 10 2016 Scott Talbert - 3.0.2-28 - Fix rename issues in Filezilla with overlay scrollbars disabled (#1381765)