|
|
Christoph Hormann wrote:
> Wolfgang Wieser wrote:
>> Here we go...
>>
>> POVRay/X11 has code to handle window close and abort rendering
>> when the window is closed. Unfortunately, the code does not work,
>> at least not for me.
>>
>> This patch fixes that. Please apply. Read on below.
>>
>> [...]
>
> It would be useful if you could simply post the changed functions as a
> whole instead of a diff so i don't need to dig out the 3.5 code to test
> the patch.
>
Okay. I changed the following functions:
-----------------------------------------------------------------------
void XWIN_display_finished()
{
if (theDisplay && opts.Options & PROMPTEXIT)
{
Bool finished = False;
Status_Info("\nClick on window to exit...");
#ifdef USE_CURSOR
/* Get rid of the watch cursor now that we don't need it anymore */
XUndefineCursor(theDisplay, theWindow);
XFreeCursor(theDisplay, theCursor);
#endif
/* Sit and handle events until we quit, but don't busy wait */
while (!finished)
{
finished = HandleXEvents(True);
}
}
}
-----------------------------------------------------------------------
int XWIN_Test_Abort()
{
if(theDisplay)
{
return(HandleXEvents(False) ? true : false);
}
return false;
}
-----------------------------------------------------------------------
int HandleXEvents(Bool finished)
{
Bool refresh = False;
Bool abortRender = False;
int refresh_x_min = theImage->width - 1;
int refresh_x_max = 0;
int refresh_y_min = theImage->height - 1;
int refresh_y_max = 0;
int npending=0;
XEvent _theEvent,*theEvent=&_theEvent; // (**)
do
{
if(!finished)
{
/* Process available events; return if no events available. */
if(!npending) npending=XPending(theDisplay);
if(!npending) break;
--npending;
}
XNextEvent(theDisplay,theEvent);
KeySym theKeySym;
#if (X11_DEBUG > 0)
Debug_Info("\nGot event %ld - ", theEvent->type);
#endif
switch (theEvent->type)
{
<<SNIPPED UNCHANGED CODE>>
}
}
while(!finished);
if (refresh && !abortRender)
{
#if (X11_DEBUG > 0)
Debug_Info("Refresh %dx%d+%d+%d\n", refresh_x_min, refresh_y_min,
refresh_x_max - refresh_x_min, refresh_y_max - refresh_y_min);
#endif
XPutImage(theDisplay,theWindow,theGC,theImage,
refresh_x_min, refresh_y_min, refresh_x_min, refresh_y_min,
(unsigned int)(refresh_x_max - refresh_x_min),
(unsigned int)(refresh_y_max - refresh_y_min));
XFlush(theDisplay);
}
return (abortRender);
}
-----------------------------------------------------------------------
Please note the (**) above. Once the patch is applied, one should
remove it and use "theEvent." instead of "theEvent->"; just did that
to make the patch more readable.
> I did not completely understand your description, does this also fix the
> problem that when you close the render window with a mouse click after
> completition (with the +p option) the mouse event is passed to whatever
> is behind the window?
>
Since we leave when the button is pressed, the below window will get
an enter notify with button pressed and the button release event
(unless you move the mouse away before). Applications may treat that
as complete button press and release. I'll write a separate patch for
that in some minutes.
>> Fixes:
>> - Closing the window while tracing will now abort the render.
>
> I always considered this as a feature rather than a bug...
>
It is easier to disable this feature once it is working than make it
work at all...
Post a reply to this message
|
|