summaryrefslogtreecommitdiff
path: root/FL/Fl_Cairo_Window.H
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2019-01-11 19:54:49 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2019-01-12 15:54:57 +0100
commit8ba982ae379f8d277bd555742ffdb83f70b54f75 (patch)
treeb23010ba139d48a2f8ddfa03ec7e4c6745ad175b /FL/Fl_Cairo_Window.H
parent1a1492a174fd0ec2942b16f4fc96f9cbd639675c (diff)
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.
Diffstat (limited to 'FL/Fl_Cairo_Window.H')
-rw-r--r--FL/Fl_Cairo_Window.H13
1 files changed, 9 insertions, 4 deletions
diff --git a/FL/Fl_Cairo_Window.H b/FL/Fl_Cairo_Window.H
index ec2d74bb4..dcec92f48 100644
--- a/FL/Fl_Cairo_Window.H
+++ b/FL/Fl_Cairo_Window.H
@@ -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: