diff options
Diffstat (limited to 'app/xterm/misc.c')
-rw-r--r-- | app/xterm/misc.c | 381 |
1 files changed, 282 insertions, 99 deletions
diff --git a/app/xterm/misc.c b/app/xterm/misc.c index d2c171794..32bbfbefb 100644 --- a/app/xterm/misc.c +++ b/app/xterm/misc.c @@ -1,4 +1,4 @@ -/* $XTermId: misc.c,v 1.550 2011/10/09 14:13:41 tom Exp $ */ +/* $XTermId: misc.c,v 1.576 2012/01/07 01:57:52 tom Exp $ */ /* * Copyright 1999-2010,2011 by Thomas E. Dickey @@ -58,6 +58,7 @@ #include <sys/stat.h> #include <stdio.h> +#include <stdarg.h> #include <signal.h> #include <ctype.h> #include <pwd.h> @@ -118,6 +119,7 @@ (event.xcrossing.window == XtWindow(XtParent(xw)))) #endif +static Boolean xtermAllocColor(XtermWidget, XColor *, const char *); static Cursor make_hidden_cursor(XtermWidget); #if OPT_EXEC_XTERM @@ -160,12 +162,14 @@ Sleep(int msec) } static void -selectwindow(TScreen * screen, int flag) +selectwindow(XtermWidget xw, int flag) { + TScreen *screen = TScreenOf(xw); + TRACE(("selectwindow(%d) flag=%d\n", screen->select, flag)); #if OPT_TEK4014 - if (TEK4014_ACTIVE(term)) { + if (TEK4014_ACTIVE(xw)) { if (!Ttoggled) TCursorToggle(tekWidget, TOGGLE); screen->select |= flag; @@ -174,8 +178,11 @@ selectwindow(TScreen * screen, int flag) } else #endif { - if (screen->xic) - XSetICFocus(screen->xic); +#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD + TInput *input = lookupTInput(xw, (Widget) xw); + if (input->xic) + XSetICFocus(input->xic); +#endif if (screen->cursor_state && CursorMoved(screen)) HideCursor(); @@ -187,18 +194,20 @@ selectwindow(TScreen * screen, int flag) } static void -unselectwindow(TScreen * screen, int flag) +unselectwindow(XtermWidget xw, int flag) { + TScreen *screen = TScreenOf(xw); + TRACE(("unselectwindow(%d) flag=%d\n", screen->select, flag)); if (screen->hide_pointer) { screen->hide_pointer = False; - xtermDisplayCursor(term); + xtermDisplayCursor(xw); } if (!screen->always_highlight) { #if OPT_TEK4014 - if (TEK4014_ACTIVE(term)) { + if (TEK4014_ACTIVE(xw)) { if (!Ttoggled) TCursorToggle(tekWidget, TOGGLE); screen->select &= ~flag; @@ -207,8 +216,11 @@ unselectwindow(TScreen * screen, int flag) } else #endif { - if (screen->xic) - XUnsetICFocus(screen->xic); +#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD + TInput *input = lookupTInput(xw, (Widget) xw); + if (input->xic) + XUnsetICFocus(input->xic); +#endif screen->select &= ~flag; if (screen->cursor_state && CursorMoved(screen)) @@ -229,7 +241,7 @@ DoSpecialEnterNotify(XtermWidget xw, XEnterWindowEvent * ev) if (((ev->detail) != NotifyInferior) && ev->focus && !(screen->select & FOCUS)) - selectwindow(screen, INWINDOW); + selectwindow(xw, INWINDOW); } static void @@ -242,7 +254,7 @@ DoSpecialLeaveNotify(XtermWidget xw, XEnterWindowEvent * ev) if (((ev->detail) != NotifyInferior) && ev->focus && !(screen->select & FOCUS)) - unselectwindow(screen, INWINDOW); + unselectwindow(xw, INWINDOW); } #ifndef XUrgencyHint @@ -770,7 +782,7 @@ HandleSpawnTerminal(Widget w GCC_UNUSED, && strncmp(ProgramName, "../", (size_t) 3)) { child_exe = xtermFindShell(ProgramName, True); } else { - fprintf(stderr, "Cannot exec-xterm given %s\n", ProgramName); + xtermWarning("Cannot exec-xterm given \"%s\"\n", ProgramName); } if (child_exe == 0) return; @@ -791,7 +803,7 @@ HandleSpawnTerminal(Widget w GCC_UNUSED, /* The reaper will take care of cleaning up the child */ pid = fork(); if (pid == -1) { - fprintf(stderr, "Could not fork: %s\n", SysErrorMsg(errno)); + xtermWarning("Could not fork: %s\n", SysErrorMsg(errno)); } else if (!pid) { /* We are the child */ if (child_cwd) { @@ -800,7 +812,7 @@ HandleSpawnTerminal(Widget w GCC_UNUSED, if (setuid(screen->uid) == -1 || setgid(screen->gid) == -1) { - fprintf(stderr, "Cannot reset uid/gid\n"); + xtermWarning("Cannot reset uid/gid\n"); } else { unsigned myargc = *nparams + 1; char **myargv = TypeMallocN(char *, myargc + 1); @@ -816,7 +828,7 @@ HandleSpawnTerminal(Widget w GCC_UNUSED, execv(child_exe, myargv); /* If we get here, we've failed */ - fprintf(stderr, "exec of '%s': %s\n", child_exe, SysErrorMsg(errno)); + xtermWarning("exec of '%s': %s\n", child_exe, SysErrorMsg(errno)); } _exit(0); } else { @@ -921,9 +933,9 @@ HandleFocusChange(Widget w GCC_UNUSED, */ if (event->detail == NotifyNonlinear && (screen->select & INWINDOW) != 0) { - unselectwindow(screen, INWINDOW); + unselectwindow(xw, INWINDOW); } - selectwindow(screen, + selectwindow(xw, ((event->detail == NotifyPointer) ? INWINDOW : FOCUS)); @@ -939,7 +951,7 @@ HandleFocusChange(Widget w GCC_UNUSED, * ignore. */ if (event->mode != NotifyGrab) { - unselectwindow(screen, + unselectwindow(xw, ((event->detail == NotifyPointer) ? INWINDOW : FOCUS)); @@ -1088,10 +1100,17 @@ Bell(XtermWidget xw, int which, int percent) static void flashWindow(TScreen * screen, Window window, GC visualGC, unsigned width, unsigned height) { - XFillRectangle(screen->display, window, visualGC, 0, 0, width, height); + int y = 0; + int x = 0; + + if (screen->flash_line) { + y = CursorY(screen, screen->cur_row); + height = (unsigned) FontHeight(screen); + } + XFillRectangle(screen->display, window, visualGC, x, y, width, height); XFlush(screen->display); Sleep(VB_DELAY); - XFillRectangle(screen->display, window, visualGC, 0, 0, width, height); + XFillRectangle(screen->display, window, visualGC, x, y, width, height); } void @@ -1139,6 +1158,34 @@ HandleBellPropertyChange(Widget w GCC_UNUSED, } } +void +xtermWarning(const char *fmt,...) +{ + va_list ap; + + fprintf(stderr, "%s: ", ProgramName); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + (void) fflush(stderr); + + va_end(ap); +} + +void +xtermPerror(const char *fmt,...) +{ + char *msg = strerror(errno); + va_list ap; + + fprintf(stderr, "%s: ", ProgramName); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ": %s\n", msg); + (void) fflush(stderr); + + va_end(ap); +} + Window WMFrameWindow(XtermWidget xw) { @@ -1590,7 +1637,7 @@ timestamp_filename(char *dst, const char *src) tstruct = localtime(&tstamp); sprintf(dst, TIMESTAMP_FMT, src, - tstruct->tm_year + 1900, + (int) tstruct->tm_year + 1900, tstruct->tm_mon + 1, tstruct->tm_mday, tstruct->tm_hour, @@ -1607,11 +1654,10 @@ open_userfile(uid_t uid, gid_t gid, char *path, Bool append) #ifdef VMS if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) { int the_error = errno; - fprintf(stderr, "%s: cannot open %s: %d:%s\n", - ProgramName, - path, - the_error, - SysErrorMsg(the_error)); + xtermWarning("cannot open %s: %d:%s\n", + path, + the_error, + SysErrorMsg(the_error)); return -1; } chown(path, uid, gid); @@ -1620,11 +1666,10 @@ open_userfile(uid_t uid, gid_t gid, char *path, Bool append) || (creat_as(uid, gid, append, path, 0644) <= 0) || ((fd = open(path, O_WRONLY | O_APPEND)) < 0)) { int the_error = errno; - fprintf(stderr, "%s: cannot open %s: %d:%s\n", - ProgramName, - path, - the_error, - SysErrorMsg(the_error)); + xtermWarning("cannot open %s: %d:%s\n", + path, + the_error, + SysErrorMsg(the_error)); return -1; } #endif @@ -1636,7 +1681,7 @@ open_userfile(uid_t uid, gid_t gid, char *path, Bool append) if (fstat(fd, &sb) < 0 || sb.st_uid != uid || (sb.st_mode & 022) != 0) { - fprintf(stderr, "%s: you do not own %s\n", ProgramName, path); + xtermWarning("you do not own %s\n", path); close(fd); return -1; } @@ -1753,11 +1798,11 @@ xtermResetIds(TScreen * screen) { int result = 0; if (setgid(screen->gid) == -1) { - fprintf(stderr, "%s: unable to reset group-id\n", ProgramName); + xtermWarning("unable to reset group-id\n"); result = -1; } if (setuid(screen->uid) == -1) { - fprintf(stderr, "%s: unable to reset user-id\n", ProgramName); + xtermWarning("unable to reset user-id\n"); result = -1; } return result; @@ -1892,9 +1937,7 @@ StartLog(XtermWidget xw) execl(shell, shell, "-c", &screen->logfile[1], (void *) 0); - fprintf(stderr, "%s: Can't exec `%s'\n", - ProgramName, - &screen->logfile[1]); + xtermWarning("Can't exec `%s'\n", &screen->logfile[1]); exit(ERROR_LOGEXEC); } close(p[0]); @@ -1983,10 +2026,9 @@ ReportAnsiColorRequest(XtermWidget xw, int colornum, int final) } } -static unsigned -getColormapSize(Display * display) +static void +getColormapInfo(Display * display, unsigned *typep, unsigned *sizep) { - unsigned result; int numFound; XVisualInfo myTemplate, *visInfoPtr; @@ -1994,9 +2036,44 @@ getColormapSize(Display * display) XDefaultScreen(display))); visInfoPtr = XGetVisualInfo(display, (long) VisualIDMask, &myTemplate, &numFound); - result = (numFound >= 1) ? (unsigned) visInfoPtr->colormap_size : 0; + *typep = (numFound >= 1) ? (unsigned) visInfoPtr->class : 0; + *sizep = (numFound >= 1) ? (unsigned) visInfoPtr->colormap_size : 0; XFree((char *) visInfoPtr); + + TRACE(("getColormapInfo type %d (%s), size %d\n", + *typep, ((*typep & 1) ? "dynamic" : "static"), *sizep)); +} + +#define MAX_COLORTABLE 4096 + +/* + * Make only one call to XQueryColors(), since it can be slow. + */ +static Boolean +loadColorTable(XtermWidget xw, unsigned length) +{ + Colormap cmap = xw->core.colormap; + TScreen *screen = TScreenOf(xw); + unsigned i; + Boolean result = False; + + if (screen->cmap_data == 0 + && length != 0 + && length < MAX_COLORTABLE) { + screen->cmap_data = TypeMallocN(XColor, (size_t) length); + if (screen->cmap_data != 0) { + screen->cmap_size = length; + + for (i = 0; i < screen->cmap_size; i++) { + screen->cmap_data[i].pixel = (unsigned long) i; + } + result = (Boolean) (XQueryColors(screen->display, + cmap, + screen->cmap_data, + (int) screen->cmap_size) != 0); + } + } return result; } @@ -2018,31 +2095,27 @@ getColormapSize(Display * display) * Return False if not able to find or allocate a color. */ static Boolean -find_closest_color(Display * dpy, Colormap cmap, XColor * def) +allocateClosestRGB(XtermWidget xw, Colormap cmap, XColor * def) { + TScreen *screen = TScreenOf(xw); Boolean result = False; - XColor *colortable; char *tried; double diff, thisRGB, bestRGB; unsigned attempts; unsigned bestInx; + unsigned cmap_type; unsigned cmap_size; unsigned i; - cmap_size = getColormapSize(dpy); - if (cmap_size != 0) { + getColormapInfo(screen->display, &cmap_type, &cmap_size); + + if ((cmap_type & 1) != 0) { - colortable = TypeMallocN(XColor, (size_t) cmap_size); - if (colortable != 0) { + if (loadColorTable(xw, cmap_size)) { tried = TypeCallocN(char, (size_t) cmap_size); if (tried != 0) { - for (i = 0; i < cmap_size; i++) { - colortable[i].pixel = (unsigned long) i; - } - XQueryColors(dpy, cmap, colortable, (int) cmap_size); - /* * Try (possibly each entry in the color map) to find the best * approximation to the requested color. @@ -2063,7 +2136,7 @@ find_closest_color(Display * dpy, Colormap cmap, XColor * def) * weights that correspond to the luminance. */ #define AddColorWeight(weight, color) \ - diff = weight * (int) ((def->color) - colortable[i].color); \ + diff = weight * (int) ((def->color) - screen->cmap_data[i].color); \ thisRGB = diff * diff AddColorWeight(0.30, red); @@ -2077,8 +2150,11 @@ find_closest_color(Display * dpy, Colormap cmap, XColor * def) } } } - if (XAllocColor(dpy, cmap, &colortable[bestInx]) != 0) { - *def = colortable[bestInx]; + if (XAllocColor(screen->display, cmap, + &screen->cmap_data[bestInx]) != 0) { + *def = screen->cmap_data[bestInx]; + TRACE(("...closest %x/%x/%x\n", def->red, + def->green, def->blue)); result = True; break; } @@ -2091,12 +2167,115 @@ find_closest_color(Display * dpy, Colormap cmap, XColor * def) } free(tried); } - free(colortable); } } return result; } +#ifndef ULONG_MAX +#define ULONG_MAX (unsigned long)(~(0L)) +#endif + +static unsigned short +searchColortable(XColor * colortable, unsigned length, unsigned color) +{ + unsigned result = 0; + unsigned n; + unsigned long best = ULONG_MAX; + unsigned long diff; + + for (n = 0; n < length; ++n) { + diff = (color - colortable[n].blue); + diff *= diff; + if (diff < best) { +#if 0 + TRACE(("...%d:looking for %x, found %x/%x/%x (%lx)\n", + n, color, + colortable[n].red, + colortable[n].green, + colortable[n].blue, + diff)); +#endif + result = n; + best = diff; + } + } + return colortable[result].blue; +} + +/* + * This is a workaround for a longstanding defect in the X libraries. + * + * According to + * http://www.unix.com/man-page/all/3x/XAllocColoA/ + * + * XAllocColor() acts differently on static and dynamic visuals. On Pseu- + * doColor, DirectColor, and GrayScale visuals, XAllocColor() fails if + * there are no unallocated colorcells and no allocated read-only cell + * exactly matches the requested RGB values. On StaticColor, TrueColor, + * and StaticGray visuals, XAllocColor() returns the closest RGB values + * available in the colormap. The colorcell_in_out structure returns the + * actual RGB values allocated. + * + * That is, XAllocColor() should suffice unless the color map is full. In that + * case, allocateClosesRGB() is useful for the dynamic display classes such as + * PseudoColor. It is not useful for TrueColor, since XQueryColors() does not + * return regular RGB triples (unless a different scheme was used for + * specifying the pixel values); only the blue value is filled in. However, it + * is filled in with the colors that the server supports. + * + * Also (the reason for this function), XAllocColor() does not really work as + * described. For some TrueColor configurations it merely returns a close + * approximation, but not the closest. + */ +static Boolean +allocateExactRGB(XtermWidget xw, Colormap cmap, XColor * def) +{ + XColor save = *def; + TScreen *screen = TScreenOf(xw); + Boolean result = (Boolean) (XAllocColor(screen->display, cmap, def) != 0); + + /* + * If this is a statically allocated display, e.g., TrueColor, see if we + * can improve on the result by using the color values actually supported + * by the server. + */ + if (result) { + unsigned cmap_type; + unsigned cmap_size; + + getColormapInfo(screen->display, &cmap_type, &cmap_size); + + if ((cmap_type & 1) == 0) { + XColor temp = *def; + + if (loadColorTable(xw, cmap_size)) { + /* + * Note: the query will return only a value in the ".blue" + * member, leaving ".red" and ".green" as zeros. + */ + temp.red = searchColortable(screen->cmap_data, cmap_size, save.red); + temp.green = searchColortable(screen->cmap_data, cmap_size, save.green); + temp.blue = searchColortable(screen->cmap_data, cmap_size, save.blue); + if (XAllocColor(screen->display, cmap, &temp) != 0) { +#if OPT_TRACE + if (temp.red != save.red + || temp.green != save.green + || temp.blue != save.blue) { + TRACE(("...improved %x/%x/%x ->%x/%x/%x\n", + save.red, save.green, save.blue, + temp.red, temp.green, temp.blue)); + } +#endif + *def = temp; + } + } + } + } + + return result; +} + /* * Allocate a color for the "ANSI" colors. That actually includes colors up * to 256. @@ -2113,12 +2292,8 @@ AllocateAnsiColor(XtermWidget xw, { int result; XColor def; - TScreen *screen = TScreenOf(xw); - Colormap cmap = xw->core.colormap; - if (XParseColor(screen->display, cmap, spec, &def) - && (XAllocColor(screen->display, cmap, &def) - || find_closest_color(screen->display, cmap, &def))) { + if (xtermAllocColor(xw, &def, spec)) { if ( #if OPT_COLOR_RES res->mode == True && @@ -2129,7 +2304,7 @@ AllocateAnsiColor(XtermWidget xw, result = 1; SET_COLOR_RES(res, def.pixel); TRACE(("AllocateAnsiColor[%d] %s (pixel 0x%06lx)\n", - (int) (res - screen->Acolors), spec, def.pixel)); + (int) (res - TScreenOf(xw)->Acolors), spec, def.pixel)); #if OPT_COLOR_RES if (!res->mode) result = 0; @@ -2161,10 +2336,8 @@ xtermGetColorRes(XtermWidget xw, ColorRes * res) if (AllocateAnsiColor(xw, res, res->resource) < 0) { res->value = TScreenOf(xw)->Tcolors[TEXT_FG].value; res->mode = -True; - fprintf(stderr, - "%s: Cannot allocate color \"%s\"\n", - ProgramName, - NonNull(res->resource)); + xtermWarning("Cannot allocate color \"%s\"\n", + NonNull(res->resource)); } result = res->value; } else { @@ -2307,9 +2480,27 @@ ResetAnsiColorRequest(XtermWidget xw, char *buf, int start) return repaint; } #else -#define find_closest_color(display, cmap, def) 0 +#define allocateClosestRGB(xw, cmap, def) 0 +#define allocateExactRGB(xw, cmap, def) XAllocColor(TScreenOf(xw)->display, cmap, def) #endif /* OPT_ISO_COLORS */ +static Boolean +xtermAllocColor(XtermWidget xw, XColor * def, const char *spec) +{ + Boolean result = False; + TScreen *screen = TScreenOf(xw); + Colormap cmap = xw->core.colormap; + + if (XParseColor(screen->display, cmap, spec, def) + && (allocateExactRGB(xw, cmap, def) + || allocateClosestRGB(xw, cmap, def))) { + TRACE(("xtermAllocColor -> %x/%x/%x\n", + def->red, def->green, def->blue)); + result = True; + } + return result; +} + #if OPT_PASTE64 static void ManipulateSelectionData(XtermWidget xw, TScreen * screen, char *buf, int final) @@ -2482,7 +2673,7 @@ GetOldColors(XtermWidget xw) if (pOldColors == NULL) { pOldColors = TypeXtMalloc(ScrnColors); if (pOldColors == NULL) { - fprintf(stderr, "allocation failure in GetOldColors\n"); + xtermWarning("allocation failure in GetOldColors\n"); return (False); } pOldColors->which = 0; @@ -3774,7 +3965,11 @@ do_decrpm(XtermWidget xw, int nparams, int *params) break; #endif case SET_EXT_MODE_MOUSE: - result = MdBool(screen->ext_mode_mouse); + /* FALLTHRU */ + case SET_SGR_EXT_MODE_MOUSE: + /* FALLTHRU */ + case SET_URXVT_EXT_MODE_MOUSE: + result = MdBool(screen->extend_coords == params[0]); break; case 1010: /* rxvt */ result = MdBool(screen->scrollttyoutput); @@ -3783,7 +3978,7 @@ do_decrpm(XtermWidget xw, int nparams, int *params) result = MdBool(screen->scrollkey); break; case 1034: - result = MdBool(screen->input_eight_bits); + result = MdBool(screen->eight_bit_meta); break; #if OPT_NUM_LOCK case 1035: @@ -4044,7 +4239,7 @@ ChangeIconName(XtermWidget xw, char *name) if (resource.zIconBeep && TScreenOf(xw)->zIconBeep_flagged) { char *newname = CastMallocN(char, strlen(name) + 4); if (!newname) { - fprintf(stderr, "malloc failed in ChangeIconName\n"); + xtermWarning("malloc failed in ChangeIconName\n"); return; } strcpy(newname, "*** "); @@ -4141,8 +4336,6 @@ AllocateTermColor(XtermWidget xw, if (always || AllowColorOps(xw, ecSetColor)) { XColor def; - TScreen *screen = TScreenOf(xw); - Colormap cmap = xw->core.colormap; char *newName; result = True; @@ -4150,11 +4343,7 @@ AllocateTermColor(XtermWidget xw, def.pixel = xw->old_foreground; } else if (!x_strcasecmp(name, XtDefaultBackground)) { def.pixel = xw->old_background; - } else if (XParseColor(screen->display, cmap, name, &def) - && (XAllocColor(screen->display, cmap, &def) - || find_closest_color(screen->display, cmap, &def))) { - ; /*empty */ - } else { + } else if (!xtermAllocColor(xw, &def, name)) { result = False; } @@ -4182,10 +4371,7 @@ Panic(const char *s GCC_UNUSED, int a GCC_UNUSED) { #ifdef DEBUG if (debug) { - fprintf(stderr, "%s: PANIC!\t", ProgramName); - fprintf(stderr, s, a); - fputs("\r\n", stderr); - fflush(stderr); + xtermWarning(s, a); } #endif /* DEBUG */ } @@ -4306,7 +4492,7 @@ Cleanup(int code) if (resource.sessionMgt) { XtVaSetValues(toplevel, XtNjoinSession, False, - NULL); + (void *) 0); } #endif } @@ -4382,7 +4568,7 @@ xtermFindShell(char *leaf, Bool warning) || strstr(result, "..") != 0 || access(result, X_OK) != 0) { if (warning) - fprintf(stderr, "No absolute path found for shell: %s\n", result); + xtermWarning("No absolute path found for shell: %s\n", result); result = 0; } return result; @@ -4485,7 +4671,7 @@ xtermSetenv(const char *var, const char *value) char **newenv; newenv = TypeMallocN(char *, need); if (newenv == 0) { - fprintf(stderr, "Cannot increase environment\n"); + xtermWarning("Cannot increase environment\n"); return; } memmove(newenv, environ, have * sizeof(*newenv)); @@ -4500,7 +4686,7 @@ xtermSetenv(const char *var, const char *value) environ[found] = CastMallocN(char, 1 + len + strlen(value)); if (environ[found] == 0) { - fprintf(stderr, "Cannot allocate environment %s\n", var); + xtermWarning("Cannot allocate environment %s\n", var); return; } sprintf(environ[found], "%s=%s", var, value); @@ -4531,7 +4717,7 @@ xtermUnsetenv(const char *var) int xerror(Display * d, XErrorEvent * ev) { - fprintf(stderr, "%s: warning, error event received:\n", ProgramName); + xtermWarning("warning, error event received:\n"); (void) XmuPrintDefaultErrorMessage(d, ev, stderr); Exit(ERROR_XERROR); return 0; /* appease the compiler */ @@ -4542,9 +4728,8 @@ ice_error(IceConn iceConn) { (void) iceConn; - fprintf(stderr, - "%s: ICE IO error handler doing an exit(), pid = %ld, errno = %d\n", - ProgramName, (long) getpid(), errno); + xtermWarning("ICE IO error handler doing an exit(), pid = %ld, errno = %d\n", + (long) getpid(), errno); Exit(ERROR_ICEERROR); } @@ -4555,10 +4740,9 @@ xioerror(Display * dpy) { int the_error = errno; - (void) fprintf(stderr, - "%s: fatal IO error %d (%s) or KillClient on X server \"%s\"\r\n", - ProgramName, the_error, SysErrorMsg(the_error), - DisplayString(dpy)); + xtermWarning("fatal IO error %d (%s) or KillClient on X server \"%s\"\r\n", + the_error, SysErrorMsg(the_error), + DisplayString(dpy)); Exit(ERROR_XIOERROR); return 0; /* appease the compiler */ @@ -4567,13 +4751,13 @@ xioerror(Display * dpy) void xt_error(String message) { - (void) fprintf(stderr, "%s Xt error: %s\n", ProgramName, message); + xtermWarning("Xt error: %s\n", message); /* * Check for the obvious - Xt does a poor job of reporting this. */ if (x_getenv("DISPLAY") == 0) { - fprintf(stderr, "%s: DISPLAY is not set\n", ProgramName); + xtermWarning("DISPLAY is not set\n"); } exit(1); } @@ -5135,8 +5319,7 @@ validWindow(Display * dpy, Window win, XWindowAttributes * attrs) if (result) { TRACE_WIN_ATTRS(attrs); } else { - fprintf(stderr, "%s: invalid window-id %ld\n", - ProgramName, (long) win); + xtermWarning("invalid window-id %ld\n", (long) win); } } return result; |