I'm new with xlib. I've have a program which has two displays and two windows. My problem is that when user resizes windows the content disappears.
Both of the windows have turns when one can draw on them. I have while-loops for each window's turn to get the events and handling them. My problem is if I try to listen not-active-window's events with XNextEvent() the program will work randomly. I pasted one of the while-loops below.
I'd really appreciate some help.
while(drawThings2) {
XNextEvent( dpy2, & e2 );// Get event
switch( e2.type ){
case ButtonPress :
switch( e2.xbutton.button ){
case Button1 :
//Start drawing
break;
case Button2 :
case Button3 :
break;
}
break;
case ButtonRelease :
switch( e2.xbutton.button ){
case Button1 :
//Draw things
break;
}
break;
case MotionNotify :
if( drawing && (e2.xmotion.state & Button1Mask) )
{
//Draw things
}
break;
case Expose :
if( e2.xexpose.count >= 0 )
{
//Redraw content if current window is resized by user
}
break;
}
if(XCheckWindowEvent( dpy, w, ExposureMask, & e )>0)
{
//Redraw the second window's content if the second window is resized by user
}
}