Re: Make GdkDevice, GdkVisual objects
- From: Alex Larsson <alexl redhat com>
- To: Owen Taylor <otaylor redhat com>
- Cc: <gtk-devel-list gnome org>
- Subject: Re: Make GdkDevice, GdkVisual objects
- Date: Fri, 29 Jun 2001 19:32:04 -0400 (EDT)
On 29 Jun 2001, Owen Taylor wrote:
>
> After some discussion with Paolo, Tim, and James yesterday, I
> just filed this bug in bugzilla [ #56861 ]:
>
> GdkDevice and GdkVisual only vaguely fit the concept of what
> should be a boxed type. GdkVisual is immutable, GdkDevice
> isn't, they both are members of a fixed set and are not
> memory managed.
>
> In a language binding, you would expect to be able to write
> something like:
>
> widget::get_colormap() == GtkColormap::get_system()
>
> But boxed types don't have a concept of preserving equality
> over a copy, so making this works forces the language
> binding to special case the equality operation for such
> types ... you won't have a persistant language object
> associated with the GDK object. Making a fixed association
> of language object <=> GDK object requires the features
> of GObject.
>
> If someone has time to make up a patch for this in the short
> term (API freeze tomorrow evening) timescale, that could
> be useful.
Here is a patch:
Index: gdk/gdkcolor.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkcolor.c,v
retrieving revision 1.25
diff -u -p -r1.25 gdkcolor.c
--- gdk/gdkcolor.c 2001/04/02 23:33:46 1.25
+++ gdk/gdkcolor.c 2001/06/29 23:30:24
@@ -231,20 +231,47 @@ gdk_color_get_type (void)
return our_type;
}
+
/* We define this here to avoid having to create a new .C file just for this
* function. The rest of GdkVisual is platform-specific
*/
+static void
+gdk_visual_finalize (GObject *object)
+{
+ g_error ("A GdkVisual object was finalized. This should not happen");
+}
+
+static void
+gdk_visual_class_init (GObjectClass *class)
+{
+ class->finalize = gdk_visual_finalize;
+}
+
GType
gdk_visual_get_type (void)
{
- static GType our_type = 0;
+ static GType object_type = 0;
+
+ if (!object_type)
+ {
+ static const GTypeInfo object_info =
+ {
+ sizeof (GdkVisualClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gdk_visual_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GdkVisual),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
+ };
+
+ object_type = g_type_register_static (G_TYPE_OBJECT,
+ "GdkVisual",
+ &object_info, 0);
+ }
- if (our_type == 0)
- our_type = g_boxed_type_register_static ("GdkVisual",
- NULL,
- (GBoxedCopyFunc)gdk_visual_ref,
- (GBoxedFreeFunc)gdk_visual_unref,
- TRUE);
- return our_type;
+ return object_type;
}
Index: gdk/gdkevents.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkevents.c,v
retrieving revision 1.38
diff -u -p -r1.38 gdkevents.c
--- gdk/gdkevents.c 2001/06/28 22:49:19 1.38
+++ gdk/gdkevents.c 2001/06/29 23:30:24
@@ -1020,28 +1020,42 @@ gdk_event_get_type (void)
/* These functions are defined here to avoid a new C file, as GdkDevice is
* platform specific. (similar to how gdk_visual_get_type() is in gdkcolor.c)
*/
-GdkDevice *
-gdk_device_ref (GdkDevice *device)
+static void
+gdk_device_finalize (GObject *object)
{
- return device;
+ g_error ("A GdkDevice object was finalized. This should not happen");
}
-void
-gdk_device_unref (GdkDevice *device)
+static void
+gdk_device_class_init (GObjectClass *class)
{
- return;
+ class->finalize = gdk_device_finalize;
}
GType
gdk_device_get_type (void)
{
- static GType our_type = 0;
+ static GType object_type = 0;
+
+ if (!object_type)
+ {
+ static const GTypeInfo object_info =
+ {
+ sizeof (GdkDeviceClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gdk_device_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GdkDevice),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
+ };
+
+ object_type = g_type_register_static (G_TYPE_OBJECT,
+ "GdkDevice",
+ &object_info, 0);
+ }
- if (our_type == 0)
- our_type = g_boxed_type_register_static ("GdkDevice",
- NULL,
- (GBoxedCopyFunc)gdk_device_ref,
- (GBoxedFreeFunc)gdk_device_unref,
- TRUE);
- return our_type;
+ return object_type;
}
Index: gdk/gdkinput.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkinput.h,v
retrieving revision 1.12
diff -u -p -r1.12 gdkinput.h
--- gdk/gdkinput.h 2001/06/28 16:35:38 1.12
+++ gdk/gdkinput.h 2001/06/29 23:30:24
@@ -7,11 +7,17 @@
extern "C" {
#endif /* __cplusplus */
-#define GDK_TYPE_DEVICE (gdk_device_get_type ())
+#define GDK_TYPE_DEVICE (gdk_device_get_type ())
+#define GDK_DEVICE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DEVICE, GdkDevice))
+#define GDK_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DEVICE, GdkDeviceClass))
+#define GDK_IS_DEVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DEVICE))
+#define GDK_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DEVICE))
+#define GDK_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DEVICE, GdkDeviceClass))
typedef struct _GdkDeviceKey GdkDeviceKey;
typedef struct _GdkDeviceAxis GdkDeviceAxis;
typedef struct _GdkDevice GdkDevice;
+typedef struct _GdkDeviceClass GdkDeviceClass;
typedef struct _GdkTimeCoord GdkTimeCoord;
typedef enum
@@ -63,6 +69,7 @@ struct _GdkDeviceAxis
struct _GdkDevice
{
+ GObject parent_instance;
/* All fields are read-only */
gchar *name;
@@ -77,6 +84,11 @@ struct _GdkDevice
GdkDeviceKey *keys;
};
+struct _GdkDeviceClass
+{
+ GObjectClass parent_class;
+};
+
/* We don't allocate each coordinate this big, but we use it to
* be ANSI compliant and avoid accessing past the defined limits.
*/
@@ -89,11 +101,6 @@ struct _GdkTimeCoord
};
GType gdk_device_get_type (void);
-/* these two are no ops provided for the boxed type code */
-/* XXXX do they need to be exposed as public APIs at all? */
-GdkDevice *gdk_device_ref (GdkDevice *device);
-void gdk_device_unref (GdkDevice *device);
-
/* Returns a list of GdkDevice * */
GList * gdk_devices_list (void);
Index: gdk/gdkvisual.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkvisual.h,v
retrieving revision 1.3
diff -u -p -r1.3 gdkvisual.h
--- gdk/gdkvisual.h 2001/04/16 12:46:00 1.3
+++ gdk/gdkvisual.h 2001/06/29 23:30:24
@@ -7,8 +7,15 @@
extern "C" {
#endif /* __cplusplus */
-#define GDK_TYPE_VISUAL gdk_visual_get_type ()
+#define GDK_TYPE_VISUAL (gdk_visual_get_type ())
+#define GDK_VISUAL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_VISUAL, GdkVisual))
+#define GDK_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_VISUAL, GdkVisualClass))
+#define GDK_IS_VISUAL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_VISUAL))
+#define GDK_IS_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_VISUAL))
+#define GDK_VISUAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_VISUAL, GdkVisualClass))
+typedef struct _GdkVisualClass GdkVisualClass;
+
/* Types of visuals.
* StaticGray:
* Grayscale:
@@ -41,6 +48,8 @@ typedef enum
*/
struct _GdkVisual
{
+ GObject parent_instance;
+
GdkVisualType type;
gint depth;
GdkByteOrder byte_order;
@@ -60,6 +69,11 @@ struct _GdkVisual
gint blue_prec;
};
+struct _GdkVisualClass
+{
+ GObjectClass parent_class;
+};
+
GType gdk_visual_get_type (void);
gint gdk_visual_get_best_depth (void);
@@ -70,10 +84,6 @@ GdkVisual* gdk_visual_get_best_with_d
GdkVisual* gdk_visual_get_best_with_type (GdkVisualType visual_type);
GdkVisual* gdk_visual_get_best_with_both (gint depth,
GdkVisualType visual_type);
-
-/* Actually, these are no-ops... */
-GdkVisual* gdk_visual_ref (GdkVisual *visual);
-void gdk_visual_unref (GdkVisual *visual);
void gdk_query_depths (gint **depths,
gint *count);
Index: gdk/x11/gdkinput-gxi.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkinput-gxi.c,v
retrieving revision 1.10
diff -u -p -r1.10 gdkinput-gxi.c
--- gdk/x11/gdkinput-gxi.c 2000/07/26 11:32:30 1.10
+++ gdk/x11/gdkinput-gxi.c 2001/06/29 23:30:24
@@ -53,6 +53,7 @@ gdk_input_init(void)
{
GList *tmp_list;
+ _gdk_init_input_core ();
gdk_input_ignore_core = FALSE;
gdk_input_core_pointer = NULL;
Index: gdk/x11/gdkinput-none.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkinput-none.c,v
retrieving revision 1.10
diff -u -p -r1.10 gdkinput-none.c
--- gdk/x11/gdkinput-none.c 2000/07/26 11:32:30 1.10
+++ gdk/x11/gdkinput-none.c 2001/06/29 23:30:24
@@ -29,6 +29,7 @@
void
gdk_input_init (void)
{
+ _gdk_init_input_core ();
gdk_input_devices = g_list_append (NULL, gdk_core_pointer);
gdk_input_ignore_core = FALSE;
Index: gdk/x11/gdkinput-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkinput-x11.c,v
retrieving revision 1.18
diff -u -p -r1.18 gdkinput-x11.c
--- gdk/x11/gdkinput-x11.c 2000/07/26 11:32:30 1.18
+++ gdk/x11/gdkinput-x11.c 2001/06/29 23:30:25
@@ -88,6 +88,34 @@ gdk_input_get_root_relative_geometry(Dis
*height_ret = height;
}
+GType
+gdk_device_private_get_type (void)
+{
+ static GType object_type = 0;
+
+ if (!object_type)
+ {
+ static const GTypeInfo object_info =
+ {
+ sizeof (GdkDevicePrivateClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) NULL /* class_init */,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GdkDevicePrivate),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
+ };
+
+ object_type = g_type_register_static (GDK_TYPE_DEVICE,
+ "GdkDevicePrivate",
+ &object_info, 0);
+ }
+
+ return object_type;
+}
+
static GdkDevicePrivate *
gdk_input_device_new (XDeviceInfo *device, gint include_core)
{
@@ -96,7 +124,7 @@ gdk_input_device_new (XDeviceInfo *devic
XAnyClassPtr class;
gint i,j;
- gdkdev = g_new(GdkDevicePrivate,1);
+ gdkdev = g_object_new (GDK_TYPE_DEVICE_PRIVATE, 1);
gdkdev->deviceid = device->id;
if (device->name[0])
@@ -245,7 +273,7 @@ gdk_input_device_new (XDeviceInfo *devic
g_free (gdkdev->info.keys);
if (gdkdev->info.axes)
g_free (gdkdev->info.axes);
- g_free (gdkdev);
+ g_object_unref (gdkdev);
return NULL;
}
Index: gdk/x11/gdkinput-xfree.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkinput-xfree.c,v
retrieving revision 1.13
diff -u -p -r1.13 gdkinput-xfree.c
--- gdk/x11/gdkinput-xfree.c 2000/07/26 11:32:30 1.13
+++ gdk/x11/gdkinput-xfree.c 2001/06/29 23:30:25
@@ -33,6 +33,7 @@ static void gdk_input_check_proximity (v
void
gdk_input_init(void)
{
+ _gdk_init_input_core ();
gdk_input_ignore_core = FALSE;
gdk_input_common_init(FALSE);
}
Index: gdk/x11/gdkinput.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkinput.c,v
retrieving revision 1.19
diff -u -p -r1.19 gdkinput.c
--- gdk/x11/gdkinput.c 2001/03/04 00:12:55 1.19
+++ gdk/x11/gdkinput.c 2001/06/29 23:30:25
@@ -39,21 +39,7 @@ static GdkDeviceAxis gdk_input_core_axes
{ GDK_AXIS_Y, 0, 0 }
};
-static const GdkDevice gdk_input_core_info =
-{
- "Core Pointer",
- GDK_SOURCE_MOUSE,
- GDK_MODE_SCREEN,
- TRUE,
-
- 2,
- gdk_input_core_axes,
-
- 0,
- NULL
-};
-
-GdkDevice *gdk_core_pointer = (GdkDevice *)&gdk_input_core_info;
+GdkDevice *gdk_core_pointer = NULL;
/* Global variables */
@@ -64,6 +50,21 @@ gint gdk_input_ignore_core;
GList *gdk_input_devices;
GList *gdk_input_windows;
+
+void
+_gdk_init_input_core (void)
+{
+ gdk_core_pointer = g_object_new (GDK_TYPE_DEVICE, NULL);
+
+ gdk_core_pointer->name = "Core Pointer";
+ gdk_core_pointer->source = GDK_SOURCE_MOUSE;
+ gdk_core_pointer->mode = GDK_MODE_SCREEN;
+ gdk_core_pointer->has_cursor = TRUE;
+ gdk_core_pointer->num_axes = 2;
+ gdk_core_pointer->axes = gdk_input_core_axes;
+ gdk_core_pointer->num_keys = 0;
+ gdk_core_pointer->keys = NULL;
+}
GList *
gdk_devices_list (void)
Index: gdk/x11/gdkinputprivate.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkinputprivate.h,v
retrieving revision 1.6
diff -u -p -r1.6 gdkinputprivate.h
--- gdk/x11/gdkinputprivate.h 2000/07/26 11:32:30 1.6
+++ gdk/x11/gdkinputprivate.h 2001/06/29 23:30:25
@@ -38,8 +38,12 @@
#include <X11/extensions/XInput.h>
#endif
+
+#define GDK_TYPE_DEVICE_PRIVATE (gdk_device_private_get_type ())
+
typedef struct _GdkAxisInfo GdkAxisInfo;
typedef struct _GdkDevicePrivate GdkDevicePrivate;
+typedef struct _GdkDevicePrivateClass GdkDevicePrivateClass;
typedef struct _GdkInputWindow GdkInputWindow;
/* information about a device axis */
@@ -94,6 +98,11 @@ struct _GdkDevicePrivate
#endif /* !XINPUT_NONE */
};
+struct _GdkDevicePrivateClass
+{
+ GdkDeviceClass parent_class;
+};
+
struct _GdkInputWindow
{
/* gdk window */
@@ -114,6 +123,8 @@ struct _GdkInputWindow
gint grabbed;
};
+
+
/* Global data */
#define GDK_IS_CORE(d) (((GdkDevice *)(d)) == gdk_core_pointer)
@@ -132,6 +143,8 @@ GdkInputWindow *gdk_input_window_find
void gdk_input_window_destroy (GdkWindow *window);
GdkTimeCoord ** _gdk_device_allocate_history (GdkDevice *device,
gint n_events);
+GType gdk_device_private_get_type (void);
+void _gdk_init_input_core (void);
/* The following functions are provided by each implementation
* (xfree, gxi, and none)
Index: gdk/x11/gdkvisual-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkvisual-x11.c,v
retrieving revision 1.21
diff -u -p -r1.21 gdkvisual-x11.c
--- gdk/x11/gdkvisual-x11.c 2000/11/13 13:15:40 1.21
+++ gdk/x11/gdkvisual-x11.c 2001/06/29 23:30:25
@@ -41,7 +41,7 @@ static gboolean gdk_visual_equal
static GdkVisualPrivate *system_visual;
-static GdkVisualPrivate *visuals;
+static GdkVisualPrivate **visuals;
static gint nvisuals;
static gint available_depths[7];
@@ -66,6 +66,35 @@ static const gchar* visual_names[] =
static GHashTable *visual_hash = NULL;
+GType
+gdk_visual_private_get_type (void)
+{
+ static GType object_type = 0;
+
+ if (!object_type)
+ {
+ static const GTypeInfo object_info =
+ {
+ sizeof (GdkVisualPrivateClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) NULL /* class_init */,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GdkVisualPrivate),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
+ };
+
+ object_type = g_type_register_static (GDK_TYPE_VISUAL,
+ "GdkVisualPrivate",
+ &object_info, 0);
+ }
+
+ return object_type;
+}
+
+
void
gdk_visual_init (void)
{
@@ -85,14 +114,17 @@ gdk_visual_init (void)
XVisualInfo *visual_list;
XVisualInfo visual_template;
- GdkVisualPrivate temp_visual;
+ GdkVisualPrivate *temp_visual;
Visual *default_xvisual;
int nxvisuals;
int i, j;
visual_template.screen = gdk_screen;
visual_list = XGetVisualInfo (gdk_display, VisualScreenMask, &visual_template, &nxvisuals);
- visuals = g_new (GdkVisualPrivate, nxvisuals);
+
+ visuals = g_new (GdkVisualPrivate *, nxvisuals);
+ for (i = 0; i < nxvisuals; i++)
+ visuals[i] = g_object_new (GDK_TYPE_VISUAL_PRIVATE, NULL);
default_xvisual = DefaultVisual (gdk_display, gdk_screen);
@@ -108,64 +140,64 @@ gdk_visual_init (void)
#endif /* __cplusplus */
{
case StaticGray:
- visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_GRAY;
+ visuals[nvisuals]->visual.type = GDK_VISUAL_STATIC_GRAY;
break;
case GrayScale:
- visuals[nvisuals].visual.type = GDK_VISUAL_GRAYSCALE;
+ visuals[nvisuals]->visual.type = GDK_VISUAL_GRAYSCALE;
break;
case StaticColor:
- visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_COLOR;
+ visuals[nvisuals]->visual.type = GDK_VISUAL_STATIC_COLOR;
break;
case PseudoColor:
- visuals[nvisuals].visual.type = GDK_VISUAL_PSEUDO_COLOR;
+ visuals[nvisuals]->visual.type = GDK_VISUAL_PSEUDO_COLOR;
break;
case TrueColor:
- visuals[nvisuals].visual.type = GDK_VISUAL_TRUE_COLOR;
+ visuals[nvisuals]->visual.type = GDK_VISUAL_TRUE_COLOR;
break;
case DirectColor:
- visuals[nvisuals].visual.type = GDK_VISUAL_DIRECT_COLOR;
+ visuals[nvisuals]->visual.type = GDK_VISUAL_DIRECT_COLOR;
break;
}
- visuals[nvisuals].visual.depth = visual_list[i].depth;
- visuals[nvisuals].visual.byte_order =
+ visuals[nvisuals]->visual.depth = visual_list[i].depth;
+ visuals[nvisuals]->visual.byte_order =
(ImageByteOrder(gdk_display) == 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;
+ 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))
+ 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);
+ 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;
+ 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;
@@ -179,27 +211,27 @@ gdk_visual_init (void)
{
for (j = i+1; j < nvisuals; j++)
{
- if (visuals[j].visual.depth >= visuals[i].visual.depth)
+ if (visuals[j]->visual.depth >= visuals[i]->visual.depth)
{
- if ((visuals[j].visual.depth == 8) && (visuals[i].visual.depth == 8))
+ if ((visuals[j]->visual.depth == 8) && (visuals[i]->visual.depth == 8))
{
- if (visuals[j].visual.type == GDK_VISUAL_PSEUDO_COLOR)
+ 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)
+ 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)))
+ 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];
@@ -210,9 +242,9 @@ gdk_visual_init (void)
}
for (i = 0; i < nvisuals; i++)
- if (default_xvisual->visualid == visuals[i].xvisual->visualid)
+ if (default_xvisual->visualid == visuals[i]->xvisual->visualid)
{
- system_visual = &visuals[i];
+ system_visual = visuals[i];
break;
}
@@ -220,8 +252,8 @@ gdk_visual_init (void)
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);
+ visual_names[visuals[i]->visual.type],
+ visuals[i]->visual.depth);
#endif /* G_ENABLE_DEBUG */
navailable_depths = 0;
@@ -229,9 +261,9 @@ gdk_visual_init (void)
{
for (j = 0; j < nvisuals; j++)
{
- if (visuals[j].visual.depth == possible_depths[i])
+ if (visuals[j]->visual.depth == possible_depths[i])
{
- available_depths[navailable_depths++] = visuals[j].visual.depth;
+ available_depths[navailable_depths++] = visuals[j]->visual.depth;
break;
}
}
@@ -245,33 +277,21 @@ gdk_visual_init (void)
{
for (j = 0; j < nvisuals; j++)
{
- if (visuals[j].visual.type == possible_types[i])
+ if (visuals[j]->visual.type == possible_types[i])
{
- available_types[navailable_types++] = visuals[j].visual.type;
+ available_types[navailable_types++] = visuals[j]->visual.type;
break;
}
}
}
for (i = 0; i < nvisuals; i++)
- gdk_visual_add ((GdkVisual*) &visuals[i]);
+ gdk_visual_add ((GdkVisual*) visuals[i]);
if (npossible_types == 0)
g_error ("unable to find a usable visual type");
}
-GdkVisual*
-gdk_visual_ref (GdkVisual *visual)
-{
- return visual;
-}
-
-void
-gdk_visual_unref (GdkVisual *visual)
-{
- return;
-}
-
gint
gdk_visual_get_best_depth (void)
{
@@ -293,7 +313,7 @@ gdk_visual_get_system (void)
GdkVisual*
gdk_visual_get_best (void)
{
- return ((GdkVisual*) &(visuals[0]));
+ return ((GdkVisual*) visuals[0]);
}
GdkVisual*
@@ -304,9 +324,9 @@ gdk_visual_get_best_with_depth (gint dep
return_val = NULL;
for (i = 0; i < nvisuals; i++)
- if (depth == visuals[i].visual.depth)
+ if (depth == visuals[i]->visual.depth)
{
- return_val = (GdkVisual*) &(visuals[i]);
+ return_val = (GdkVisual*) visuals[i];
break;
}
@@ -321,9 +341,9 @@ gdk_visual_get_best_with_type (GdkVisual
return_val = NULL;
for (i = 0; i < nvisuals; i++)
- if (visual_type == visuals[i].visual.type)
+ if (visual_type == visuals[i]->visual.type)
{
- return_val = (GdkVisual*) &(visuals[i]);
+ return_val = (GdkVisual*) visuals[i];
break;
}
@@ -339,10 +359,10 @@ gdk_visual_get_best_with_both (gint
return_val = NULL;
for (i = 0; i < nvisuals; i++)
- if ((depth == visuals[i].visual.depth) &&
- (visual_type == visuals[i].visual.type))
+ if ((depth == visuals[i]->visual.depth) &&
+ (visual_type == visuals[i]->visual.type))
{
- return_val = (GdkVisual*) &(visuals[i]);
+ return_val = (GdkVisual*) visuals[i];
break;
}
@@ -373,7 +393,7 @@ gdk_list_visuals (void)
list = NULL;
for (i = 0; i < nvisuals; ++i)
- list = g_list_append (list, (gpointer) &visuals[i]);
+ list = g_list_append (list, (gpointer) visuals[i]);
return list;
}
@@ -397,8 +417,8 @@ gdkx_visual_get (VisualID xvisualid)
int i;
for (i = 0; i < nvisuals; i++)
- if (xvisualid == visuals[i].xvisual->visualid)
- return (GdkVisual*) &visuals[i];
+ if (xvisualid == visuals[i]->xvisual->visualid)
+ return (GdkVisual*) visuals[i];
return NULL;
}
Index: gdk/x11/gdkx.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkx.h,v
retrieving revision 1.19
diff -u -p -r1.19 gdkx.h
--- gdk/x11/gdkx.h 2001/06/29 01:59:00 1.19
+++ gdk/x11/gdkx.h 2001/06/29 23:30:25
@@ -36,11 +36,14 @@
#include <gdk/x11/gdkwindow-x11.h>
#include <gdk/x11/gdkpixmap-x11.h>
-typedef struct _GdkColormapPrivateX11 GdkColormapPrivateX11;
+#define GDK_TYPE_VISUAL_PRIVATE gdk_visual_private_get_type ()
+
+typedef struct _GdkColormapPrivateX11 GdkColormapPrivateX11;
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkFontPrivateX GdkFontPrivateX;
-typedef struct _GdkImagePrivateX11 GdkImagePrivateX11;
+typedef struct _GdkImagePrivateX11 GdkImagePrivateX11;
typedef struct _GdkVisualPrivate GdkVisualPrivate;
+typedef struct _GdkVisualPrivateClass GdkVisualPrivateClass;
struct _GdkCursorPrivate
{
@@ -66,6 +69,11 @@ struct _GdkVisualPrivate
Visual *xvisual;
};
+struct _GdkVisualPrivateClass
+{
+ GdkVisualClass parent_class;
+};
+
struct _GdkColormapPrivateX11
{
Colormap xcolormap;
@@ -150,6 +158,8 @@ extern Window gdk_leader_window;
extern Atom gdk_selection_property;
extern gchar *gdk_progclass;
+
+GType gdk_visual_private_get_type (void);
GdkVisual* gdkx_visual_get (VisualID xvisualid);
/* XXX: Do not use this function until it is fixed. An X Colormap
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]