]> git.saurik.com Git - wxWidgets.git/commitdiff
update GTK size hints when window decorations change
authorPaul Cornett <paulcor@bullseye.com>
Tue, 26 Feb 2008 06:14:32 +0000 (06:14 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Tue, 26 Feb 2008 06:14:32 +0000 (06:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52100 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/toplevel.h
src/gtk/toplevel.cpp

index 62bbf361150159aea5d6ee14f32ad0b8925de805..a8bc266b57a30af5366d7b7ad859ed3916348c79 100644 (file)
@@ -114,6 +114,8 @@ public:
     // return the size of the window without WM decorations
     void GTKDoGetSize(int *width, int *height) const;
 
+    void GTKUpdateDecorSize(const wxSize& decorSize);
+
 protected:
     // give hints to the Window Manager for how the size
     // of the TLW can be changed by dragging
@@ -143,6 +145,8 @@ private:
 
     // is the frame currently grabbed explicitly by the application?
     bool m_grabbed;
+
+    wxSize m_sizeIncHint;
 };
 
 #endif // _WX_GTK_TOPLEVEL_H_
index 7de72841d889a4f04a7c7c18c167982651c4d684..35197bcd419b5623dcce60129429d297a7461b29 100644 (file)
@@ -268,7 +268,6 @@ gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget),
 }
 }
 
-
 //-----------------------------------------------------------------------------
 // "configure_event"
 //-----------------------------------------------------------------------------
@@ -404,54 +403,7 @@ static gboolean property_notify_event(
             long* p = (long*)data;
             const wxSize decorSize =
                 wxSize(int(p[0] + p[1]), int(p[2] + p[3]));
-            if (win->m_decorSize != decorSize)
-            {
-                const wxSize diff = decorSize - win->m_decorSize;
-                win->m_decorSize = decorSize;
-                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;
-                    if (win->m_width  < 0) win->m_width  = 0;
-                    if (win->m_height < 0) win->m_height = 0;
-                    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);
-            }
+            win->GTKUpdateDecorSize(decorSize);
         }
         if (data)
             XFree(data);
@@ -464,7 +416,6 @@ BEGIN_EVENT_TABLE(wxTopLevelWindowGTK, wxTopLevelWindowBase)
     EVT_SYS_COLOUR_CHANGED(wxTopLevelWindowGTK::OnSysColourChanged)
 END_EVENT_TABLE()
 
-
 // ----------------------------------------------------------------------------
 // wxTopLevelWindowGTK creation
 // ----------------------------------------------------------------------------
@@ -988,6 +939,8 @@ void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH,
                                           int incW, int incH )
 {
     wxTopLevelWindowBase::DoSetSizeHints( minW, minH, maxW, maxH, incW, incH );
+    m_sizeIncHint.x = incW;
+    m_sizeIncHint.y = incH;
 
     const wxSize minSize = GetMinSize();
     const wxSize maxSize = GetMaxSize();
@@ -1023,6 +976,48 @@ void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH,
         (GtkWindow*)m_widget, NULL, &hints, (GdkWindowHints)hints_mask);
 }
 
+void wxTopLevelWindowGTK::GTKUpdateDecorSize(const wxSize& decorSize)
+{
+    if (m_decorSize != decorSize)
+    {
+        const wxSize diff = decorSize - m_decorSize;
+        m_decorSize = decorSize;
+        SetSizeHints(GetMinSize(), GetMaxSize(), m_sizeIncHint);
+        if (m_deferShow)
+        {
+            // keep overall size unchanged by shrinking m_widget
+            int w, h;
+            GTKDoGetSize(&w, &h);
+            gtk_window_resize(GTK_WINDOW(m_widget), w, h);
+        }
+        else
+        {
+            // adjust overall size to match change in frame extents
+            m_width  += diff.x;
+            m_height += diff.y;
+            if (m_width  < 0) m_width  = 0;
+            if (m_height < 0) m_height = 0;
+            m_oldClientWidth = 0;
+            gtk_widget_queue_resize(m_wxwindow);
+        }
+    }
+    if (m_deferShow)
+    {
+        // gtk_widget_show() was deferred, do it now
+        m_deferShow = false;
+        GetClientSize(&m_oldClientWidth, &m_oldClientHeight);
+        wxSizeEvent sizeEvent(GetSize(), GetId());
+        sizeEvent.SetEventObject(this);
+        HandleWindowEvent(sizeEvent);
+
+        gtk_widget_show(m_widget);
+
+        wxShowEvent showEvent(GetId(), true);
+        showEvent.SetEventObject(this);
+        HandleWindowEvent(showEvent);
+    }
+}
+
 void wxTopLevelWindowGTK::OnInternalIdle()
 {
     // set the focus if not done yet and if we can already do it