]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/toplevel.cpp
call Show(false) from ~wxDialog to call EndModal if the dialog is still modal consist...
[wxWidgets.git] / src / gtk / toplevel.cpp
index 4bcfa186381b7025aea42fb8ccb735baafc9df12..2f08c8dedde010046b150b8932d8fa6808f17471 100644 (file)
@@ -392,48 +392,62 @@ static gboolean property_notify_event(
         Atom type;
         int format;
         gulong nitems, bytes_after;
-        long* data = NULL;
+        guchar* data;
         Status status = XGetWindowProperty(
             gdk_x11_drawable_get_xdisplay(event->window),
             gdk_x11_drawable_get_xid(event->window),
             xproperty,
             0, 4, false, XA_CARDINAL,
-            &type, &format, &nitems, &bytes_after, (guchar**)&data);
+            &type, &format, &nitems, &bytes_after, &data);
         if (status == Success && data && nitems == 4)
         {
+            long* p = (long*)data;
             const wxSize decorSize =
-                wxSize(int(data[0] + data[1]), int(data[2] + data[3]));
+                wxSize(int(p[0] + p[1]), int(p[2] + p[3]));
             if (win->m_decorSize != decorSize)
             {
-                const wxSize diff = win->m_decorSize - decorSize;
+                const wxSize diff = decorSize - win->m_decorSize;
                 win->m_decorSize = decorSize;
-                if (!win->m_deferShow)
+                bool resized = false;
+                if (win->m_deferShow)
+                {
+                    // keep overall size unchanged by shrinking m_widget,
+                    // if min size will allow it
+                    const wxSize minSize = win->GetMinSize();
+                    int w, h;
+                    win->GTKDoGetSize(&w, &h);
+                    if (w >= minSize.x && h >= minSize.y)
+                    {
+                        gtk_window_resize(GTK_WINDOW(win->m_widget), w, h);
+                        resized = true;
+                    }
+                }
+                if (!resized)
                 {
                     // adjust overall size to match change in frame extents
-                    win->m_width  -= diff.x;
-                    win->m_height -= diff.y;
+                    win->m_width  += diff.x;
+                    win->m_height += diff.y;
                     if (win->m_width  < 0) win->m_width  = 0;
                     if (win->m_height < 0) win->m_height = 0;
-                    win->m_oldClientWidth = 0;
-                    gtk_widget_queue_resize(win->m_wxwindow);
-                }
-                else
-                {
-                    // Window not yet visible, adjust client size. This would
-                    // cause an obvious size change if window was visible.
-                    int w, h;
-                    win->GTKDoGetSize(&w, &h);
-                    gtk_window_resize(GTK_WINDOW(win->m_widget), w, h);
+                    if (!win->m_deferShow)
+                    {
+                        win->m_oldClientWidth = 0;
+                        gtk_widget_queue_resize(win->m_wxwindow);
+                    }
                 }
             }
             if (win->m_deferShow)
             {
                 // gtk_widget_show() was deferred, do it now
                 win->m_deferShow = false;
+                win->GetClientSize(
+                    &win->m_oldClientWidth, &win->m_oldClientHeight);
                 wxSizeEvent sizeEvent(win->GetSize(), win->GetId());
                 sizeEvent.SetEventObject(win);
                 win->HandleWindowEvent(sizeEvent);
+
                 gtk_widget_show(win->m_widget);
+
                 wxShowEvent showEvent(win->GetId(), true);
                 showEvent.SetEventObject(win);
                 win->HandleWindowEvent(showEvent);
@@ -942,6 +956,14 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si
     }
 }
 
+void wxTopLevelWindowGTK::DoSetClientSize(int width, int height)
+{
+    if (m_deferShow && !m_isShown)
+        // Since client size is being explicitly set, don't change it later
+        m_deferShow = false;
+    wxTopLevelWindowBase::DoSetClientSize(width, height);
+}
+
 void wxTopLevelWindowGTK::DoGetClientSize( int *width, int *height ) const
 {
     wxASSERT_MSG(m_widget, wxT("invalid frame"));