int Isleep (int argc, lvar_t *argv) { #ifndef FEATURE_MS struct timeval tz; float f; Gsync (); f = Tgetnumber (argv[0].o); tz.tv_sec = f; tz.tv_usec = (f - tz.tv_sec) * 1000000; if (select (0, NULL, NULL, NULL, &tz) == -1) return L_FAILURE; #endif return L_SUCCESS; }
static int processinput (int waitflag) { fd_set fdset; #ifndef FEATURE_MS struct timeval tz, *tzp; #else HANDLE evs[MAXIMUM_WAIT_OBJECTS]; int evn; #endif int n, rtn; int ioi; rtn = 0; while (Gprocessevents (FALSE, G_MANYEVENTS)) rtn = 1; #ifndef FEATURE_MS for (ioi = 0, n = 0; ioi < ion; ioi++) if ( iop[ioi].inuse && iop[ioi].ismonitored && FD_ISSET (fileno (iop[ioi].ifp), &inputfds) && canread (iop[ioi].ifp) ) GFXmonitorfile (ioi), n++; if (n || rtn) return 1; if (Gneedredraw) return 0; tz = (waitflag && !rtn) ? longwait : zerowait; tzp = &tz; fdset = inputfds; if ((n = select (FD_SETSIZE, &fdset, NULL, NULL, tzp)) <= 0) return rtn; rtn = 1; if (FD_ISSET (Gxfd, &fdset)) Gprocessevents (TRUE, G_MANYEVENTS), n--; if (!n) return rtn; Gsync (); for (ioi = 0; n > 0 && ioi < ion; ioi++) if ( iop[ioi].inuse && iop[ioi].ismonitored && FD_ISSET (fileno (iop[ioi].ifp), &fdset) ) GFXmonitorfile (ioi), n--; #else for (ioi = 0, n = 0, evn = 0; ioi < ion; ioi++) { if (!iop[ioi].inuse || !IOismonitored (ioi)) continue; if ( (iop[ioi].type == IO_FILE && canread (iop[ioi].ifp)) || (iop[ioi].type == IO_PIPE && iop[ioi].buf[0]) ) GFXmonitorfile (ioi), n++; if (iop[ioi].type != IO_PIPE) continue; evs[evn++] = iop[ioi].ifp; } if (n) return 1; if (Gneedredraw) return 0; n = MsgWaitForMultipleObjects ( evn, evs, FALSE, (waitflag && !rtn) ? 1 : 0, QS_ALLINPUT ); if (n == WAIT_TIMEOUT || n < WAIT_OBJECT_0 || n > WAIT_OBJECT_0 + evn) return rtn; if (n == WAIT_OBJECT_0 + evn) Gprocessevents (TRUE, G_MANYEVENTS); Gsync (); for (ioi = 0; ioi < ion; ioi++) if ( iop[ioi].inuse && IOismonitored (ioi) && (iop[ioi].type == IO_FILE || (iop[ioi].type == IO_PIPE && evs[n - WAIT_OBJECT_0] == iop[ioi].ifp)) ) GFXmonitorfile (ioi); #endif return rtn; }
int GCsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp) { PIXsize_t ps; int ai, r, g, b, color; GdkColor *cp; for (ai = 0; ai < attrn; ai++) { switch (attrp[ai].id) { case G_ATTRSIZE: GETSIZE(attrp[ai].u.s, ps, MINCWSIZE); gtk_drawing_area_size(GTK_DRAWING_AREA(widget->w), ps.x, ps.y); break; case G_ATTRBORDERWIDTH: break; case G_ATTRCURSOR: if (Strcmp(attrp[ai].u.t, "watch") == 0) { gdk_window_set_cursor(widget->w->window, gdk_cursor_new(GDK_WATCH)); } else { gdk_window_set_cursor(widget->w->window, gdk_cursor_new(GDK_LEFT_PTR)); } Gsync(); break; case G_ATTRCOLOR: color = attrp[ai].u.c.index; if (color < 0 || color > G_MAXCOLORS) { Gerr(POS, G_ERRBADCOLORINDEX, color); return -1; } r = attrp[ai].u.c.r * 257; g = attrp[ai].u.c.g * 257; b = attrp[ai].u.c.b * 257; cp = &WCU->colors[color].color; if (WCU->colors[color].inuse) if (cp->red != r || cp->green != g || cp->blue != b) if (color > 1 || WCU->allocedcolor[color]) gdk_colormap_free_colors(WCU->cmap, cp, 1); cp->red = r, cp->green = g, cp->blue = b; if (gdk_colormap_alloc_color(WCU->cmap, cp, TRUE, TRUE)) { WCU->colors[color].inuse = TRUE; if (color <= 1) WCU->allocedcolor[color] = TRUE; } cp->red = r, cp->green = g, cp->blue = b; if (color == WCU->gattr.color) WCU->gattr.color = -1; break; case G_ATTRVIEWPORT: WCU->vsize.x = (int) (attrp[ai].u.s.x + 0.5); WCU->vsize.y = (int) (attrp[ai].u.s.y + 0.5); break; case G_ATTRWINDOW: WCU->wrect = attrp[ai].u.r; adjustclip(widget); break; case G_ATTRWINDOWID: Gerr(POS, G_ERRCANNOTSETATTR2, "windowid"); return -1; case G_ATTREVENTCB: WCU->func = (Gcanvascb) attrp[ai].u.func; break; case G_ATTRUSERDATA: widget->udata = attrp[ai].u.u; break; default: Gerr(POS, G_ERRBADATTRID, attrp[ai].id); return -1; } } return 0; }