Пример #1
0
static void *
bgloader_thread(void *aux)
{
  bg_helper_t *bgh = aux;

  rstr_t *current_bg = NULL;
  float current_alpha = 0;

  while(1) {
    struct prop_notify_queue q;

    float alpha = 1.0f;
    int timo = alpha != current_alpha ? 16 : 0;

    prop_courier_wait(bgh->pc, &q, timo);
    prop_notify_dispatch(&q);

    rstr_t *bg;
    if(bgh->bg_url[0]) {
      bg = bgh->bg_url[0];

      if(bgh->bg_alpha[0])
	alpha = bgh->bg_alpha[0];
    } else if(bgh->bg_url[1]) {
      bg = bgh->bg_url[1];

      if(bgh->bg_alpha[1])
	alpha = bgh->bg_alpha[1];
    } else {
      bg = bgh->bg_url[2];
    }

    if(bgh->fullwindow || bgh->screensaver)
      alpha = 0;

    if(alpha != current_alpha) {
      if(current_alpha < alpha)
	current_alpha = MIN(alpha, current_alpha + 0.1);
      else if(current_alpha > alpha)
	current_alpha = MAX(alpha, current_alpha - 0.1);

      bgh->set_alpha(current_alpha, bgh->opaque);
    }

    if(!rstr_eq(current_bg, bg)) {
      rstr_set(&current_bg, bg);
      const char *v[3];

      v[0] = "skin";
      v[1] = rstr_get(bgh->skin_path);
      v[2] = NULL;

      bgh->set_image(bg, v, bgh->opaque);
    }

  }
  return NULL;
}
Пример #2
0
JSBool
js_wait_for_value(JSContext *cx, prop_t *root, const char *subname,
		  jsval value, jsval *rval)
{
  prop_courier_t *pc = prop_courier_create_waitable();
  prop_sub_t *s;
  wfv_t wfv;
  wfv.value = value;
  wfv.done = 0;

  s = prop_subscribe(0,
		     PROP_TAG_ROOT, root,
		     PROP_TAG_COURIER, pc,
		     PROP_TAG_CALLBACK, vfw_setval, &wfv,
		     PROP_TAG_NAMESTR, subname,
		     NULL);

  if(s == NULL) {
    JS_ReportError(cx, "Unable to subscribe to %s", subname);
    return JS_FALSE;
  }
  *rval = JSVAL_TRUE;

  while(!wfv.done) {

    struct prop_notify_queue exp, nor;
    jsrefcount s = JS_SuspendRequest(cx);
    prop_courier_wait(pc, &nor, &exp);
    JS_ResumeRequest(cx, s);
    prop_notify_dispatch(&exp);
    prop_notify_dispatch(&nor);
  }

  prop_unsubscribe(s);
  prop_courier_destroy(pc);
  return JS_TRUE;
}