From 8f47d9ad48d3c59090d3d6f8c9c4bb4eab9dce0f Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 16 Mar 2022 21:35:18 -0700 Subject: [PATCH] Fix size of un-resizeable TLW with Wayland GTK3 does not add the decoration size when using gtk_widget_set_size_request(). See #22155 --- src/gtk/toplevel.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 65e1fa8045..918e8983c7 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -841,11 +841,12 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, } m_decorSize = GetCachedDecorSize(); - int w, h; - GTKDoGetSize(&w, &h); + int w = m_width; + int h = m_height; if (style & wxRESIZE_BORDER) { + GTKDoGetSize(&w, &h); gtk_window_set_default_size(GTK_WINDOW(m_widget), w, h); #ifndef __WXGTK3__ gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1); @@ -857,6 +858,8 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, // gtk_window_set_default_size() does not work for un-resizable windows, // unless you set the size hints, but that causes Ubuntu's WM to make // the window resizable even though GDK_FUNC_RESIZE is not set. + if (!HasClientDecor(m_widget)) + GTKDoGetSize(&w, &h); gtk_widget_set_size_request(m_widget, w, h); } @@ -1289,11 +1292,19 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si m_pendingFittingClientSizeFlags &= ~wxSIZE_SET_CURRENT; #endif // __WXGTK3__ - int w, h; - GTKDoGetSize(&w, &h); - gtk_window_resize(GTK_WINDOW(m_widget), w, h); - if (!gtk_window_get_resizable(GTK_WINDOW(m_widget))) + int w = m_width; + int h = m_height; + if (gtk_window_get_resizable(GTK_WINDOW(m_widget))) + { + GTKDoGetSize(&w, &h); + gtk_window_resize(GTK_WINDOW(m_widget), w, h); + } + else + { + if (!HasClientDecor(m_widget)) + GTKDoGetSize(&w, &h); gtk_widget_set_size_request(GTK_WIDGET(m_widget), w, h); + } DoGetClientSize(&m_clientWidth, &m_clientHeight); wxSizeEvent event(GetSize(), GetId());