Delete unused private gdk_visual_lookup(), make gdk_colormap_lookup()

Tue Sep 24 16:04:44 2002  Owen Taylor  <otaylor@redhat.com>

        * gdkprivate-x11.h gdkcolor-x11.c gdkvisual-x11.c
        gdkwindow-x11.c: Delete unused private gdk_visual_lookup(),
        make gdk_colormap_lookup() private gdkcolor-x11.c.
        make gdk_window_add_colormap_windows private to gdkwindow-x11.c
        (#85674)

        * gdk/x11/gdkx.h gdk/x11/gdkcolor-x11.c
        gdkscreen-x11.h: Add gdk_x11_colormap_foreign_new(),
        GDK_ENABLE_BROKEN gdkx_colormap_get(), make the
        colormap hash per-screen. (#85697)

        * gdk/x11/gdkxid.c (gdk_xid_table_lookup_for_display):
        Remove a bit of unecessary code.
This commit is contained in:
Owen Taylor 2002-09-24 20:20:08 +00:00 committed by Owen Taylor
parent ed737365c9
commit f9d267ae80
14 changed files with 224 additions and 84 deletions

View File

@ -1,3 +1,19 @@
Tue Sep 24 16:04:44 2002 Owen Taylor <otaylor@redhat.com>
* gdkprivate-x11.h gdkcolor-x11.c gdkvisual-x11.c
gdkwindow-x11.c: Delete unused private gdk_visual_lookup(),
make gdk_colormap_lookup() private gdkcolor-x11.c.
make gdk_window_add_colormap_windows private to gdkwindow-x11.c
(#85674)
* gdk/x11/gdkx.h gdk/x11/gdkcolor-x11.c
gdkscreen-x11.h: Add gdk_x11_colormap_foreign_new(),
GDK_ENABLE_BROKEN gdkx_colormap_get(), make the
colormap hash per-screen. (#85697)
* gdk/x11/gdkxid.c (gdk_xid_table_lookup_for_display):
Remove a bit of unecessary code.
Thu Aug 8 16:58:22 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_real_change_value):

View File

@ -1,3 +1,19 @@
Tue Sep 24 16:04:44 2002 Owen Taylor <otaylor@redhat.com>
* gdkprivate-x11.h gdkcolor-x11.c gdkvisual-x11.c
gdkwindow-x11.c: Delete unused private gdk_visual_lookup(),
make gdk_colormap_lookup() private gdkcolor-x11.c.
make gdk_window_add_colormap_windows private to gdkwindow-x11.c
(#85674)
* gdk/x11/gdkx.h gdk/x11/gdkcolor-x11.c
gdkscreen-x11.h: Add gdk_x11_colormap_foreign_new(),
GDK_ENABLE_BROKEN gdkx_colormap_get(), make the
colormap hash per-screen. (#85697)
* gdk/x11/gdkxid.c (gdk_xid_table_lookup_for_display):
Remove a bit of unecessary code.
Thu Aug 8 16:58:22 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_real_change_value):

View File

@ -1,3 +1,19 @@
Tue Sep 24 16:04:44 2002 Owen Taylor <otaylor@redhat.com>
* gdkprivate-x11.h gdkcolor-x11.c gdkvisual-x11.c
gdkwindow-x11.c: Delete unused private gdk_visual_lookup(),
make gdk_colormap_lookup() private gdkcolor-x11.c.
make gdk_window_add_colormap_windows private to gdkwindow-x11.c
(#85674)
* gdk/x11/gdkx.h gdk/x11/gdkcolor-x11.c
gdkscreen-x11.h: Add gdk_x11_colormap_foreign_new(),
GDK_ENABLE_BROKEN gdkx_colormap_get(), make the
colormap hash per-screen. (#85697)
* gdk/x11/gdkxid.c (gdk_xid_table_lookup_for_display):
Remove a bit of unecessary code.
Thu Aug 8 16:58:22 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_real_change_value):

View File

@ -1,3 +1,19 @@
Tue Sep 24 16:04:44 2002 Owen Taylor <otaylor@redhat.com>
* gdkprivate-x11.h gdkcolor-x11.c gdkvisual-x11.c
gdkwindow-x11.c: Delete unused private gdk_visual_lookup(),
make gdk_colormap_lookup() private gdkcolor-x11.c.
make gdk_window_add_colormap_windows private to gdkwindow-x11.c
(#85674)
* gdk/x11/gdkx.h gdk/x11/gdkcolor-x11.c
gdkscreen-x11.h: Add gdk_x11_colormap_foreign_new(),
GDK_ENABLE_BROKEN gdkx_colormap_get(), make the
colormap hash per-screen. (#85697)
* gdk/x11/gdkxid.c (gdk_xid_table_lookup_for_display):
Remove a bit of unecessary code.
Thu Aug 8 16:58:22 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_real_change_value):

View File

@ -1,3 +1,19 @@
Tue Sep 24 16:04:44 2002 Owen Taylor <otaylor@redhat.com>
* gdkprivate-x11.h gdkcolor-x11.c gdkvisual-x11.c
gdkwindow-x11.c: Delete unused private gdk_visual_lookup(),
make gdk_colormap_lookup() private gdkcolor-x11.c.
make gdk_window_add_colormap_windows private to gdkwindow-x11.c
(#85674)
* gdk/x11/gdkx.h gdk/x11/gdkcolor-x11.c
gdkscreen-x11.h: Add gdk_x11_colormap_foreign_new(),
GDK_ENABLE_BROKEN gdkx_colormap_get(), make the
colormap hash per-screen. (#85697)
* gdk/x11/gdkxid.c (gdk_xid_table_lookup_for_display):
Remove a bit of unecessary code.
Thu Aug 8 16:58:22 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_real_change_value):

View File

@ -1,3 +1,19 @@
Tue Sep 24 16:04:44 2002 Owen Taylor <otaylor@redhat.com>
* gdkprivate-x11.h gdkcolor-x11.c gdkvisual-x11.c
gdkwindow-x11.c: Delete unused private gdk_visual_lookup(),
make gdk_colormap_lookup() private gdkcolor-x11.c.
make gdk_window_add_colormap_windows private to gdkwindow-x11.c
(#85674)
* gdk/x11/gdkx.h gdk/x11/gdkcolor-x11.c
gdkscreen-x11.h: Add gdk_x11_colormap_foreign_new(),
GDK_ENABLE_BROKEN gdkx_colormap_get(), make the
colormap hash per-screen. (#85697)
* gdk/x11/gdkxid.c (gdk_xid_table_lookup_for_display):
Remove a bit of unecessary code.
Thu Aug 8 16:58:22 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_real_change_value):

View File

@ -44,6 +44,8 @@ struct _GdkColormapPrivateX11
GHashTable *hash;
GdkColorInfo *info;
time_t last_sync_time;
guint foreign : 1;
};
#define GDK_COLORMAP_PRIVATE_DATA(cmap) ((GdkColormapPrivateX11 *) GDK_COLORMAP (cmap)->windowing_data)
@ -53,6 +55,10 @@ static gint gdk_colormap_match_color (GdkColormap *cmap,
const gchar *available);
static void gdk_colormap_add (GdkColormap *cmap);
static void gdk_colormap_remove (GdkColormap *cmap);
static GdkColormap *gdk_colormap_lookup (GdkScreen *screen,
Colormap xcolormap);
static guint gdk_colormap_hash (Colormap *cmap);
static gboolean gdk_colormap_equal (Colormap *a,
Colormap *b);
@ -65,8 +71,6 @@ static void gdk_colormap_finalize (GObject *object);
static gpointer parent_class = NULL;
static GHashTable *colormap_hash = NULL;
GType
gdk_colormap_get_type (void)
{
@ -161,7 +165,7 @@ gdk_colormap_new (GdkVisual *visual,
g_return_val_if_fail (visual != NULL, NULL);
colormap = g_object_new (gdk_colormap_get_type (), NULL);
colormap = g_object_new (GDK_TYPE_COLORMAP, NULL);
private = GDK_COLORMAP_PRIVATE_DATA (colormap);
colormap->visual = visual;
@ -374,7 +378,7 @@ gdk_screen_get_system_colormap (GdkScreen *screen)
if (screen_x11->system_colormap)
return screen_x11->system_colormap;
colormap = g_object_new (gdk_colormap_get_type (), NULL);
colormap = g_object_new (GDK_TYPE_COLORMAP, NULL);
private = GDK_COLORMAP_PRIVATE_DATA (colormap);
private->screen = screen;
@ -1140,65 +1144,112 @@ gdk_color_change (GdkColormap *colormap,
return TRUE;
}
/* XXX: Do not use this function until it is fixed. An X Colormap
* is useless unless we also have the visual.
*/
GdkColormap*
gdkx_colormap_get (Colormap xcolormap)
/**
* gdk_x11_colormap_foreign_new:
* @visual: a #GdkVisual
* @xcolormap: The XID of a colormap with visual @visual
*
* If xcolormap refers to a colormap previously known to GTK+,
* returns a new reference to the existing #GdkColormap object,
* otherwise creates a new GdkColormap object and returns that
*
* Return value: the #GdkColormap object for @xcolormap.
* Free with g_object_unref(). Note that for colormap created
* with gdk_x11_colormap_foreign_new(), unref'ing the last
* reference to the object will only free the #GdkColoramp
* object and not call XFreeColormap()
**/
GdkColormap *
gdk_x11_colormap_foreign_new (GdkVisual *visual,
Colormap xcolormap)
{
GdkColormap *colormap;
#if 0
GdkScreen *screen;
GdkColormapPrivateX11 *private;
g_return_val_if_fail (GDK_IS_VISUAL (visual), NULL);
g_return_val_if_fail (xcolormap != None, NULL);
colormap = gdk_colormap_lookup (xcolormap);
screen = gdk_visual_get_screen (visual);
if (xcolormap == DefaultColormap (GDK_SCREEN_XDISPLAY (screen),
GDK_SCREEN_XNUMBER (screen)));
return g_object_ref (gdk_screen_get_system_colormap (screen));
colormap = gdk_colormap_lookup (screen, xcolormap);
if (colormap)
return colormap;
return g_object_ref (colormap);
if (xcolormap == DefaultColormap (gdk_display, _gdk_screen))
return gdk_colormap_get_system ();
colormap = g_object_new (gdk_colormap_get_type (), NULL);
colormap = g_object_new (GDK_TYPE_COLORMAP, NULL);
private = GDK_COLORMAP_PRIVATE_DATA (colormap);
private->xdisplay = gdk_display;
colormap->visual = visual;
private->screen = screen;
private->xcolormap = xcolormap;
colormap->visual = NULL;
private->private_val = TRUE;
#endif
private->xdisplay = GDK_SCREEN_XDISPLAY (screen);
private->private_val = FALSE;
/* To do the following safely, we would have to have some way of finding
* out what the size or visual of the given colormap is. It seems
* X doesn't allow this
*/
colormap->size = visual->colormap_size;
#if 0
for (i = 0; i < 256; i++)
switch (colormap->visual->type)
{
xpalette[i].pixel = i;
xpalette[i].red = 0;
xpalette[i].green = 0;
xpalette[i].blue = 0;
case GDK_VISUAL_GRAYSCALE:
case GDK_VISUAL_PSEUDO_COLOR:
private->info = g_new0 (GdkColorInfo, colormap->size);
private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
(GEqualFunc) gdk_color_equal);
/* Fall through */
case GDK_VISUAL_STATIC_GRAY:
case GDK_VISUAL_STATIC_COLOR:
case GDK_VISUAL_DIRECT_COLOR:
colormap->colors = g_new (GdkColor, colormap->size);
gdk_colormap_sync (colormap, TRUE);
case GDK_VISUAL_TRUE_COLOR:
break;
}
XQueryColors (gdk_display, private->xcolormap, xpalette, 256);
for (i = 0; i < 256; i++)
{
colormap->colors[i].pixel = xpalette[i].pixel;
colormap->colors[i].red = xpalette[i].red;
colormap->colors[i].green = xpalette[i].green;
colormap->colors[i].blue = xpalette[i].blue;
}
#endif
colormap->colors = NULL;
colormap->size = 0;
gdk_colormap_add (colormap);
return colormap;
}
/**
* gdkx_colormap_get:
* @xcolormap: the XID of a colormap for the default screen.
*
* Returns a #GdkColormap corresponding to a X colormap;
* this function only works if the colormap is already
* known to GTK+ (a colormap created by GTK+ or the default
* colormap for the screen), since GTK+
*
* Always use gdk_x11_colormap_foreign_new() instead.
*
* Return value: the existing #GdkColormap object if it was
* already known to GTK+, otherwise warns and return
* %NULL.
**/
GdkColormap*
gdkx_colormap_get (Colormap xcolormap)
{
GdkScreen *screen = gdk_screen_get_default ();
GdkColormap *colormap;
if (xcolormap == DefaultColormap (GDK_SCREEN_XDISPLAY (screen),
GDK_SCREEN_XNUMBER (screen)));
return g_object_ref (gdk_screen_get_system_colormap (screen));
colormap = gdk_colormap_lookup (screen, xcolormap);
if (colormap)
return g_object_ref (colormap);
g_warning ("Colormap passed to gdkx_colormap_get\n"
"does not previously exist");
return NULL;
}
static gint
gdk_colormap_match_color (GdkColormap *cmap,
@ -1239,46 +1290,51 @@ gdk_colormap_match_color (GdkColormap *cmap,
}
GdkColormap*
gdk_colormap_lookup (Colormap xcolormap)
static GdkColormap*
gdk_colormap_lookup (GdkScreen *screen,
Colormap xcolormap)
{
GdkColormap *cmap;
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
if (!colormap_hash)
if (screen_x11->colormap_hash)
return g_hash_table_lookup (screen_x11->colormap_hash, &xcolormap);
else
return NULL;
cmap = g_hash_table_lookup (colormap_hash, &xcolormap);
return cmap;
}
static void
gdk_colormap_add (GdkColormap *cmap)
{
GdkScreenX11 *screen_x11;
GdkColormapPrivateX11 *private;
if (!colormap_hash)
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
(GEqualFunc) gdk_colormap_equal);
private = GDK_COLORMAP_PRIVATE_DATA (cmap);
screen_x11 = GDK_SCREEN_X11 (private->screen);
g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
if (!screen_x11->colormap_hash)
screen_x11->colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
(GEqualFunc) gdk_colormap_equal);
g_hash_table_insert (screen_x11->colormap_hash, &private->xcolormap, cmap);
}
static void
gdk_colormap_remove (GdkColormap *cmap)
{
GdkScreenX11 *screen_x11;
GdkColormapPrivateX11 *private;
private = GDK_COLORMAP_PRIVATE_DATA (cmap);
screen_x11 = GDK_SCREEN_X11 (private->screen);
g_hash_table_remove (colormap_hash, &private->xcolormap);
if (screen_x11->colormap_hash)
g_hash_table_remove (screen_x11->colormap_hash, &private->xcolormap);
}
static guint
gdk_colormap_hash (Colormap *cmap)
gdk_colormap_hash (Colormap *colormap)
{
return *cmap;
return *colormap;
}
static gboolean

View File

@ -116,11 +116,6 @@ GdkGC *_gdk_x11_gc_new (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask values_mask);
GdkColormap * gdk_colormap_lookup (Colormap xcolormap);
GdkVisual * gdk_visual_lookup (Visual *xvisual);
void gdk_window_add_colormap_windows (GdkWindow *window);
GdkImage *_gdk_x11_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,

View File

@ -264,6 +264,7 @@ gdk_screen_x11_finalize (GObject *object)
g_object_unref (G_OBJECT (screen_x11->visuals[i]));*/
g_free (screen_x11->visuals);
g_hash_table_destroy (screen_x11->visual_hash);
g_hash_table_destroy (screen_x11->colormap_hash);
/* X settings */
g_free (screen_x11->xsettings_client);

View File

@ -64,6 +64,7 @@ struct _GdkScreenX11
GdkVisualType available_types[6];
gint navailable_types;
GHashTable *visual_hash;
GHashTable *colormap_hash;
/* Colormap Part */
GdkColormap *default_colormap;

View File

@ -536,17 +536,6 @@ gdk_screen_list_visuals (GdkScreen *screen)
return list;
}
GdkVisual*
gdk_visual_lookup (Visual *xvisual)
{
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (gdk_screen_get_default ());
if (!screen_x11->visual_hash)
return NULL;
return g_hash_table_lookup (screen_x11->visual_hash, xvisual);
}
/**
* gdkx_visual_get_for_screen:
* @screen: a #GdkScreen.

View File

@ -82,6 +82,7 @@ static void gdk_window_set_static_win_gravity (GdkWindow *window,
gboolean on);
static gboolean gdk_window_have_shape_ext (GdkDisplay *display);
static gboolean gdk_window_icon_name_set (GdkWindow *window);
static void gdk_window_add_colormap_windows (GdkWindow *window);
static GdkColormap* gdk_window_impl_x11_get_colormap (GdkDrawable *drawable);
static void gdk_window_impl_x11_set_colormap (GdkDrawable *drawable,
@ -2621,7 +2622,7 @@ gdk_window_set_events (GdkWindow *window,
}
}
void
static void
gdk_window_add_colormap_windows (GdkWindow *window)
{
GdkWindow *toplevel;

View File

@ -122,11 +122,15 @@ GdkVisual* gdkx_visual_get_for_screen (GdkScreen *screen,
GdkVisual* gdkx_visual_get (VisualID xvisualid);
#endif
/* XXX: Do not use this function until it is fixed. An X Colormap
* is useless unless we also have the visual. */
#ifdef GDK_ENABLE_BROKEN
/* XXX: An X Colormap is useless unless we also have the visual. */
GdkColormap* gdkx_colormap_get (Colormap xcolormap);
#endif
/* Return the Gdk* for a particular XID */
GdkColormap *gdk_x11_colormap_foreign_new (GdkVisual *visual,
Colormap xcolormap)
/* Return the Gdk* for a particular XID */
gpointer gdk_xid_table_lookup_for_display (GdkDisplay *display,
XID xid);
guint32 gdk_x11_get_server_time (GdkWindow *window);

View File

@ -62,11 +62,8 @@ _gdk_xid_table_remove (GdkDisplay *display,
display_x11 = GDK_DISPLAY_X11 (display);
if (!display_x11->xid_ht)
display_x11->xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
(GEqualFunc) gdk_xid_equal);
g_hash_table_remove (display_x11->xid_ht, &xid);
if (display_x11->xid_ht)
g_hash_table_remove (display_x11->xid_ht, &xid);
}
/**