simplify code setting backing pixmap

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73359 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2013-01-10 06:28:18 +00:00
parent d377092637
commit b387025d5d
2 changed files with 12 additions and 47 deletions

View File

@@ -311,8 +311,6 @@ public:
wxRegion m_nativeUpdateRegion; // not transformed for RTL wxRegion m_nativeUpdateRegion; // not transformed for RTL
bool m_dirtyTabOrder:1; // tab order changed, GTK focus bool m_dirtyTabOrder:1; // tab order changed, GTK focus
// chain needs update // chain needs update
bool m_needsStyleChange:1; // May not be able to change
// background style until OnIdle
bool m_mouseButtonDown:1; bool m_mouseButtonDown:1;
bool m_showOnIdle:1; // postpone showing the window until idle bool m_showOnIdle:1; // postpone showing the window until idle

View File

@@ -1982,12 +1982,14 @@ void wxWindowGTK::GTKHandleRealized()
if (IsFrozen()) if (IsFrozen())
DoFreeze(); DoFreeze();
GdkWindow* const window = GTKGetDrawingWindow();
if (m_imData) if (m_imData)
{ {
gtk_im_context_set_client_window gtk_im_context_set_client_window
( (
m_imData->context, m_imData->context,
m_wxwindow ? GTKGetDrawingWindow() window ? window
: gtk_widget_get_window(m_widget) : gtk_widget_get_window(m_widget)
); );
} }
@@ -1998,7 +2000,6 @@ void wxWindowGTK::GTKHandleRealized()
#if wxGTK_HAS_COMPOSITING_SUPPORT #if wxGTK_HAS_COMPOSITING_SUPPORT
if (IsTransparentBackgroundSupported()) if (IsTransparentBackgroundSupported())
{ {
GdkWindow* const window = GTKGetDrawingWindow();
if (window) if (window)
gdk_window_set_composited(window, true); gdk_window_set_composited(window, true);
} }
@@ -2010,16 +2011,14 @@ void wxWindowGTK::GTKHandleRealized()
} }
} }
#ifndef __WXGTK3__
// We cannot set colours and fonts before the widget if (window && (
// been realized, so we do this directly after realization m_backgroundStyle == wxBG_STYLE_PAINT ||
// or otherwise in idle time m_backgroundStyle == wxBG_STYLE_TRANSPARENT))
if (m_needsStyleChange)
{ {
SetBackgroundStyle(GetBackgroundStyle()); gdk_window_set_back_pixmap(window, NULL, false);
m_needsStyleChange = false;
} }
#endif
wxWindowCreateEvent event(static_cast<wxWindow*>(this)); wxWindowCreateEvent event(static_cast<wxWindow*>(this));
event.SetEventObject( this ); event.SetEventObject( this );
@@ -2214,8 +2213,6 @@ void wxWindowGTK::Init()
m_clipPaintRegion = false; m_clipPaintRegion = false;
m_needsStyleChange = false;
m_cursor = *wxSTANDARD_CURSOR; m_cursor = *wxSTANDARD_CURSOR;
m_imData = NULL; m_imData = NULL;
@@ -4221,40 +4218,10 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
#ifndef __WXGTK3__ #ifndef __WXGTK3__
GdkWindow *window; GdkWindow *window;
if ( m_wxwindow ) if ((style == wxBG_STYLE_PAINT || style == wxBG_STYLE_TRANSPARENT) &&
(window = GTKGetDrawingWindow()))
{ {
window = GTKGetDrawingWindow(); gdk_window_set_back_pixmap(window, NULL, false);
}
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
{
// apply style change (forceStyle=true so that new style is applied
// even if the bg colour changed from valid to wxNullColour):
GTKApplyWidgetStyle(true);
} }
#endif // !__WXGTK3__ #endif // !__WXGTK3__