#include "dat.h" #include "fn.h" Channel *drawc; Channel *keyc; void usage(void) { fprint(2, "usage: strans mapdir\n"); threadexitsall("usage"); } void die(char *fmt, ...) { va_list ap; fprint(2, "strans: "); va_start(ap, fmt); vfprint(2, fmt, ap); va_end(ap); fprint(2, "\n"); threadexitsall("die"); } void* emalloc(ulong n) { void *p; p = mallocz(n, 1); if(p == nil) die("out of memory"); return p; } void* erealloc(void *p, ulong n) { p = realloc(p, n); if(p == nil) die("out of memory"); return p; } void threadmain(int argc, char **argv) { char *display, *scale; if(argc != 2) usage(); /* Whichever popup runs is sized from it, and setfont reads Fontsz. */ scale = getenv("GDK_SCALE"); if(scale != nil && atoi(scale) > 1) popupscale = min(atoi(scale), 4); drawc = chancreate(sizeof(Drawcmd), 4); keyc = chancreate(sizeof(Keyreq), 0); langinit(argv[1]); composeinit(); srvinit(); proccreate(srvthread, nil, 16384); proccreate(ibusthread, nil, 32768); /* One popup per session: the Wayland frontend draws its own, so the * X11 one and the XIM it serves stand down. */ if(getenv("WAYLAND_DISPLAY") != nil && wlinit()) proccreate(wlthread, nil, 32768); else{ proccreate(drawthread, nil, 16384); display = getenv("DISPLAY"); if(display != nil && display[0] != '\0') proccreate(ximthread, nil, 32768); } imthread(nil); }