handle->red_shift   = xxlib_get_shift_from_mask(handle, handle->x_visual_info->red_mask); handle->red_prec    = xxlib_get_prec_from_mask(handle, handle->x_visual_info->red_mask); handle->green_shift = xxlib_get_shift_from_mask(handle, handle->x_visual_info->green_mask); handle->green_prec  = xxlib_get_prec_from_mask(handle, handle->x_visual_info->green_mask); handle->blue_shift  = xxlib_get_shift_from_mask(handle, handle->x_visual_info->blue_mask); handle->blue_prec   = xxlib_get_prec_from_mask(handle, handle->x_visual_info->blue_mask);
handle->red_shift   = xxlib_get_shift_from_mask(handle->x_visual_info->red_mask); handle->red_prec    = xxlib_get_prec_from_mask(handle->x_visual_info->red_mask); handle->green_shift = xxlib_get_shift_from_mask(handle->x_visual_info->green_mask); handle->green_prec  = xxlib_get_prec_from_mask(handle->x_visual_info->green_mask); handle->blue_shift  = xxlib_get_shift_from_mask(handle->x_visual_info->blue_mask); handle->blue_prec   = xxlib_get_prec_from_mask(handle->x_visual_info->blue_mask);
xxlib_rgb_choose_visual (XlibRgbHandle *handle){  XVisualInfo *visuals;  XVisualInfo *visual;  XVisualInfo *best_visual;  XVisualInfo *final_visual;  XVisualInfo template;  int num_visuals;  uint32 score, best_score;  int cur_visual = 1;  int i;    template.screen = handle->screen_num;  visuals = XGetVisualInfo(handle->display, VisualScreenMask,                           &template, &num_visuals);    best_visual = visuals;  best_score = xxlib_rgb_score_visual (handle, best_visual);  for (i = cur_visual; i < num_visuals; i++)  {    visual = &visuals[i];    score = xxlib_rgb_score_visual (handle, visual);    if (score > best_score)    {      best_score = score;      best_visual = visual;    }  }  /* make a copy of the visual so that we can free   * the allocated visual list above. */  final_visual = malloc(sizeof(XVisualInfo));  memcpy(final_visual, best_visual, sizeof(XVisualInfo));  handle->x_visual_info = final_visual;  XFree(visuals);  /* set up the shift and the precision for the red, green and blue.     this only applies to cool visuals like true color and direct color. */  if (handle->x_visual_info->class == TrueColor ||      handle->x_visual_info->class == DirectColor) {    handle->red_shift   = xxlib_get_shift_from_mask(handle, handle->x_visual_info->red_mask);    handle->red_prec    = xxlib_get_prec_from_mask(handle, handle->x_visual_info->red_mask);    handle->green_shift = xxlib_get_shift_from_mask(handle, handle->x_visual_info->green_mask);    handle->green_prec  = xxlib_get_prec_from_mask(handle, handle->x_visual_info->green_mask);    handle->blue_shift  = xxlib_get_shift_from_mask(handle, handle->x_visual_info->blue_mask);    handle->blue_prec   = xxlib_get_prec_from_mask(handle, handle->x_visual_info->blue_mask);  }}