static void CacheAtoms (vout_window_sys_t *p_sys) { xcb_connection_t *conn = p_sys->conn; xcb_intern_atom_cookie_t wm_state_ck, wm_state_above_ck, wm_state_below_ck, wm_state_fs_ck; wm_state_ck = intern_string (conn, "_NET_WM_STATE"); wm_state_above_ck = intern_string (conn, "_NET_WM_STATE_ABOVE"); wm_state_below_ck = intern_string (conn, "_NET_WM_STATE_BELOW"); wm_state_fs_ck = intern_string (conn, "_NET_WM_STATE_FULLSCREEN"); #ifdef MATCHBOX_HACK xcb_intern_atom_cookie_t mb_current_app_window; mb_current_app_window = xcb_intern_atom (conn, true, strlen ("_MB_CURRENT_APP_WINDOW"), "_MB_CURRENT_APP_WINDOW"); #endif p_sys->wm_state = get_atom (conn, wm_state_ck); p_sys->wm_state_above = get_atom (conn, wm_state_above_ck); p_sys->wm_state_below = get_atom (conn, wm_state_below_ck); p_sys->wm_state_fullscreen = get_atom (conn, wm_state_fs_ck); #ifdef MATCHBOX_HACK p_sys->mb_current_app_window = get_atom (conn, mb_current_app_window); #endif }
dispatcher::dispatcher( xcb_connection_t *c, const std::shared_ptr<keyboard> &k, const std::shared_ptr<mouse> &m ) : _connection( c ), _keyboard( k ), _mouse( m ) { precondition( _connection, "null connection" ); _atom_wm_protocols = get_atom( _connection, "WM_PROTOCOLS" ); _atom_delete_window = get_atom( _connection, "WM_DELETE_WINDOW" ); }
int ei_decode_ref(const char *buf, int *index, erlang_ref *p) { const char *s = buf + *index; const char *s0 = s; int count, i; switch (get8(s)) { case ERL_REFERENCE_EXT: /* nodename */ if (get_atom(&s, p->node, &p->node_org_enc) < 0) return -1; /* now the numbers: num (4), creation (1) */ if (p) { p->n[0] = get32be(s); p->len = 1; p->creation = get8(s) & 0x03; } else s += 5; *index += s-s0; return 0; break; case ERL_NEW_REFERENCE_EXT: /* first the integer count */ count = get16be(s); if (p) p->len = count; /* then the nodename */ if (get_atom(&s, p->node, &p->node_org_enc) < 0) return -1; /* creation */ if (p) { p->creation = get8(s) & 0x03; } else s += 1; /* finally the id integers */ if (p) { for (i = 0; (i<count) && (i<3); i++) { p->n[i] = get32be(s); } } else s += 4 * count; *index += s-s0; return 0; break; default: return -1; } }
static void set_net_wm_status(struct WM_t *W, struct wmclient *C) { Atom props[2]; props[0] = get_atom(W, "_NET_WM_STATE_MAXIMIZED_HORZ"); props[1] = get_atom(W, "_NET_WM_STATE_MAXIMIZED_VERT"); XChangeProperty(W->XDisplay, C->win, get_atom(W, "_NET_WM_STATE"), XA_ATOM, 32, PropModeReplace, (unsigned char *) props, C->fullscreen ? sizeof(props) / sizeof(Atom) : 0); }
void nif_write(couchfile_modify_request *rq, couchfile_pointer_info *dst, nif_writerq* wrq, ssize_t size) { dst->writerq_resource = wrq; dst->pointer = 0; wrq->ptr = dst; ErlNifEnv* msg_env = enif_alloc_env(); ERL_NIF_TERM msg_term = enif_make_tuple4(msg_env, get_atom(msg_env, "append_bin_btnif"), get_atom(msg_env, "snappy"), //COMPRESSION TYPE enif_make_resource(msg_env, wrq), enif_make_resource_binary(msg_env, wrq, &wrq->buf, size)); enif_send(rq->caller_env, &rq->writer, msg_env, msg_term); enif_free_env(msg_env); enif_release_resource(wrq); }
static void CacheAtoms (vout_window_sys_t *p_sys) { xcb_connection_t *conn = p_sys->conn; xcb_intern_atom_cookie_t wm_state_ck, wm_state_above_ck, wm_state_below_ck, wm_state_fs_ck; wm_state_ck = intern_string (conn, "_NET_WM_STATE"); wm_state_above_ck = intern_string (conn, "_NET_WM_STATE_ABOVE"); wm_state_below_ck = intern_string (conn, "_NET_WM_STATE_BELOW"); wm_state_fs_ck = intern_string (conn, "_NET_WM_STATE_FULLSCREEN"); p_sys->wm_state = get_atom (conn, wm_state_ck); p_sys->wm_state_above = get_atom (conn, wm_state_above_ck); p_sys->wm_state_below = get_atom (conn, wm_state_below_ck); p_sys->wm_state_fullscreen = get_atom (conn, wm_state_fs_ck); }
/** * @brief Initialize X atoms. */ void wm_get_atoms(session_t *ps) { #define T_GETATOM(name) name = get_atom(ps, # name) XA_WM_STATE = get_atom(ps, "WM_STATE"); T_GETATOM(WM_CLIENT_LEADER); XA_UTF8_STRING = get_atom(ps, "UTF8_STRING"); T_GETATOM(_XROOTPMAP_ID); T_GETATOM(ESETROOT_PMAP_ID); T_GETATOM(WM_PROTOCOLS), T_GETATOM(WM_DELETE_WINDOW), T_GETATOM(_NET_SUPPORTING_WM_CHECK); T_GETATOM(_NET_SUPPORTED); T_GETATOM(_NET_NUMBER_OF_DESKTOPS); T_GETATOM(_NET_CLIENT_LIST); T_GETATOM(_NET_CLIENT_LIST_STACKING); T_GETATOM(_NET_CURRENT_DESKTOP); T_GETATOM(_NET_WM_DESKTOP); T_GETATOM(_NET_WM_STATE); T_GETATOM(_NET_WM_STATE_HIDDEN); T_GETATOM(_NET_WM_STATE_SKIP_TASKBAR); T_GETATOM(_NET_WM_STATE_SKIP_PAGER); T_GETATOM(_NET_WM_STATE_FULLSCREEN); T_GETATOM(_NET_WM_STATE_ABOVE); T_GETATOM(_NET_WM_STATE_STICKY); T_GETATOM(_NET_WM_WINDOW_TYPE); T_GETATOM(_NET_WM_WINDOW_TYPE_DESKTOP); T_GETATOM(_NET_WM_WINDOW_TYPE_DOCK); T_GETATOM(_NET_WM_WINDOW_TYPE_NORMAL); T_GETATOM(_NET_WM_WINDOW_TYPE_TOOLTIP); T_GETATOM(_NET_WM_VISIBLE_NAME); T_GETATOM(_NET_WM_NAME); T_GETATOM(_NET_CLOSE_WINDOW); T_GETATOM(_NET_WM_STATE_SHADED); T_GETATOM(_WIN_SUPPORTING_WM_CHECK); T_GETATOM(_WIN_WORKSPACE); T_GETATOM(_WIN_WORKSPACE_COUNT); T_GETATOM(_WIN_PROTOCOLS); T_GETATOM(_WIN_CLIENT_LIST); T_GETATOM(_WIN_STATE); T_GETATOM(_WIN_HINTS); #undef T_GETATOM }
int main(void) { xcb_connection_t *dpy = xcb_connect(NULL, NULL); if (dpy == NULL) { fprintf(stderr, "Can't connect to X.\n"); return EXIT_FAILURE; } xcb_atom_t WM_PROTOCOLS, WM_DELETE_WINDOW; if (!get_atom(dpy, "WM_PROTOCOLS", &WM_PROTOCOLS) || !get_atom(dpy, "WM_DELETE_WINDOW", &WM_DELETE_WINDOW)) { fprintf(stderr, "Can't get required atoms.\n"); xcb_disconnect(dpy); return EXIT_FAILURE; } xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(dpy)).data; if (screen == NULL) { fprintf(stderr, "Can't get current screen.\n"); xcb_disconnect(dpy); return EXIT_FAILURE; } xcb_window_t win = xcb_generate_id(dpy); uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; uint32_t values[] = {0xff111111, XCB_EVENT_MASK_EXPOSURE}; xcb_create_window(dpy, XCB_COPY_FROM_PARENT, win, screen->root, 0, 0, 320, 240, 2, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, mask, values); xcb_icccm_set_wm_class(dpy, win, sizeof(TEST_WINDOW_IC), TEST_WINDOW_IC); xcb_map_window(dpy, win); xcb_flush(dpy); xcb_generic_event_t *evt; bool running = true; while (running && (evt = xcb_wait_for_event(dpy)) != NULL) { uint8_t rt = XCB_EVENT_RESPONSE_TYPE(evt); if (rt == XCB_CLIENT_MESSAGE) { xcb_client_message_event_t *cme = (xcb_client_message_event_t *) evt; if (cme->type == WM_PROTOCOLS && cme->data.data32[0] == WM_DELETE_WINDOW) { running = false; } } else if (rt == XCB_EXPOSE) { render_text(dpy, win, 12, 24); } free(evt); } xcb_destroy_window(dpy, win); xcb_disconnect(dpy); return EXIT_SUCCESS; }
/* Print at the end of $line $n property $val:ues of type $t. */ static void fmtprop(Display *dpy, Atom t, unsigned n, void const *val, GString *line) { unsigned i; if (t == XA_STRING || t == XA_utf8_string) { char const *str; g_string_append_c(line, '"'); for (str = (char *)val; n > 0; str++, n--) { if (*str == '\0') g_string_append(line, "\",\""); else if (*str == '"') g_string_append(line, "\\\""); else // This is not UTF-safe. g_string_append_c(line, *str); } g_string_append_c(line, '"'); return; } if (n == 0) { g_string_append(line, "<empty>"); return; } else if (t == XA_wm_state) { fmtwmstate(dpy, *(CARD32 *)val, line); return; } if (n > 1) g_string_append_c(line, '['); for (i = 0; ;) { if (t == XA_ATOM) g_string_append(line, get_atom(dpy, ((Atom *)val)[i])); else if (t == XA_WINDOW) g_string_append_printf(line, "0x%lx", ((Window *)val)[i]); else if (t == XA_INTEGER) g_string_append_printf(line, "%d", ((int *)val)[i]); else if (t == XA_CARDINAL) g_string_append_printf(line, "%u", ((unsigned *)val)[i]); if (++i >= n) break; g_string_append(line, ", "); } if (n > 1) g_string_append_c(line, ']'); } /* fmtprop */
void switch_to_desktop(int desktop) { xcb_atom_t atom = get_atom("_NET_CURRENT_DESKTOP"); uint32_t data[5] = {desktop, 0, 0, 0, 0}; send_client_message(scrn->root, scrn->root, atom, data); xcb_flush(conn); }
void focus_window(xcb_window_t window) { xcb_atom_t atom = get_atom("_NET_ACTIVE_WINDOW"); uint32_t data[5] = {2, 0, 0, 0, 0}; send_client_message(scrn->root, window, atom, data); xcb_flush(conn); }
void set_group(char *grp, xcb_window_t wid) { xcb_atom_t atom = get_atom(); xcb_void_cookie_t cookie; cookie = xcb_change_property_checked(conn, XCB_PROP_MODE_REPLACE, wid, atom, XCB_ATOM_STRING, 8, strlen(grp), grp); xcb_generic_error_t *error; if ((error = xcb_request_check(conn, cookie))) { fprintf(stderr, "unable to set group\n"); free(error); } }
void AtomsX11::set_netwm_single_state( ::Window p_window, String p_name,bool p_state) { XClientMessageEvent clientmsg; memset(&clientmsg, 0, sizeof (clientmsg)); clientmsg.type=ClientMessage; clientmsg.serial=0; clientmsg.display=x11_display; clientmsg.window=p_window; clientmsg.message_type=get_atom("_NET_WM_STATE"); clientmsg.format=32; clientmsg.data.l[0]=p_state?get_atom("_NET_WM_STATE_ADD"):get_atom("_NET_WM_STATE_REMOVE"); clientmsg.data.l[1]=get_atom(p_name); clientmsg.data.l[2]=0; XSendEvent(x11_display, DefaultRootWindow(x11_display), false,SubstructureRedirectMask | SubstructureNotifyMask,(XEvent*)&clientmsg); }
WORD KlwGetSlotBinding(char *slot, ATOMID *idName, LPEXP lpExp, SLOTID *idSlot) { char *sname = strtok(slot, ":"); char *next = strtok(NULL, ":"); BOOL bMulti = FALSE; *idName = get_atom(sname); if (!*idName) return GV_NOTATOM; while (sname = next) { OBJECTID idObj = KppGetItemFromName(OBJCLA, *idName, NULL); WORD wType = OBJECT_TYPE(idObj); if (!idObj) return GV_NOTOBJECT; *idName = get_atom(sname); if (!*idName) return GV_NOTATOM; *idName = get_value(wType, idObj, *idName, &bMulti, idSlot); if (!*idName) return GV_NOTSLOT; next[-1] = ':'; next = strtok(NULL, ":"); if (next && bMulti) return GV_NOTSINGLE; } EXPFLAGS(lpExp) = bMulti ? EXPLIST : EXPATOM; CAR(lpExp) = *idName; return 0; }
static int init_wm() { struct sigaction act; sigemptyset(&act.sa_mask); act.sa_flags = 0; act.sa_handler = &handle_signal; sigaction(SIGCHLD, &act, 0); /* alloc workspaces */ nil_.ws = malloc(sizeof(struct workspace_t) * cfg_.num_workspaces); if (!nil_.ws) { NIL_ERR("out of mem %d", cfg_.num_workspaces); return -1; } memset(nil_.ws, 0, sizeof(struct workspace_t) * cfg_.num_workspaces); for (nil_.ws_idx = cfg_.num_workspaces - 1; ; --nil_.ws_idx) { nil_.ws[nil_.ws_idx].master_size = cfg_.master_size; if (nil_.ws_idx == 0) { break; } } /* workspace area (top) */ nil_.x = 0; nil_.y = 0; nil_.w = nil_.scr->width_in_pixels; nil_.h = nil_.scr->height_in_pixels - bar_.h; NIL_LOG("workspace %d,%d %ux%u", nil_.x, nil_.y, nil_.w, nil_.h); /* init atoms */ nil_.atom.net_supported = get_atom("_NET_SUPPORTED"); nil_.atom.net_wm_name = get_atom("_NET_WM_NAME"); nil_.atom.wm_protocols = get_atom("WM_PROTOCOLS"); nil_.atom.wm_delete = get_atom("WM_DELETE_WINDOW"); nil_.atom.wm_state = get_atom("WM_STATE"); return 0; }
long get_protein(atom* atm, FILE* file) { char* line = malloc(LINELEN * sizeof(char) + 1); long result, linenum; atom* atmc = atm; atom* atmn; if((result = find_atom_section(file)) == -1) return(-1); else linenum = result + 1; fgets(line, LINELEN, file); if((result = get_atom(atm, line)) == 2) return(linenum); while(fgets(line, LINELEN, file) != NULL) { linenum++; atmn = malloc(sizeof(atom)); if((result = get_atom(atmn, line)) == 2) return(linenum); else if(result == 0) { atmc->next = atmn; atmc = atmn; } } return(0); }
IMPATOM_BEGIN_NAMESPACE HelixRestraint::HelixRestraint(Residues rs, bool ideal) : Restraint(rs[0]->get_model(), "HelixRestraint%1%") { //dihedral info //Float dih1,std1,dih2,std2,distON,kON; Float dih1 = -1.117010721276371; //mean = -64deg, std = 6deg Float std1 = 0.10471975511965977; Float dih2 = -0.715584993317675; //mean = -41deg, std = 8deg Float std2 = 0.13962634015954636; Float corr = -0.25; Float weight = 0.5; core::BinormalTerm bt; bt.set_means(std::make_pair(dih1,dih2)); bt.set_standard_deviations(std::make_pair(std1,std2)); bt.set_correlation(corr); bt.set_weight(weight); //bond info Float distON = 2.96; Float kON = core::Harmonic::get_k_from_standard_deviation(0.11); //will expand to more bonds and residue types bond_ON_score_ = new core::HarmonicDistancePairScore(distON,kON); if (rs.size()>=3){ for(size_t nr=0;nr<rs.size()-2;nr++){ core::XYZ a1(get_atom(rs[nr],AT_C)); core::XYZ a2(get_atom(rs[nr+1],AT_N)); core::XYZ a3(get_atom(rs[nr+1],AT_CA)); core::XYZ a4(get_atom(rs[nr+1],AT_C)); core::XYZ a5(get_atom(rs[nr+2],AT_N)); IMP_NEW(core::MultipleBinormalRestraint, mbr,(get_model(), ParticleIndexQuad(a1,a2,a3,a4), ParticleIndexQuad(a2,a3,a4,a5))); mbr->add_term(bt); dihedral_rs_.push_back(mbr); } } if (rs.size()>=5){ for(size_t nr=0;nr<rs.size()-4;nr++){ bonds_ON_.push_back(ParticleIndexPair( get_atom(rs[nr],AT_O).get_particle_index(), get_atom(rs[nr+4],AT_N).get_particle_index())); } } }
void AtomsX11::request_active_window( ::Window p_current, ::Window p_next,unsigned long p_timestamp ) { XClientMessageEvent clientmsg; memset(&clientmsg, 0, sizeof (clientmsg)); clientmsg.type=ClientMessage; clientmsg.serial=0; clientmsg.display=x11_display; clientmsg.window=p_next; clientmsg.message_type=get_atom("_NET_ACTIVE_WINDOW"); clientmsg.format=32; clientmsg.data.l[0]=1; clientmsg.data.l[1]=p_timestamp; clientmsg.data.l[2]=p_current; XSendEvent(x11_display, DefaultRootWindow(x11_display), false,SubstructureRedirectMask | SubstructureNotifyMask,(XEvent*)&clientmsg); }
int desktop_of_window(xcb_window_t w) { xcb_get_property_cookie_t c; xcb_get_property_reply_t *r; int desktop = 0; xcb_atom_t atom = get_atom("_NET_WM_DESKTOP"); c = xcb_get_property(conn, 0, w, atom, XCB_ATOM_CARDINAL, 0, 1); r = xcb_get_property_reply(conn, c, NULL); if (r) { desktop = *((int *) xcb_get_property_value(r)); } free(r); return desktop; }
int client_list(xcb_window_t w, xcb_window_t **windows) { xcb_get_property_cookie_t c; xcb_get_property_reply_t *r; int wn = 0; xcb_atom_t atom = get_atom("_NET_CLIENT_LIST"); c = xcb_get_property(conn, 0, w, atom, XCB_ATOM_WINDOW, 0L, 32L); r = xcb_get_property_reply(conn, c, NULL); if (r) { *windows = malloc(sizeof(xcb_window_t) * r->length); memcpy(*windows, xcb_get_property_value(r), sizeof(xcb_window_t) * r->length); wn = r->length; } free(r); return wn; }
int ei_decode_port(const char *buf, int *index, erlang_port *p) { const char *s = buf + *index; const char *s0 = s; if (get8(s) != ERL_PORT_EXT) return -1; /* first the nodename */ if (get_atom(&s, p->node, &p->node_org_enc) < 0) return -1; /* now the numbers: num (4), creation (1) */ if (p) { p->id = get32be(s) & 0x0fffffff /* 28 bits */; p->creation = get8(s) & 0x03; } else s += 5; *index += s-s0; return 0; }
/* Print an XPropertyEvent into $line. If it's changed try to print * the new value as well. */ static void property_event(Display *dpy, XPropertyEvent const *ev, GString *line) { char *name; Atom t; int fmt; unsigned long n, b; unsigned char *val; fmtxid(line, ev->window); name = get_atom(dpy, ev->atom); if (ev->state == PropertyDelete) { g_string_append_printf(line, "%s deleted", name); goto out0; } else if (XGetWindowProperty(dpy, ev->window, ev->atom, 0, ~0, False, AnyPropertyType, &t, &fmt, &n, &b, &val) != Success) { /* Couldn't get the new value, it could be already deleted. */ g_string_append_printf(line, "%s changed", name); goto out0; } else if ((t != XA_ATOM && t != XA_WINDOW && t != XA_INTEGER && t != XA_CARDINAL && t != XA_STRING && t != XA_utf8_string && t != XA_wm_state)) { /* We don't know this type. */ g_string_append_printf(line, "%s changed", name); goto out1; } /* Print the new value. */ g_string_append(line, name); g_string_append_c(line, '='); fmtprop(dpy, t, n, val, line); out1: XFree(val); out0: output(line, ev->send_event); } /* property_event */
void get_it(const char *valoare) { get_atom(); if ( strcmp(atom.nume,valoare) != 0) eroare("valoarea asteptata nu a fost gasita"); }
/* Constructs the GL shapes of the current molecule */ static void build_molecule (ModeInfo *mi) { molecule_configuration *mc = &mcs[MI_SCREEN(mi)]; int wire = cur_wire; int i; molecule *m = &mc->molecules[mc->which]; if (wire) { glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); glDisable(GL_DEPTH_TEST); glDisable(GL_NORMALIZE); glDisable(GL_CULL_FACE); } else { glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glEnable(GL_CULL_FACE); } if (!wire) set_atom_color (mi, 0, False); if (do_bonds) for (i = 0; i < m->nbonds; i++) { molecule_bond *b = &m->bonds[i]; molecule_atom *from = get_atom(m->atoms, m->natoms, b->from, MI_IS_VERBOSE(mi)); molecule_atom *to = get_atom(m->atoms, m->natoms, b->to, MI_IS_VERBOSE(mi)); if (wire) { glBegin(GL_LINES); glVertex3f(from->x, from->y, from->z); glVertex3f(to->x, to->y, to->z); glEnd(); } else { int faces = (scale_down ? TUBE_FACES_2 : TUBE_FACES); # ifdef SMOOTH_TUBE int smooth = True; # else int smooth = False; # endif GLfloat thickness = 0.07 * b->strength; GLfloat cap_size = 0.03; if (thickness > 0.3) thickness = 0.3; tube (from->x, from->y, from->z, to->x, to->y, to->z, thickness, cap_size, faces, smooth, !do_atoms, wire); } } for (i = 0; i < m->natoms; i++) { molecule_atom *a = &m->atoms[i]; int i; if (!wire && do_atoms) { GLfloat size = atom_size (a); set_atom_color (mi, a, False); sphere (a->x, a->y, a->z, size, wire); } if (do_labels) { glPushAttrib (GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT); glDisable (GL_LIGHTING); glDisable (GL_DEPTH_TEST); if (!wire) set_atom_color (mi, a, True); glRasterPos3f (a->x, a->y, a->z); { GLdouble mm[17], pm[17]; GLint vp[5]; GLdouble wx=-1, wy=-1, wz=-1; glGetDoublev (GL_MODELVIEW_MATRIX, mm); glGetDoublev (GL_PROJECTION_MATRIX, pm); glGetIntegerv (GL_VIEWPORT, vp); /* Convert 3D coordinates to window coordinates */ gluProject (a->x, a->y, a->z, mm, pm, vp, &wx, &wy, &wz); /* Fudge the window coordinates to center the string */ wx -= string_width (mc->xfont1, a->label) / 2; wy -= mc->xfont1->descent; /* Convert new window coordinates back to 3D coordinates */ gluUnProject (wx, wy, wz, mm, pm, vp, &wx, &wy, &wz); glRasterPos3f (wx, wy, wz); } for (i = 0; i < (int) strlen(a->label); i++) glCallList (mc->font1_dlist + (int)(a->label[i])); glPopAttrib(); } } if (do_bbox) draw_bounding_box (mi); if (do_titles && m->label && *m->label) print_title_string (mi, m->label, 10, MI_HEIGHT(mi) - 10, mc->xfont2->ascent + mc->xfont2->descent); }
/* Print an XClientMessageEvent. Decode the parameters if we know the * message type. */ static void client_message(Display *dpy, XClientMessageEvent const *msg, GString *line) { char *msgtype; unsigned n, i; fmtxid(line, msg->window); msgtype = get_atom(dpy, msg->message_type); g_string_append(line, msgtype); /* Decode the parameters if we know the message type. */ i = 0; g_string_append_c(line, '('); if (!strcmp(msgtype, "_NET_WM_STATE") && msg->format == 32) { static char const *actions[] = { "Remove", "Add", "Toggle" }; long const *args = msg->data.l; long action; action = args[i++]; if (0 <= action && action < G_N_ELEMENTS(actions)) g_string_append_printf(line, "%s, ", actions[action]); else g_string_append_printf(line, "%ld, ", action); g_string_append_printf(line, "%s, ", get_atom(dpy, args[i++])); g_string_append_printf(line, "%s, ", get_atom(dpy, args[i++])); } else if (!strcmp(msgtype, "WM_PROTOCOLS") && msg->format == 32) { char const *action; long const *args = msg->data.l; action = get_atom(dpy, args[i++]); g_string_append_printf(line, "%s, %ld, ", action, args[i++]); if (!strcmp(action, "_NET_WM_PING")) g_string_append(line, "win="); } else if (!strcmp(msgtype, "WM_CHANGE_STATE") && msg->format == 32) { long const *args = msg->data.l; fmtwmstate(dpy, args[i++], line); g_string_append(line, ", "); } else if (!strcmp(msgtype, "_NET_ACTIVE_WINDOW") && msg->format == 32) { static char const *sources[] = { "OldClient", "App", "Pager" }; long const *args = msg->data.l; long source; source = args[i++]; if (0 <= source && source < G_N_ELEMENTS(sources)) g_string_append_printf(line, "ReqBy%s, ", sources[source]); else g_string_append_printf(line, "%ld, ", source); g_string_append_printf(line, "%ld, requestor=", args[i++]); } /* if */ /* Just dump the rest of the parameters. */ switch (msg->format) { case 8: n = G_N_ELEMENTS(msg->data.b); for (; i < n; i++) g_string_append_printf(line, i+1 < n ? "0x%x, " : "0x%x", msg->data.b[i]); break; case 16: n = G_N_ELEMENTS(msg->data.s); for (; i < n; i++) g_string_append_printf(line, i+1 < n ? "0x%x, " : "0x%x", msg->data.s[i]); break; case 32: n = G_N_ELEMENTS(msg->data.l); for (; i < n; i++) g_string_append_printf(line, i+1 < n ? "0x%lx, " : "0x%lx", msg->data.l[i]); break; } /* switch */ g_string_append_c(line, ')'); output(line, False); } /* client_message */
/* Constructs the GL shapes of the current molecule */ static void build_molecule (ModeInfo *mi, Bool transparent_p) { molecule_configuration *mc = &mcs[MI_SCREEN(mi)]; int wire = MI_IS_WIREFRAME(mi); int i; GLfloat alpha = transparent_p ? shell_alpha : 1.0; int polys = 0; molecule *m = &mc->molecules[mc->which]; if (wire) { glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); glDisable(GL_DEPTH_TEST); glDisable(GL_NORMALIZE); glDisable(GL_CULL_FACE); } else { glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glEnable(GL_CULL_FACE); } if (!wire) set_atom_color (mi, 0, False, alpha); if (do_bonds) for (i = 0; i < m->nbonds; i++) { const molecule_bond *b = &m->bonds[i]; const molecule_atom *from = get_atom (m->atoms, m->natoms, b->from); const molecule_atom *to = get_atom (m->atoms, m->natoms, b->to); if (wire) { glBegin(GL_LINES); glVertex3f(from->x, from->y, from->z); glVertex3f(to->x, to->y, to->z); glEnd(); polys++; } else { int faces = (mc->scale_down ? TUBE_FACES_2 : TUBE_FACES); # ifdef SMOOTH_TUBE int smooth = True; # else int smooth = False; # endif GLfloat thickness = 0.07 * b->strength; GLfloat cap_size = 0.03; if (thickness > 0.3) thickness = 0.3; polys += tube (from->x, from->y, from->z, to->x, to->y, to->z, thickness, cap_size, faces, smooth, (!do_atoms || do_shells), wire); } } if (!wire && do_atoms) for (i = 0; i < m->natoms; i++) { const molecule_atom *a = &m->atoms[i]; GLfloat size = atom_size (a); set_atom_color (mi, a, False, alpha); polys += sphere (mc, a->x, a->y, a->z, size, wire); } if (do_bbox && !transparent_p) { draw_bounding_box (mi); polys += 4; } mc->polygon_count += polys; }
int ei_decode_ei_term(const char* buf, int* index, ei_term* term) { const char* s = buf + *index, * s0 = s; int i, n, sign; char c; if (term == NULL) return -1; c = term->ei_type = get8(s); switch (c) { case ERL_SMALL_INTEGER_EXT: term->value.i_val = get8(s); break; case ERL_INTEGER_EXT: term->value.i_val = get32be(s); break; case ERL_FLOAT_EXT: case NEW_FLOAT_EXT: return ei_decode_double(buf, index, &term->value.d_val); case ERL_ATOM_EXT: case ERL_ATOM_UTF8_EXT: case ERL_SMALL_ATOM_EXT: case ERL_SMALL_ATOM_UTF8_EXT: return ei_decode_atom(buf, index, term->value.atom_name); case ERL_REFERENCE_EXT: /* first the nodename */ if (get_atom(&s, term->value.ref.node, &term->value.ref.node_org_enc) < 0) return -1; /* now the numbers: num (4), creation (1) */ term->value.ref.n[0] = get32be(s); term->value.ref.len = 1; term->value.ref.creation = get8(s) & 0x03; break; case ERL_NEW_REFERENCE_EXT: /* first the integer count */ term->value.ref.len = get16be(s); /* then the nodename */ if (get_atom(&s, term->value.ref.node, &term->value.ref.node_org_enc) < 0) return -1; /* creation */ term->value.ref.creation = get8(s) & 0x03; /* finally the id integers */ for (i = 0; (i<term->value.ref.len) && (i<3); i++) { term->value.ref.n[i] = get32be(s); } if (term->value.ref.len > 3) { s += 4 * (term->value.ref.len - 3); } break; case ERL_PORT_EXT: if (get_atom(&s, term->value.port.node, &term->value.port.node_org_enc) < 0) return -1; term->value.port.id = get32be(s) & 0x0fffffff; /* 28 bits */; term->value.port.creation = get8(s) & 0x03; break; case ERL_PID_EXT: if (get_atom(&s, term->value.pid.node, &term->value.port.node_org_enc) < 0) return -1; /* now the numbers: num (4), serial (4), creation (1) */ term->value.pid.num = get32be(s) & 0x7fff; /* 15 bits */ term->value.pid.serial = get32be(s) & 0x1fff; /* 13 bits */ term->value.pid.creation = get8(s) & 0x03; /* 2 bits */ break; case ERL_SMALL_TUPLE_EXT: term->arity = get8(s); break; case ERL_LARGE_TUPLE_EXT: term->arity = get32be(s); break; case ERL_NIL_EXT: term->arity = 0; break; case ERL_STRING_EXT: term->size = get16be(s); return 0; case ERL_LIST_EXT: term->arity = get32be(s); break; case ERL_BINARY_EXT: term->size = get32be(s); return 0; case ERL_SMALL_BIG_EXT: if ((term->arity = get8(s)) != 4) return -1; sign = get8(s); /* Little Endian, and n always positive, except for LONG_MIN */ n = get32le(s); if (sign) { /* check for overflow */ if ((n - 1) < 0) return -1; n = -n; } else { /* check for overflow */ if (n < 0) return -1; } break; case ERL_LARGE_BIG_EXT: return 0; case ERL_PASS_THROUGH: return 0; case ERL_NEW_CACHE: return -1; case ERL_CACHED_ATOM: return -1; default: return -1; } *index += s-s0; return 1; }
/** * Create an X11 window. */ static int Open (vout_window_t *wnd, const vout_window_cfg_t *cfg) { xcb_generic_error_t *err; xcb_void_cookie_t ck; vout_window_sys_t *p_sys = malloc (sizeof (*p_sys)); if (p_sys == NULL) return VLC_ENOMEM; p_sys->embedded = false; /* Connect to X */ char *display = var_InheritString (wnd, "x11-display"); int snum; xcb_connection_t *conn = xcb_connect (display, &snum); if (xcb_connection_has_error (conn) /*== NULL*/) goto error; /* Find configured screen */ const xcb_setup_t *setup = xcb_get_setup (conn); const xcb_screen_t *scr = NULL; for (xcb_screen_iterator_t i = xcb_setup_roots_iterator (setup); i.rem > 0; xcb_screen_next (&i)) { if (snum == 0) { scr = i.data; break; } snum--; } if (scr == NULL) { msg_Err (wnd, "bad X11 screen number"); goto error; } /* Create window */ const uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; uint32_t values[2] = { /* XCB_CW_BACK_PIXEL */ scr->black_pixel, /* XCB_CW_EVENT_MASK */ XCB_EVENT_MASK_KEY_PRESS, }; xcb_window_t window = xcb_generate_id (conn); ck = xcb_create_window_checked (conn, scr->root_depth, window, scr->root, cfg->x, cfg->y, cfg->width, cfg->height, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, scr->root_visual, mask, values); err = xcb_request_check (conn, ck); if (err) { msg_Err (wnd, "creating window: X11 error %d", err->error_code); free (err); goto error; } wnd->handle.xid = window; wnd->display.x11 = display; wnd->control = Control; wnd->sys = p_sys; p_sys->conn = conn; if (var_InheritBool (wnd, "keyboard-events")) p_sys->keys = CreateKeyHandler (VLC_OBJECT(wnd), conn); else p_sys->keys = NULL; p_sys->root = scr->root; /* ICCCM * No cut&paste nor drag&drop, only Window Manager communication. */ set_ascii_prop (conn, window, XA_WM_NAME, /* xgettext: This is a plain ASCII spelling of "VLC media player" for the ICCCM window name. This must be pure ASCII. The limitation is partially with ICCCM and partially with VLC. For Latin script languages, you may need to strip accents. For other scripts, you will need to transliterate into Latin. */ vlc_pgettext ("ASCII", "VLC media player")); set_ascii_prop (conn, window, XA_WM_ICON_NAME, /* xgettext: This is a plain ASCII spelling of "VLC" for the ICCCM window name. This must be pure ASCII. */ vlc_pgettext ("ASCII", "VLC")); set_wm_hints (conn, window); xcb_change_property (conn, XCB_PROP_MODE_REPLACE, window, XA_WM_CLASS, XA_STRING, 8, 8, "vlc\0Vlc"); set_hostname_prop (conn, window); /* EWMH */ xcb_intern_atom_cookie_t utf8_string_ck = intern_string (conn, "UTF8_STRING");; xcb_intern_atom_cookie_t net_wm_name_ck = intern_string (conn, "_NET_WM_NAME"); xcb_intern_atom_cookie_t net_wm_icon_name_ck = intern_string (conn, "_NET_WM_ICON_NAME"); xcb_intern_atom_cookie_t wm_window_role_ck = intern_string (conn, "WM_WINDOW_ROLE"); xcb_atom_t utf8 = get_atom (conn, utf8_string_ck); xcb_atom_t net_wm_name = get_atom (conn, net_wm_name_ck); char *title = var_InheritString (wnd, "video-title"); if (title) { set_string (conn, window, utf8, net_wm_name, title); free (title); } else set_string (conn, window, utf8, net_wm_name, _("VLC media player")); xcb_atom_t net_wm_icon_name = get_atom (conn, net_wm_icon_name_ck); set_string (conn, window, utf8, net_wm_icon_name, _("VLC")); xcb_atom_t wm_window_role = get_atom (conn, wm_window_role_ck); set_ascii_prop (conn, window, wm_window_role, "vlc-video"); /* Cache any EWMH atom we may need later */ CacheAtoms (p_sys); /* Make the window visible */ xcb_map_window (conn, window); if (var_InheritBool (wnd, "video-wallpaper")) { vout_window_SetState (wnd, VOUT_WINDOW_STATE_BELOW); vout_window_SetFullScreen (wnd, true); } /* Create the event thread. It will dequeue all events, so any checked * request from this thread must be completed at this point. */ if ((p_sys->keys != NULL) && vlc_clone (&p_sys->thread, Thread, wnd, VLC_THREAD_PRIORITY_LOW)) DestroyKeyHandler (p_sys->keys); xcb_flush (conn); /* Make sure map_window is sent (should be useless) */ return VLC_SUCCESS; error: xcb_disconnect (conn); free (display); free (p_sys); return VLC_EGENERIC; }
std::vector<value> parse(Range &r, parse_flag_t flags, unsigned n = ~0) { std::vector<value> ret; for(; n != 0; --n) { type_t const t = get_type(r); switch(t) { case SMALL_INTEGER_EXT: ret.push_back(value(t, get_small_integer(r))); break; case INTEGER_EXT: ret.push_back(value(t, get_integer(r))); break; case FLOAT_EXT: ret.push_back(value(t, get_float(r))); break; case ATOM_EXT: ret.push_back(value(t, get_atom(r))); break; case SMALL_TUPLE_EXT: { if(flags & parse_complex) { // TODO } byte_t const size = get_small_tuple_size(r); ret.push_back(value(t, parse(r, flags, size))); } break; case LARGE_TUPLE_EXT: { if(flags & parse_complex) { // TODO } boost::uint32_t const size = get_large_tuple_size(r); ret.push_back(value(t, parse(r, flags, size))); } break; case NIL_EXT: ret.push_back(value()); break; case STRING_EXT: ret.push_back(value(t, get_string(r))); break; case LIST_EXT: { // TODO handle Tail! boost::uint32_t const size = get_list_size(r); /* not optimal: collecting into a vector and then constructing a list from that */ std::vector<value> tmp = parse(r, flags, size); ret.push_back(value(t, std::list<value>(tmp.begin(), tmp.end()))); } break; case BINARY_EXT: ret.push_back(value(t, get_binary(r))); break; #ifndef LIBBERT_NO_EXTENSION case X_NEW_FLOAT_EXT: ret.push_back(value(FLOAT_EXT, x_get_new_float(r))); break; #endif default: throw bert_exception("unknown type"); }; } return ret; }
/** * Do postprocessing on a condition leaf. */ static bool c2_l_postprocess(session_t *ps, c2_l_t *pleaf) { // Give a pattern type to a leaf with exists operator, if needed if (C2_L_OEXISTS == pleaf->op && !pleaf->ptntype) { pleaf->ptntype = (C2_L_TSTRING == pleaf->type ? C2_L_PTSTRING: C2_L_PTINT); } // Get target atom if it's not a predefined one if (!pleaf->predef) { pleaf->tgtatom = get_atom(ps, pleaf->tgt); if (!pleaf->tgtatom) c2_error("Failed to get atom for target \"%s\".", pleaf->tgt); } // Insert target Atom into atom track list if (pleaf->tgtatom) { bool found = false; for (latom_t *platom = ps->track_atom_lst; platom; platom = platom->next) { if (pleaf->tgtatom == platom->atom) { found = true; break; } } if (!found) { latom_t *pnew = malloc(sizeof(latom_t)); if (!pnew) printf_errfq(1, "(): Failed to allocate memory for new track atom."); pnew->next = ps->track_atom_lst; pnew->atom = pleaf->tgtatom; ps->track_atom_lst = pnew; } } // Enable specific tracking options in compton if needed by the condition // TODO: Add track_leader if (pleaf->predef) { switch (pleaf->predef) { case C2_L_PFOCUSED: ps->o.track_focus = true; break; case C2_L_PNAME: case C2_L_PCLASSG: case C2_L_PCLASSI: case C2_L_PROLE: ps->o.track_wdata = true; break; default: break; } } // Warn about lower case characters in target name if (!pleaf->predef) { for (const char *pc = pleaf->tgt; *pc; ++pc) { if (islower(*pc)) { printf_errf("(): Warning: Lowercase character in target name \"%s\".", pleaf->tgt); break; } } } // PCRE patterns if (C2_L_PTSTRING == pleaf->ptntype && C2_L_MPCRE == pleaf->match) { #ifdef CONFIG_REGEX_PCRE const char *error = NULL; int erroffset = 0; int options = 0; // Ignore case flag if (pleaf->match_ignorecase) options |= PCRE_CASELESS; // Compile PCRE expression pleaf->regex_pcre = pcre_compile(pleaf->ptnstr, options, &error, &erroffset, NULL); if (!pleaf->regex_pcre) c2_error("Pattern \"%s\": PCRE regular expression parsing failed on " "offset %d: %s", pleaf->ptnstr, erroffset, error); #ifdef CONFIG_REGEX_PCRE_JIT pleaf->regex_pcre_extra = pcre_study(pleaf->regex_pcre, PCRE_STUDY_JIT_COMPILE, &error); if (!pleaf->regex_pcre_extra) { printf("Pattern \"%s\": PCRE regular expression study failed: %s", pleaf->ptnstr, error); } #endif // Free the target string // free(pleaf->tgt); // pleaf->tgt = NULL; #else c2_error("PCRE regular expression support not compiled in."); #endif } return true; }