diff options
Diffstat (limited to 'app/xterm/misc.c')
-rw-r--r-- | app/xterm/misc.c | 112 |
1 files changed, 60 insertions, 52 deletions
diff --git a/app/xterm/misc.c b/app/xterm/misc.c index ce3c0c1f2..384f27f2f 100644 --- a/app/xterm/misc.c +++ b/app/xterm/misc.c @@ -1,7 +1,7 @@ -/* $XTermId: misc.c,v 1.511 2010/11/10 00:56:29 tom Exp $ */ +/* $XTermId: misc.c,v 1.520 2011/02/13 21:03:21 tom Exp $ */ /* - * Copyright 1999-2009,2010 by Thomas E. Dickey + * Copyright 1999-2010,2011 by Thomas E. Dickey * * All Rights Reserved * @@ -250,17 +250,19 @@ DoSpecialLeaveNotify(XtermWidget xw, XEnterWindowEvent * ev) #endif static void -setXUrgency(TScreen * screen, Bool enable) +setXUrgency(XtermWidget xw, Bool enable) { + TScreen *screen = TScreenOf(xw); + if (screen->bellIsUrgent) { - XWMHints *h = XGetWMHints(screen->display, VShellWindow); + XWMHints *h = XGetWMHints(screen->display, VShellWindow(xw)); if (h != 0) { - if (enable) { + if (enable && !(screen->select & FOCUS)) { h->flags |= XUrgencyHint; } else { h->flags &= ~XUrgencyHint; } - XSetWMHints(screen->display, VShellWindow, h); + XSetWMHints(screen->display, VShellWindow(xw), h); } } } @@ -739,9 +741,9 @@ HandleFocusChange(Widget w GCC_UNUSED, if (screen->quiet_grab && (event->mode == NotifyGrab || event->mode == NotifyUngrab)) { - ; + /* EMPTY */ ; } else if (event->type == FocusIn) { - setXUrgency(screen, False); + setXUrgency(xw, False); /* * NotifyNonlinear only happens (on FocusIn) if the pointer was not in @@ -856,7 +858,7 @@ xtermBell(XtermWidget xw, int which, int percent) #if defined(HAVE_XKB_BELL_EXT) if (tony != None) { - XkbBell(screen->display, VShellWindow, percent, tony); + XkbBell(screen->display, VShellWindow(xw), percent, tony); } else #endif XBell(screen->display, percent); @@ -874,7 +876,7 @@ Bell(XtermWidget xw, int which, int percent) return; } - setXUrgency(screen, True); + setXUrgency(xw, True); /* has enough time gone by that we are allowed to ring the bell again? */ @@ -901,7 +903,7 @@ Bell(XtermWidget xw, int which, int percent) } if (screen->poponbell) - XRaiseWindow(screen->display, VShellWindow); + XRaiseWindow(screen->display, VShellWindow(xw)); if (screen->bellSuppressTime) { /* now we change a property and wait for the notify event to come @@ -972,19 +974,19 @@ HandleBellPropertyChange(Widget w GCC_UNUSED, } Window -WMFrameWindow(XtermWidget termw) +WMFrameWindow(XtermWidget xw) { Window win_root, win_current, *children; Window win_parent = 0; unsigned int nchildren; - win_current = XtWindow(termw); + win_current = XtWindow(xw); /* find the parent which is child of root */ do { if (win_parent) win_current = win_parent; - XQueryTree(TScreenOf(termw)->display, + XQueryTree(TScreenOf(xw)->display, win_current, &win_root, &win_parent, @@ -1196,7 +1198,7 @@ HandleDeIconify(Widget w, if ((xw = getXtermWidget(w)) != 0) { TScreen *screen = TScreenOf(xw); - XMapWindow(screen->display, VShellWindow); + XMapWindow(screen->display, VShellWindow(xw)); } } @@ -1212,15 +1214,15 @@ HandleIconify(Widget w, if ((xw = getXtermWidget(w)) != 0) { TScreen *screen = TScreenOf(xw); XIconifyWindow(screen->display, - VShellWindow, + VShellWindow(xw), DefaultScreen(screen->display)); } } int -QueryMaximize(XtermWidget termw, unsigned *width, unsigned *height) +QueryMaximize(XtermWidget xw, unsigned *width, unsigned *height) { - TScreen *screen = TScreenOf(termw); + TScreen *screen = TScreenOf(xw); XSizeHints hints; long supp = 0; Window root_win; @@ -1230,7 +1232,7 @@ QueryMaximize(XtermWidget termw, unsigned *width, unsigned *height) unsigned root_depth; if (XGetGeometry(screen->display, - RootWindowOfScreen(XtScreen(termw)), + RootWindowOfScreen(XtScreen(xw)), &root_win, &root_x, &root_y, @@ -1250,7 +1252,7 @@ QueryMaximize(XtermWidget termw, unsigned *width, unsigned *height) hints.flags = PMaxSize; if (XGetWMNormalHints(screen->display, - VShellWindow, + VShellWindow(xw), &hints, &supp) && (hints.flags & PMaxSize) != 0) { @@ -1270,9 +1272,9 @@ QueryMaximize(XtermWidget termw, unsigned *width, unsigned *height) } void -RequestMaximize(XtermWidget termw, int maximize) +RequestMaximize(XtermWidget xw, int maximize) { - TScreen *screen = TScreenOf(termw); + TScreen *screen = TScreenOf(xw); XWindowAttributes wm_attrs, vshell_attrs; unsigned root_width, root_height; @@ -1280,14 +1282,14 @@ RequestMaximize(XtermWidget termw, int maximize) if (maximize) { - if (QueryMaximize(termw, &root_width, &root_height)) { + if (QueryMaximize(xw, &root_width, &root_height)) { if (XGetWindowAttributes(screen->display, - WMFrameWindow(termw), + WMFrameWindow(xw), &wm_attrs)) { if (XGetWindowAttributes(screen->display, - VShellWindow, + VShellWindow(xw), &vshell_attrs)) { if (screen->restore_data != True @@ -1313,7 +1315,7 @@ RequestMaximize(XtermWidget termw, int maximize) (unsigned) ((wm_attrs.height - vshell_attrs.height) + (wm_attrs.border_width * 2)); - XMoveResizeWindow(screen->display, VShellWindow, + XMoveResizeWindow(screen->display, VShellWindow(xw), 0 + wm_attrs.border_width, /* x */ 0 + wm_attrs.border_width, /* y */ root_width, @@ -1331,7 +1333,7 @@ RequestMaximize(XtermWidget termw, int maximize) screen->restore_data = False; XMoveResizeWindow(screen->display, - VShellWindow, + VShellWindow(xw), screen->restore_x, screen->restore_y, screen->restore_width, @@ -1440,7 +1442,7 @@ open_userfile(uid_t uid, gid_t gid, char *path, Bool append) 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", - xterm_name, + ProgramName, path, the_error, SysErrorMsg(the_error)); @@ -1453,7 +1455,7 @@ open_userfile(uid_t uid, gid_t gid, char *path, Bool append) || ((fd = open(path, O_WRONLY | O_APPEND)) < 0)) { int the_error = errno; fprintf(stderr, "%s: cannot open %s: %d:%s\n", - xterm_name, + ProgramName, path, the_error, SysErrorMsg(the_error)); @@ -1468,7 +1470,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", xterm_name, path); + fprintf(stderr, "%s: you do not own %s\n", ProgramName, path); close(fd); return -1; } @@ -1722,7 +1724,8 @@ StartLog(XtermWidget xw) execl(shell, shell, "-c", &screen->logfile[1], (void *) 0); - fprintf(stderr, "%s: Can't exec `%s'\n", xterm_name, + fprintf(stderr, "%s: Can't exec `%s'\n", + ProgramName, &screen->logfile[1]); exit(ERROR_LOGEXEC); } @@ -1992,7 +1995,7 @@ xtermGetColorRes(XtermWidget xw, ColorRes * res) res->mode = -True; fprintf(stderr, "%s: Cannot allocate color \"%s\"\n", - xterm_name, + ProgramName, NonNull(res->resource)); } result = res->value; @@ -2309,7 +2312,7 @@ GetOldColors(XtermWidget xw) { int i; if (pOldColors == NULL) { - pOldColors = (ScrnColors *) XtMalloc((Cardinal) sizeof(ScrnColors)); + pOldColors = TypeXtMalloc(ScrnColors); if (pOldColors == NULL) { fprintf(stderr, "allocation failure in GetOldColors\n"); return (False); @@ -2673,7 +2676,9 @@ ChangeFontRequest(XtermWidget xw, String buf) } #if OPT_RENDERFONT if (UsingRenderFont(xw)) { - ; /* there is only one font entry to load */ + /* EMPTY */ + /* there is only one font entry to load */ + ; } else #endif { @@ -3172,7 +3177,7 @@ parse_ansi_params(ANSI * params, const char **string) if (++nparam < NPARAM) params->a_nparam = nparam; } else if (ch < 32) { - ; + /* EMPTY */ ; } else { /* should be 0x30 to 0x7e */ params->a_final = ch; @@ -3342,7 +3347,7 @@ do_dcs(XtermWidget xw, Char * dcsbuf, size_t dcslen) } else #endif if (code == XK_TCAPNAME) { - unparseputs(xw, xterm_name); + unparseputs(xw, resource.term_name); } else { XKeyEvent event; event.state = state; @@ -3826,14 +3831,14 @@ ChangeGroup(XtermWidget xw, const char *attribute, char *value) if (IsSetUtf8Title(xw)) { TRACE(("...updating %s\n", propname)); TRACE(("...value is %s\n", value)); - XChangeProperty(dpy, VShellWindow, my_atom, + XChangeProperty(dpy, VShellWindow(xw), my_atom, XA_UTF8_STRING(dpy), 8, PropModeReplace, (Char *) value, (int) strlen(value)); } else { TRACE(("...deleting %s\n", propname)); - XDeleteProperty(dpy, VShellWindow, my_atom); + XDeleteProperty(dpy, VShellWindow(xw), my_atom); } } } @@ -3985,7 +3990,7 @@ Panic(const char *s GCC_UNUSED, int a GCC_UNUSED) { #ifdef DEBUG if (debug) { - fprintf(stderr, "%s: PANIC!\t", xterm_name); + fprintf(stderr, "%s: PANIC!\t", ProgramName); fprintf(stderr, s, a); fputs("\r\n", stderr); fflush(stderr); @@ -4068,7 +4073,7 @@ SysError(int code) { int oerrno = errno; - fprintf(stderr, "%s: Error %d, errno %d: ", xterm_name, code, oerrno); + fprintf(stderr, "%s: Error %d, errno %d: ", ProgramName, code, oerrno); fprintf(stderr, "%s\n", SysErrorMsg(oerrno)); fprintf(stderr, "Reason: %s\n", SysReasonMsg(code)); @@ -4255,7 +4260,7 @@ xtermSetenv(const char *var, const char *value) int xerror(Display * d, XErrorEvent * ev) { - fprintf(stderr, "%s: warning, error event received:\n", xterm_name); + fprintf(stderr, "%s: warning, error event received:\n", ProgramName); (void) XmuPrintDefaultErrorMessage(d, ev, stderr); Exit(ERROR_XERROR); return 0; /* appease the compiler */ @@ -4269,7 +4274,7 @@ xioerror(Display * dpy) (void) fprintf(stderr, "%s: fatal IO error %d (%s) or KillClient on X server \"%s\"\r\n", - xterm_name, the_error, SysErrorMsg(the_error), + ProgramName, the_error, SysErrorMsg(the_error), DisplayString(dpy)); Exit(ERROR_XIOERROR); @@ -4316,16 +4321,17 @@ withdraw_window(Display * dpy, Window w, int scr) void set_vt_visibility(Bool on) { - TScreen *screen = TScreenOf(term); + XtermWidget xw = term; + TScreen *screen = TScreenOf(xw); TRACE(("set_vt_visibility(%d)\n", on)); if (on) { - if (!screen->Vshow && term) { - VTInit(term); - XtMapWidget(XtParent(term)); + if (!screen->Vshow && xw) { + VTInit(xw); + XtMapWidget(XtParent(xw)); #if OPT_TOOLBAR /* we need both of these during initialization */ - XtMapWidget(SHELL_OF(term)); + XtMapWidget(SHELL_OF(xw)); ShowToolbar(resource.toolBar); #endif screen->Vshow = True; @@ -4333,10 +4339,10 @@ set_vt_visibility(Bool on) } #if OPT_TEK4014 else { - if (screen->Vshow && term) { - withdraw_window(XtDisplay(term), - VShellWindow, - XScreenNumberOfScreen(XtScreen(term))); + if (screen->Vshow && xw) { + withdraw_window(XtDisplay(xw), + VShellWindow(xw), + XScreenNumberOfScreen(XtScreen(xw))); screen->Vshow = False; } } @@ -4547,6 +4553,7 @@ sortedOpts(OptionHelp * options, XrmOptionDescRec * descs, Cardinal numDescs) #if OPT_TRACE for (j = 0; j < opt_count; j++) { if (!strncmp(opt_array[j].opt, "-/+", 3)) { + char temp[80]; const char *name = opt_array[j].opt + 3; for (k = 0; k < numDescs; ++k) { const char *value = res_array[k].value; @@ -4557,7 +4564,8 @@ sortedOpts(OptionHelp * options, XrmOptionDescRec * descs, Cardinal numDescs) } else { code = 0; } - if (x_strindex(opt_array[j].desc, "inhibit") != 0) + strcpy(temp, opt_array[j].desc); + if (x_strindex(temp, "inhibit") != 0) code = -code; if (code != 0 && res_array[k].value != 0 |