From 43696e841d807d9dba7b50314517069634d4cba2 Mon Sep 17 00:00:00 2001 From: Alex Larsson Date: Sat, 30 Jun 2001 02:56:50 +0000 Subject: [PATCH] Convert GdkVisual to a GObject. 2001-06-29 Alex Larsson * gdk/gdkvisual.h: * gdk/gdkcolor.c: * gdk/x11/gdkx.h: * gdk/x11/gdkvisual-x11.c: Convert GdkVisual to a GObject. * gdk/gdkinput.h: * gdk/gdkevents.c: * gdk/x11/gdkinputprivate.h: * gdk/x11/gdkinput-gxi.c: * gdk/x11/gdkinput-none.c: * gdk/x11/gdkinput-x11.c: * gdk/x11/gdkinput-xfree.c: * gdk/x11/gdkinput.c: Convert GdkDevice to a GObject. --- ChangeLog | 18 ++++ ChangeLog.pre-2-0 | 18 ++++ ChangeLog.pre-2-10 | 18 ++++ ChangeLog.pre-2-2 | 18 ++++ ChangeLog.pre-2-4 | 18 ++++ ChangeLog.pre-2-6 | 18 ++++ ChangeLog.pre-2-8 | 18 ++++ gdk/gdkcolor.c | 18 ---- gdk/gdkevents.c | 29 ------ gdk/gdkinput.h | 14 +-- gdk/gdkvisual.h | 18 +++- gdk/x11/gdkinput-gxi.c | 1 + gdk/x11/gdkinput-none.c | 1 + gdk/x11/gdkinput-x11.c | 4 +- gdk/x11/gdkinput-xfree.c | 1 + gdk/x11/gdkinput.c | 71 ++++++++++++--- gdk/x11/gdkinputprivate.h | 9 ++ gdk/x11/gdkvisual-x11.c | 187 ++++++++++++++++++++++---------------- gdk/x11/gdkx.h | 9 +- 19 files changed, 335 insertions(+), 153 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a41a14e5c..6a3e0e6778 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2001-06-29 Alex Larsson + + * gdk/gdkvisual.h: + * gdk/gdkcolor.c: + * gdk/x11/gdkx.h: + * gdk/x11/gdkvisual-x11.c: + Convert GdkVisual to a GObject. + + * gdk/gdkinput.h: + * gdk/gdkevents.c: + * gdk/x11/gdkinputprivate.h: + * gdk/x11/gdkinput-gxi.c: + * gdk/x11/gdkinput-none.c: + * gdk/x11/gdkinput-x11.c: + * gdk/x11/gdkinput-xfree.c: + * gdk/x11/gdkinput.c: + Convert GdkDevice to a GObject. + Fri Jun 29 22:13:28 2001 Jonathan Blandford * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 9a41a14e5c..6a3e0e6778 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,21 @@ +2001-06-29 Alex Larsson + + * gdk/gdkvisual.h: + * gdk/gdkcolor.c: + * gdk/x11/gdkx.h: + * gdk/x11/gdkvisual-x11.c: + Convert GdkVisual to a GObject. + + * gdk/gdkinput.h: + * gdk/gdkevents.c: + * gdk/x11/gdkinputprivate.h: + * gdk/x11/gdkinput-gxi.c: + * gdk/x11/gdkinput-none.c: + * gdk/x11/gdkinput-x11.c: + * gdk/x11/gdkinput-xfree.c: + * gdk/x11/gdkinput.c: + Convert GdkDevice to a GObject. + Fri Jun 29 22:13:28 2001 Jonathan Blandford * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9a41a14e5c..6a3e0e6778 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,21 @@ +2001-06-29 Alex Larsson + + * gdk/gdkvisual.h: + * gdk/gdkcolor.c: + * gdk/x11/gdkx.h: + * gdk/x11/gdkvisual-x11.c: + Convert GdkVisual to a GObject. + + * gdk/gdkinput.h: + * gdk/gdkevents.c: + * gdk/x11/gdkinputprivate.h: + * gdk/x11/gdkinput-gxi.c: + * gdk/x11/gdkinput-none.c: + * gdk/x11/gdkinput-x11.c: + * gdk/x11/gdkinput-xfree.c: + * gdk/x11/gdkinput.c: + Convert GdkDevice to a GObject. + Fri Jun 29 22:13:28 2001 Jonathan Blandford * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 9a41a14e5c..6a3e0e6778 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,21 @@ +2001-06-29 Alex Larsson + + * gdk/gdkvisual.h: + * gdk/gdkcolor.c: + * gdk/x11/gdkx.h: + * gdk/x11/gdkvisual-x11.c: + Convert GdkVisual to a GObject. + + * gdk/gdkinput.h: + * gdk/gdkevents.c: + * gdk/x11/gdkinputprivate.h: + * gdk/x11/gdkinput-gxi.c: + * gdk/x11/gdkinput-none.c: + * gdk/x11/gdkinput-x11.c: + * gdk/x11/gdkinput-xfree.c: + * gdk/x11/gdkinput.c: + Convert GdkDevice to a GObject. + Fri Jun 29 22:13:28 2001 Jonathan Blandford * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9a41a14e5c..6a3e0e6778 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,21 @@ +2001-06-29 Alex Larsson + + * gdk/gdkvisual.h: + * gdk/gdkcolor.c: + * gdk/x11/gdkx.h: + * gdk/x11/gdkvisual-x11.c: + Convert GdkVisual to a GObject. + + * gdk/gdkinput.h: + * gdk/gdkevents.c: + * gdk/x11/gdkinputprivate.h: + * gdk/x11/gdkinput-gxi.c: + * gdk/x11/gdkinput-none.c: + * gdk/x11/gdkinput-x11.c: + * gdk/x11/gdkinput-xfree.c: + * gdk/x11/gdkinput.c: + Convert GdkDevice to a GObject. + Fri Jun 29 22:13:28 2001 Jonathan Blandford * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9a41a14e5c..6a3e0e6778 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,21 @@ +2001-06-29 Alex Larsson + + * gdk/gdkvisual.h: + * gdk/gdkcolor.c: + * gdk/x11/gdkx.h: + * gdk/x11/gdkvisual-x11.c: + Convert GdkVisual to a GObject. + + * gdk/gdkinput.h: + * gdk/gdkevents.c: + * gdk/x11/gdkinputprivate.h: + * gdk/x11/gdkinput-gxi.c: + * gdk/x11/gdkinput-none.c: + * gdk/x11/gdkinput-x11.c: + * gdk/x11/gdkinput-xfree.c: + * gdk/x11/gdkinput.c: + Convert GdkDevice to a GObject. + Fri Jun 29 22:13:28 2001 Jonathan Blandford * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9a41a14e5c..6a3e0e6778 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,21 @@ +2001-06-29 Alex Larsson + + * gdk/gdkvisual.h: + * gdk/gdkcolor.c: + * gdk/x11/gdkx.h: + * gdk/x11/gdkvisual-x11.c: + Convert GdkVisual to a GObject. + + * gdk/gdkinput.h: + * gdk/gdkevents.c: + * gdk/x11/gdkinputprivate.h: + * gdk/x11/gdkinput-gxi.c: + * gdk/x11/gdkinput-none.c: + * gdk/x11/gdkinput-x11.c: + * gdk/x11/gdkinput-xfree.c: + * gdk/x11/gdkinput.c: + Convert GdkDevice to a GObject. + Fri Jun 29 22:13:28 2001 Jonathan Blandford * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types diff --git a/gdk/gdkcolor.c b/gdk/gdkcolor.c index 237835632d..3e03493635 100644 --- a/gdk/gdkcolor.c +++ b/gdk/gdkcolor.c @@ -230,21 +230,3 @@ gdk_color_get_type (void) FALSE); 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 - */ -GType -gdk_visual_get_type (void) -{ - static GType our_type = 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; -} - diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 72bfbc236b..5650694f71 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -1016,32 +1016,3 @@ gdk_event_get_type (void) FALSE); return our_type; } - -/* 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) -{ - return device; -} - -void -gdk_device_unref (GdkDevice *device) -{ - return; -} - -GType -gdk_device_get_type (void) -{ - static GType our_type = 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; -} diff --git a/gdk/gdkinput.h b/gdk/gdkinput.h index d2a17f2eba..ecd8be5891 100644 --- a/gdk/gdkinput.h +++ b/gdk/gdkinput.h @@ -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; @@ -89,11 +96,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); diff --git a/gdk/gdkvisual.h b/gdk/gdkvisual.h index f9ae20c1b7..bcae03b43f 100644 --- a/gdk/gdkvisual.h +++ b/gdk/gdkvisual.h @@ -7,7 +7,14 @@ 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: @@ -41,6 +48,8 @@ typedef enum */ struct _GdkVisual { + GObject parent_instance; + GdkVisualType type; gint depth; GdkByteOrder byte_order; @@ -71,9 +80,10 @@ 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); +#ifndef GTK_DISABLE_DEPRECATED +#define gdk_visual_ref(v) g_object_ref(v) +#define gdk_visual_unref(v) g_object_unref(v) +#endif void gdk_query_depths (gint **depths, gint *count); diff --git a/gdk/x11/gdkinput-gxi.c b/gdk/x11/gdkinput-gxi.c index 5ce6e7f447..b7469cea01 100644 --- a/gdk/x11/gdkinput-gxi.c +++ b/gdk/x11/gdkinput-gxi.c @@ -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; diff --git a/gdk/x11/gdkinput-none.c b/gdk/x11/gdkinput-none.c index 7ee8644b7b..3295169d5d 100644 --- a/gdk/x11/gdkinput-none.c +++ b/gdk/x11/gdkinput-none.c @@ -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; diff --git a/gdk/x11/gdkinput-x11.c b/gdk/x11/gdkinput-x11.c index 46ed5b5c58..1dd32e4a37 100644 --- a/gdk/x11/gdkinput-x11.c +++ b/gdk/x11/gdkinput-x11.c @@ -96,7 +96,7 @@ gdk_input_device_new (XDeviceInfo *device, gint include_core) 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 +245,7 @@ gdk_input_device_new (XDeviceInfo *device, gint include_core) g_free (gdkdev->info.keys); if (gdkdev->info.axes) g_free (gdkdev->info.axes); - g_free (gdkdev); + g_object_unref (gdkdev); return NULL; } diff --git a/gdk/x11/gdkinput-xfree.c b/gdk/x11/gdkinput-xfree.c index b0034cbacc..e2260934e9 100644 --- a/gdk/x11/gdkinput-xfree.c +++ b/gdk/x11/gdkinput-xfree.c @@ -33,6 +33,7 @@ static void gdk_input_check_proximity (void); void gdk_input_init(void) { + _gdk_init_input_core (); gdk_input_ignore_core = FALSE; gdk_input_common_init(FALSE); } diff --git a/gdk/x11/gdkinput.c b/gdk/x11/gdkinput.c index b4525987c1..2232f584d4 100644 --- a/gdk/x11/gdkinput.c +++ b/gdk/x11/gdkinput.c @@ -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 */ @@ -65,6 +51,61 @@ 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; +} + +static void +gdk_device_finalize (GObject *object) +{ + g_error ("A GdkDevice object was finalized. This should not happen"); +} + +static void +gdk_device_class_init (GObjectClass *class) +{ + class->finalize = gdk_device_finalize; +} + +GType +gdk_device_get_type (void) +{ + 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 (GdkDevicePrivate), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL, + }; + + object_type = g_type_register_static (G_TYPE_OBJECT, + "GdkDevice", + &object_info, 0); + } + + return object_type; +} + GList * gdk_devices_list (void) { diff --git a/gdk/x11/gdkinputprivate.h b/gdk/x11/gdkinputprivate.h index e74f9fdd68..acfb26d23d 100644 --- a/gdk/x11/gdkinputprivate.h +++ b/gdk/x11/gdkinputprivate.h @@ -38,6 +38,7 @@ #include #endif + typedef struct _GdkAxisInfo GdkAxisInfo; typedef struct _GdkDevicePrivate GdkDevicePrivate; typedef struct _GdkInputWindow GdkInputWindow; @@ -94,6 +95,11 @@ struct _GdkDevicePrivate #endif /* !XINPUT_NONE */ }; +struct _GdkDeviceClass +{ + GObjectClass parent_class; +}; + struct _GdkInputWindow { /* gdk window */ @@ -114,6 +120,8 @@ struct _GdkInputWindow gint grabbed; }; + + /* Global data */ #define GDK_IS_CORE(d) (((GdkDevice *)(d)) == gdk_core_pointer) @@ -132,6 +140,7 @@ GdkInputWindow *gdk_input_window_find (GdkWindow *window); void gdk_input_window_destroy (GdkWindow *window); GdkTimeCoord ** _gdk_device_allocate_history (GdkDevice *device, gint n_events); +void _gdk_init_input_core (void); /* The following functions are provided by each implementation * (xfree, gxi, and none) diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c index ebbd755919..617b15dd94 100644 --- a/gdk/x11/gdkvisual-x11.c +++ b/gdk/x11/gdkvisual-x11.c @@ -41,7 +41,7 @@ static gboolean gdk_visual_equal (Visual *a, static GdkVisualPrivate *system_visual; -static GdkVisualPrivate *visuals; +static GdkVisualPrivate **visuals; static gint nvisuals; static gint available_depths[7]; @@ -66,6 +66,48 @@ static const gchar* visual_names[] = static GHashTable *visual_hash = NULL; +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 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 (GdkVisualPrivate), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL, + }; + + object_type = g_type_register_static (G_TYPE_OBJECT, + "GdkVisual", + &object_info, 0); + } + + return object_type; +} + + void gdk_visual_init (void) { @@ -85,14 +127,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, NULL); default_xvisual = DefaultVisual (gdk_display, gdk_screen); @@ -108,64 +153,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.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.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.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.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.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.blue_mask = 0; + visuals[nvisuals]->visual.blue_shift = 0; + visuals[nvisuals]->visual.blue_prec = 0; } nvisuals += 1; @@ -179,27 +224,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 +255,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 +265,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 +274,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 +290,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 +326,7 @@ gdk_visual_get_system (void) GdkVisual* gdk_visual_get_best (void) { - return ((GdkVisual*) &(visuals[0])); + return ((GdkVisual*) visuals[0]); } GdkVisual* @@ -304,9 +337,9 @@ gdk_visual_get_best_with_depth (gint depth) 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 +354,9 @@ gdk_visual_get_best_with_type (GdkVisualType visual_type) 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 +372,10 @@ gdk_visual_get_best_with_both (gint depth, 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 +406,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 +430,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; } diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 7125127fc0..40b8b954c0 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -36,10 +36,10 @@ #include #include -typedef struct _GdkColormapPrivateX11 GdkColormapPrivateX11; +typedef struct _GdkColormapPrivateX11 GdkColormapPrivateX11; typedef struct _GdkCursorPrivate GdkCursorPrivate; typedef struct _GdkFontPrivateX GdkFontPrivateX; -typedef struct _GdkImagePrivateX11 GdkImagePrivateX11; +typedef struct _GdkImagePrivateX11 GdkImagePrivateX11; typedef struct _GdkVisualPrivate GdkVisualPrivate; struct _GdkCursorPrivate @@ -66,6 +66,11 @@ struct _GdkVisualPrivate Visual *xvisual; }; +struct _GdkVisualClass +{ + GObjectClass parent_class; +}; + struct _GdkColormapPrivateX11 { Colormap xcolormap;