You probably need to draw the line _after_ the window is shown. Windows in X normally don't have backingstore, so you need to redraw their contents whenever a previously invisible region becomes visible. I imagine there is some signal you should connect to your draw function to have it called whenever needed.