static void setprops(Display *d, Window w) { long *l; if(!xlib) init(d); if(getprop_long(d, w, "_NET_WM_PID", "CARDINAL", 0L, &l, 1L)) free(l); else { changeprop_long(d, w, "_NET_WM_PID", "CARDINAL", &pid, 1); changeprop_string(d, w, "WM_CLIENT_MACHINE", hostname); } /* Kludge. */ if(starttime == 0) starttime = time(0); else if(time(0) > starttime + Timeout) return; if(transient) changeprop_long(d, w, "WM_TRANSIENT_FOR", "WINDOW", &transient, 1); if(ntypes) changeprop_long(d, w, "_NET_WM_WINDOW_TYPE", "ATOM", (long*)types, ntypes); if(tags) changeprop_textlist(d, w, "_WMII_TAGS", "UTF8_STRING", tags); if(stime) changeprop_long(d, w, "_WMII_LAUNCH_TIME", "CARDINAL", &stime, 1); }
void ewmh_init(void) { char myname[] = "wmii"; long win; ewmhwin = createwindow(&scr.root, Rect(0, 0, 1, 1), 0 /*depth*/, InputOnly, nil, 0); win = ewmhwin->xid; changeprop_long(&scr.root, Net("SUPPORTING_WM_CHECK"), "WINDOW", &win, 1); changeprop_long(ewmhwin, Net("SUPPORTING_WM_CHECK"), "WINDOW", &win, 1); changeprop_string(ewmhwin, Net("WM_NAME"), myname); changeprop_long(&scr.root, Net("DESKTOP_VIEWPORT"), "CARDINAL", (long[2]){0, 0}, 2);
void xdnd_initwindow(Window *w) { long l; l = 3; /* They are insane. Why is this an ATOM?! */ changeprop_long(w, "XdndAware", "ATOM", &l, 1); }
void ewmh_setstrut(Window *w, Rectangle struts[4]) { long strut[Last]; int i; strut[LeftMin] = struts[Left].min.y; strut[Left] = struts[Left].max.x; strut[LeftMax] = struts[Left].max.y; strut[RightMin] = struts[Right].min.y; strut[Right] = -struts[Right].min.x; strut[RightMax] = struts[Right].max.y; strut[TopMin] = struts[Top].min.x; strut[Top] = struts[Top].max.y; strut[TopMax] = struts[Top].max.x; strut[BottomMin] = struts[Bottom].min.x; strut[Bottom] = -struts[Bottom].min.y; strut[BottomMax] = struts[Bottom].max.x; for(i=0; i<Last; i++) if(strut[i] < 0) strut[i] = 0; changeprop_long(w, Net("WM_STRUT_PARTIAL"), "CARDINAL", strut, nelem(strut)); }
static void clientprop_long(Client *c, int cache, char *prop, char *type, long *data, int l) { if(l != c->proplen[cache] || memcmp(&c->propcache[cache], data, l * sizeof *data)) { c->proplen[cache] = l; memcpy(&c->propcache[cache], data, l * sizeof *data); changeprop_long(&c->w, prop, type, data, l); } }
void xtime_kludge(void) { Window *w; WinAttr wa; XEvent e; long l; w = createwindow(&scr.root, Rect(0, 0, 1, 1), 0, InputOnly, &wa, 0); XSelectInput(display, w->xid, PropertyChangeMask); changeprop_long(w, "ATOM", "ATOM", &l, 0); XIfEvent(display, &e, findtime, (void*)w); destroywindow(w); }
static void init_atoms(void) { Atom net[] = { xatom("_NET_SUPPORTED"), xatom("_NET_WM_NAME") }; changeprop_long(&scr.root, "_NET_SUPPORTED", "ATOM", (long*)net, nelem(net)); }