]> git.saurik.com Git - wxWidgets.git/commitdiff
simplify code setting backing pixmap
authorPaul Cornett <paulcor@bullseye.com>
Thu, 10 Jan 2013 06:28:18 +0000 (06:28 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Thu, 10 Jan 2013 06:28:18 +0000 (06:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73359 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index decd337ac02c0e51c852247530b6c7fae2701677..29b7311b705386223ca8e79ca353d25c7a23ab75 100644 (file)
@@ -311,8 +311,6 @@ public:
     wxRegion             m_nativeUpdateRegion;  // not transformed for RTL
     bool                 m_dirtyTabOrder:1;     // tab order changed, GTK focus
                                                 // chain needs update
-    bool                 m_needsStyleChange:1;  // May not be able to change
-                                                // background style until OnIdle
     bool                 m_mouseButtonDown:1;
 
     bool                 m_showOnIdle:1;        // postpone showing the window until idle
index 64d11330d5472f22bb7da1e9ea79a9cd8a9c15df..def1a71657228298accb95c3212dedace760d18f 100644 (file)
@@ -1982,12 +1982,14 @@ void wxWindowGTK::GTKHandleRealized()
     if (IsFrozen())
         DoFreeze();
 
+    GdkWindow* const window = GTKGetDrawingWindow();
+
     if (m_imData)
     {
         gtk_im_context_set_client_window
         (
             m_imData->context,
-            m_wxwindow ? GTKGetDrawingWindow()
+            window ? window
                        : gtk_widget_get_window(m_widget)
         );
     }
@@ -1998,7 +2000,6 @@ void wxWindowGTK::GTKHandleRealized()
 #if wxGTK_HAS_COMPOSITING_SUPPORT
         if (IsTransparentBackgroundSupported())
         {
-            GdkWindow* const window = GTKGetDrawingWindow();
             if (window)
                 gdk_window_set_composited(window, true);
         }
@@ -2010,16 +2011,14 @@ void wxWindowGTK::GTKHandleRealized()
         }
     }
 
-
-    // We cannot set colours and fonts before the widget
-    // been realized, so we do this directly after realization
-    // or otherwise in idle time
-
-    if (m_needsStyleChange)
+#ifndef __WXGTK3__
+    if (window && (
+        m_backgroundStyle == wxBG_STYLE_PAINT ||
+        m_backgroundStyle == wxBG_STYLE_TRANSPARENT))
     {
-        SetBackgroundStyle(GetBackgroundStyle());
-        m_needsStyleChange = false;
+        gdk_window_set_back_pixmap(window, NULL, false);
     }
+#endif
 
     wxWindowCreateEvent event(static_cast<wxWindow*>(this));
     event.SetEventObject( this );
@@ -2214,8 +2213,6 @@ void wxWindowGTK::Init()
 
     m_clipPaintRegion = false;
 
-    m_needsStyleChange = false;
-
     m_cursor = *wxSTANDARD_CURSOR;
 
     m_imData = NULL;
@@ -4221,40 +4218,10 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
 
 #ifndef __WXGTK3__
     GdkWindow *window;
-    if ( m_wxwindow )
-    {
-        window = GTKGetDrawingWindow();
-    }
-    else
-    {
-        GtkWidget * const w = GetConnectWidget();
-        window = w ? gtk_widget_get_window(w) : NULL;
-    }
-
-    bool wantNoBackPixmap = style == wxBG_STYLE_PAINT || style == wxBG_STYLE_TRANSPARENT;
-
-    if ( wantNoBackPixmap )
-    {
-        if (window)
-        {
-            // Make sure GDK/X11 doesn't refresh the window
-            // automatically.
-            gdk_window_set_back_pixmap( window, NULL, FALSE );
-            m_needsStyleChange = false;
-        }
-        else // window not realized yet
-        {
-            // Do when window is realized
-            m_needsStyleChange = true;
-        }
-
-        // Don't apply widget style, or we get a grey background
-    }
-    else
+    if ((style == wxBG_STYLE_PAINT || style == wxBG_STYLE_TRANSPARENT) &&
+        (window = GTKGetDrawingWindow()))
     {
-        // apply style change (forceStyle=true so that new style is applied
-        // even if the bg colour changed from valid to wxNullColour):
-        GTKApplyWidgetStyle(true);
+        gdk_window_set_back_pixmap(window, NULL, false);
     }
 #endif // !__WXGTK3__