static int cmdfd;
static pid_t pid;
static Selection sel;
-static int iofd = STDOUT_FILENO;
+static int iofd = 1;
static char **opt_cmd = NULL;
static char *opt_io = NULL;
static char *opt_title = NULL;
va_start(ap, errstr);
vfprintf(stderr, errstr, ap);
va_end(ap);
- exit(EXIT_FAILURE);
+ exit(1);
}
void
signal(SIGALRM, SIG_DFL);
execvp(prog, args);
- _exit(EXIT_FAILURE);
+ _exit(1);
}
void
sigchld(int a) {
- int stat, ret;
+ int stat;
pid_t p;
if((p = waitpid(pid, &stat, WNOHANG)) < 0)
if(pid != p)
return;
- ret = WIFEXITED(stat) ? WEXITSTATUS(stat) : EXIT_FAILURE;
- if (ret != EXIT_SUCCESS)
+ if (!WIFEXITED(stat) || WEXITSTATUS(stat))
die("child finished with error '%d'\n", stat);
- exit(EXIT_SUCCESS);
+ exit(0);
}
if(opt_io) {
term.mode |= MODE_PRINT;
iofd = (!strcmp(opt_io, "-")) ?
- STDOUT_FILENO :
- open(opt_io, O_WRONLY | O_CREAT, 0666);
+ 1 : open(opt_io, O_WRONLY | O_CREAT, 0666);
if(iofd < 0) {
fprintf(stderr, "Error opening %s:%s\n",
opt_io, strerror(errno));
if (opt_line) {
if((cmdfd = open(opt_line, O_RDWR)) < 0)
die("open line failed: %s\n", strerror(errno));
- close(STDIN_FILENO);
+ close(0);
dup(cmdfd);
stty();
return;
case 0:
close(iofd);
setsid(); /* create a new process group */
- dup2(s, STDIN_FILENO);
- dup2(s, STDOUT_FILENO);
- dup2(s, STDERR_FILENO);
+ dup2(s, 0);
+ dup2(s, 1);
+ dup2(s, 2);
if(ioctl(s, TIOCSCTTY, NULL) < 0)
die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
close(s);
void
xloadfonts(char *fontstr, double fontsize) {
FcPattern *pattern;
- FcResult r_sz, r_psz;
double fontval;
float ceilf(float);
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize);
usedfontsize = fontsize;
} else {
- r_psz = FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval);
- r_sz = FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval);
- if(r_psz == FcResultMatch) {
+ if(FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) ==
+ FcResultMatch) {
usedfontsize = fontval;
- } else if(r_sz == FcResultMatch) {
+ } else if(FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval) ==
+ FcResultMatch) {
usedfontsize = -1;
} else {
/*
xzoom(const Arg *arg) {
Arg larg;
- larg.i = usedfontsize + arg->i;
+ larg.f = usedfontsize + arg->f;
xzoomabs(&larg);
}
void
xzoomabs(const Arg *arg) {
xunloadfonts();
- xloadfonts(usedfont, arg->i);
+ xloadfonts(usedfont, arg->f);
cresize(0, 0);
redraw();
xhints();
Arg larg;
if(defaultfontsize > 0) {
- larg.i = defaultfontsize;
+ larg.f = defaultfontsize;
xzoomabs(&larg);
}
}
} else if(e->xclient.data.l[0] == xw.wmdeletewin) {
/* Send SIGHUP to shell */
kill(pid, SIGHUP);
- exit(EXIT_SUCCESS);
+ exit(0);
}
}
/* Waiting for window mapping */
do {
XNextEvent(xw.dpy, &ev);
+ /*
+ * XFilterEvent is required to be called after you using XOpenIM,
+ * this is not unnecessary.It does not only filter the key event,
+ * but some clientmessage for input method as well.
+ */
+ if(XFilterEvent(&ev, None))
+ continue;
if(ev.type == ConfigureNotify) {
w = ev.xconfigure.width;
h = ev.xconfigure.height;