Skip to content

Commit

Permalink
Windows: avoid changing the current Fl_Surface_Device when drawing an…
Browse files Browse the repository at this point in the history
… Fl_Double_Window.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12792 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Mar 24, 2018
1 parent a3a5a3d commit db55dfb
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
Expand Up @@ -307,12 +307,30 @@ void Fl_WinAPI_Window_Driver::flush_double()
}
if (pWindow->damage() & ~FL_DAMAGE_EXPOSE) {
fl_clip_region(i->region); i->region = 0;
#if 0 /* Short form that transiently changes the current Fl_Surface_Device */
fl_begin_offscreen(other_xid);
fl_graphics_driver->clip_region( 0 );
draw();
fl_end_offscreen();
#else
/* Alternative form that avoids changing the current Fl_Surface_Device.
The code run in the window draw() method can call Fl_Surface_Device::surface()
and conclude that it's drawing to the display, which is ultimately true
for an Fl_Double_Window.
*/
HDC sgc = fl_gc;
Window save_w = fl_window; fl_window = (Window)other_xid;
fl_gc = fl_makeDC(other_xid);
int savedc = SaveDC(fl_gc);
fl_graphics_driver->gc(fl_gc);
fl_graphics_driver->restore_clip(); // duplicate clip region into new gc
draw();
RestoreDC(fl_gc, savedc);
DeleteDC(fl_gc);
fl_window = save_w;
fl_graphics_driver->gc(sgc);
#endif
}

int X,Y,W,H; fl_clip_box(0,0,w(),h(),X,Y,W,H);
if (other_xid) fl_copy_offscreen(X, Y, W, H, other_xid, X, Y);
}
Expand Down

0 comments on commit db55dfb

Please sign in to comment.