XQuartz: Use ErrorF rather than fprintf to log errors

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
This commit is contained in:
Jeremy Huddleston 2011-04-25 22:00:41 -07:00
parent cb083b05c4
commit 6f29dbf5e3
10 changed files with 136 additions and 138 deletions

View File

@ -507,7 +507,7 @@ bool getGlCapabilities(struct glCapabilities *cap) {
err = CGLQueryRendererInfo((GLuint)-1, &info, &numRenderers); err = CGLQueryRendererInfo((GLuint)-1, &info, &numRenderers);
if(err) { if(err) {
fprintf(stderr, "CGLQueryRendererInfo error: %s\n", CGLErrorString(err)); ErrorF("CGLQueryRendererInfo error: %s\n", CGLErrorString(err));
return err; return err;
} }
@ -518,8 +518,8 @@ bool getGlCapabilities(struct glCapabilities *cap) {
err = handleRendererDescriptions(info, r, &tmpconf); err = handleRendererDescriptions(info, r, &tmpconf);
if(err) { if(err) {
fprintf(stderr, "handleRendererDescriptions returned error: %s\n", CGLErrorString(err)); ErrorF("handleRendererDescriptions returned error: %s\n", CGLErrorString(err));
fprintf(stderr, "trying to continue...\n"); ErrorF("trying to continue...\n");
continue; continue;
} }

View File

@ -978,7 +978,7 @@ static inline pthread_t create_thread(void *(*func)(void *), void *arg) {
static void *xpbproxy_x_thread(void *args) { static void *xpbproxy_x_thread(void *args) {
xpbproxy_run(); xpbproxy_run();
fprintf(stderr, "xpbproxy thread is terminating unexpectedly.\n"); ErrorF("xpbproxy thread is terminating unexpectedly.\n");
return NULL; return NULL;
} }
@ -1021,15 +1021,15 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
last_key_layout = TISCopyCurrentKeyboardLayoutInputSource(); last_key_layout = TISCopyCurrentKeyboardLayoutInputSource();
if(!last_key_layout) if(!last_key_layout)
fprintf(stderr, "X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n"); ErrorF("X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n");
#else #else
KLGetCurrentKeyboardLayout(&last_key_layout); KLGetCurrentKeyboardLayout(&last_key_layout);
if(!last_key_layout) if(!last_key_layout)
fprintf(stderr, "X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n"); ErrorF("X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n");
#endif #endif
if (!QuartsResyncKeymap(FALSE)) { if (!QuartsResyncKeymap(FALSE)) {
fprintf(stderr, "X11ApplicationMain: Could not build a valid keymap.\n"); ErrorF("X11ApplicationMain: Could not build a valid keymap.\n");
} }
/* Tell the server thread that it can proceed */ /* Tell the server thread that it can proceed */
@ -1370,7 +1370,7 @@ static const char *untrusted_str(NSEvent *e) {
#endif #endif
/* Update keyInfo */ /* Update keyInfo */
if (!QuartsResyncKeymap(TRUE)) { if (!QuartsResyncKeymap(TRUE)) {
fprintf(stderr, "sendX11NSEvent: Could not build a valid keymap.\n"); ErrorF("sendX11NSEvent: Could not build a valid keymap.\n");
} }
} }
} }

View File

@ -136,9 +136,9 @@ const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
void void
DarwinPrintBanner(void) DarwinPrintBanner(void)
{ {
// this should change depending on which specific server we are building
ErrorF("Xquartz starting:\n"); ErrorF("Xquartz starting:\n");
ErrorF("X.Org X Server %s\nBuild Date: %s\n", XSERVER_VERSION, BUILD_DATE ); ErrorF("X.Org X Server %s\n", XSERVER_VERSION);
ErrorF("Build Date: %s\n", BUILD_DATE );
} }

View File

@ -64,6 +64,9 @@
/* From darwinEvents.c ... but don't want to pull in all the server cruft */ /* From darwinEvents.c ... but don't want to pull in all the server cruft */
void DarwinListenOnOpenFD(int fd); void DarwinListenOnOpenFD(int fd);
/* Ditto, from os/log.c */
extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
extern int noPanoramiXExtension; extern int noPanoramiXExtension;
#define DEFAULT_CLIENT X11BINDIR "/xterm" #define DEFAULT_CLIENT X11BINDIR "/xterm"
@ -134,13 +137,13 @@ static mach_port_t checkin_or_register(char *bname) {
/* We probably were not started by launchd or the old mach_init */ /* We probably were not started by launchd or the old mach_init */
kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp); kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp);
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
fprintf(stderr, "mach_port_allocate(): %s\n", mach_error_string(kr)); ErrorF("mach_port_allocate(): %s\n", mach_error_string(kr));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
kr = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND); kr = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND);
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
fprintf(stderr, "mach_port_insert_right(): %s\n", mach_error_string(kr)); ErrorF("mach_port_insert_right(): %s\n", mach_error_string(kr));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -154,7 +157,7 @@ static mach_port_t checkin_or_register(char *bname) {
#endif #endif
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
fprintf(stderr, "bootstrap_register(): %s\n", mach_error_string(kr)); ErrorF("bootstrap_register(): %s\n", mach_error_string(kr));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -197,7 +200,7 @@ static int accept_fd_handoff(int connected_fd) {
*((int*)CMSG_DATA(cmsg)) = -1; *((int*)CMSG_DATA(cmsg)) = -1;
if(recvmsg(connected_fd, &msg, 0) < 0) { if(recvmsg(connected_fd, &msg, 0) < 0) {
fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", strerror(errno)); ErrorF("X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", strerror(errno));
return -1; return -1;
} }
@ -230,14 +233,14 @@ static void *socket_handoff_thread(void *arg) {
while(launchd_fd == -1) { while(launchd_fd == -1) {
connected_fd = accept(handoff_data->fd, NULL, NULL); connected_fd = accept(handoff_data->fd, NULL, NULL);
if(connected_fd == -1) { if(connected_fd == -1) {
fprintf(stderr, "X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno)); ErrorF("X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno));
sleep(2); sleep(2);
continue; continue;
} }
launchd_fd = accept_fd_handoff(connected_fd); launchd_fd = accept_fd_handoff(connected_fd);
if(launchd_fd == -1) if(launchd_fd == -1)
fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n"); ErrorF("X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n");
close(connected_fd); close(connected_fd);
} }
@ -246,7 +249,7 @@ static void *socket_handoff_thread(void *arg) {
unlink(handoff_data->filename); unlink(handoff_data->filename);
free(handoff_data); free(handoff_data);
fprintf(stderr, "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd); ErrorF("X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd);
DarwinListenOnOpenFD(launchd_fd); DarwinListenOnOpenFD(launchd_fd);
#ifndef HAVE_LIBDISPATCH #ifndef HAVE_LIBDISPATCH
@ -274,24 +277,24 @@ static int create_socket(char *filename_out) {
ret_fd = socket(PF_UNIX, SOCK_STREAM, 0); ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if(ret_fd == -1) { if(ret_fd == -1) {
fprintf(stderr, "X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno)); ErrorF("X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno));
continue; continue;
} }
if(bind(ret_fd, servaddr, servaddr_len) != 0) { if(bind(ret_fd, servaddr, servaddr_len) != 0) {
fprintf(stderr, "X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno)); ErrorF("X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno));
close(ret_fd); close(ret_fd);
return 0; return 0;
} }
if(listen(ret_fd, 10) != 0) { if(listen(ret_fd, 10) != 0) {
fprintf(stderr, "X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno)); ErrorF("X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno));
close(ret_fd); close(ret_fd);
return 0; return 0;
} }
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "X11.app: Listening on socket for fd handoff: (%d) %s\n", ret_fd, filename_out); ErrorF("X11.app: Listening on socket for fd handoff: (%d) %s\n", ret_fd, filename_out);
#endif #endif
return ret_fd; return ret_fd;
@ -309,7 +312,7 @@ kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename)
handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t)); handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t));
if(!handoff_data) { if(!handoff_data) {
fprintf(stderr, "X11.app: Error allocating memory for handoff_data\n"); ErrorF("X11.app: Error allocating memory for handoff_data\n");
return KERN_FAILURE; return KERN_FAILURE;
} }
@ -330,7 +333,7 @@ kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename)
#endif #endif
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n"); ErrorF("X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n");
#endif #endif
return KERN_SUCCESS; return KERN_SUCCESS;
@ -355,7 +358,7 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
* unset DISPLAY or we can run into problems with pbproxy * unset DISPLAY or we can run into problems with pbproxy
*/ */
if(!launchd_socket_handed_off) { if(!launchd_socket_handed_off) {
fprintf(stderr, "X11.app: No launchd socket handed off, unsetting DISPLAY\n"); ErrorF("X11.app: No launchd socket handed off, unsetting DISPLAY\n");
unsetenv("DISPLAY"); unsetenv("DISPLAY");
} }
@ -363,10 +366,10 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
return KERN_FAILURE; return KERN_FAILURE;
} }
fprintf(stderr, "X11.app: do_start_x11_server(): argc=%d\n", argvCnt); ErrorF("X11.app: do_start_x11_server(): argc=%d\n", argvCnt);
for(i=0; i < argvCnt; i++) { for(i=0; i < argvCnt; i++) {
_argv[i] = argv[i]; _argv[i] = argv[i];
fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]); ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
} }
_argv[argvCnt] = NULL; _argv[argvCnt] = NULL;
@ -404,7 +407,7 @@ static int startup_trigger(int argc, char **argv, char **envp) {
newenvp = (string_array_t)alloca(envpc * sizeof(string_t)); newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
if(!newargv || !newenvp) { if(!newargv || !newenvp) {
fprintf(stderr, "Memory allocation failure\n"); ErrorF("Memory allocation failure\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -418,16 +421,16 @@ static int startup_trigger(int argc, char **argv, char **envp) {
kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp); kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
fprintf(stderr, "bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr)); ErrorF("bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr));
#else #else
fprintf(stderr, "bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr); ErrorF("bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr);
#endif #endif
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
kr = start_x11_server(mp, newargv, argc, newenvp, envpc); kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
fprintf(stderr, "start_x11_server: %s\n", mach_error_string(kr)); ErrorF("start_x11_server: %s\n", mach_error_string(kr));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
@ -449,10 +452,10 @@ static int startup_trigger(int argc, char **argv, char **envp) {
/* Start the server */ /* Start the server */
if((s = getenv("DISPLAY"))) { if((s = getenv("DISPLAY"))) {
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s); ErrorF("X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s);
unsetenv("DISPLAY"); unsetenv("DISPLAY");
} else { } else {
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n"); ErrorF("X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
} }
return execute(command_from_prefs("startx_script", DEFAULT_STARTX)); return execute(command_from_prefs("startx_script", DEFAULT_STARTX));
} }
@ -496,7 +499,7 @@ static void setup_env(void) {
server_bootstrap_name = strdup(pds); server_bootstrap_name = strdup(pds);
if(!server_bootstrap_name) { if(!server_bootstrap_name) {
fprintf(stderr, "X11.app: Memory allocation error.\n"); ErrorF("X11.app: Memory allocation error.\n");
exit(1); exit(1);
} }
setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1); setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1);
@ -504,7 +507,7 @@ static void setup_env(void) {
len = strlen(server_bootstrap_name); len = strlen(server_bootstrap_name);
bundle_id_prefix = malloc(sizeof(char) * (len - 3)); bundle_id_prefix = malloc(sizeof(char) * (len - 3));
if(!bundle_id_prefix) { if(!bundle_id_prefix) {
fprintf(stderr, "X11.app: Memory allocation error.\n"); ErrorF("X11.app: Memory allocation error.\n");
exit(1); exit(1);
} }
strlcpy(bundle_id_prefix, server_bootstrap_name, len - 3); strlcpy(bundle_id_prefix, server_bootstrap_name, len - 3);
@ -520,11 +523,11 @@ static void setup_env(void) {
if(s && *s) { if(s && *s) {
if(strcmp(bundle_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) { if(strcmp(bundle_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) {
fprintf(stderr, "X11.app: Detected old style launchd DISPLAY, please update xinit.\n"); ErrorF("X11.app: Detected old style launchd DISPLAY, please update xinit.\n");
} else { } else {
temp = (char *)malloc(sizeof(char) * len); temp = (char *)malloc(sizeof(char) * len);
if(!temp) { if(!temp) {
fprintf(stderr, "X11.app: Memory allocation error creating space for socket name test.\n"); ErrorF("X11.app: Memory allocation error creating space for socket name test.\n");
exit(1); exit(1);
} }
strlcpy(temp, bundle_id_prefix, len); strlcpy(temp, bundle_id_prefix, len);
@ -532,14 +535,14 @@ static void setup_env(void) {
if(strcmp(temp, s) != 0) { if(strcmp(temp, s) != 0) {
/* If we don't have a match, unset it. */ /* If we don't have a match, unset it. */
fprintf(stderr, "X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, bundle_id_prefix); ErrorF("X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, bundle_id_prefix);
unsetenv("DISPLAY"); unsetenv("DISPLAY");
} }
free(temp); free(temp);
} }
} else { } else {
/* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */ /* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */
fprintf(stderr, "X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n"); ErrorF("X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n");
unsetenv("DISPLAY"); unsetenv("DISPLAY");
} }
} }
@ -570,9 +573,9 @@ int main(int argc, char **argv, char **envp) {
/* Setup the initial crasherporter info */ /* Setup the initial crasherporter info */
strlcpy(__crashreporter_info_buff__, __crashreporter_info__base, sizeof(__crashreporter_info_buff__)); strlcpy(__crashreporter_info_buff__, __crashreporter_info__base, sizeof(__crashreporter_info_buff__));
fprintf(stderr, "X11.app: main(): argc=%d\n", argc); ErrorF("X11.app: main(): argc=%d\n", argc);
for(i=0; i < argc; i++) { for(i=0; i < argc; i++) {
fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]); ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
if(!strcmp(argv[i], "--listenonly")) { if(!strcmp(argv[i], "--listenonly")) {
listenOnly = TRUE; listenOnly = TRUE;
} }
@ -580,7 +583,7 @@ int main(int argc, char **argv, char **envp) {
mp = checkin_or_register(server_bootstrap_name); mp = checkin_or_register(server_bootstrap_name);
if(mp == MACH_PORT_NULL) { if(mp == MACH_PORT_NULL) {
fprintf(stderr, "NULL mach service: %s", server_bootstrap_name); ErrorF("NULL mach service: %s", server_bootstrap_name);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -629,10 +632,10 @@ int main(int argc, char **argv, char **envp) {
} }
/* Main event loop */ /* Main event loop */
fprintf(stderr, "Waiting for startup parameters via Mach IPC.\n"); ErrorF("Waiting for startup parameters via Mach IPC.\n");
kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0); kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
fprintf(stderr, "%s.X11(mp): %s\n", BUNDLE_ID_PREFIX, mach_error_string(kr)); ErrorF("%s.X11(mp): %s\n", BUNDLE_ID_PREFIX, mach_error_string(kr));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -648,9 +651,9 @@ static int execute(const char *command) {
newargv[2] = command; newargv[2] = command;
newargv[3] = NULL; newargv[3] = NULL;
fprintf(stderr, "X11.app: Launching %s:\n", command); ErrorF("X11.app: Launching %s:\n", command);
for(p=newargv; *p; p++) { for(p=newargv; *p; p++) {
fprintf(stderr, "\targv[%ld] = %s\n", (long int)(p - newargv), *p); ErrorF("\targv[%ld] = %s\n", (long int)(p - newargv), *p);
} }
execvp (newargv[0], (char * const *) newargv); execvp (newargv[0], (char * const *) newargv);

View File

@ -53,12 +53,22 @@ static void signal_handler (int sig) {
} }
} }
void
ErrorF(const char * f, ...)
{
va_list args;
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
}
int main (int argc, const char *argv[]) { int main (int argc, const char *argv[]) {
const char *s; const char *s;
int i; int i;
#ifdef DEBUG #ifdef DEBUG
printf("pid: %u\n", getpid()); ErrorF("pid: %u\n", getpid());
#endif #endif
xpbproxy_is_standalone = YES; xpbproxy_is_standalone = YES;
@ -70,13 +80,13 @@ int main (int argc, const char *argv[]) {
if(strcmp (argv[i], "--prefs-domain") == 0 && i+1 < argc) { if(strcmp (argv[i], "--prefs-domain") == 0 && i+1 < argc) {
app_prefs_domain = argv[++i]; app_prefs_domain = argv[++i];
} else if (strcmp (argv[i], "--help") == 0) { } else if (strcmp (argv[i], "--help") == 0) {
printf("usage: xpbproxy OPTIONS\n" ErrorF("usage: xpbproxy OPTIONS\n"
"Pasteboard proxying for X11.\n\n" "Pasteboard proxying for X11.\n\n"
"--prefs-domain <domain> Change the domain used for reading preferences\n" "--prefs-domain <domain> Change the domain used for reading preferences\n"
" (default: %s)\n", app_prefs_domain); " (default: %s)\n", app_prefs_domain);
return 0; return 0;
} else { } else {
fprintf(stderr, "usage: xpbproxy OPTIONS...\n" ErrorF("usage: xpbproxy OPTIONS...\n"
"Try 'xpbproxy --help' for more information.\n"); "Try 'xpbproxy --help' for more information.\n");
return 1; return 1;
} }

View File

@ -105,7 +105,7 @@ int xpbproxy_run (void) {
} }
if (xpbproxy_dpy == NULL) { if (xpbproxy_dpy == NULL) {
fprintf (stderr, "xpbproxy: can't open default display\n"); ErrorF("xpbproxy: can't open default display\n");
[pool release]; [pool release];
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -115,7 +115,7 @@ int xpbproxy_run (void) {
if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base, if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
&xpbproxy_apple_wm_error_base)) { &xpbproxy_apple_wm_error_base)) {
fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n"); ErrorF("xpbproxy: can't open AppleWM server extension\n");
[pool release]; [pool release];
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -147,19 +147,3 @@ Time xpbproxy_current_timestamp (void) {
/* FIXME: may want to fetch a timestamp from the server.. */ /* FIXME: may want to fetch a timestamp from the server.. */
return CurrentTime; return CurrentTime;
} }
void debug_printf (const char *fmt, ...) {
static int spew = -1;
if (spew == -1) {
char *x = getenv ("DEBUG");
spew = (x != NULL && atoi (x) != 0);
}
if (spew) {
va_list args;
va_start(args, fmt);
vfprintf (stderr, fmt, args);
va_end(args);
}
}

View File

@ -77,14 +77,16 @@ extern BOOL xpbproxy_have_xfixes;
/* from x-input.m */ /* from x-input.m */
extern BOOL xpbproxy_input_register (void); extern BOOL xpbproxy_input_register (void);
/* os/log.c or app-main.m */
extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
#ifdef DEBUG #ifdef DEBUG
/* BEWARE: this can cause a string memory leak, according to the leaks program. */ /* BEWARE: this can cause a string memory leak, according to the leaks program. */
# define DB(msg, args...) debug_printf("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args) # define DebugF(msg, args...) ErrorF("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args)
#else #else
# define DB(msg, args...) do {} while (0) # define DebugF(...) /* */
#endif #endif
#define TRACE() DB("TRACE\n") #define TRACE() DebugF("TRACE\n")
extern void debug_printf (const char *fmt, ...);
#endif /* PBPROXY_H */ #endif /* PBPROXY_H */

View File

@ -87,7 +87,7 @@ static void xpbproxy_process_xevents(void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if(pool == nil) { if(pool == nil) {
fprintf(stderr, "unable to allocate/init auto release pool!\n"); ErrorF("unable to allocate/init auto release pool!\n");
return; return;
} }

View File

@ -81,19 +81,19 @@ static struct propdata null_propdata = {NULL, 0, 0};
#ifdef DEBUG #ifdef DEBUG
static void static void
dump_prefs (FILE *fp) { dump_prefs() {
fprintf(fp, ErrorF(fp,
"pbproxy preferences:\n" "pbproxy preferences:\n"
"\tactive %u\n" "\tactive %u\n"
"\tprimary_on_grab %u\n" "\tprimary_on_grab %u\n"
"\tclipboard_to_pasteboard %u\n" "\tclipboard_to_pasteboard %u\n"
"\tpasteboard_to_primary %u\n" "\tpasteboard_to_primary %u\n"
"\tpasteboard_to_clipboard %u\n", "\tpasteboard_to_clipboard %u\n",
pbproxy_prefs.active, pbproxy_prefs.active,
pbproxy_prefs.primary_on_grab, pbproxy_prefs.primary_on_grab,
pbproxy_prefs.clipboard_to_pasteboard, pbproxy_prefs.clipboard_to_pasteboard,
pbproxy_prefs.pasteboard_to_primary, pbproxy_prefs.pasteboard_to_primary,
pbproxy_prefs.pasteboard_to_clipboard); pbproxy_prefs.pasteboard_to_clipboard);
} }
#endif #endif
@ -152,7 +152,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
unsigned char *newbuf = NULL; unsigned char *newbuf = NULL;
#ifdef TEST #ifdef TEST
printf("bytesleft %lu\n", bytesleft); ErrorF("bytesleft %lu\n", bytesleft);
#endif #endif
if (Success != XGetWindowProperty (xpbproxy_dpy, win, property, if (Success != XGetWindowProperty (xpbproxy_dpy, win, property,
@ -161,17 +161,17 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
type, &format, &numitems, type, &format, &numitems,
&bytesleft, &chunk)) &bytesleft, &chunk))
{ {
DB ("Error while getting window property.\n"); DebugF ("Error while getting window property.\n");
*pdata = null_propdata; *pdata = null_propdata;
free (buf); free (buf);
return True; return True;
} }
#ifdef TEST #ifdef TEST
printf("format %d numitems %lu bytesleft %lu\n", ErrorF("format %d numitems %lu bytesleft %lu\n",
format, numitems, bytesleft); format, numitems, bytesleft);
printf("type %s\n", XGetAtomName (xpbproxy_dpy, *type)); ErrorF("type %s\n", XGetAtomName (xpbproxy_dpy, *type));
#endif #endif
/* Format is the number of bits. */ /* Format is the number of bits. */
@ -183,7 +183,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
chunkbytesize = numitems * sizeof(long); chunkbytesize = numitems * sizeof(long);
#ifdef TEST #ifdef TEST
printf("chunkbytesize %zu\n", chunkbytesize); ErrorF("chunkbytesize %zu\n", chunkbytesize);
#endif #endif
newbuflen = buflen + chunkbytesize; newbuflen = buflen + chunkbytesize;
if (newbuflen > 0) if (newbuflen > 0)
@ -211,7 +211,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
} }
#ifdef TEST #ifdef TEST
printf("bytesleft %lu\n", bytesleft); ErrorF("bytesleft %lu\n", bytesleft);
#endif #endif
} while (bytesleft > 0); } while (bytesleft > 0);
@ -236,7 +236,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (pdata->format != 32) if (pdata->format != 32)
{ {
fprintf(stderr, "Atom list is expected to be formatted as an array of 32bit values.\n"); ErrorF("Atom list is expected to be formatted as an array of 32bit values.\n");
return None; return None;
} }
@ -265,7 +265,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
char *type = XGetAtomName(xpbproxy_dpy, a); char *type = XGetAtomName(xpbproxy_dpy, a);
if (type) if (type)
{ {
DB("Unhandled X11 mime type: %s", type); DebugF("Unhandled X11 mime type: %s", type);
XFree(type); XFree(type);
} }
} }
@ -378,7 +378,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (countNow != changeCount) if (countNow != changeCount)
{ {
DB ("changed pasteboard!\n"); DebugF ("changed pasteboard!\n");
changeCount = countNow; changeCount = countNow;
if (pbproxy_prefs.pasteboard_to_primary) if (pbproxy_prefs.pasteboard_to_primary)
@ -462,9 +462,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
return TRUE; return TRUE;
if(owner != None) { if(owner != None) {
fprintf (stderr, "A clipboard manager using window 0x%lx " ErrorF("A clipboard manager using window 0x%lx already owns the clipboard selection. "
"already owns the clipboard selection. " "pbproxy will not sync clipboard to pasteboard.\n", owner);
"pbproxy will not sync clipboard to pasteboard.\n", owner);
return FALSE; return FALSE;
} }
@ -491,7 +490,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
TRACE (); TRACE ();
DB ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection)); DebugF ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
if(e->selection == atoms->clipboard) { if(e->selection == atoms->clipboard) {
/* /*
@ -508,7 +507,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* Another CLIPBOARD_MANAGER has set itself as owner. Disable syncing /* Another CLIPBOARD_MANAGER has set itself as owner. Disable syncing
* to avoid a race. * to avoid a race.
*/ */
fprintf(stderr, "Another clipboard manager was started! " ErrorF("Another clipboard manager was started! "
"xpbproxy is disabling syncing with clipboard.\n"); "xpbproxy is disabling syncing with clipboard.\n");
pbproxy_prefs.clipboard_to_pasteboard = NO; pbproxy_prefs.clipboard_to_pasteboard = NO;
} }
@ -533,7 +532,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* The owner probably died or we are just starting up pbproxy. * The owner probably died or we are just starting up pbproxy.
* Set pbproxy's _selection_window as the owner, and continue. * Set pbproxy's _selection_window as the owner, and continue.
*/ */
DB ("No clipboard owner.\n"); DebugF ("No clipboard owner.\n");
[self copy_completed:atoms->clipboard]; [self copy_completed:atoms->clipboard];
return; return;
} else if (owner == _selection_window) { } else if (owner == _selection_window) {
@ -541,7 +540,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
return; return;
} }
DB ("requesting targets\n"); DebugF ("requesting targets\n");
request_atom = atoms->targets; request_atom = atoms->targets;
XConvertSelection (xpbproxy_dpy, atoms->clipboard, atoms->targets, XConvertSelection (xpbproxy_dpy, atoms->clipboard, atoms->targets,
@ -581,7 +580,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* We are supposed to use an empty event mask, and not propagate * We are supposed to use an empty event mask, and not propagate
* the event, according to the ICCCM. * the event, according to the ICCCM.
*/ */
DB ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor); DebugF ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor);
XSendEvent (xpbproxy_dpy, reply->xselection.requestor, False, 0, reply); XSendEvent (xpbproxy_dpy, reply->xselection.requestor, False, 0, reply);
XFlush (xpbproxy_dpy); XFlush (xpbproxy_dpy);
@ -618,7 +617,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if ([pbtypes containsObject:NSStringPboardType]) if ([pbtypes containsObject:NSStringPboardType])
{ {
/* We have a string type that we can convert to UTF8, or Latin-1... */ /* We have a string type that we can convert to UTF8, or Latin-1... */
DB ("NSStringPboardType\n"); DebugF ("NSStringPboardType\n");
list[count] = atoms->utf8_string; list[count] = atoms->utf8_string;
++count; ++count;
list[count] = atoms->string; list[count] = atoms->string;
@ -639,7 +638,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
|| [pbtypes containsObject:NSTIFFPboardType]) || [pbtypes containsObject:NSTIFFPboardType])
{ {
/* We can convert a TIFF to a PNG or JPEG. */ /* We can convert a TIFF to a PNG or JPEG. */
DB ("NSTIFFPboardType\n"); DebugF ("NSTIFFPboardType\n");
list[count] = atoms->image_png; list[count] = atoms->image_png;
++count; ++count;
list[count] = atoms->image_jpeg; list[count] = atoms->image_jpeg;
@ -684,7 +683,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
return; return;
} }
DB ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]); DebugF ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]);
data = [pb stringForType:NSStringPboardType]; data = [pb stringForType:NSStringPboardType];
@ -704,19 +703,19 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
length = strlen (bytes); length = strlen (bytes);
if (length < 50) { if (length < 50) {
DB ("UTF-8: %s\n", bytes); DebugF ("UTF-8: %s\n", bytes);
DB ("UTF-8 length: %u\n", length); DebugF ("UTF-8 length: %u\n", length);
} }
} }
else else
{ {
DB ("Latin-1\n"); DebugF ("Latin-1\n");
bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding]; bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding];
/*WARNING: bytes is not NUL-terminated. */ /*WARNING: bytes is not NUL-terminated. */
length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding]; length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
} }
DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target)); DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target, XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
8, PropModeReplace, (unsigned char *) bytes, length); 8, PropModeReplace, (unsigned char *) bytes, length);
@ -758,7 +757,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{ {
if (8 != textprop.format) if (8 != textprop.format)
DB ("textprop.format is unexpectedly not 8 - it's %d instead\n", DebugF ("textprop.format is unexpectedly not 8 - it's %d instead\n",
textprop.format); textprop.format);
XChangeProperty (xpbproxy_dpy, e->requestor, e->property, XChangeProperty (xpbproxy_dpy, e->requestor, e->property,
@ -850,7 +849,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (nil == data) if (nil == data)
{ {
[img autorelease]; [img autorelease];
fprintf(stderr, "unable to convert PICT to TIFF!\n"); ErrorF("unable to convert PICT to TIFF!\n");
return YES; return YES;
} }
@ -926,7 +925,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
imagetype = NSJPEGFileType; imagetype = NSJPEGFileType;
else else
{ {
fprintf(stderr, "internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n"); ErrorF("internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n");
} }
pbtypes = [pb types]; pbtypes = [pb types];
@ -997,7 +996,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (None != e->target) if (None != e->target)
DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target)); DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
if (e->target == atoms->targets) if (e->target == atoms->targets)
{ {
@ -1049,15 +1048,15 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[self release_pending]; [self release_pending];
if (None == e->property) { if (None == e->property) {
DB ("e->property is None.\n"); DebugF ("e->property is None.\n");
[self copy_completed:e->selection]; [self copy_completed:e->selection];
/* Nothing is selected. */ /* Nothing is selected. */
return; return;
} }
#if 0 #if 0
printf ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection)); ErrorF("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
printf ("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property)); ErrorF("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property));
#endif #endif
if ([self is_incr_type:e]) if ([self is_incr_type:e])
@ -1066,7 +1065,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* This is an INCR-style transfer, which means that we * This is an INCR-style transfer, which means that we
* will get the data after a series of PropertyNotify events. * will get the data after a series of PropertyNotify events.
*/ */
DB ("is INCR\n"); DebugF ("is INCR\n");
if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type)) if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type))
{ {
@ -1083,7 +1082,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
pending.requestor = e->requestor; pending.requestor = e->requestor;
pending.selection = e->selection; pending.selection = e->selection;
DB ("set pending.requestor to 0x%lx\n", pending.requestor); DebugF ("set pending.requestor to 0x%lx\n", pending.requestor);
} }
else else
{ {
@ -1096,7 +1095,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* We have the complete selection data.*/ /* We have the complete selection data.*/
[self handle_selection:e->selection type:type propdata:&pdata]; [self handle_selection:e->selection type:type propdata:&pdata];
DB ("handled selection with the first notify_event\n"); DebugF ("handled selection with the first notify_event\n");
} }
} }
@ -1116,7 +1115,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (name) if (name)
{ {
DB ("e->atom %s\n", name); DebugF ("e->atom %s\n", name);
XFree(name); XFree(name);
} }
#endif #endif
@ -1124,7 +1123,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (None != pending.requestor && PropertyNewValue == e->state) if (None != pending.requestor && PropertyNewValue == e->state)
{ {
DB ("pending.requestor 0x%lx\n", pending.requestor); DebugF ("pending.requestor 0x%lx\n", pending.requestor);
if (get_property (e->window, e->atom, &pdata, /*Delete*/ True, &type)) if (get_property (e->window, e->atom, &pdata, /*Delete*/ True, &type))
{ {
@ -1166,7 +1165,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
case XFixesSelectionWindowDestroyNotify: case XFixesSelectionWindowDestroyNotify:
case XFixesSelectionClientCloseNotify: case XFixesSelectionClientCloseNotify:
default: default:
fprintf(stderr, "Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype); ErrorF("Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype);
break; break;
} }
} }
@ -1196,7 +1195,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (name) if (name)
{ {
DB ("requesting %s\n", name); DebugF ("requesting %s\n", name);
} }
#endif #endif
request_atom = preferred; request_atom = preferred;
@ -1220,11 +1219,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (nil == data) if (nil == data)
{ {
DB ("unable to create NSData object!\n"); DebugF ("unable to create NSData object!\n");
return; return;
} }
DB ("data retainCount before NSBitmapImageRep initWithData: %u\n", DebugF ("data retainCount before NSBitmapImageRep initWithData: %u\n",
[data retainCount]); [data retainCount]);
bmimage = [[NSBitmapImageRep alloc] initWithData:data]; bmimage = [[NSBitmapImageRep alloc] initWithData:data];
@ -1232,11 +1231,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (nil == bmimage) if (nil == bmimage)
{ {
[data autorelease]; [data autorelease];
DB ("unable to create NSBitmapImageRep!\n"); DebugF ("unable to create NSBitmapImageRep!\n");
return; return;
} }
DB ("data retainCount after NSBitmapImageRep initWithData: %u\n", DebugF ("data retainCount after NSBitmapImageRep initWithData: %u\n",
[data retainCount]); [data retainCount]);
@try @try
@ -1246,13 +1245,13 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
@catch (NSException *e) @catch (NSException *e)
{ {
DB ("NSTIFFException!\n"); DebugF ("NSTIFFException!\n");
[data autorelease]; [data autorelease];
[bmimage autorelease]; [bmimage autorelease];
return; return;
} }
DB ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]); DebugF ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]);
pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil]; pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil];
@ -1266,12 +1265,12 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[pb declareTypes:pbtypes owner:nil]; [pb declareTypes:pbtypes owner:nil];
if (YES != [pb setData:tiff forType:NSTIFFPboardType]) if (YES != [pb setData:tiff forType:NSTIFFPboardType])
{ {
DB ("writing pasteboard data failed!\n"); DebugF ("writing pasteboard data failed!\n");
} }
[data autorelease]; [data autorelease];
DB ("bmimage retainCount before release %u\n", [bmimage retainCount]); DebugF ("bmimage retainCount before release %u\n", [bmimage retainCount]);
[bmimage autorelease]; [bmimage autorelease];
} }
@ -1299,10 +1298,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[pb declareTypes:pbtypes owner:nil]; [pb declareTypes:pbtypes owner:nil];
if (YES != [pb setString:string forType:NSStringPboardType]) { if (YES != [pb setString:string forType:NSStringPboardType]) {
fprintf(stderr, "pasteboard setString:forType: failed!\n"); ErrorF("pasteboard setString:forType: failed!\n");
} }
[string autorelease]; [string autorelease];
DB ("done handling utf8 string\n"); DebugF ("done handling utf8 string\n");
} }
/* This handles the STRING type, which should be in Latin-1. */ /* This handles the STRING type, which should be in Latin-1. */
@ -1328,7 +1327,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[pb declareTypes:pbtypes owner:nil]; [pb declareTypes:pbtypes owner:nil];
if (YES != [pb setString:string forType:NSStringPboardType]) { if (YES != [pb setString:string forType:NSStringPboardType]) {
fprintf(stderr, "pasteboard setString:forType failed in handle_string!\n"); ErrorF("pasteboard setString:forType failed in handle_string!\n");
} }
[string autorelease]; [string autorelease];
} }
@ -1394,7 +1393,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
name = XGetAtomName (xpbproxy_dpy, selection); name = XGetAtomName (xpbproxy_dpy, selection);
if (name) if (name)
{ {
DB ("copy_completed: %s\n", name); DebugF ("copy_completed: %s\n", name);
XFree (name); XFree (name);
} }
#endif #endif
@ -1455,10 +1454,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
pbproxy_prefs.pasteboard_to_clipboard = prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), pbproxy_prefs.pasteboard_to_clipboard); pbproxy_prefs.pasteboard_to_clipboard = prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), pbproxy_prefs.pasteboard_to_clipboard);
/* This is used for debugging. */ /* This is used for debugging. */
//dump_prefs(stdout); //dump_prefs();
if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !xpbproxy_have_xfixes) { if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !xpbproxy_have_xfixes) {
fprintf(stderr, "Disabling sync_primary_on_select functionality due to missing XFixes extension.\n"); ErrorF("Disabling sync_primary_on_select functionality due to missing XFixes extension.\n");
pbproxy_prefs.primary_on_grab = NO; pbproxy_prefs.primary_on_grab = NO;
} }

View File

@ -367,9 +367,9 @@ static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue
if (pDev->kbdfeed) if (pDev->kbdfeed)
memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize); memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize);
//fprintf(stderr, "per_key_repeat =\n"); //ErrorF("per_key_repeat =\n");
//for(i=0; i < XkbPerKeyBitArraySize; i++) //for(i=0; i < XkbPerKeyBitArraySize; i++)
// fprintf(stderr, "%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n"); // ErrorF("%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n");
/* And now we notify the puppies about the changes */ /* And now we notify the puppies about the changes */
XkbDDXChangeControls(pDev, &old, ctrl); XkbDDXChangeControls(pDev, &old, ctrl);