From 92c277c27cf63ef85d7254de87f3ccbe2a8eb143 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Feb 24 2016 04:18:13 +0000 Subject: Fix wxStaticText growing (BZ#1282142) and Wayland window sizing (BZ#1294229) --- diff --git a/wxGTK3-3.0.2-getbestsize.patch b/wxGTK3-3.0.2-getbestsize.patch new file mode 100644 index 0000000..ba7a4c1 --- /dev/null +++ b/wxGTK3-3.0.2-getbestsize.patch @@ -0,0 +1,29 @@ +From 2bc3721f065fd7d47674ccaf7e8d9d6cc195aab5 Mon Sep 17 00:00:00 2001 +From: Paul Cornett +Date: Sat, 6 Feb 2016 08:58:53 -0800 +Subject: [PATCH] Fix GetBestSize() for GTK3 after size has been set + +Need to reset size request to get actual best size. +See Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=1282142 + +(cherry picked from commit 6ed7e27bf270f9f7767b59ebaa9a7f37c5bb3bed) +--- + src/gtk/control.cpp | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp +index 3352965..20cd746 100644 +--- a/src/gtk/control.cpp ++++ b/src/gtk/control.cpp +@@ -319,7 +319,11 @@ wxSize wxControl::GTKGetPreferredSize(GtkWidget* widget) const + { + GtkRequisition req; + #ifdef __WXGTK3__ ++ int w, h; ++ gtk_widget_get_size_request(widget, &w, &h); ++ gtk_widget_set_size_request(widget, -1, -1); + gtk_widget_get_preferred_size(widget, NULL, &req); ++ gtk_widget_set_size_request(widget, w, h); + #else + GTK_WIDGET_GET_CLASS(widget)->size_request(widget, &req); + #endif diff --git a/wxGTK3-3.0.2-wayland-window-sizing1.patch b/wxGTK3-3.0.2-wayland-window-sizing1.patch new file mode 100644 index 0000000..34f026c --- /dev/null +++ b/wxGTK3-3.0.2-wayland-window-sizing1.patch @@ -0,0 +1,171 @@ +From 41be4271e18a21acbcc30d1e61653190f8ef7a6d Mon Sep 17 00:00:00 2001 +From: Paul Cornett +Date: Fri, 5 Feb 2016 10:26:06 -0800 +Subject: [PATCH] Adapt window decorations cache for client-side decorations + +Fixes size calculations for TLWs created after the first one, +with Wayland, Mir and Broadway. See #17336 + +(cherry picked from commit 91ea4872813b90ff91702a11abbe644cb1e5044b) +--- + src/gtk/toplevel.cpp | 93 +++++++++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 84 insertions(+), 9 deletions(-) + +diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp +index 7530b0f..c3d42e8 100644 +--- a/src/gtk/toplevel.cpp ++++ b/src/gtk/toplevel.cpp +@@ -40,6 +40,15 @@ + #endif + #ifdef GDK_WINDOWING_WAYLAND + #include ++ #define HAS_CLIENT_DECOR ++#endif ++#ifdef GDK_WINDOWING_MIR ++ #include ++ #define HAS_CLIENT_DECOR ++#endif ++#ifdef GDK_WINDOWING_BROADWAY ++ #include ++ #define HAS_CLIENT_DECOR + #endif + + #include "wx/gtk/private.h" +@@ -82,6 +91,26 @@ static enum { + static bool gs_decorCacheValid; + #endif + ++#ifdef HAS_CLIENT_DECOR ++static bool HasClientDecor(GtkWidget* widget) ++{ ++ GdkDisplay* display = gtk_widget_get_display(widget); ++#ifdef GDK_WINDOWING_WAYLAND ++ if (GDK_IS_WAYLAND_DISPLAY(display)) ++ return true; ++#endif ++#ifdef GDK_WINDOWING_MIR ++ if (GDK_IS_MIR_DISPLAY(display)) ++ return true; ++#endif ++#ifdef GDK_WINDOWING_BROADWAY ++ if (GDK_IS_BROADWAY_DISPLAY(display)) ++ return true; ++#endif ++ return false; ++} ++#endif // HAS_CLIENT_DECOR ++ + //----------------------------------------------------------------------------- + // RequestUserAttention related functions + //----------------------------------------------------------------------------- +@@ -235,8 +264,24 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxTopLevelWindowGTK* win) + GtkAllocation a; + gtk_widget_get_allocation(win->m_widget, &a); + wxSize size(a.width, a.height); +- size.x += win->m_decorSize.left + win->m_decorSize.right; +- size.y += win->m_decorSize.top + win->m_decorSize.bottom; ++#ifdef HAS_CLIENT_DECOR ++ if (HasClientDecor(win->m_widget)) ++ { ++ GtkAllocation a2; ++ gtk_widget_get_allocation(win->m_mainWidget, &a2); ++ wxTopLevelWindowGTK::DecorSize decorSize; ++ decorSize.left = a2.x; ++ decorSize.right = a.width - a2.width - a2.x; ++ decorSize.top = a2.y; ++ decorSize.bottom = a.height - a2.height - a2.y; ++ win->GTKUpdateDecorSize(decorSize); ++ } ++ else ++#endif ++ { ++ size.x += win->m_decorSize.left + win->m_decorSize.right; ++ size.y += win->m_decorSize.top + win->m_decorSize.bottom; ++ } + win->m_width = size.x; + win->m_height = size.y; + +@@ -1062,8 +1107,13 @@ void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXU + void wxTopLevelWindowGTK::GTKDoGetSize(int *width, int *height) const + { + wxSize size(m_width, m_height); +- size.x -= m_decorSize.left + m_decorSize.right; +- size.y -= m_decorSize.top + m_decorSize.bottom; ++#ifdef HAS_CLIENT_DECOR ++ if (!HasClientDecor(m_widget)) ++#endif ++ { ++ size.x -= m_decorSize.left + m_decorSize.right; ++ size.y -= m_decorSize.top + m_decorSize.bottom; ++ } + if (size.x < 0) size.x = 0; + if (size.y < 0) size.y = 0; + #if wxUSE_LIBHILDON2 +@@ -1171,7 +1221,12 @@ void wxTopLevelWindowGTK::DoGetClientSize( int *width, int *height ) const + base_type::DoGetClientSize(width, height); + else + { +- GTKDoGetSize(width, height); ++ int w = m_width - (m_decorSize.left + m_decorSize.right); ++ int h = m_height - (m_decorSize.top + m_decorSize.bottom); ++ if (w < 0) w = 0; ++ if (h < 0) h = 0; ++ if (width) *width = w; ++ if (height) *height = h; + } + } + +@@ -1193,8 +1248,20 @@ void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH, + hints.min_height = 1; + hints.max_width = INT_MAX; + hints.max_height = INT_MAX; +- const int decorSize_x = m_decorSize.left + m_decorSize.right; +- const int decorSize_y = m_decorSize.top + m_decorSize.bottom; ++ int decorSize_x; ++ int decorSize_y; ++#ifdef HAS_CLIENT_DECOR ++ if (HasClientDecor(m_widget)) ++ { ++ decorSize_x = 0; ++ decorSize_y = 0; ++ } ++ else ++#endif ++ { ++ decorSize_x = m_decorSize.left + m_decorSize.right; ++ decorSize_y = m_decorSize.top + m_decorSize.bottom; ++ } + if (minSize.x > decorSize_x) + hints.min_width = minSize.x - decorSize_x; + if (minSize.y > decorSize_y) +@@ -1221,11 +1288,19 @@ void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH, + (GtkWindow*)m_widget, NULL, &hints, (GdkWindowHints)hints_mask); + } + +-#ifdef GDK_WINDOWING_X11 + void wxTopLevelWindowGTK::GTKUpdateDecorSize(const DecorSize& decorSize) + { + if (!IsMaximized() && !IsFullScreen()) + GetCachedDecorSize() = decorSize; ++ ++#ifdef HAS_CLIENT_DECOR ++ if (HasClientDecor(m_widget)) ++ { ++ m_decorSize = decorSize; ++ return; ++ } ++#endif ++#ifdef GDK_WINDOWING_X11 + if (m_updateDecorSize && memcmp(&m_decorSize, &decorSize, sizeof(DecorSize))) + { + m_useCachedClientSize = false; +@@ -1292,8 +1367,8 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const DecorSize& decorSize) + showEvent.SetEventObject(this); + HandleWindowEvent(showEvent); + } +-} + #endif // GDK_WINDOWING_X11 ++} + + wxTopLevelWindowGTK::DecorSize& wxTopLevelWindowGTK::GetCachedDecorSize() + { diff --git a/wxGTK3-3.0.2-wayland-window-sizing2.patch b/wxGTK3-3.0.2-wayland-window-sizing2.patch new file mode 100644 index 0000000..c32b8be --- /dev/null +++ b/wxGTK3-3.0.2-wayland-window-sizing2.patch @@ -0,0 +1,59 @@ +From 0388ce8e25535415d9bdd79ce14eb20e73859279 Mon Sep 17 00:00:00 2001 +From: Paul Cornett +Date: Sat, 6 Feb 2016 16:07:28 -0800 +Subject: [PATCH] Allow SetClientSize() to set correct size even when size of + window decorations is not known + +This should allow correct sizing of first TLW (when using SetClientSize()) +with backends using client-side decorations such as Wayland. + +(cherry picked from commit bc4df78421a5b1e6fd9b218e89d03e59bd846d0a) +--- + src/gtk/toplevel.cpp | 27 +++++++++++++++++++++++++++ + 1 file changed, 27 insertions(+) + +diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp +index c3d42e8..a52dad0 100644 +--- a/src/gtk/toplevel.cpp ++++ b/src/gtk/toplevel.cpp +@@ -1194,6 +1194,14 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si + } + } + ++extern "C" { ++static gboolean reset_size_request(void* data) ++{ ++ gtk_widget_set_size_request(GTK_WIDGET(data), -1, -1); ++ return false; ++} ++} ++ + void wxTopLevelWindowGTK::DoSetClientSize(int width, int height) + { + base_type::DoSetClientSize(width, height); +@@ -1202,6 +1210,25 @@ void wxTopLevelWindowGTK::DoSetClientSize(int width, int height) + // Has to be done after calling base because it calls SetSize, + // which sets this true + m_deferShowAllowed = false; ++ ++ if (m_wxwindow) ++ { ++ // If window is not resizable or not yet shown, set size request on ++ // client widget, to make it more likely window will get correct size ++ // even if our decorations size cache is incorrect (as it will be before ++ // showing first TLW). ++ if (!gtk_window_get_resizable(GTK_WINDOW(m_widget))) ++ { ++ gtk_widget_set_size_request(m_widget, -1, -1); ++ gtk_widget_set_size_request(m_wxwindow, m_clientWidth, m_clientHeight); ++ } ++ else if (!IsShown()) ++ { ++ gtk_widget_set_size_request(m_wxwindow, m_clientWidth, m_clientHeight); ++ // Cancel size request at next idle to allow resizing ++ g_idle_add_full(G_PRIORITY_LOW, reset_size_request, m_wxwindow, NULL); ++ } ++ } + } + + void wxTopLevelWindowGTK::DoGetClientSize( int *width, int *height ) const diff --git a/wxGTK3.spec b/wxGTK3.spec index 9331a79..64f7f33 100644 --- a/wxGTK3.spec +++ b/wxGTK3.spec @@ -11,7 +11,7 @@ Name: %{wxgtkname} Version: 3.0.2 -Release: 16%{?dist} +Release: 17%{?dist} Summary: GTK port of the wxWidgets GUI library License: wxWidgets Group: System Environment/Libraries @@ -47,6 +47,16 @@ Patch5: %{name}-%{version}-stc-gcc6.patch # For more details, see the upstream commit: # https://github.com/wxWidgets/wxWidgets/commit/01f62c02957cc1443ea761ddffe0b4322d987a1d Patch6: %{name}-%{version}-string-tests-gcc6.patch +# This prevents wxStaticText from widening each time SetLabel() is called +# For more details, see the upstream commit: +# https://github.com/wxWidgets/wxWidgets/commit/2bc3721f065fd7d47674ccaf7e8d9d6cc195aab5 +Patch7: %{name}-%{version}-getbestsize.patch +# These patches fix top level window sizing under Wayland +# For more details, see the upstream commits: +# https://github.com/wxWidgets/wxWidgets/commit/41be4271e18a21acbcc30d1e61653190f8ef7a6d +# https://github.com/wxWidgets/wxWidgets/commit/0388ce8e25535415d9bdd79ce14eb20e73859279 +Patch8: %{name}-%{version}-wayland-window-sizing1.patch +Patch9: %{name}-%{version}-wayland-window-sizing2.patch BuildRequires: gtk%{gtkver}-devel #Note webkitgtk (GTK2) does not appear to be supported %if %{gtkver} == 3 @@ -166,6 +176,9 @@ This package provides XML documentation for the %{srcname} library. %patch4 -p1 -b .wayland %patch5 -p1 -b .stc-gcc6 %patch6 -p1 -b .strings-tests-gcc6 +%patch7 -p1 -b .getbestsize +%patch8 -p1 -b .wayland-window-sizing1 +%patch9 -p1 -b .wayland-window-sizing2 # patch some installed files to avoid conflicts with 2.8.* sed -i -e 's|aclocal)|aclocal/wxwin3.m4)|' Makefile.in @@ -303,6 +316,10 @@ popd %doc docs/doxygen/out/xml/* %changelog +* Wed Feb 24 2016 Scott Talbert - 3.0.2-17 +- Add patch to resolve issue with wxStaticText growing, fixes RH#1282142 +- Add patches to resolve issues under Wayland with window sizing, RH#1294229 + * Tue Feb 23 2016 Scott Talbert - 3.0.2-16 - Add -xmldocs subpackage containing XML documentation (needed for Phoenix)