GNOME Bugzilla – Bug 694925
non-expose based draw() doesn't render window background
Last modified: 2013-03-01 11:50:52 UTC
The GdStack widget uses what amounts to gtk_widget_draw() during animations, rather than relying on expose events. However, this does not work for instance with GtkTextview, because that is a windowed widget which uses gtk_style_context_set_background(), but not gtk_render_background(), but gtk_widget_draw() does not cleat the resulting draw to the window background. There are two possibilities here that I see: a) Make the drawing machinery clear to the window bg in this case. In the full generality this is kind of hard, but for the simple case of a windowed widget and/or subwindows that are direct children of widget->window we can make this sort of work (patch attached) b) Declare that such widgets are wrong and fix them.
Created attachment 237697 [details] [review] Draw gdkwindow backgrounds during for non-exposed draws If we get a draw signal which is not from an expose we don't clear the background as per the GdkWindow background during the expose call, so we do this during the draw() signal handler.
Created attachment 237699 [details] [review] TextView: Properly render background We always need to render the background, as the window background is not always set (i.e. during gtk_widget_draw()) or when its partially visible.
gtk_style_context_set_background() is essentially deprecated. We only use it for the gdk_window_move_region() hack if we can guarantee that a window is opaque, otherwise we set the window backgrounds to none. We have to, as for transparency we'd draw the background twice (once by the GdkWindow, once by the widget). So the obviously correct solution is (b). As a side-note, we only check the CSS background-color for the window background as that's the only thing that can be represented using X semantics. Background images can be modified in so many amazing ways, that there's no way we could create a pixmap that represents the widget's background nearly well enough.
Attachment 237699 [details] pushed as b5ee44b - TextView: Properly render background