title: What is the right way to render Cairo updates in Gtk2hs?
body: <p>I'm writing a Haskell program with click-and-drag functionality, so with each mouse movement event an update gets painted to the window. At the moment I'm using </p>
  
  <pre><code>renderWithDrawable myCanvas update
  </code></pre>
  
  <p>However this is flickering a lot. My understanding is that I need to create a separate drawable (a "surface"?), render to that, and then blit it onto the screen window in a single operation. However I'm confused as to the right way to do this.</p>
  
  <p>I've found <code>drawWindowBeginPaintRegion</code>, which talks about eliminating flicker.
  However it is <em>removed in Gtk3</em> according to the Haddock docs. So I'm not sure if I should use this, as it seems to be deprecated.</p>
  
  <p>I've also found <code>renderWithSimilarSurface</code> in Cairo, which seems to do something similar.</p>
  
  <p>I'm also not sure how these functions relate to <code>renderWithDrawable</code>: do I have to use them inside that function, or what?</p>
  
  <p>What is the right way to do this?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>This seems to be a known thing in Cairo. I'm trying to figure out how to handle this in Haskell.</p>
  
  <ul>
  <li><p><a href="http://www.islascruz.org/html/index.php/blog/show/Drawing-with-Cairo-without-flicker.html" rel="noreferrer">Explanation and solution in Python</a></p></li>
  <li><p><a href="http://cairographics.org/threaded_animation_with_cairo/" rel="noreferrer">Description of how to handle this issue in raw C</a></p></li>
  </ul>