static void check_preselect(IxpServer *s) { USED(s); check_x_event(nil); }
int main(int argc, char *argv[]) { char *wmiirc; WMScreen *s; WinAttr wa; int i; fmtinstall('r', errfmt); fmtinstall('C', Cfmt); wmiirc = "wmiistartrc"; ARGBEGIN{ case 'v': print("%s", version); exit(0); case 'V': verbose = True; break; case 'a': address = EARGF(usage()); break; case 'r': wmiirc = EARGF(usage()); break; default: usage(); break; }ARGEND; if(argc) usage(); setlocale(LC_CTYPE, ""); starting = True; initdisplay(); xlib_errorhandler = XSetErrorHandler(errorhandler); check_other_wm = True; XSelectInput(display, scr.root.w, SubstructureRedirectMask | EnterWindowMask); XSync(display, False); check_other_wm = False; passwd = getpwuid(getuid()); user = estrdup(passwd->pw_name); init_environment(); sock = ixp_announce(address); if(sock < 0) fatal("Can't create socket '%s': %r", address); if(wmiirc) spawn_command(wmiirc); init_traps(); init_atoms(); init_cursors(); init_lock_keys(); srv.preselect = check_preselect; ixp_listen(&srv, sock, &p9srv, serve_9pcon, nil); ixp_listen(&srv, ConnectionNumber(display), nil, check_x_event, closedisplay); def.font = loadfont(FONT); def.border = 1; def.colmode = Coldefault; def.mod = Mod1Mask; strcpy(def.grabmod, "Mod1"); loadcolor(&def.focuscolor, FOCUSCOLORS); loadcolor(&def.normcolor, NORMCOLORS); num_screens = 1; screens = emallocz(num_screens * sizeof(*screens)); screen = &screens[0]; for(i = 0; i < num_screens; i++) { s = &screens[i]; init_screen(s); s->ibuf = allocimage(Dx(s->r), Dy(s->r), scr.depth); wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask; wa.cursor = cursor[CurNormal]; setwinattr(&scr.root, &wa, CWEventMask | CWCursor); initbar(s); } screen->focus = nil; setfocus(screen->barwin, RevertToParent); scan_wins(); starting = False; select_view("nil"); update_views(); write_event("FocusTag %s\n", screen->sel->name); check_x_event(nil); i = ixp_serverloop(&srv); if(i) fprint(2, "%s: error: %r\n", argv0); cleanup(); if(exitsignal) raise(exitsignal); if(execstr) execl("/bin/sh", "sh", "-c", execstr, nil); return i; }