Commit e5ae081e authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Start implementing display/screen closing scheme; keep a flag for whether

Thu Aug  1 11:26:03 2002  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
	Start implementing display/screen closing scheme; keep a
	flag for whether displays and screens are closed,
	call g_object_run_dispose(). Remove public gdk_screen_close().

	* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
	dispose() methods; move appropriate parts of the finalize
	there.

	* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
	gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
	gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
	gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
	Start of making everything correctly ignore operations
	when a display has been closed.

	* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
	Handle decorations == NULL.

	* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
	Remove unnecessary hash table creation.

	* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
	Fix up gdk_device_get_history - handle events, n_events == NULL,
	etc.

	* gdk/x11/gdkproperty-x11.c (gdk_property_get):
	Handle failure better.

	* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
	Handle failure better, handle data == NULL, move docs
	here, remove an excess round trip by asking for
	all selection data at once.

	* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
	  gdk/{x11,win32}/gdkmain-{x11,win32}.c	gdk/gdkdisplay.c: Move
	gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
	gdk_display_set_sm_client_id() to display-independent part of GDK.

	* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
	into the right place.
parent d202b55b
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-07-31 jacob berkman <jacob@ximian.com>
* gtk/queryimmodules.c (print_escaped): escape_string() only takes
......
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-07-31 jacob berkman <jacob@ximian.com>
* gtk/queryimmodules.c (print_escaped): escape_string() only takes
......
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-07-31 jacob berkman <jacob@ximian.com>
* gtk/queryimmodules.c (print_escaped): escape_string() only takes
......
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-07-31 jacob berkman <jacob@ximian.com>
* gtk/queryimmodules.c (print_escaped): escape_string() only takes
......
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-07-31 jacob berkman <jacob@ximian.com>
* gtk/queryimmodules.c (print_escaped): escape_string() only takes
......
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-07-31 jacob berkman <jacob@ximian.com>
* gtk/queryimmodules.c (print_escaped): escape_string() only takes
......
......@@ -265,21 +265,13 @@ form.
<!-- ##### FUNCTION gdk_selection_property_get ##### -->
<para>
Retrieves selection data that was stored by the selection
data in response to a call to gdk_selection_convert().
</para>
@requestor: the window on which the data is stored
@data: location to store a pointer to the retrieved data.
If the retrieval failed, %NULL we be stored here, otherwise, it
will be non-%NULL and the returned data should be freed with g_free()
when you are finished using it. The length of the
allocated memory is one more than the the length
of the returned data, and the final byte will always
be zero, to ensure nul-termination of strings.
@prop_type: location to store the type of the property.
@prop_format: location to store the format of the property.
@Returns: the length of the retrieved data.
@requestor:
@data:
@prop_type:
@prop_format:
@Returns:
<!-- ##### FUNCTION gdk_selection_send_notify ##### -->
......
......@@ -91,6 +91,7 @@ gdk_public_h_sources = @STRIP_BEGIN@ \
gdk.h \
gdkcolor.h \
gdkcursor.h \
gdkdisplay.h \
gdkdnd.h \
gdkdrawable.h \
gdkevents.h \
......@@ -108,12 +109,11 @@ gdk_public_h_sources = @STRIP_BEGIN@ \
gdkproperty.h \
gdkregion.h \
gdkrgb.h \
gdkscreen.h \
gdkselection.h \
gdktypes.h \
gdkvisual.h \
gdkwindow.h \
gdkdisplay.h \
gdkscreen.h \
@STRIP_END@
gdk_headers = @STRIP_BEGIN@ \
......@@ -126,6 +126,7 @@ gdk_c_sources = @STRIP_BEGIN@ \
gdk.c \
gdkcolor.c \
gdkcursor.c \
gdkdisplay.c \
gdkdraw.c \
gdkevents.c \
gdkfont.c \
......@@ -147,11 +148,10 @@ gdk_c_sources = @STRIP_BEGIN@ \
gdkrectangle.c \
gdkregion-generic.c \
gdkregion-generic.h \
gdkscreen.c \
gdkselection.c \
gdkvisual.c \
gdkwindow.c \
gdkdisplay.c \
gdkscreen.c \
@STRIP_END@
#
......
......@@ -29,6 +29,7 @@
static void gdk_display_class_init (GdkDisplayClass *class);
static void gdk_display_init (GdkDisplay *display);
static void gdk_display_dispose (GObject *object);
static void gdk_display_finalize (GObject *object);
static GObjectClass *parent_class;
......@@ -67,6 +68,7 @@ gdk_display_class_init (GdkDisplayClass *class)
parent_class = g_type_class_peek_parent (class);
object_class->finalize = gdk_display_finalize;
object_class->dispose = gdk_display_dispose;
}
static void
......@@ -81,6 +83,12 @@ gdk_display_init (GdkDisplay *display)
display->double_click_time = 250;
}
static void
gdk_display_dispose (GObject *object)
{
GdkDisplay *display = GDK_DISPLAY_OBJECT (object);
}
static void
gdk_display_finalize (GObject *object)
{
......@@ -99,13 +107,22 @@ gdk_display_finalize (GObject *object)
* gdk_display_close:
* @display: a #GdkDisplay
*
* Closes and cleanup the resources used by the @display
* Closes the connection windowing system for the given display,
* and cleans up associated resources.
*/
void
gdk_display_close (GdkDisplay *display)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
g_object_unref (G_OBJECT (display));
if (!display->closed)
{
display->closed = TRUE;
g_object_run_dispose (G_OBJECT (display));
g_object_unref (G_OBJECT (display));
}
}
/**
......@@ -294,3 +311,24 @@ gdk_display_get_core_pointer (GdkDisplay *display)
{
return display->core_pointer;
}
/**
* gdk_set_sm_client_id:
* @sm_client_id: the client id assigned by the session manager when the
* connection was opened, or %NULL to remove the property.
*
* Sets the <literal>SM_CLIENT_ID</literal> property on the application's leader window so that
* the window manager can save the application's state using the X11R6 ICCCM
* session management protocol.
*
* See the X Session Management Library documentation for more information on
* session management and the Inter-Client Communication Conventions Manual
* (ICCCM) for information on the <literal>WM_CLIENT_LEADER</literal> property.
* (Both documents are part of the X Window System distribution.)
**/
void
gdk_set_sm_client_id (const gchar* sm_client_id)
{
gdk_display_set_sm_client_id (gdk_display_get_default (), sm_client_id);
}
......@@ -55,9 +55,10 @@ struct _GdkDisplay
GdkWindow *button_window[2]; /* The last 2 windows to receive button presses. */
guint button_number[2]; /* The last 2 buttons to be pressed. */
guint double_click_time; /* Maximum time between clicks in msecs */
GdkDevice *core_pointer; /* Core pointer device */
guint double_click_time; /* Maximum time between clicks in msecs */
guint closed : 1; /* Whether this display has been closed */
};
struct _GdkDisplayClass
......
......@@ -216,7 +216,8 @@ GdkImage *_gdk_drawable_copy_to_image (GdkDrawable *drawable,
void _gdk_window_destroy (GdkWindow *window,
gboolean foreign_destroy);
void _gdk_window_clear_update_area (GdkWindow *window);
void _gdk_screen_close (GdkScreen *screen);
/*****************************************
* Interfaces provided by windowing code *
......
......@@ -54,20 +54,16 @@ gdk_screen_get_type (void)
return object_type;
}
/**
* gdk_screen_close:
* @screen: a #GdkScreen
*
* Closes the @screen connection and cleanup its resources.
* Note that this function is called automatically by gdk_display_close().
**/
void
gdk_screen_close (GdkScreen *screen)
_gdk_screen_close (GdkScreen *screen)
{
g_return_if_fail (GDK_IS_SCREEN (screen));
g_object_run_dispose (G_OBJECT (screen));
if (!screen->closed)
{
screen->closed = TRUE;
g_object_run_dispose (G_OBJECT (screen));
}
}
/**
......
......@@ -41,6 +41,8 @@ typedef struct _GdkScreenClass GdkScreenClass;
struct _GdkScreen
{
GObject parent_instance;
guint closed : 1;
};
struct _GdkScreenClass
......@@ -67,7 +69,6 @@ gint gdk_screen_get_width (GdkScreen *screen);
gint gdk_screen_get_height (GdkScreen *screen);
gint gdk_screen_get_width_mm (GdkScreen *screen);
gint gdk_screen_get_height_mm (GdkScreen *screen);
void gdk_screen_close (GdkScreen *screen);
GList * gdk_screen_list_visuals (GdkScreen *screen);
GList * gdk_screen_get_toplevel_windows (GdkScreen *screen);
......
......@@ -32,6 +32,17 @@ gdk_selection_send_notify (guint32 requestor,
target, property, time);
}
gint
gdk_text_property_to_text_list (GdkAtom encoding,
gint format,
const guchar *text,
gint length,
gchar ***list)
{
return gdk_text_property_to_text_list_for_display (gdk_display_get_default (),
encoding, format, text, length, list);
}
/**
* gdk_text_property_to_utf8_list:
* @encoding: an atom representing the encoding of the text
......@@ -58,6 +69,18 @@ gdk_text_property_to_utf8_list (GdkAtom encoding,
encoding, format, text, length, list);
}
gint
gdk_string_to_compound_text (const gchar *str,
GdkAtom *encoding,
gint *format,
guchar **ctext,
gint *length)
{
return gdk_string_to_compound_text_for_display (gdk_display_get_default (),
str, encoding, format,
ctext, length);
}
/**
* gdk_utf8_to_compound_text:
* @str: a UTF-8 string
......
......@@ -184,8 +184,10 @@ gdk_device_get_history (GdkDevice *device,
g_return_val_if_fail (events != NULL, FALSE);
g_return_val_if_fail (n_events != NULL, FALSE);
*n_events = 0;
*events = NULL;
if (n_events)
*n_events = 0;
if (events)
*events = NULL;
if (GDK_WINDOW_DESTROYED (window))
return FALSE;
......
......@@ -181,7 +181,7 @@ gdk_screen_get_height_mm (GdkScreen *screen)
}
void
gdk_set_sm_client_id (const gchar* sm_client_id)
gdk_display_set_sm_client_id (const gchar* sm_client_id)
{
g_warning("gdk_set_sm_client_id %s", sm_client_id ? sm_client_id : "NULL");
}
......
......@@ -560,11 +560,11 @@ gdk_selection_send_notify_for_display (GdkDisplay *display,
/* Simplistic implementations of text list and compound text functions */
gint
gdk_text_property_to_text_list (GdkAtom encoding,
gint format,
const guchar *text,
gint length,
gchar ***list)
gdk_text_property_to_text_list_for_display (GdkAtom encoding,
gint format,
const guchar *text,
gint length,
gchar ***list)
{
gchar *enc_name;
......@@ -592,11 +592,11 @@ gdk_free_text_list (gchar **list)
}
gint
gdk_string_to_compound_text (const gchar *str,
GdkAtom *encoding,
gint *format,
guchar **ctext,
gint *length)
gdk_string_to_compound_text_for_display (const gchar *str,
GdkAtom *encoding,
gint *format,
guchar **ctext,
gint *length)
{
GDK_NOTE (DND, g_print ("gdk_string_to_compound_text: %.20s\n", str));
......
......@@ -131,7 +131,8 @@ gdk_colormap_finalize (GObject *object)
gdk_colormap_remove (colormap);
XFreeColormap (GDK_SCREEN_XDISPLAY (private->screen), private->xcolormap);
if (!private->screen->closed)
XFreeColormap (GDK_SCREEN_XDISPLAY (private->screen), private->xcolormap);
if (private->hash)
g_hash_table_destroy (private->hash);
......@@ -278,7 +279,7 @@ gdk_colormap_sync_palette (GdkColormap *colormap)
nlookup++;
}
}
XQueryColors (GDK_SCREEN_XDISPLAY (private->screen),
private->xcolormap, xpalette, nlookup);
......@@ -334,9 +335,12 @@ gdk_colormap_sync (GdkColormap *colormap,
{
time_t current_time;
GdkColormapPrivateX11 *private = GDK_COLORMAP_PRIVATE_DATA (colormap);
g_return_if_fail (GDK_IS_COLORMAP (colormap));
if (private->screen->closed)
return;
current_time = time (NULL);
if (!force && ((current_time - private->last_sync_time) < MIN_SYNC_TIME))
return;
......@@ -434,6 +438,9 @@ gdk_colormap_change (GdkColormap *colormap,
private = GDK_COLORMAP_PRIVATE_DATA (colormap);
if (private->screen->closed)
return;
xdisplay = GDK_SCREEN_XDISPLAY (private->screen);
palette = g_new (XColor, ncolors);
......@@ -519,6 +526,9 @@ gdk_colors_alloc (GdkColormap *colormap,
private = GDK_COLORMAP_PRIVATE_DATA (colormap);
if (private->screen->closed)
return FALSE;
return_val = XAllocColorCells (GDK_SCREEN_XDISPLAY (private->screen),
private->xcolormap,contiguous, planes,
nplanes, pixels, npixels);
......@@ -577,7 +587,7 @@ gdk_colors_free (GdkColormap *colormap,
}
}
if (npixels)
if (npixels && !private->screen->closed)
XFreeColors (GDK_SCREEN_XDISPLAY (private->screen), private->xcolormap,
pixels, npixels, planes);
g_free (pixels);
......@@ -625,7 +635,7 @@ gdk_colormap_free_colors (GdkColormap *colormap,
}
}
if (npixels)
if (npixels && !private->screen->closed)
XFreeColors (GDK_SCREEN_XDISPLAY (private->screen), private->xcolormap,
pixels, npixels, 0);
......@@ -979,11 +989,14 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
gint nremaining = 0;
XColor xcolor;
g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
g_return_val_if_fail (colors != NULL, FALSE);
g_return_val_if_fail (GDK_IS_COLORMAP (colormap), ncolors);
g_return_val_if_fail (colors != NULL, ncolors);
private = GDK_COLORMAP_PRIVATE_DATA (colormap);
if (private->screen->closed)
return ncolors;
for (i=0; i<ncolors; i++)
{
success[i] = FALSE;
......@@ -1051,7 +1064,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
* #GdkImage contains image data in hardware format, a #GdkPixbuf
* contains image data in a canonical 24-bit RGB format.)
*
* This function is rarely useful, it's used for example to
* This function is rarely useful; it's used for example to
* implement the eyedropper feature in #GtkColorSelection.
*
**/
......@@ -1083,10 +1096,15 @@ gdk_colormap_query_color (GdkColormap *colormap,
break;
case GDK_VISUAL_STATIC_COLOR:
xcolor.pixel = pixel;
XQueryColor (GDK_SCREEN_XDISPLAY (private->screen), private->xcolormap, &xcolor);
result->red = xcolor.red;
result->green = xcolor.green;
result->blue = xcolor.blue;
if (!private->screen->closed)
{
XQueryColor (GDK_SCREEN_XDISPLAY (private->screen), private->xcolormap, &xcolor);
result->red = xcolor.red;
result->green = xcolor.green;
result->blue = xcolor.blue;
}
else
result->red = result->green = result->blue = 0;
break;