Both popups read it, each just before its own textinit, and the second copy needed a comment to say why it was there at all. One frontend runs per session and popupscale is one global, so threadmain reads it before it starts either -- which is before any setfont, the only ordering the two copies were keeping. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
78 lines
1.4 KiB
C
78 lines
1.4 KiB
C
#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);
|
|
}
|