Window does not receive expose events and therefore is not redrawn

Adam Jackson ajax at
Wed Dec 9 11:54:10 PST 2015

On Wed, 2015-12-09 at 19:24 +0100, Marcus Reinhard wrote:

Standard disclaimer: coding to Xlib is for people who enjoy making
their lives hard, there's a reason we discourage it. But, since you

> To be more specific, the window is drawn correctly at first, but altough 
> I see the lines in the terminal showing the mouse-/keyboard-input, the 
> window itself is not redrawn,

I think you misunderstand what Expose events mean. They're generated
when the server has _lost_ the contents of the window, they're not just
generated for fun. You get one when the window is first mapped only
because the window doesn't have defined content yet. Your code here
doesn't redraw anything based on 'auswahl' unless it receives an Expose
event, and merely hitting an arrow key doesn't destroy the window
content so it's not going to generate an Expose.

You could fabricate one with XSendEvent if you wanted, I suppose, but
why ask the server to tell you to repaint when you could just do it
yourself. In this case, you'd factor everything from ClearWindow to the
final DrawLine into a repaint() function and call it whenever any
variable it depends on is modified.

> and if I force this by 
> minimizing/restoring the window, the symbol (here a simple line) showing 
> which section was selected with the arrow-keys, is not drawn except when 
> the selection is back at the first section which is the default-selection...

This is just a math error. You're drawing long lines at y=75 and y=125,
and the short line at y={1,2,3} * 50 - 25, which works out to 25, 75,
and 125. So when auswahl is 2 or 3, you draw the short line _over top_
of an existing line, which is why you don't see it.

- ajax

More information about the xorg mailing list