|
|
2103d41 |
From 0388ce8e25535415d9bdd79ce14eb20e73859279 Mon Sep 17 00:00:00 2001
|
|
|
2103d41 |
From: Paul Cornett <paulcor@users.noreply.github.com>
|
|
|
2103d41 |
Date: Sat, 6 Feb 2016 16:07:28 -0800
|
|
|
2103d41 |
Subject: [PATCH] Allow SetClientSize() to set correct size even when size of
|
|
|
2103d41 |
window decorations is not known
|
|
|
2103d41 |
|
|
|
2103d41 |
This should allow correct sizing of first TLW (when using SetClientSize())
|
|
|
2103d41 |
with backends using client-side decorations such as Wayland.
|
|
|
2103d41 |
|
|
|
2103d41 |
(cherry picked from commit bc4df78421a5b1e6fd9b218e89d03e59bd846d0a)
|
|
|
2103d41 |
---
|
|
|
2103d41 |
src/gtk/toplevel.cpp | 27 +++++++++++++++++++++++++++
|
|
|
2103d41 |
1 file changed, 27 insertions(+)
|
|
|
2103d41 |
|
|
|
2103d41 |
diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp
|
|
|
2103d41 |
index c3d42e8..a52dad0 100644
|
|
|
2103d41 |
--- a/src/gtk/toplevel.cpp
|
|
|
2103d41 |
+++ b/src/gtk/toplevel.cpp
|
|
|
2103d41 |
@@ -1194,6 +1194,14 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si
|
|
|
2103d41 |
}
|
|
|
2103d41 |
}
|
|
|
2103d41 |
|
|
|
2103d41 |
+extern "C" {
|
|
|
2103d41 |
+static gboolean reset_size_request(void* data)
|
|
|
2103d41 |
+{
|
|
|
2103d41 |
+ gtk_widget_set_size_request(GTK_WIDGET(data), -1, -1);
|
|
|
2103d41 |
+ return false;
|
|
|
2103d41 |
+}
|
|
|
2103d41 |
+}
|
|
|
2103d41 |
+
|
|
|
2103d41 |
void wxTopLevelWindowGTK::DoSetClientSize(int width, int height)
|
|
|
2103d41 |
{
|
|
|
2103d41 |
base_type::DoSetClientSize(width, height);
|
|
|
2103d41 |
@@ -1202,6 +1210,25 @@ void wxTopLevelWindowGTK::DoSetClientSize(int width, int height)
|
|
|
2103d41 |
// Has to be done after calling base because it calls SetSize,
|
|
|
2103d41 |
// which sets this true
|
|
|
2103d41 |
m_deferShowAllowed = false;
|
|
|
2103d41 |
+
|
|
|
2103d41 |
+ if (m_wxwindow)
|
|
|
2103d41 |
+ {
|
|
|
2103d41 |
+ // If window is not resizable or not yet shown, set size request on
|
|
|
2103d41 |
+ // client widget, to make it more likely window will get correct size
|
|
|
2103d41 |
+ // even if our decorations size cache is incorrect (as it will be before
|
|
|
2103d41 |
+ // showing first TLW).
|
|
|
2103d41 |
+ if (!gtk_window_get_resizable(GTK_WINDOW(m_widget)))
|
|
|
2103d41 |
+ {
|
|
|
2103d41 |
+ gtk_widget_set_size_request(m_widget, -1, -1);
|
|
|
2103d41 |
+ gtk_widget_set_size_request(m_wxwindow, m_clientWidth, m_clientHeight);
|
|
|
2103d41 |
+ }
|
|
|
2103d41 |
+ else if (!IsShown())
|
|
|
2103d41 |
+ {
|
|
|
2103d41 |
+ gtk_widget_set_size_request(m_wxwindow, m_clientWidth, m_clientHeight);
|
|
|
2103d41 |
+ // Cancel size request at next idle to allow resizing
|
|
|
2103d41 |
+ g_idle_add_full(G_PRIORITY_LOW, reset_size_request, m_wxwindow, NULL);
|
|
|
2103d41 |
+ }
|
|
|
2103d41 |
+ }
|
|
|
2103d41 |
}
|
|
|
2103d41 |
|
|
|
2103d41 |
void wxTopLevelWindowGTK::DoGetClientSize( int *width, int *height ) const
|