PrologNativeCode * PrologHttpServiceClass :: getNativeCode (char * name) { set_atoms (); if (strcmp (name, "webserver") == 0) return new webserver (this); if (strcmp (name, "daemon") == 0) return new webserver (this, true); if (strcmp (name, "fork") == 0) return new fork_code (this -> root); if (strcmp (name, "wait_for") == 0) return new wait_for_code (); if (strcmp (name, "http_request") == 0) return new http_request_code (this); return 0; }
int main(int argc, char **argv) { Display *dpy; XEvent e; XSetWindowAttributes wa; if(!(dpy = XOpenDisplay(NULL))) return 1; wa.cursor = XCreateFontCursor(dpy, XC_left_ptr); wa.event_mask = SubstructureNotifyMask|StructureNotifyMask; XChangeWindowAttributes(dpy, DefaultRootWindow(dpy) , CWEventMask|CWCursor, &wa); set_atoms(dpy); for(;;) { XNextEvent(dpy, &e); if(handler[e.type]) handler[e.type](dpy, &e); } }
/*! * \param[in,out] m Mapping structure. * \param[in] g Current index group. * \param[in] bMaskOnly true if the unused blocks should be masked with * -1 instead of removing them. * * Updates the index group mapping with the new index group \p g. * * \see gmx_ana_indexmap_t */ void gmx_ana_indexmap_update(gmx_ana_indexmap_t *m, gmx_ana_index_t *g, bool bMaskOnly) { int i, j, bi, bj; /* Process the simple cases first */ if (m->type == INDEX_UNKNOWN && m->b.nra == 0) { return; } if (m->type == INDEX_ALL) { set_atoms(m, g->isize, g->index); if (m->b.nr > 0) { m->mapb.index[1] = g->isize; } return; } /* Reset the reference IDs and mapping if necessary */ const bool bToFull = (g->isize == m->b.nra); const bool bWasFull = (m->mapb.nra == m->b.nra); if (bToFull || bMaskOnly) { if (!m->bStatic) { for (bj = 0; bj < m->b.nr; ++bj) { m->refid[bj] = bj; } } if (!bWasFull) { for (bj = 0; bj < m->b.nr; ++bj) { m->mapid[bj] = m->orgid[bj]; } for (bj = 0; bj <= m->b.nr; ++bj) { m->mapb.index[bj] = m->b.index[bj]; } } set_atoms(m, m->b.nra, m->b.a); m->mapb.nr = m->b.nr; } /* Exit immediately if the group is static */ if (bToFull) { m->bStatic = true; return; } if (bMaskOnly) { for (i = j = bj = 0; i < g->isize; ++i, ++j) { /* Find the next atom in the block */ while (m->b.a[j] != g->index[i]) { ++j; } /* Mark blocks that did not contain any atoms */ while (bj < m->b.nr && m->b.index[bj+1] <= j) { m->refid[bj++] = -1; } /* Advance the block index if we have reached the next block */ if (m->b.index[bj] <= j) { ++bj; } } /* Mark the last blocks as not accessible */ while (bj < m->b.nr) { m->refid[bj++] = -1; } } else { set_atoms(m, g->isize, g->index); for (i = j = bi = 0, bj = -1; i < g->isize; ++i) { /* Find the next atom in the block */ while (m->b.a[j] != g->index[i]) { ++j; } /* If we have reached a new block, add it */ if (m->b.index[bj+1] <= j) { /* Skip any blocks in between */ while (bj < m->b.nr && m->b.index[bj+1] <= j) { ++bj; } m->refid[bi] = bj; m->mapid[bi] = m->orgid[bj]; m->mapb.index[bi] = i; bi++; } } /* Update the number of blocks */ m->mapb.index[bi] = g->isize; m->mapb.nr = bi; } m->bStatic = false; }
int set_wm_state(client_t *c, unsigned long state) { return set_atoms(c->win, wm_state, wm_state, &state, 1); }
client_t *new_client(Window w) { client_t *c; XWindowAttributes attr; XColor exact; long supplied; Atom win_type; c = malloc(sizeof *c); c->next = head; head = c; c->name = get_wm_name(w); c->win = w; c->frame = None; c->size.flags = 0; c->ignore_unmap = 0; #ifdef SHAPE c->shaped = 0; #endif c->shaded = 0; c->zoomed = 0; c->decor = 1; XGetWMNormalHints(dpy, c->win, &c->size, &supplied); XGetTransientForHint(dpy, c->win, &c->trans); XGetWindowAttributes(dpy, c->win, &attr); c->geom.x = attr.x; c->geom.y = attr.y; c->geom.w = attr.width; c->geom.h = attr.height; c->cmap = attr.colormap; c->old_bw = attr.border_width; #ifdef DEBUG dump_name(c, "creating", 'w'); dump_geom(c, "initial"); #endif XAllocNamedColor(dpy, c->cmap, opt_fg, &fg, &exact); XAllocNamedColor(dpy, c->cmap, opt_bg, &bg, &exact); XAllocNamedColor(dpy, c->cmap, opt_bd, &bd, &exact); if (get_atoms(c->win, net_wm_wintype, XA_ATOM, 0, &win_type, 1, NULL)) c->decor = HAS_DECOR(win_type); if (get_atoms(c->win, net_wm_desk, XA_CARDINAL, 0, &c->desk, 1, NULL)) { if (c->desk == -1) c->desk = DESK_ALL; /* FIXME */ if (c->desk >= ndesks && c->desk != DESK_ALL) c->desk = cur_desk; } else { set_atoms(c->win, net_wm_desk, XA_CARDINAL, &cur_desk, 1); c->desk = cur_desk; } #ifdef DEBUG dump_info(c); #endif check_states(c); /* We are not actually keeping the stack one in order. However, every * fancy panel uses it and nothing else, no matter what the spec says. * (I'm not sure why, as rearranging the list every time the stacking * changes would be distracting. GNOME's window list applet doesn't.) */ append_atoms(root, net_client_list, XA_WINDOW, &c->win, 1); append_atoms(root, net_client_stack, XA_WINDOW, &c->win, 1); return c; }