DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
To reproduce the problem:
Uncomment the first statement in main() of test/device.cxx to get
Then print to a .ps or .pdf file to save paper.
The plastic background of the main window does not appear in the
The cause is that Fl_Tiled_Image::draw() calls Fl_Window::current()
to identify which window contains the Fl_Tiled_Image being drawn.
This works well when the draw operation goes to the display
because Fl_Window::make_current() has necessarily been applied
to that window before any drawing is done.
But this fails when the draw operation is to another drawing surface,
such as the printer, because Fl_Window::current() is set to the
last window drawn on the display, not to the window being printed.
The attached patch should fix that problem, by making
Fl_Window::draw() temporarily set Fl_Window::current_
when the drawing surface is not the display.
The patch would hopefully also satisfy the comment
// This should be fixed! (AlbrechtS, 01 Mar 2015)
waiting at line 172 of src/Fl_Tiled_Image.cxx
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx
index 0b4961062..fb77cf01d 100644
@@ -482,6 +482,9 @@ void Fl_Window::flush()
+ Fl_Window *save_current = current_;
+ bool to_display = Fl_Display_Device::display_device()->is_current();
+ if (!to_display) current_ = this; // so drawing of background Fl_Tiled_Image is correct
// The following is similar to Fl_Group::draw(), but ...
@@ -510,6 +513,7 @@ void Fl_Window::draw()
+ if (!to_display) current_ = save_current;
# if defined(FLTK_USE_CAIRO)
Fl::cairo_make_current(this); // checkout if an update is necessary
[ Direct Link to Message ]