]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/toplevel.cpp
remove always-true tests of unsigned >= 0
[wxWidgets.git] / src / gtk / toplevel.cpp
index 747e6218fa3fba49dff16bfd2867dcb0859de12b..4e3e5603235e8ba503b61951b562e5fb97b9daa2 100644 (file)
@@ -339,7 +339,6 @@ gtk_frame_map_callback( GtkWidget*,
                         wxTopLevelWindow *win )
 {
     const bool wasIconized = win->IsIconized();
                         wxTopLevelWindow *win )
 {
     const bool wasIconized = win->IsIconized();
-    win->SetIconizeState(false);
     if (wasIconized)
     {
         // Because GetClientSize() returns (0,0) when IsIconized() is true,
     if (wasIconized)
     {
         // Because GetClientSize() returns (0,0) when IsIconized() is true,
@@ -358,23 +357,32 @@ gtk_frame_map_callback( GtkWidget*,
         eventShow.SetEventObject(win);
         win->GetEventHandler()->ProcessEvent(eventShow);
     }
         eventShow.SetEventObject(win);
         win->GetEventHandler()->ProcessEvent(eventShow);
     }
-    // restore focus-on-map setting in case ShowWithoutActivating() was called
-    gtk_window_set_focus_on_map(GTK_WINDOW(win->m_widget), true);
+
+#if GTK_CHECK_VERSION(2,6,0)
+    if (!gtk_check_version(2,6,0))
+    {
+        // restore focus-on-map setting in case ShowWithoutActivating() was called
+        gtk_window_set_focus_on_map(GTK_WINDOW(win->m_widget), true);
+    }
+#endif // GTK+ 2.6+
+
     return false;
 }
 }
 
 //-----------------------------------------------------------------------------
     return false;
 }
 }
 
 //-----------------------------------------------------------------------------
-// "unmap_event" from m_widget
+// "window-state-event" from m_widget
 //-----------------------------------------------------------------------------
 
 extern "C" {
 static gboolean
 //-----------------------------------------------------------------------------
 
 extern "C" {
 static gboolean
-gtk_frame_unmap_callback( GtkWidget * WXUNUSED(widget),
-                          GdkEvent * WXUNUSED(event),
+gtk_frame_window_state_callback( GtkWidget* WXUNUSED(widget),
+                          GdkEventWindowState *event,
                           wxTopLevelWindow *win )
 {
                           wxTopLevelWindow *win )
 {
-    win->SetIconizeState(true);
+    if (event->changed_mask & GDK_WINDOW_STATE_ICONIFIED)
+        win->SetIconizeState((event->new_window_state & GDK_WINDOW_STATE_ICONIFIED) != 0);
+
     return false;
 }
 }
     return false;
 }
 }
@@ -539,6 +547,8 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
     {
         gtk_window_set_keep_above(GTK_WINDOW(m_widget), TRUE);
     }
     {
         gtk_window_set_keep_above(GTK_WINDOW(m_widget), TRUE);
     }
+    if (style & wxMAXIMIZE)
+        gtk_window_maximize(GTK_WINDOW(m_widget));
 
 #if 0
     if (!name.empty())
 
 #if 0
     if (!name.empty())
@@ -583,11 +593,14 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
     g_signal_connect (m_widget, "realize",
                       G_CALLBACK (gtk_frame_realized_callback), this);
 
     g_signal_connect (m_widget, "realize",
                       G_CALLBACK (gtk_frame_realized_callback), this);
 
-    // map and unmap for iconized state
+    // for some reported size corrections
     g_signal_connect (m_widget, "map_event",
                       G_CALLBACK (gtk_frame_map_callback), this);
     g_signal_connect (m_widget, "map_event",
                       G_CALLBACK (gtk_frame_map_callback), this);
-    g_signal_connect (m_widget, "unmap_event",
-                      G_CALLBACK (gtk_frame_unmap_callback), this);
+
+    // for iconized state
+    g_signal_connect (m_widget, "window_state_event",
+                      G_CALLBACK (gtk_frame_window_state_callback), this);
+
 
     // for wxMoveEvent
     g_signal_connect (m_widget, "configure_event",
 
     // for wxMoveEvent
     g_signal_connect (m_widget, "configure_event",
@@ -878,7 +891,7 @@ bool wxTopLevelWindowGTK::Show( bool show )
         HandleWindowEvent(event);
     }
 
         HandleWindowEvent(event);
     }
 
-    bool change = wxTopLevelWindowBase::Show(show);
+    bool change = base_type::Show(show);
 
     if (change && !show)
     {
 
     if (change && !show)
     {
@@ -895,7 +908,11 @@ void wxTopLevelWindowGTK::ShowWithoutActivating()
 {
     if (!m_isShown)
     {
 {
     if (!m_isShown)
     {
-        gtk_window_set_focus_on_map(GTK_WINDOW(m_widget), false);
+#if GTK_CHECK_VERSION(2,6,0)
+        if (!gtk_check_version(2,6,0))
+            gtk_window_set_focus_on_map(GTK_WINDOW(m_widget), false);
+#endif // GTK+ 2.6+
+
         Show(true);
     }
 }
         Show(true);
     }
 }
@@ -991,7 +1008,7 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si
 
 void wxTopLevelWindowGTK::DoSetClientSize(int width, int height)
 {
 
 void wxTopLevelWindowGTK::DoSetClientSize(int width, int height)
 {
-    wxTopLevelWindowBase::DoSetClientSize(width, height);
+    base_type::DoSetClientSize(width, height);
 
     // Since client size is being explicitly set, don't change it later
     // Has to be done after calling base because it calls SetSize,
 
     // Since client size is being explicitly set, don't change it later
     // Has to be done after calling base because it calls SetSize,
@@ -1022,7 +1039,7 @@ void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH,
                                           int maxW, int maxH,
                                           int incW, int incH )
 {
                                           int maxW, int maxH,
                                           int incW, int incH )
 {
-    wxTopLevelWindowBase::DoSetSizeHints( minW, minH, maxW, maxH, incW, incH );
+    base_type::DoSetSizeHints(minW, minH, maxW, maxH, incW, incH);
 
     const wxSize minSize = GetMinSize();
     const wxSize maxSize = GetMaxSize();
 
     const wxSize minSize = GetMinSize();
     const wxSize maxSize = GetMaxSize();
@@ -1127,7 +1144,7 @@ wxSize& wxTopLevelWindowGTK::GetCachedDecorSize()
 
 void wxTopLevelWindowGTK::OnInternalIdle()
 {
 
 void wxTopLevelWindowGTK::OnInternalIdle()
 {
-    wxWindow::OnInternalIdle();
+    wxTopLevelWindowBase::OnInternalIdle();
 
     // Synthetize activate events.
     if ( g_sendActivateEvent != -1 )
 
     // Synthetize activate events.
     if ( g_sendActivateEvent != -1 )
@@ -1164,7 +1181,7 @@ void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons )
 {
     wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
 
 {
     wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
 
-    wxTopLevelWindowBase::SetIcons( icons );
+    base_type::SetIcons(icons);
 
     // Setting icons before window is realized can cause a GTK assertion if
     // another TLW is realized before this one, and it has this one as it's
 
     // Setting icons before window is realized can cause a GTK assertion if
     // another TLW is realized before this one, and it has this one as it's
@@ -1406,7 +1423,7 @@ bool wxTopLevelWindowGTK::SetTransparent(wxByte alpha)
 bool wxTopLevelWindowGTK::CanSetTransparent()
 {
     // allow to override automatic detection as it's far from perfect
 bool wxTopLevelWindowGTK::CanSetTransparent()
 {
     // allow to override automatic detection as it's far from perfect
-    static const wxChar *SYSOPT_TRANSPARENT = wxT("gtk.tlw.can-set-transparent");
+    const wxString SYSOPT_TRANSPARENT = "gtk.tlw.can-set-transparent";
     if ( wxSystemOptions::HasOption(SYSOPT_TRANSPARENT) )
     {
         return wxSystemOptions::GetOptionInt(SYSOPT_TRANSPARENT) != 0;
     if ( wxSystemOptions::HasOption(SYSOPT_TRANSPARENT) )
     {
         return wxSystemOptions::GetOptionInt(SYSOPT_TRANSPARENT) != 0;