Example #1
0
static VALUE
rg_initialize(VALUE self, VALUE visual, VALUE allocate)
{
    GdkColormap *cmap  = gdk_colormap_new(GDK_VISUAL(RVAL2GOBJ(visual)),
                                          RVAL2CBOOL(allocate));
    G_INITIALIZE(self, cmap);
    return Qnil;
}
Example #2
0
USER_OBJECT_
S_GdkVisualGetBlueMask (USER_OBJECT_ s_obj)
{
   USER_OBJECT_ _result = NULL_USER_OBJECT;

   GdkVisual *obj;
   guint32 val;

   obj = GDK_VISUAL(getPtrValue(s_obj)) ;
   val = obj->blue_mask;
   _result = asRNumeric(val);

   return(_result);
} 
Example #3
0
USER_OBJECT_
S_GdkVisualGetBluePrec (USER_OBJECT_ s_obj)
{
   USER_OBJECT_ _result = NULL_USER_OBJECT;

   GdkVisual *obj;
   gint val;

   obj = GDK_VISUAL(getPtrValue(s_obj)) ;
   val = obj->blue_prec;
   _result = asRInteger(val);

   return(_result);
} 
Example #4
0
USER_OBJECT_
S_GdkVisualGetBitsPerRgb (USER_OBJECT_ s_obj)
{
   USER_OBJECT_ _result = NULL_USER_OBJECT;

   GdkVisual *obj;
   gint val;

   obj = GDK_VISUAL(getPtrValue(s_obj)) ;
   val = obj->bits_per_rgb;
   _result = asRInteger(val);

   return(_result);
} 
Example #5
0
USER_OBJECT_
S_GdkVisualGetGreenShift (USER_OBJECT_ s_obj)
{
   USER_OBJECT_ _result = NULL_USER_OBJECT;

   GdkVisual *obj;
   gint val;

   obj = GDK_VISUAL(getPtrValue(s_obj)) ;
   val = obj->green_shift;
   _result = asRInteger(val);

   return(_result);
} 
Example #6
0
USER_OBJECT_
S_GdkVisualGetColormapSize (USER_OBJECT_ s_obj)
{
   USER_OBJECT_ _result = NULL_USER_OBJECT;

   GdkVisual *obj;
   gint val;

   obj = GDK_VISUAL(getPtrValue(s_obj)) ;
   val = obj->colormap_size;
   _result = asRInteger(val);

   return(_result);
} 
Example #7
0
USER_OBJECT_
S_GdkVisualGetByteOrder (USER_OBJECT_ s_obj)
{
   USER_OBJECT_ _result = NULL_USER_OBJECT;

   GdkVisual *obj;
   GdkByteOrder val;

   obj = GDK_VISUAL(getPtrValue(s_obj)) ;
   val = obj->byte_order;
   _result = asREnum(val, GDK_TYPE_BYTE_ORDER);

   return(_result);
} 
Example #8
0
USER_OBJECT_
S_GdkVisualGetType (USER_OBJECT_ s_obj)
{
   USER_OBJECT_ _result = NULL_USER_OBJECT;

   GdkVisual *obj;
   GdkVisualType val;

   obj = GDK_VISUAL(getPtrValue(s_obj)) ;
   val = obj->type;
   _result = asREnum(val, GDK_TYPE_VISUAL_TYPE);

   return(_result);
} 
Example #9
0
static VALUE
rg_initialize(VALUE self, VALUE type, VALUE visual, VALUE w, VALUE h)
{
    GdkImage* image = gdk_image_new((GdkImageType)RVAL2GENUM(type, GDK_TYPE_IMAGE_TYPE),
                                    GDK_VISUAL(RVAL2GOBJ(visual)),
                                    NUM2INT(w), NUM2INT(h));

    if (image)
        G_INITIALIZE(self, image);
    else
        rb_raise(rb_eArgError, "The image could not be created.");

    return Qnil;
}
void
_gdk_visual_init (GdkScreen *screen)
{
  static const gint possible_depths[8] = { 32, 30, 24, 16, 15, 8, 4, 1 };
  static const GdkVisualType possible_types[6] =
    {
      GDK_VISUAL_DIRECT_COLOR,
      GDK_VISUAL_TRUE_COLOR,
      GDK_VISUAL_PSEUDO_COLOR,
      GDK_VISUAL_STATIC_COLOR,
      GDK_VISUAL_GRAYSCALE,
      GDK_VISUAL_STATIC_GRAY
    };

  GdkScreenX11 *screen_x11;
  XVisualInfo *visual_list;
  XVisualInfo visual_template;
  GdkVisualPrivate *temp_visual;
  Visual *default_xvisual;
  GdkVisualPrivate **visuals;
  int nxvisuals;
  int nvisuals;
  int i, j;
  
  g_return_if_fail (GDK_IS_SCREEN (screen));
  screen_x11 = GDK_SCREEN_X11 (screen);

  nxvisuals = 0;
  visual_template.screen = screen_x11->screen_num;
  visual_list = XGetVisualInfo (screen_x11->xdisplay, VisualScreenMask, &visual_template, &nxvisuals);
  
  visuals = g_new (GdkVisualPrivate *, nxvisuals);
  for (i = 0; i < nxvisuals; i++)
    visuals[i] = g_object_new (GDK_TYPE_VISUAL, NULL);

  default_xvisual = DefaultVisual (screen_x11->xdisplay, screen_x11->screen_num);

  nvisuals = 0;
  for (i = 0; i < nxvisuals; i++)
    {
      visuals[nvisuals]->screen = screen;
      
      if (visual_list[i].depth >= 1)
	{
#ifdef __cplusplus
	  switch (visual_list[i].c_class)
#else /* __cplusplus */
	  switch (visual_list[i].class)
#endif /* __cplusplus */
	    {
	    case StaticGray:
	      visuals[nvisuals]->visual.type = GDK_VISUAL_STATIC_GRAY;
	      break;
	    case GrayScale:
	      visuals[nvisuals]->visual.type = GDK_VISUAL_GRAYSCALE;
	      break;
	    case StaticColor:
	      visuals[nvisuals]->visual.type = GDK_VISUAL_STATIC_COLOR;
	      break;
	    case PseudoColor:
	      visuals[nvisuals]->visual.type = GDK_VISUAL_PSEUDO_COLOR;
	      break;
	    case TrueColor:
	      visuals[nvisuals]->visual.type = GDK_VISUAL_TRUE_COLOR;
	      break;
	    case DirectColor:
	      visuals[nvisuals]->visual.type = GDK_VISUAL_DIRECT_COLOR;
	      break;
	    }

	  visuals[nvisuals]->visual.depth = visual_list[i].depth;
	  visuals[nvisuals]->visual.byte_order =
	    (ImageByteOrder(screen_x11->xdisplay) == LSBFirst) ?
	    GDK_LSB_FIRST : GDK_MSB_FIRST;
	  visuals[nvisuals]->visual.red_mask = visual_list[i].red_mask;
	  visuals[nvisuals]->visual.green_mask = visual_list[i].green_mask;
	  visuals[nvisuals]->visual.blue_mask = visual_list[i].blue_mask;
	  visuals[nvisuals]->visual.colormap_size = visual_list[i].colormap_size;
	  visuals[nvisuals]->visual.bits_per_rgb = visual_list[i].bits_per_rgb;
	  visuals[nvisuals]->xvisual = visual_list[i].visual;

	  if ((visuals[nvisuals]->visual.type == GDK_VISUAL_TRUE_COLOR) ||
	      (visuals[nvisuals]->visual.type == GDK_VISUAL_DIRECT_COLOR))
	    {
	      gdk_visual_decompose_mask (visuals[nvisuals]->visual.red_mask,
					 &visuals[nvisuals]->visual.red_shift,
					 &visuals[nvisuals]->visual.red_prec);

	      gdk_visual_decompose_mask (visuals[nvisuals]->visual.green_mask,
					 &visuals[nvisuals]->visual.green_shift,
					 &visuals[nvisuals]->visual.green_prec);

	      gdk_visual_decompose_mask (visuals[nvisuals]->visual.blue_mask,
					 &visuals[nvisuals]->visual.blue_shift,
					 &visuals[nvisuals]->visual.blue_prec);
	    }
	  else
	    {
	      visuals[nvisuals]->visual.red_mask = 0;
	      visuals[nvisuals]->visual.red_shift = 0;
	      visuals[nvisuals]->visual.red_prec = 0;

	      visuals[nvisuals]->visual.green_mask = 0;
	      visuals[nvisuals]->visual.green_shift = 0;
	      visuals[nvisuals]->visual.green_prec = 0;

	      visuals[nvisuals]->visual.blue_mask = 0;
	      visuals[nvisuals]->visual.blue_shift = 0;
	      visuals[nvisuals]->visual.blue_prec = 0;
	    }
	  
	  nvisuals += 1;
	}
    }

  if (visual_list)
    XFree (visual_list);

  for (i = 0; i < nvisuals; i++)
    {
      for (j = i+1; j < nvisuals; j++)
	{
	  if (visuals[j]->visual.depth >= visuals[i]->visual.depth)
	    {
	      if ((visuals[j]->visual.depth == 8) && (visuals[i]->visual.depth == 8))
		{
		  if (visuals[j]->visual.type == GDK_VISUAL_PSEUDO_COLOR)
		    {
		      temp_visual = visuals[j];
		      visuals[j] = visuals[i];
		      visuals[i] = temp_visual;
		    }
		  else if ((visuals[i]->visual.type != GDK_VISUAL_PSEUDO_COLOR) &&
			   visuals[j]->visual.type > visuals[i]->visual.type)
		    {
		      temp_visual = visuals[j];
		      visuals[j] = visuals[i];
		      visuals[i] = temp_visual;
		    }
		}
	      else if ((visuals[j]->visual.depth > visuals[i]->visual.depth) ||
		       ((visuals[j]->visual.depth == visuals[i]->visual.depth) &&
			(visuals[j]->visual.type > visuals[i]->visual.type)))
		{
		  temp_visual = visuals[j];
		  visuals[j] = visuals[i];
		  visuals[i] = temp_visual;
		}
	    }
	}
    }

  for (i = 0; i < nvisuals; i++)
    {
      if (default_xvisual->visualid == visuals[i]->xvisual->visualid)
	screen_x11->system_visual = visuals[i];

      /* For now, we only support 8888 ARGB for the "rgba visual".
       * Additional formats (like ABGR) could be added later if they
       * turn up.
       */
      if (visuals[i]->visual.depth == 32 &&
	  (visuals[i]->visual.red_mask   == 0xff0000 &&
	   visuals[i]->visual.green_mask == 0x00ff00 &&
	   visuals[i]->visual.blue_mask  == 0x0000ff))
	{
	  screen_x11->rgba_visual = GDK_VISUAL (visuals[i]);
	}
    }

#ifdef G_ENABLE_DEBUG 
  if (_gdk_debug_flags & GDK_DEBUG_MISC)
    for (i = 0; i < nvisuals; i++)
      g_message ("visual: %s: %d",
		 visual_names[visuals[i]->visual.type],
		 visuals[i]->visual.depth);
#endif /* G_ENABLE_DEBUG */

  screen_x11->navailable_depths = 0;
  for (i = 0; i < G_N_ELEMENTS (possible_depths); i++)
    {
      for (j = 0; j < nvisuals; j++)
	{
	  if (visuals[j]->visual.depth == possible_depths[i])
	    {
	      screen_x11->available_depths[screen_x11->navailable_depths++] = visuals[j]->visual.depth;
	      break;
	    }
	}
    }

  if (screen_x11->navailable_depths == 0)
    g_error ("unable to find a usable depth");

  screen_x11->navailable_types = 0;
  for (i = 0; i < G_N_ELEMENTS (possible_types); i++)
    {
      for (j = 0; j < nvisuals; j++)
	{
	  if (visuals[j]->visual.type == possible_types[i])
	    {
	      screen_x11->available_types[screen_x11->navailable_types++] = visuals[j]->visual.type;
	      break;
	    }
	}
    }

  for (i = 0; i < nvisuals; i++)
    gdk_visual_add ((GdkVisual*) visuals[i]);

  if (screen_x11->navailable_types == 0)
    g_error ("unable to find a usable visual type");

  screen_x11->visuals = visuals;
  screen_x11->nvisuals = nvisuals;
}
Example #11
0
static VALUE
rg_set_visual(VALUE self, VALUE val)
{
    _SELF(self)->visual = GDK_VISUAL(RVAL2GOBJ(val));
    return self;
}