2022-01-21 16:27:44 +01:00
|
|
|
/* PipeWire
|
|
|
|
|
*
|
|
|
|
|
* Copyright © 2022 Wim Taymans <wim.taymans@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <spa/utils/string.h>
|
|
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
#include <X11/Xlib-xcb.h>
|
|
|
|
|
#include <X11/XKBlib.h>
|
|
|
|
|
|
2022-02-17 20:16:22 +01:00
|
|
|
#ifdef HAVE_XFIXES_6
|
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-01-21 16:27:44 +01:00
|
|
|
#include <canberra.h>
|
|
|
|
|
|
pipewire: module-x11-bell: handle X11 errors
Unfortunately, libX11 has global error and I/O error handlers,
which make it inconvenient to use them from library code.
Since libX11 1.7.0, there is a per-display "exit_handler" which
is called from `_XIOError()`, however, the global I/O error
handler is still called before that, and that - by default -
calls `exit(1)` in `_XDefaultIOError()` after printing the error
to stderr.
To avoid exiting, custom handlers will be registered when
libpipewire-module-x11-bell.so is loaded given that at
that moment the default handlers are installed.
When the shared object is unloaded, the handlers will
be reset to the default ones given that the currently
registered handlers are the ones that were registered
when the module was loaded.
The logic only works correctly if there are no concurrent
calls to `XSet{IO}ErrorHandler()` while `{set,restore}_x11_handlers()`
is running. Since module-x11-bell is probably mostly going to
be loaded in `pipewire-pulse`, this seems like a reasonable
assumption to make.
2022-02-17 19:39:30 +01:00
|
|
|
#include <pipewire/pipewire.h>
|
|
|
|
|
#include <pipewire/impl.h>
|
2022-01-21 16:27:44 +01:00
|
|
|
|
|
|
|
|
/** \page page_module_x11_bell PipeWire Module: X11 Bell
|
|
|
|
|
*
|
|
|
|
|
* The `x11-bell` module intercept the X11 bell events and uses libcanberra to
|
|
|
|
|
* play a sound.
|
|
|
|
|
*
|
|
|
|
|
* ## Module Options
|
|
|
|
|
*
|
|
|
|
|
* - `sink.name = <str>`: node.name of the sink to connect to
|
|
|
|
|
* - `sample.name = <str>`: the name of the sample to play, default 'bell-window-system'
|
|
|
|
|
* - `x11.display = <str>`: the X11 display to use
|
|
|
|
|
* - `x11.xauthority = <str>`: the X11 XAuthority string placed in XAUTHORITY env
|
|
|
|
|
*
|
|
|
|
|
* ## General options
|
|
|
|
|
*
|
|
|
|
|
* There are no general options for this module.
|
|
|
|
|
*
|
|
|
|
|
* ## Example configuration
|
|
|
|
|
*\code{.unparsed}
|
|
|
|
|
* context.modules = [
|
|
|
|
|
* { name = libpipewire-x11-bell }
|
|
|
|
|
* args = {
|
|
|
|
|
* #sink.name = @DEFAULT_SINK@
|
|
|
|
|
* sample.name = "bell-window-system"
|
|
|
|
|
* #x11.display = ":1"
|
|
|
|
|
* #x11.xauthority = "test"
|
|
|
|
|
* ]
|
|
|
|
|
*\endcode
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define NAME "x11-bell"
|
|
|
|
|
|
|
|
|
|
PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|
|
|
|
#define PW_LOG_TOPIC_DEFAULT mod_topic
|
|
|
|
|
|
|
|
|
|
struct impl {
|
|
|
|
|
struct pw_context *context;
|
|
|
|
|
struct pw_thread_loop *thread_loop;
|
2022-02-17 01:13:57 +01:00
|
|
|
struct pw_loop *thread_loop_loop;
|
2022-01-21 16:27:44 +01:00
|
|
|
struct pw_loop *loop;
|
|
|
|
|
struct spa_source *source;
|
|
|
|
|
|
|
|
|
|
struct pw_properties *properties;
|
|
|
|
|
|
2022-02-17 00:51:27 +01:00
|
|
|
struct pw_impl_module *module;
|
2022-01-21 16:27:44 +01:00
|
|
|
struct spa_hook module_listener;
|
|
|
|
|
|
|
|
|
|
Display *display;
|
|
|
|
|
};
|
|
|
|
|
|
2022-02-17 01:13:57 +01:00
|
|
|
static int play_sample(struct impl *impl)
|
2022-01-21 16:27:44 +01:00
|
|
|
{
|
2022-02-17 01:13:57 +01:00
|
|
|
const char *sample = NULL;
|
2022-01-21 16:27:44 +01:00
|
|
|
ca_context *ca;
|
2022-02-17 01:13:57 +01:00
|
|
|
int res;
|
|
|
|
|
|
|
|
|
|
if (impl->properties)
|
|
|
|
|
sample = pw_properties_get(impl->properties, "sample.name");
|
|
|
|
|
if (sample == NULL)
|
|
|
|
|
sample = "bell-window-system";
|
|
|
|
|
|
2022-10-03 12:00:16 +02:00
|
|
|
pw_log_info("play sample %s", sample);
|
2022-01-21 16:27:44 +01:00
|
|
|
|
|
|
|
|
if ((res = ca_context_create(&ca)) < 0) {
|
|
|
|
|
pw_log_error("canberra context create error: %s", ca_strerror(res));
|
|
|
|
|
res = -EIO;
|
|
|
|
|
goto exit;
|
|
|
|
|
}
|
|
|
|
|
if ((res = ca_context_open(ca)) < 0) {
|
|
|
|
|
pw_log_error("canberra context open error: %s", ca_strerror(res));
|
|
|
|
|
res = -EIO;
|
|
|
|
|
goto exit_destroy;
|
|
|
|
|
}
|
2022-01-21 16:47:42 +01:00
|
|
|
if ((res = ca_context_play(ca, 0,
|
2022-01-21 16:27:44 +01:00
|
|
|
CA_PROP_EVENT_ID, sample,
|
|
|
|
|
CA_PROP_MEDIA_NAME, "X11 bell event",
|
|
|
|
|
CA_PROP_CANBERRA_CACHE_CONTROL, "permanent",
|
2022-01-21 16:47:42 +01:00
|
|
|
NULL)) < 0) {
|
|
|
|
|
pw_log_warn("can't play sample (%s): %s", sample, ca_strerror(res));
|
2022-02-17 01:13:57 +01:00
|
|
|
res = -EIO;
|
|
|
|
|
goto exit_destroy;
|
2022-01-21 16:47:42 +01:00
|
|
|
}
|
2022-01-21 16:27:44 +01:00
|
|
|
|
|
|
|
|
exit_destroy:
|
|
|
|
|
ca_context_destroy(ca);
|
|
|
|
|
exit:
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2022-02-17 01:13:57 +01:00
|
|
|
|
|
|
|
|
static int do_play_sample(struct spa_loop *loop, bool async, uint32_t seq, const void *data, size_t size, void *user_data)
|
|
|
|
|
{
|
|
|
|
|
play_sample(user_data);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-21 16:27:44 +01:00
|
|
|
static void display_io(void *data, int fd, uint32_t mask)
|
|
|
|
|
{
|
|
|
|
|
struct impl *impl = data;
|
|
|
|
|
XEvent e;
|
|
|
|
|
|
|
|
|
|
while (XPending(impl->display)) {
|
|
|
|
|
XNextEvent(impl->display, &e);
|
|
|
|
|
|
|
|
|
|
if (((XkbEvent*) &e)->any.xkb_type != XkbBellNotify)
|
|
|
|
|
continue;
|
|
|
|
|
|
2022-02-17 01:13:57 +01:00
|
|
|
pw_loop_invoke(impl->thread_loop_loop, do_play_sample, 0, NULL, 0, false, impl);
|
2022-01-21 16:27:44 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
pipewire: module-x11-bell: handle X11 errors
Unfortunately, libX11 has global error and I/O error handlers,
which make it inconvenient to use them from library code.
Since libX11 1.7.0, there is a per-display "exit_handler" which
is called from `_XIOError()`, however, the global I/O error
handler is still called before that, and that - by default -
calls `exit(1)` in `_XDefaultIOError()` after printing the error
to stderr.
To avoid exiting, custom handlers will be registered when
libpipewire-module-x11-bell.so is loaded given that at
that moment the default handlers are installed.
When the shared object is unloaded, the handlers will
be reset to the default ones given that the currently
registered handlers are the ones that were registered
when the module was loaded.
The logic only works correctly if there are no concurrent
calls to `XSet{IO}ErrorHandler()` while `{set,restore}_x11_handlers()`
is running. Since module-x11-bell is probably mostly going to
be loaded in `pipewire-pulse`, this seems like a reasonable
assumption to make.
2022-02-17 19:39:30 +01:00
|
|
|
#ifdef HAVE_XSETIOERROREXITHANDLER
|
|
|
|
|
static void x11_io_error_exit_handler(Display *display, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct impl *impl = data;
|
|
|
|
|
|
|
|
|
|
spa_assert(display == impl->display);
|
|
|
|
|
|
|
|
|
|
pw_log_warn("X11 display (%s) has encountered a fatal I/O error", DisplayString(display));
|
|
|
|
|
|
|
|
|
|
pw_loop_destroy_source(impl->loop, impl->source);
|
|
|
|
|
impl->source = NULL;
|
|
|
|
|
|
|
|
|
|
pw_impl_module_schedule_destroy(impl->module);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-01-21 16:27:44 +01:00
|
|
|
static int x11_connect(struct impl *impl, const char *name)
|
|
|
|
|
{
|
2022-02-17 02:40:44 +01:00
|
|
|
int major, minor;
|
2022-01-21 16:27:44 +01:00
|
|
|
unsigned int auto_ctrls, auto_values;
|
|
|
|
|
|
|
|
|
|
if (!(impl->display = XOpenDisplay(name))) {
|
2022-02-17 02:20:40 +01:00
|
|
|
pw_log_error("XOpenDisplay() failed");
|
2022-02-17 02:40:44 +01:00
|
|
|
return -EIO;
|
2022-01-21 16:27:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl->source = pw_loop_add_io(impl->loop,
|
|
|
|
|
ConnectionNumber(impl->display),
|
|
|
|
|
SPA_IO_IN, false, display_io, impl);
|
2022-02-17 04:43:47 +01:00
|
|
|
if (!impl->source)
|
|
|
|
|
return -errno;
|
2022-01-21 16:27:44 +01:00
|
|
|
|
pipewire: module-x11-bell: handle X11 errors
Unfortunately, libX11 has global error and I/O error handlers,
which make it inconvenient to use them from library code.
Since libX11 1.7.0, there is a per-display "exit_handler" which
is called from `_XIOError()`, however, the global I/O error
handler is still called before that, and that - by default -
calls `exit(1)` in `_XDefaultIOError()` after printing the error
to stderr.
To avoid exiting, custom handlers will be registered when
libpipewire-module-x11-bell.so is loaded given that at
that moment the default handlers are installed.
When the shared object is unloaded, the handlers will
be reset to the default ones given that the currently
registered handlers are the ones that were registered
when the module was loaded.
The logic only works correctly if there are no concurrent
calls to `XSet{IO}ErrorHandler()` while `{set,restore}_x11_handlers()`
is running. Since module-x11-bell is probably mostly going to
be loaded in `pipewire-pulse`, this seems like a reasonable
assumption to make.
2022-02-17 19:39:30 +01:00
|
|
|
#ifdef HAVE_XSETIOERROREXITHANDLER
|
|
|
|
|
XSetIOErrorExitHandler(impl->display, x11_io_error_exit_handler, impl);
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-02-17 20:16:22 +01:00
|
|
|
#ifdef HAVE_XFIXES_6
|
|
|
|
|
XFixesSetClientDisconnectMode(impl->display, XFixesClientDisconnectFlagTerminate);
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-01-21 16:27:44 +01:00
|
|
|
major = XkbMajorVersion;
|
|
|
|
|
minor = XkbMinorVersion;
|
|
|
|
|
|
|
|
|
|
if (!XkbLibraryVersion(&major, &minor)) {
|
2022-02-17 02:20:40 +01:00
|
|
|
pw_log_error("XkbLibraryVersion() failed");
|
2022-02-17 02:40:44 +01:00
|
|
|
return -EIO;
|
2022-01-21 16:27:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
major = XkbMajorVersion;
|
|
|
|
|
minor = XkbMinorVersion;
|
|
|
|
|
|
2022-02-17 18:26:27 +01:00
|
|
|
if (!XkbQueryExtension(impl->display, NULL, NULL, NULL, &major, &minor)) {
|
2022-02-17 02:20:40 +01:00
|
|
|
pw_log_error("XkbQueryExtension() failed");
|
2022-02-17 02:40:44 +01:00
|
|
|
return -EIO;
|
2022-01-21 16:27:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XkbSelectEvents(impl->display, XkbUseCoreKbd, XkbBellNotifyMask, XkbBellNotifyMask);
|
|
|
|
|
auto_ctrls = auto_values = XkbAudibleBellMask;
|
|
|
|
|
XkbSetAutoResetControls(impl->display, XkbAudibleBellMask, &auto_ctrls, &auto_values);
|
|
|
|
|
XkbChangeEnabledControls(impl->display, XkbUseCoreKbd, XkbAudibleBellMask, 0);
|
|
|
|
|
|
2022-02-17 02:40:44 +01:00
|
|
|
return 0;
|
2022-01-21 16:27:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void module_destroy(void *data)
|
|
|
|
|
{
|
|
|
|
|
struct impl *impl = data;
|
|
|
|
|
|
2022-02-17 00:51:27 +01:00
|
|
|
if (impl->module)
|
|
|
|
|
spa_hook_remove(&impl->module_listener);
|
2022-01-21 16:27:44 +01:00
|
|
|
|
2022-02-17 02:38:06 +01:00
|
|
|
if (impl->source)
|
|
|
|
|
pw_loop_destroy_source(impl->loop, impl->source);
|
|
|
|
|
|
|
|
|
|
if (impl->display)
|
|
|
|
|
XCloseDisplay(impl->display);
|
2022-01-21 16:27:44 +01:00
|
|
|
|
2022-02-17 01:13:57 +01:00
|
|
|
if (impl->thread_loop)
|
2022-01-21 16:27:44 +01:00
|
|
|
pw_thread_loop_destroy(impl->thread_loop);
|
|
|
|
|
|
|
|
|
|
pw_properties_free(impl->properties);
|
|
|
|
|
|
|
|
|
|
free(impl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct pw_impl_module_events module_events = {
|
|
|
|
|
PW_VERSION_IMPL_MODULE_EVENTS,
|
|
|
|
|
.destroy = module_destroy,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct spa_dict_item module_x11_bell_info[] = {
|
|
|
|
|
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
|
|
|
|
{ PW_KEY_MODULE_DESCRIPTION, "X11 Bell interceptor" },
|
|
|
|
|
{ PW_KEY_MODULE_USAGE, "sink.name=<name for the sink> "
|
|
|
|
|
"sample.name=<the sample name> "
|
|
|
|
|
"x11.display=<the X11 display> "
|
|
|
|
|
"x11.xauthority=<the X11 XAuthority> " },
|
|
|
|
|
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
|
|
|
|
|
};
|
|
|
|
|
SPA_EXPORT
|
|
|
|
|
int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|
|
|
|
{
|
|
|
|
|
struct pw_context *context = pw_impl_module_get_context(module);
|
|
|
|
|
struct impl *impl;
|
|
|
|
|
const char *name = NULL, *str;
|
|
|
|
|
int res;
|
|
|
|
|
|
|
|
|
|
PW_LOG_TOPIC_INIT(mod_topic);
|
|
|
|
|
|
|
|
|
|
impl = calloc(1, sizeof(struct impl));
|
|
|
|
|
if (impl == NULL)
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
pw_log_debug("module %p: new", impl);
|
|
|
|
|
|
|
|
|
|
impl->context = context;
|
2022-02-17 01:13:57 +01:00
|
|
|
impl->loop = pw_context_get_main_loop(context);
|
|
|
|
|
|
2022-01-21 16:27:44 +01:00
|
|
|
impl->thread_loop = pw_thread_loop_new("X11 Bell", NULL);
|
|
|
|
|
if (impl->thread_loop == NULL) {
|
|
|
|
|
res = -errno;
|
|
|
|
|
pw_log_error("can't create thread loop: %m");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
2022-02-17 01:13:57 +01:00
|
|
|
impl->thread_loop_loop = pw_thread_loop_get_loop(impl->thread_loop);
|
2022-01-21 16:27:44 +01:00
|
|
|
impl->properties = args ? pw_properties_new_string(args) : NULL;
|
|
|
|
|
|
2022-02-17 00:51:27 +01:00
|
|
|
impl->module = module;
|
2022-01-21 16:27:44 +01:00
|
|
|
pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
|
|
|
|
pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_x11_bell_info));
|
|
|
|
|
|
|
|
|
|
if (impl->properties) {
|
|
|
|
|
if ((str = pw_properties_get(impl->properties, "x11.xauthority")) != NULL) {
|
|
|
|
|
if (setenv("XAUTHORITY", str, 1)) {
|
|
|
|
|
res = -errno;
|
|
|
|
|
pw_log_error("XAUTHORITY setenv failed: %m");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
name = pw_properties_get(impl->properties, "x11.display");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* we need to use a thread loop because this module will connect
|
|
|
|
|
* to pipewire eventually and will then block the mainloop. */
|
|
|
|
|
pw_thread_loop_start(impl->thread_loop);
|
|
|
|
|
|
2022-02-17 02:20:40 +01:00
|
|
|
res = x11_connect(impl, name);
|
|
|
|
|
if (res < 0)
|
|
|
|
|
goto error;
|
2022-01-21 16:27:44 +01:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
error:
|
|
|
|
|
module_destroy(impl);
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
|
|
}
|
pipewire: module-x11-bell: handle X11 errors
Unfortunately, libX11 has global error and I/O error handlers,
which make it inconvenient to use them from library code.
Since libX11 1.7.0, there is a per-display "exit_handler" which
is called from `_XIOError()`, however, the global I/O error
handler is still called before that, and that - by default -
calls `exit(1)` in `_XDefaultIOError()` after printing the error
to stderr.
To avoid exiting, custom handlers will be registered when
libpipewire-module-x11-bell.so is loaded given that at
that moment the default handlers are installed.
When the shared object is unloaded, the handlers will
be reset to the default ones given that the currently
registered handlers are the ones that were registered
when the module was loaded.
The logic only works correctly if there are no concurrent
calls to `XSet{IO}ErrorHandler()` while `{set,restore}_x11_handlers()`
is running. Since module-x11-bell is probably mostly going to
be loaded in `pipewire-pulse`, this seems like a reasonable
assumption to make.
2022-02-17 19:39:30 +01:00
|
|
|
|
|
|
|
|
static int x11_error_handler(Display *display, XErrorEvent *error)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("X11 error handler called on display %s with error %d",
|
|
|
|
|
DisplayString(display), error->error_code);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int x11_io_error_handler(Display *display)
|
|
|
|
|
{
|
|
|
|
|
pw_log_warn("X11 I/O error handler called on display %s", DisplayString(display));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__attribute__((constructor))
|
|
|
|
|
static void set_x11_handlers(void)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
XErrorHandler prev = XSetErrorHandler(NULL);
|
|
|
|
|
XErrorHandler def = XSetErrorHandler(x11_error_handler);
|
|
|
|
|
|
|
|
|
|
if (prev != def)
|
|
|
|
|
XSetErrorHandler(prev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
XIOErrorHandler prev = XSetIOErrorHandler(NULL);
|
|
|
|
|
XIOErrorHandler def = XSetIOErrorHandler(x11_io_error_handler);
|
|
|
|
|
|
|
|
|
|
if (prev != def)
|
|
|
|
|
XSetIOErrorHandler(prev);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__attribute__((destructor))
|
|
|
|
|
static void restore_x11_handlers(void)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
XErrorHandler prev = XSetErrorHandler(NULL);
|
|
|
|
|
if (prev != x11_error_handler)
|
|
|
|
|
XSetErrorHandler(prev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
XIOErrorHandler prev = XSetIOErrorHandler(NULL);
|
|
|
|
|
if (prev != x11_io_error_handler)
|
|
|
|
|
XSetIOErrorHandler(prev);
|
|
|
|
|
}
|
|
|
|
|
}
|