eserte / perl-tk

the perl module Tk
https://metacpan.org/release/Tk
Other
44 stars 31 forks source link

X11 error handler set by another application #65

Open pmarguinaud opened 4 years ago

pmarguinaud commented 4 years ago

Hello,

I have created a Perl/Tk interface for an existing X11 application based on GLFW.

It works very well, except that I have a problem with X11 errors handling; each time the GLFW library creates a new window, the XSetErrorHandler is called, whereas PerlTk calls this X11 routine once and for all.

See tkError.c:115 :

    if (defaultHandler == NULL) {
    defaultHandler = XSetErrorHandler(ErrorProc);
    }

Then PerlTk is completely lost, and the application exits, reporting an X11 error.

I would like to know whether it would be possible to reset defaultHandler, calling XSetErrorHandler each time Tk_CreateErrorHandler is invoked, as this does not seem to bring any performance penalty (I have tested it).

Maybe we could have that as an option, or create another mean to force PerlTk to reset this variable.

I can contribute to this, if necessary.

Regards,

Philippe