Fix Cairo callback drawing (needs flush)

This commit adds a cairo_surface flush after calling the draw callback.
This fixes the test/cairo_test demo program under Windows.

At least under Windows the Cairo callback used in Fl_Cairo_Window
didn't draw anything with current Windows 10, MinGW (32-bit) and
Cairo 1.15.12 for Windows. It worked well under Linux though. Anyway,
the flush should do no harm.
This commit is contained in:
Albrecht Schlosser
2019-01-11 19:54:49 +01:00
parent 1a1492a174
commit 8ba982ae37
+9 -4
View File
@@ -59,10 +59,15 @@ protected:
/** Overloaded to provide cairo callback support */
void draw() {
Fl_Double_Window::draw();
// manual method ? if yes explicitly get a cairo_context here
if (!Fl::cairo_autolink_context())
Fl::cairo_make_current(this);
if (draw_cb_) draw_cb_(this, Fl::cairo_cc());
if (draw_cb_) { // call the Cairo draw callback
// manual method ? if yes explicitly get a cairo_context here
if (!Fl::cairo_autolink_context())
Fl::cairo_make_current(this);
draw_cb_(this, Fl::cairo_cc());
// flush cairo drawings: necessary at least for Windows
cairo_surface_t *s = cairo_get_target(Fl::cairo_cc());
cairo_surface_flush(s);
}
}
public: