summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdk.c34
-rw-r--r--gdk/gdkdraw.c20
-rw-r--r--gdk/gdkgc.c28
-rw-r--r--gdk/gdkimage.c6
-rw-r--r--gdk/gdkinput.c16
-rw-r--r--gdk/gdkpixmap.c18
-rw-r--r--gdk/gdkproperty.c18
-rw-r--r--gdk/gdkselection.c10
-rw-r--r--gdk/gdkwindow.c215
-rw-r--r--gdk/x11/gdkimage-x11.c6
-rw-r--r--gdk/x11/gdkinput.c16
-rw-r--r--gdk/x11/gdkmain-x11.c34
-rw-r--r--gdk/x11/gdkpixmap-x11.c18
-rw-r--r--gdk/x11/gdkproperty-x11.c18
-rw-r--r--gdk/x11/gdkselection-x11.c10
-rw-r--r--gdk/x11/gdkwindow-x11.c215
16 files changed, 479 insertions, 203 deletions
diff --git a/gdk/gdk.c b/gdk/gdk.c
index f87f1a2af8..ad62f9bc68 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -1248,7 +1248,7 @@ gdk_pointer_grab (GdkWindow * window,
xwindow = window_private->xwindow;
- if (!confine_to)
+ if (!confine_to || confine_to_private->destroyed)
xconfine_to = None;
else
xconfine_to = confine_to_private->xwindow;
@@ -1277,14 +1277,17 @@ gdk_pointer_grab (GdkWindow * window,
return_val = Success;;
if (return_val == Success)
- return_val = XGrabPointer (window_private->xdisplay,
- xwindow,
- owner_events,
- xevent_mask,
- GrabModeAsync, GrabModeAsync,
- xconfine_to,
- xcursor,
- time);
+ if (!window_private->destroyed)
+ return_val = XGrabPointer (window_private->xdisplay,
+ xwindow,
+ owner_events,
+ xevent_mask,
+ GrabModeAsync, GrabModeAsync,
+ xconfine_to,
+ xcursor,
+ time);
+ else
+ return_val = AlreadyGrabbed;
if (return_val == GrabSuccess)
xgrab_window = window_private;
@@ -1371,11 +1374,14 @@ gdk_keyboard_grab (GdkWindow * window,
window_private = (GdkWindowPrivate*) window;
xwindow = window_private->xwindow;
- return XGrabKeyboard (window_private->xdisplay,
- xwindow,
- owner_events,
- GrabModeAsync, GrabModeAsync,
- time);
+ if (!window_private->destroyed)
+ return XGrabKeyboard (window_private->xdisplay,
+ xwindow,
+ owner_events,
+ GrabModeAsync, GrabModeAsync,
+ time);
+ else
+ return AlreadyGrabbed;
}
/*
diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c
index 47482f72e6..de23f6c4f5 100644
--- a/gdk/gdkdraw.c
+++ b/gdk/gdkdraw.c
@@ -34,6 +34,8 @@ gdk_draw_point (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
gc_private = (GdkGCPrivate*) gc;
XDrawPoint (drawable_private->xdisplay, drawable_private->xwindow,
@@ -55,6 +57,8 @@ gdk_draw_line (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
gc_private = (GdkGCPrivate*) gc;
XDrawLine (drawable_private->xdisplay, drawable_private->xwindow,
@@ -77,6 +81,8 @@ gdk_draw_rectangle (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
@@ -110,6 +116,8 @@ gdk_draw_arc (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
@@ -139,6 +147,8 @@ gdk_draw_polygon (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
gc_private = (GdkGCPrivate*) gc;
if (filled)
@@ -183,6 +193,8 @@ gdk_draw_string (GdkDrawable *drawable,
g_return_if_fail (string != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
gc_private = (GdkGCPrivate*) gc;
font_private = (GdkFontPrivate*) font;
@@ -237,6 +249,8 @@ gdk_draw_text (GdkDrawable *drawable,
g_return_if_fail (text != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
gc_private = (GdkGCPrivate*) gc;
font_private = (GdkFontPrivate*) font;
@@ -286,6 +300,8 @@ gdk_draw_pixmap (GdkDrawable *drawable,
drawable_private = (GdkWindowPrivate*) drawable;
src_private = (GdkWindowPrivate*) src;
+ if (drawable_private->destroyed || src_private->destroyed)
+ return;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
@@ -346,6 +362,8 @@ gdk_draw_points (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
gc_private = (GdkGCPrivate*) gc;
XDrawPoints (drawable_private->xdisplay,
@@ -373,6 +391,8 @@ gdk_draw_segments (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
gc_private = (GdkGCPrivate*) gc;
XDrawSegments (drawable_private->xdisplay,
diff --git a/gdk/gdkgc.c b/gdk/gdkgc.c
index 826b0829be..d007fd6e6f 100644
--- a/gdk/gdkgc.c
+++ b/gdk/gdkgc.c
@@ -32,17 +32,24 @@ gdk_gc_new_with_values (GdkWindow *window,
GdkGCValues *values,
GdkGCValuesMask values_mask)
{
+ GdkWindowPrivate *window_private;
GdkGC *gc;
GdkGCPrivate *private;
Window xwindow;
XGCValues xvalues;
unsigned long xvalues_mask;
+ g_return_val_if_fail (window != NULL, NULL);
+
+ window_private = (GdkWindowPrivate*) window;
+ if (window_private->destroyed)
+ return NULL;
+
private = g_new (GdkGCPrivate, 1);
gc = (GdkGC*) private;
- xwindow = ((GdkWindowPrivate*) window)->xwindow;
- private->xdisplay = ((GdkWindowPrivate*) window)->xdisplay;
+ xwindow = window_private->xwindow;
+ private->xdisplay = window_private->xdisplay;
xvalues.function = GXcopy;
xvalues.fill_style = FillSolid;
@@ -512,15 +519,22 @@ gdk_gc_set_clip_mask (GdkGC *gc,
{
GdkGCPrivate *private;
Pixmap xmask;
-
+
g_return_if_fail (gc != NULL);
-
- private = (GdkGCPrivate*) gc;
-
+
if (mask)
- xmask = ((GdkWindowPrivate*) mask)->xwindow;
+ {
+ GdkWindowPrivate *mask_private;
+
+ mask_private = (GdkWindowPrivate*) mask;
+ if (mask_private->destroyed)
+ return;
+ xmask = mask_private->xwindow;
+ }
else
xmask = None;
+
+ private = (GdkGCPrivate*) gc;
XSetClipMask (private->xdisplay, private->xgc, xmask);
}
diff --git a/gdk/gdkimage.c b/gdk/gdkimage.c
index bcda3119fc..0e4caab797 100644
--- a/gdk/gdkimage.c
+++ b/gdk/gdkimage.c
@@ -330,6 +330,8 @@ gdk_image_get (GdkWindow *window,
g_return_val_if_fail (window != NULL, NULL);
win_private = (GdkWindowPrivate *) window;
+ if (win_private->destroyed)
+ return NULL;
private = g_new (GdkImagePrivate, 1);
image = (GdkImage*) private;
@@ -447,6 +449,8 @@ gdk_image_put_normal (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
image_private = (GdkImagePrivate*) image;
gc_private = (GdkGCPrivate*) gc;
@@ -478,6 +482,8 @@ gdk_image_put_shared (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
image_private = (GdkImagePrivate*) image;
gc_private = (GdkGCPrivate*) gc;
diff --git a/gdk/gdkinput.c b/gdk/gdkinput.c
index 2efee8606a..8a66b8365f 100644
--- a/gdk/gdkinput.c
+++ b/gdk/gdkinput.c
@@ -118,14 +118,20 @@ gdk_input_motion_events (GdkWindow *window,
guint32 stop,
gint *nevents_return)
{
+ GdkWindowPrivate *window_private;
XTimeCoord *xcoords;
GdkTimeCoord *coords;
int i;
+ g_return_val_if_fail (window != NULL, NULL);
+ window_private = (GdkWindowPrivate *) window;
+ if (window_private->destroyed)
+ return NULL;
+
if (deviceid == GDK_CORE_POINTER)
{
xcoords = XGetMotionEvents (gdk_display,
- ((GdkWindowPrivate *)window)->xwindow,
+ window_private->xwindow,
start, stop, nevents_return);
if (xcoords)
{
@@ -204,10 +210,14 @@ void
gdk_input_set_extension_events (GdkWindow *window, gint mask,
GdkExtensionMode mode)
{
+ GdkWindowPrivate *window_private;
GList *tmp_list;
GdkInputWindow *iw;
g_return_if_fail (window != NULL);
+ window_private = (GdkWindowPrivate*) window;
+ if (window_private->destroyed)
+ return;
if (mode == GDK_EXTENSION_EVENTS_NONE)
mask = 0;
@@ -224,7 +234,7 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask,
iw->grabbed = FALSE;
gdk_input_windows = g_list_append(gdk_input_windows,iw);
- ((GdkWindowPrivate *)window)->extension_events = mask;
+ window_private->extension_events = mask;
/* Add enter window events to the event mask */
/* FIXME, this is not needed for XINPUT_NONE */
@@ -241,7 +251,7 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask,
g_free(iw);
}
- ((GdkWindowPrivate *)window)->extension_events = 0;
+ window_private->extension_events = 0;
}
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
diff --git a/gdk/gdkpixmap.c b/gdk/gdkpixmap.c
index e0f4d580b2..48b072b91c 100644
--- a/gdk/gdkpixmap.c
+++ b/gdk/gdkpixmap.c
@@ -46,14 +46,16 @@ gdk_pixmap_new (GdkWindow *window,
if (!window)
window = (GdkWindow*) &gdk_root_parent;
+ window_private = (GdkWindowPrivate*) window;
+ if (window_private->destroyed)
+ return NULL;
+
if (depth == -1)
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
private = g_new (GdkWindowPrivate, 1);
pixmap = (GdkPixmap*) private;
- window_private = (GdkWindowPrivate*) window;
-
private->xdisplay = window_private->xdisplay;
private->window_type = GDK_WINDOW_PIXMAP;
private->xwindow = XCreatePixmap (private->xdisplay, window_private->xwindow,
@@ -87,11 +89,13 @@ gdk_bitmap_create_from_data (GdkWindow *window,
if (!window)
window = (GdkWindow*) &gdk_root_parent;
+ window_private = (GdkWindowPrivate*) window;
+ if (window_private->destroyed)
+ return NULL;
+
private = g_new (GdkWindowPrivate, 1);
pixmap = (GdkPixmap*) private;
- window_private = (GdkWindowPrivate*) window;
-
private->parent = NULL;
private->xdisplay = window_private->xdisplay;
private->window_type = GDK_WINDOW_PIXMAP;
@@ -132,14 +136,16 @@ gdk_pixmap_create_from_data (GdkWindow *window,
if (!window)
window = (GdkWindow*) &gdk_root_parent;
+ window_private = (GdkWindowPrivate*) window;
+ if (window_private->destroyed)
+ return NULL;
+
if (depth == -1)
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
private = g_new (GdkWindowPrivate, 1);
pixmap = (GdkPixmap*) private;
- window_private = (GdkWindowPrivate*) window;
-
private->parent = NULL;
private->xdisplay = window_private->xdisplay;
private->window_type = GDK_WINDOW_PIXMAP;
diff --git a/gdk/gdkproperty.c b/gdk/gdkproperty.c
index c18fd70379..8eaba3aae9 100644
--- a/gdk/gdkproperty.c
+++ b/gdk/gdkproperty.c
@@ -67,7 +67,6 @@ gdk_property_get (GdkWindow *window,
gint *actual_length,
guchar **data)
{
- GdkWindowPrivate *private;
Display *xdisplay;
Window xwindow;
Atom ret_prop_type;
@@ -79,7 +78,12 @@ gdk_property_get (GdkWindow *window,
if (window)
{
+ GdkWindowPrivate *private;
+
private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return FALSE;
+
xdisplay = private->xdisplay;
xwindow = private->xwindow;
}
@@ -156,13 +160,17 @@ gdk_property_change (GdkWindow *window,
guchar *data,
gint nelements)
{
- GdkWindowPrivate *private;
Display *xdisplay;
Window xwindow;
if (window)
{
+ GdkWindowPrivate *private;
+
private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
+
xdisplay = private->xdisplay;
xwindow = private->xwindow;
}
@@ -180,13 +188,17 @@ void
gdk_property_delete (GdkWindow *window,
GdkAtom property)
{
- GdkWindowPrivate *private;
Display *xdisplay;
Window xwindow;
if (window)
{
+ GdkWindowPrivate *private;
+
private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
+
xdisplay = private->xdisplay;
xwindow = private->xwindow;
}
diff --git a/gdk/gdkselection.c b/gdk/gdkselection.c
index f1fb5c6109..b8f1c9ff60 100644
--- a/gdk/gdkselection.c
+++ b/gdk/gdkselection.c
@@ -29,13 +29,17 @@ gdk_selection_owner_set (GdkWindow *owner,
guint32 time,
gint send_event)
{
- GdkWindowPrivate *private;
Display *xdisplay;
Window xwindow;
if (owner)
{
+ GdkWindowPrivate *private;
+
private = (GdkWindowPrivate*) owner;
+ if (private->destroyed)
+ return FALSE;
+
xdisplay = private->xdisplay;
xwindow = private->xwindow;
}
@@ -73,6 +77,8 @@ gdk_selection_convert (GdkWindow *requestor,
g_return_if_fail (requestor != NULL);
private = (GdkWindowPrivate*) requestor;
+ if (private->destroyed)
+ return;
XConvertSelection (private->xdisplay, selection, target,
gdk_selection_property, private->xwindow, time);
@@ -99,6 +105,8 @@ gdk_selection_property_get (GdkWindow *requestor,
moderate length, to avoid two round trips to the server */
private = (GdkWindowPrivate*) requestor;
+ if (private->destroyed)
+ return 0;
XGetWindowProperty (private->xdisplay, private->xwindow,
gdk_selection_property, 0, 0, False,
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index e13ce6df04..35e09cfc5a 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -103,6 +103,9 @@ gdk_window_new (GdkWindow *parent,
parent = (GdkWindow*) &gdk_root_parent;
parent_private = (GdkWindowPrivate*) parent;
+ if (parent_private->destroyed)
+ return NULL;
+
xparent = parent_private->xwindow;
parent_display = parent_private->xdisplay;
@@ -508,12 +511,15 @@ gdk_window_move (GdkWindow *window,
g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
- XMoveWindow (private->xdisplay, private->xwindow, x, y);
-
- if (private->window_type == GDK_WINDOW_CHILD)
+ if (!private->destroyed)
{
- private->x = x;
- private->y = y;
+ XMoveWindow (private->xdisplay, private->xwindow, x, y);
+
+ if (private->window_type == GDK_WINDOW_CHILD)
+ {
+ private->x = x;
+ private->y = y;
+ }
}
}
@@ -566,15 +572,17 @@ gdk_window_move_resize (GdkWindow *window,
height = 1;
private = (GdkWindowPrivate*) window;
- XMoveResizeWindow (private->xdisplay, private->xwindow, x, y, width, height);
-
- if (!private->destroyed &&
- (private->window_type == GDK_WINDOW_CHILD))
+ if (!private->destroyed)
{
- private->x = x;
- private->y = y;
- private->width = width;
- private->height = height;
+ XMoveResizeWindow (private->xdisplay, private->xwindow, x, y, width, height);
+
+ if (private->window_type == GDK_WINDOW_CHILD)
+ {
+ private->x = x;
+ private->y = y;
+ private->width = width;
+ private->height = height;
+ }
}
}
@@ -595,10 +603,11 @@ gdk_window_reparent (GdkWindow *window,
window_private = (GdkWindowPrivate*) window;
parent_private = (GdkWindowPrivate*) new_parent;
- XReparentWindow (window_private->xdisplay,
- window_private->xwindow,
- parent_private->xwindow,
- x, y);
+ if (!window_private->destroyed && !parent_private->destroyed)
+ XReparentWindow (window_private->xdisplay,
+ window_private->xwindow,
+ parent_private->xwindow,
+ x, y);
}
void
@@ -610,7 +619,8 @@ gdk_window_clear (GdkWindow *window)
private = (GdkWindowPrivate*) window;
- XClearWindow (private->xdisplay, private->xwindow);
+ if (!private->destroyed)
+ XClearWindow (private->xdisplay, private->xwindow);
}
void
@@ -621,11 +631,11 @@ gdk_window_clear_area (GdkWindow *window,
gint height)
{
GdkWindowPrivate *private;
-
+
g_return_if_fail (window != NULL);
-
+
private = (GdkWindowPrivate*) window;
-
+
if (!private->destroyed)
XClearArea (private->xdisplay, private->xwindow,
x, y, width, height, False);
@@ -641,9 +651,9 @@ gdk_window_clear_area_e (GdkWindow *window,
GdkWindowPrivate *private;
g_return_if_fail (window != NULL);
-
+
private = (GdkWindowPrivate*) window;
-
+
if (!private->destroyed)
XClearArea (private->xdisplay, private->xwindow,
x, y, width, height, True);
@@ -735,6 +745,9 @@ gdk_window_set_hints (GdkWindow *window,
g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
+
size_hints.flags = 0;
if (flags & GDK_HINT_POS)
@@ -771,8 +784,9 @@ gdk_window_set_title (GdkWindow *window,
g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
- XmbSetWMProperties (private->xdisplay, private->xwindow,
- title, title, NULL, 0, NULL, NULL, NULL);
+ if (!private->destroyed)
+ XmbSetWMProperties (private->xdisplay, private->xwindow,
+ title, title, NULL, 0, NULL, NULL, NULL);
}
void
@@ -784,7 +798,8 @@ gdk_window_set_background (GdkWindow *window,
g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
- XSetWindowBackground (private->xdisplay, private->xwindow, color->pixel);
+ if (!private->destroyed)
+ XSetWindowBackground (private->xdisplay, private->xwindow, color->pixel);
}
void
@@ -809,7 +824,8 @@ gdk_window_set_back_pixmap (GdkWindow *window,
if (parent_relative)
xpixmap = ParentRelative;
- XSetWindowBackgroundPixmap (window_private->xdisplay, window_private->xwindow, xpixmap);
+ if (!window_private->destroyed)
+ XSetWindowBackgroundPixmap (window_private->xdisplay, window_private->xwindow, xpixmap);
}
void
@@ -830,7 +846,8 @@ gdk_window_set_cursor (GdkWindow *window,
else
xcursor = cursor_private->xcursor;
- XDefineCursor (window_private->xdisplay, window_private->xwindow, xcursor);
+ if (!window_private->destroyed)
+ XDefineCursor (window_private->xdisplay, window_private->xwindow, xcursor);
}
void
@@ -846,12 +863,15 @@ gdk_window_set_colormap (GdkWindow *window,
window_private = (GdkWindowPrivate*) window;
colormap_private = (GdkColormapPrivate*) colormap;
- XSetWindowColormap (window_private->xdisplay,
- window_private->xwindow,
- colormap_private->xcolormap);
-
- if (window_private->window_type != GDK_WINDOW_TOPLEVEL)
- gdk_window_add_colormap_windows (window);
+ if (!window_private->destroyed)
+ {
+ XSetWindowColormap (window_private->xdisplay,
+ window_private->xwindow,
+ colormap_private->xcolormap);
+
+ if (window_private->window_type != GDK_WINDOW_TOPLEVEL)
+ gdk_window_add_colormap_windows (window);
+ }
}
void
@@ -885,19 +905,22 @@ gdk_window_get_geometry (GdkWindow *window,
window_private = (GdkWindowPrivate*) window;
- XGetGeometry (window_private->xdisplay, window_private->xwindow,
- &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
-
- if (x)
- *x = tx;
- if (y)
- *y = ty;
- if (width)
- *width = twidth;
- if (height)
- *height = theight;
- if (depth)
- *depth = tdepth;
+ if (!window_private->destroyed)
+ {
+ XGetGeometry (window_private->xdisplay, window_private->xwindow,
+ &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
+
+ if (x)
+ *x = tx;
+ if (y)
+ *y = ty;
+ if (width)
+ *width = twidth;
+ if (height)
+ *height = theight;
+ if (depth)
+ *depth = tdepth;
+ }
}
void
@@ -947,7 +970,7 @@ gdk_window_get_visual (GdkWindow *window)
while (window_private && (window_private->window_type == GDK_WINDOW_PIXMAP))
window_private = (GdkWindowPrivate*) window_private->parent;
- if (window_private)
+ if (window_private && !window_private->destroyed)
{
XGetWindowAttributes (window_private->xdisplay,
window_private->xwindow,
@@ -969,11 +992,16 @@ gdk_window_get_colormap (GdkWindow *window)
window_private = (GdkWindowPrivate*) window;
- XGetWindowAttributes (window_private->xdisplay,
- window_private->xwindow,
- &window_attributes);
+ if (!window_private->destroyed)
+ {
+ XGetWindowAttributes (window_private->xdisplay,
+ window_private->xwindow,
+ &window_attributes);
+
+ return gdk_colormap_lookup (window_attributes.colormap);
+ }
- return gdk_colormap_lookup (window_attributes.colormap);
+ return NULL;
}
GdkWindowType
@@ -1001,17 +1029,22 @@ gdk_window_get_origin (GdkWindow *window,
private = (GdkWindowPrivate*) window;
- return_val = XTranslateCoordinates (private->xdisplay,
- private->xwindow,
- gdk_root_window,
- 0, 0, &tx, &ty,
- &child);
-
- if (x)
- *x = tx;
- if (y)
- *y = ty;
-
+ if (!private->destroyed)
+ {
+ return_val = XTranslateCoordinates (private->xdisplay,
+ private->xwindow,
+ gdk_root_window,
+ 0, 0, &tx, &ty,
+ &child);
+
+ if (x)
+ *x = tx;
+ if (y)
+ *y = ty;
+ }
+ else
+ return_val = 0;
+
return return_val;
}
@@ -1035,17 +1068,18 @@ gdk_window_get_pointer (GdkWindow *window,
private = (GdkWindowPrivate*) window;
return_val = NULL;
- if (XQueryPointer (private->xdisplay, private->xwindow, &root, &child,
+ if (!private->destroyed &&
+ XQueryPointer (private->xdisplay, private->xwindow, &root, &child,
&rootx, &rooty, &winx, &winy, &xmask))
{
if (x) *x = winx;
if (y) *y = winy;
if (mask) *mask = xmask;
-
+
if (child)
return_val = gdk_window_lookup (child);
}
-
+
return return_val;
}
@@ -1090,6 +1124,8 @@ gdk_window_get_children (GdkWindow *window)
g_return_val_if_fail (window != NULL, NULL);
private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return NULL;
XQueryTree (private->xdisplay, private->xwindow,
&root, &parent, &xchildren, &nchildren);
@@ -1114,11 +1150,18 @@ gdk_window_get_children (GdkWindow *window)
GdkEventMask
gdk_window_get_events (GdkWindow *window)
{
+ GdkWindowPrivate *private;
XWindowAttributes attrs;
GdkEventMask event_mask;
int i;
- XGetWindowAttributes (gdk_display, ((GdkWindowPrivate *)window)->xwindow,
+ g_return_val_if_fail (window != NULL, 0);
+
+ private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return 0;
+
+ XGetWindowAttributes (gdk_display, private->xwindow,
&attrs);
event_mask = 0;
@@ -1135,9 +1178,16 @@ void
gdk_window_set_events (GdkWindow *window,
GdkEventMask event_mask)
{
+ GdkWindowPrivate *private;
long xevent_mask;
int i;
+ g_return_if_fail (window != NULL);
+
+ private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
+
xevent_mask = StructureNotifyMask;
for (i = 0; i < nevent_masks; i++)
{
@@ -1145,7 +1195,7 @@ gdk_window_set_events (GdkWindow *window,
xevent_mask |= event_mask_table[i];
}
- XSelectInput (gdk_display, ((GdkWindowPrivate *)window)->xwindow,
+ XSelectInput (gdk_display, private->xwindow,
xevent_mask);
}
@@ -1164,6 +1214,8 @@ gdk_window_add_colormap_windows (GdkWindow *window)
toplevel = gdk_window_get_toplevel (window);
toplevel_private = (GdkWindowPrivate*) toplevel;
window_private = (GdkWindowPrivate*) window;
+ if (window_private->destroyed)
+ return;
if (!XGetWMColormapWindows (toplevel_private->xdisplay,
toplevel_private->xwindow,
@@ -1211,6 +1263,8 @@ gdk_window_shape_combine_mask (GdkWindow *window,
window_private = (GdkWindowPrivate*) window;
pixmap_private = (GdkWindowPrivate*) mask;
+ if (window_private->destroyed)
+ return;
XShapeCombineMask (window_private->xdisplay,
window_private->xwindow,
@@ -1228,6 +1282,8 @@ gdk_dnd_drag_addwindow (GdkWindow *window)
g_return_if_fail (window != NULL);
window_private = (GdkWindowPrivate *) window;
+ if (window_private->destroyed)
+ return;
if (window_private->dnd_drag_enabled == 1 && gdk_dnd.drag_really == 0)
{
@@ -1253,6 +1309,8 @@ gdk_window_dnd_drag_set (GdkWindow *window,
g_return_if_fail (window != NULL);
window_private = (GdkWindowPrivate *) window;
+ if (window_private->destroyed)
+ return;
window_private->dnd_drag_enabled = drag_enable ? 1 : 0;
@@ -1309,8 +1367,9 @@ gdk_window_dnd_drop_set (GdkWindow *window,
int i;
g_return_if_fail (window != NULL);
-
window_private = (GdkWindowPrivate *) window;
+ if (window_private->destroyed)
+ return;
window_private->dnd_drop_enabled = drop_enable ? 1 : 0;
if (drop_enable)
@@ -1357,6 +1416,8 @@ gdk_window_dnd_data_set (GdkWindow *window,
window_private = (GdkWindowPrivate *) window;
g_return_if_fail (window_private->dnd_drag_accepted != 0);
+ if (window_private->destroyed)
+ return;
/* We set the property on our window... */
gdk_property_change (window, window_private->dnd_drag_data_type,
@@ -1405,7 +1466,11 @@ gdk_window_add_filter (GdkWindow *window,
GList *tmp_list;
GdkEventFilter *filter;
- private = (GdkWindowPrivate *)window;
+ g_return_if_fail (window != NULL);
+
+ private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
tmp_list = private->filters;
while (tmp_list)
@@ -1432,7 +1497,8 @@ gdk_window_remove_filter (GdkWindow *window,
GList *tmp_list;
GdkEventFilter *filter;
- private = (GdkWindowPrivate *)window;
+ g_return_if_fail (window != NULL);
+ private = (GdkWindowPrivate*) window;
tmp_list = private->filters;
while (tmp_list)
@@ -1455,7 +1521,14 @@ void
gdk_window_set_override_redirect(GdkWindow *window,
gboolean override_redirect)
{
+ GdkWindowPrivate *private;
XSetWindowAttributes attr;
+
+ g_return_if_fail (window != NULL);
+ private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
+
attr.override_redirect = (override_redirect == FALSE)?False:True;
XChangeWindowAttributes(gdk_display,
((GdkWindowPrivate *)window)->xwindow,
diff --git a/gdk/x11/gdkimage-x11.c b/gdk/x11/gdkimage-x11.c
index bcda3119fc..0e4caab797 100644
--- a/gdk/x11/gdkimage-x11.c
+++ b/gdk/x11/gdkimage-x11.c
@@ -330,6 +330,8 @@ gdk_image_get (GdkWindow *window,
g_return_val_if_fail (window != NULL, NULL);
win_private = (GdkWindowPrivate *) window;
+ if (win_private->destroyed)
+ return NULL;
private = g_new (GdkImagePrivate, 1);
image = (GdkImage*) private;
@@ -447,6 +449,8 @@ gdk_image_put_normal (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
image_private = (GdkImagePrivate*) image;
gc_private = (GdkGCPrivate*) gc;
@@ -478,6 +482,8 @@ gdk_image_put_shared (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
image_private = (GdkImagePrivate*) image;
gc_private = (GdkGCPrivate*) gc;
diff --git a/gdk/x11/gdkinput.c b/gdk/x11/gdkinput.c
index 2efee8606a..8a66b8365f 100644
--- a/gdk/x11/gdkinput.c
+++ b/gdk/x11/gdkinput.c
@@ -118,14 +118,20 @@ gdk_input_motion_events (GdkWindow *window,
guint32 stop,
gint *nevents_return)
{
+ GdkWindowPrivate *window_private;
XTimeCoord *xcoords;
GdkTimeCoord *coords;
int i;
+ g_return_val_if_fail (window != NULL, NULL);
+ window_private = (GdkWindowPrivate *) window;
+ if (window_private->destroyed)
+ return NULL;
+
if (deviceid == GDK_CORE_POINTER)
{
xcoords = XGetMotionEvents (gdk_display,
- ((GdkWindowPrivate *)window)->xwindow,
+ window_private->xwindow,
start, stop, nevents_return);
if (xcoords)
{
@@ -204,10 +210,14 @@ void
gdk_input_set_extension_events (GdkWindow *window, gint mask,
GdkExtensionMode mode)
{
+ GdkWindowPrivate *window_private;
GList *tmp_list;
GdkInputWindow *iw;
g_return_if_fail (window != NULL);
+ window_private = (GdkWindowPrivate*) window;
+ if (window_private->destroyed)
+ return;
if (mode == GDK_EXTENSION_EVENTS_NONE)
mask = 0;
@@ -224,7 +234,7 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask,
iw->grabbed = FALSE;
gdk_input_windows = g_list_append(gdk_input_windows,iw);
- ((GdkWindowPrivate *)window)->extension_events = mask;
+ window_private->extension_events = mask;
/* Add enter window events to the event mask */
/* FIXME, this is not needed for XINPUT_NONE */
@@ -241,7 +251,7 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask,
g_free(iw);
}
- ((GdkWindowPrivate *)window)->extension_events = 0;
+ window_private->extension_events = 0;
}
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
index f87f1a2af8..ad62f9bc68 100644
--- a/gdk/x11/gdkmain-x11.c
+++ b/gdk/x11/gdkmain-x11.c
@@ -1248,7 +1248,7 @@ gdk_pointer_grab (GdkWindow * window,
xwindow = window_private->xwindow;
- if (!confine_to)
+ if (!confine_to || confine_to_private->destroyed)
xconfine_to = None;
else
xconfine_to = confine_to_private->xwindow;
@@ -1277,14 +1277,17 @@ gdk_pointer_grab (GdkWindow * window,
return_val = Success;;
if (return_val == Success)
- return_val = XGrabPointer (window_private->xdisplay,
- xwindow,
- owner_events,
- xevent_mask,
- GrabModeAsync, GrabModeAsync,
- xconfine_to,
- xcursor,
- time);
+ if (!window_private->destroyed)
+ return_val = XGrabPointer (window_private->xdisplay,
+ xwindow,
+ owner_events,
+ xevent_mask,
+ GrabModeAsync, GrabModeAsync,
+ xconfine_to,
+ xcursor,
+ time);
+ else
+ return_val = AlreadyGrabbed;
if (return_val == GrabSuccess)
xgrab_window = window_private;
@@ -1371,11 +1374,14 @@ gdk_keyboard_grab (GdkWindow * window,
window_private = (GdkWindowPrivate*) window;
xwindow = window_private->xwindow;
- return XGrabKeyboard (window_private->xdisplay,
- xwindow,
- owner_events,
- GrabModeAsync, GrabModeAsync,
- time);
+ if (!window_private->destroyed)
+ return XGrabKeyboard (window_private->xdisplay,
+ xwindow,
+ owner_events,
+ GrabModeAsync, GrabModeAsync,
+ time);
+ else
+ return AlreadyGrabbed;
}
/*
diff --git a/gdk/x11/gdkpixmap-x11.c b/gdk/x11/gdkpixmap-x11.c
index e0f4d580b2..48b072b91c 100644
--- a/gdk/x11/gdkpixmap-x11.c
+++ b/gdk/x11/gdkpixmap-x11.c
@@ -46,14 +46,16 @@ gdk_pixmap_new (GdkWindow *window,
if (!window)
window = (GdkWindow*) &gdk_root_parent;
+ window_private = (GdkWindowPrivate*) window;
+ if (window_private->destroyed)
+ return NULL;
+
if (depth == -1)
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
private = g_new (GdkWindowPrivate, 1);
pixmap = (GdkPixmap*) private;
- window_private = (GdkWindowPrivate*) window;
-
private->xdisplay = window_private->xdisplay;
private->window_type = GDK_WINDOW_PIXMAP;
private->xwindow = XCreatePixmap (private->xdisplay, window_private->xwindow,
@@ -87,11 +89,13 @@ gdk_bitmap_create_from_data (GdkWindow *window,
if (!window)
window = (GdkWindow*) &gdk_root_parent;
+ window_private = (GdkWindowPrivate*) window;
+ if (window_private->destroyed)
+ return NULL;
+
private = g_new (GdkWindowPrivate, 1);
pixmap = (GdkPixmap*) private;
- window_private = (GdkWindowPrivate*) window;
-
private->parent = NULL;
private->xdisplay = window_private->xdisplay;
private->window_type = GDK_WINDOW_PIXMAP;
@@ -132,14 +136,16 @@ gdk_pixmap_create_from_data (GdkWindow *window,
if (!window)
window = (GdkWindow*) &gdk_root_parent;
+ window_private = (GdkWindowPrivate*) window;
+ if (window_private->destroyed)
+ return NULL;
+
if (depth == -1)
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
private = g_new (GdkWindowPrivate, 1);
pixmap = (GdkPixmap*) private;
- window_private = (GdkWindowPrivate*) window;
-
private->parent = NULL;
private->xdisplay = window_private->xdisplay;
private->window_type = GDK_WINDOW_PIXMAP;
diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c
index c18fd70379..8eaba3aae9 100644
--- a/gdk/x11/gdkproperty-x11.c
+++ b/gdk/x11/gdkproperty-x11.c
@@ -67,7 +67,6 @@ gdk_property_get (GdkWindow *window,
gint *actual_length,
guchar **data)
{
- GdkWindowPrivate *private;
Display *xdisplay;
Window xwindow;
Atom ret_prop_type;
@@ -79,7 +78,12 @@ gdk_property_get (GdkWindow *window,
if (window)
{
+ GdkWindowPrivate *private;
+
private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return FALSE;
+
xdisplay = private->xdisplay;
xwindow = private->xwindow;
}
@@ -156,13 +160,17 @@ gdk_property_change (GdkWindow *window,
guchar *data,
gint nelements)
{
- GdkWindowPrivate *private;
Display *xdisplay;
Window xwindow;
if (window)
{
+ GdkWindowPrivate *private;
+
private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
+
xdisplay = private->xdisplay;
xwindow = private->xwindow;
}
@@ -180,13 +188,17 @@ void
gdk_property_delete (GdkWindow *window,
GdkAtom property)
{
- GdkWindowPrivate *private;
Display *xdisplay;
Window xwindow;
if (window)
{
+ GdkWindowPrivate *private;
+
private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
+
xdisplay = private->xdisplay;
xwindow = private->xwindow;
}
diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c
index f1fb5c6109..b8f1c9ff60 100644
--- a/gdk/x11/gdkselection-x11.c
+++ b/gdk/x11/gdkselection-x11.c
@@ -29,13 +29,17 @@ gdk_selection_owner_set (GdkWindow *owner,
guint32 time,
gint send_event)
{
- GdkWindowPrivate *private;
Display *xdisplay;
Window xwindow;
if (owner)
{
+ GdkWindowPrivate *private;
+
private = (GdkWindowPrivate*) owner;
+ if (private->destroyed)
+ return FALSE;
+
xdisplay = private->xdisplay;
xwindow = private->xwindow;
}
@@ -73,6 +77,8 @@ gdk_selection_convert (GdkWindow *requestor,
g_return_if_fail (requestor != NULL);
private = (GdkWindowPrivate*) requestor;
+ if (private->destroyed)
+ return;
XConvertSelection (private->xdisplay, selection, target,
gdk_selection_property, private->xwindow, time);
@@ -99,6 +105,8 @@ gdk_selection_property_get (GdkWindow *requestor,
moderate length, to avoid two round trips to the server */
private = (GdkWindowPrivate*) requestor;
+ if (private->destroyed)
+ return 0;
XGetWindowProperty (private->xdisplay, private->xwindow,
gdk_selection_property, 0, 0, False,
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index e13ce6df04..35e09cfc5a 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -103,6 +103,9 @@ gdk_window_new (GdkWindow *parent,
parent = (GdkWindow*) &gdk_root_parent;
parent_private = (GdkWindowPrivate*) parent;
+ if (parent_private->destroyed)
+ return NULL;
+
xparent = parent_private->xwindow;
parent_display = parent_private->xdisplay;
@@ -508,12 +511,15 @@ gdk_window_move (GdkWindow *window,
g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
- XMoveWindow (private->xdisplay, private->xwindow, x, y);
-
- if (private->window_type == GDK_WINDOW_CHILD)
+ if (!private->destroyed)
{
- private->x = x;
- private->y = y;
+ XMoveWindow (private->xdisplay, private->xwindow, x, y);
+
+ if (private->window_type == GDK_WINDOW_CHILD)
+ {
+ private->x = x;
+ private->y = y;
+ }
}
}
@@ -566,15 +572,17 @@ gdk_window_move_resize (GdkWindow *window,
height = 1;
private = (GdkWindowPrivate*) window;
- XMoveResizeWindow (private->xdisplay, private->xwindow, x, y, width, height);
-
- if (!private->destroyed &&
- (private->window_type == GDK_WINDOW_CHILD))
+ if (!private->destroyed)
{
- private->x = x;
- private->y = y;
- private->width = width;
- private->height = height;
+ XMoveResizeWindow (private->xdisplay, private->xwindow, x, y, width, height);
+
+ if (private->window_type == GDK_WINDOW_CHILD)
+ {
+ private->x = x;
+ private->y = y;
+ private->width = width;
+ private->height = height;
+ }
}
}
@@ -595,10 +603,11 @@ gdk_window_reparent (GdkWindow *window,
window_private = (GdkWindowPrivate*) window;
parent_private = (GdkWindowPrivate*) new_parent;
- XReparentWindow (window_private->xdisplay,
- window_private->xwindow,
- parent_private->xwindow,
- x, y);
+ if (!window_private->destroyed && !parent_private->destroyed)
+ XReparentWindow (window_private->xdisplay,
+ window_private->xwindow,
+ parent_private->xwindow,
+ x, y);
}
void
@@ -610,7 +619,8 @@ gdk_window_clear (GdkWindow *window)
private = (GdkWindowPrivate*) window;
- XClearWindow (private->xdisplay, private->xwindow);
+ if (!private->destroyed)
+ XClearWindow (private->xdisplay, private->xwindow);
}
void
@@ -621,11 +631,11 @@ gdk_window_clear_area (GdkWindow *window,
gint height)
{
GdkWindowPrivate *private;
-
+
g_return_if_fail (window != NULL);
-
+
private = (GdkWindowPrivate*) window;
-
+
if (!private->destroyed)
XClearArea (private->xdisplay, private->xwindow,
x, y, width, height, False);
@@ -641,9 +651,9 @@ gdk_window_clear_area_e (GdkWindow *window,
GdkWindowPrivate *private;
g_return_if_fail (window != NULL);
-
+
private = (GdkWindowPrivate*) window;
-
+
if (!private->destroyed)
XClearArea (private->xdisplay, private->xwindow,
x, y, width, height, True);
@@ -735,6 +745,9 @@ gdk_window_set_hints (GdkWindow *window,
g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
+
size_hints.flags = 0;
if (flags & GDK_HINT_POS)
@@ -771,8 +784,9 @@ gdk_window_set_title (GdkWindow *window,
g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
- XmbSetWMProperties (private->xdisplay, private->xwindow,
- title, title, NULL, 0, NULL, NULL, NULL);
+ if (!private->destroyed)
+ XmbSetWMProperties (private->xdisplay, private->xwindow,
+ title, title, NULL, 0, NULL, NULL, NULL);
}
void
@@ -784,7 +798,8 @@ gdk_window_set_background (GdkWindow *window,
g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
- XSetWindowBackground (private->xdisplay, private->xwindow, color->pixel);
+ if (!private->destroyed)
+ XSetWindowBackground (private->xdisplay, private->xwindow, color->pixel);
}
void
@@ -809,7 +824,8 @@ gdk_window_set_back_pixmap (GdkWindow *window,
if (parent_relative)
xpixmap = ParentRelative;
- XSetWindowBackgroundPixmap (window_private->xdisplay, window_private->xwindow, xpixmap);
+ if (!window_private->destroyed)
+ XSetWindowBackgroundPixmap (window_private->xdisplay, window_private->xwindow, xpixmap);
}
void
@@ -830,7 +846,8 @@ gdk_window_set_cursor (GdkWindow *window,
else
xcursor = cursor_private->xcursor;
- XDefineCursor (window_private->xdisplay, window_private->xwindow, xcursor);
+ if (!window_private->destroyed)
+ XDefineCursor (window_private->xdisplay, window_private->xwindow, xcursor);
}
void
@@ -846,12 +863,15 @@ gdk_window_set_colormap (GdkWindow *window,
window_private = (GdkWindowPrivate*) window;
colormap_private = (GdkColormapPrivate*) colormap;
- XSetWindowColormap (window_private->xdisplay,
- window_private->xwindow,
- colormap_private->xcolormap);
-
- if (window_private->window_type != GDK_WINDOW_TOPLEVEL)
- gdk_window_add_colormap_windows (window);
+ if (!window_private->destroyed)
+ {
+ XSetWindowColormap (window_private->xdisplay,
+ window_private->xwindow,
+ colormap_private->xcolormap);
+
+ if (window_private->window_type != GDK_WINDOW_TOPLEVEL)
+ gdk_window_add_colormap_windows (window);
+ }
}
void
@@ -885,19 +905,22 @@ gdk_window_get_geometry (GdkWindow *window,
window_private = (GdkWindowPrivate*) window;
- XGetGeometry (window_private->xdisplay, window_private->xwindow,
- &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
-
- if (x)
- *x = tx;
- if (y)
- *y = ty;
- if (width)
- *width = twidth;
- if (height)
- *height = theight;
- if (depth)
- *depth = tdepth;
+ if (!window_private->destroyed)
+ {
+ XGetGeometry (window_private->xdisplay, window_private->xwindow,
+ &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
+
+ if (x)
+ *x = tx;
+ if (y)
+ *y = ty;
+ if (width)
+ *width = twidth;
+ if (height)
+ *height = theight;
+ if (depth)
+ *depth = tdepth;
+ }
}
void
@@ -947,7 +970,7 @@ gdk_window_get_visual (GdkWindow *window)
while (window_private && (window_private->window_type == GDK_WINDOW_PIXMAP))
window_private = (GdkWindowPrivate*) window_private->parent;
- if (window_private)
+ if (window_private && !window_private->destroyed)
{
XGetWindowAttributes (window_private->xdisplay,
window_private->xwindow,
@@ -969,11 +992,16 @@ gdk_window_get_colormap (GdkWindow *window)
window_private = (GdkWindowPrivate*) window;
- XGetWindowAttributes (window_private->xdisplay,
- window_private->xwindow,
- &window_attributes);
+ if (!window_private->destroyed)
+ {
+ XGetWindowAttributes (window_private->xdisplay,
+ window_private->xwindow,
+ &window_attributes);
+
+ return gdk_colormap_lookup (window_attributes.colormap);
+ }
- return gdk_colormap_lookup (window_attributes.colormap);
+ return NULL;
}
GdkWindowType
@@ -1001,17 +1029,22 @@ gdk_window_get_origin (GdkWindow *window,
private = (GdkWindowPrivate*) window;
- return_val = XTranslateCoordinates (private->xdisplay,
- private->xwindow,
- gdk_root_window,
- 0, 0, &tx, &ty,
- &child);
-
- if (x)
- *x = tx;
- if (y)
- *y = ty;
-
+ if (!private->destroyed)
+ {
+ return_val = XTranslateCoordinates (private->xdisplay,
+ private->xwindow,
+ gdk_root_window,
+ 0, 0, &tx, &ty,
+ &child);
+
+ if (x)
+ *x = tx;
+ if (y)
+ *y = ty;
+ }
+ else
+ return_val = 0;
+
return return_val;
}
@@ -1035,17 +1068,18 @@ gdk_window_get_pointer (GdkWindow *window,
private = (GdkWindowPrivate*) window;
return_val = NULL;
- if (XQueryPointer (private->xdisplay, private->xwindow, &root, &child,
+ if (!private->destroyed &&
+ XQueryPointer (private->xdisplay, private->xwindow, &root, &child,
&rootx, &rooty, &winx, &winy, &xmask))
{
if (x) *x = winx;
if (y) *y = winy;
if (mask) *mask = xmask;
-
+
if (child)
return_val = gdk_window_lookup (child);
}
-
+
return return_val;
}
@@ -1090,6 +1124,8 @@ gdk_window_get_children (GdkWindow *window)
g_return_val_if_fail (window != NULL, NULL);
private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return NULL;
XQueryTree (private->xdisplay, private->xwindow,
&root, &parent, &xchildren, &nchildren);
@@ -1114,11 +1150,18 @@ gdk_window_get_children (GdkWindow *window)
GdkEventMask
gdk_window_get_events (GdkWindow *window)
{
+ GdkWindowPrivate *private;
XWindowAttributes attrs;
GdkEventMask event_mask;
int i;
- XGetWindowAttributes (gdk_display, ((GdkWindowPrivate *)window)->xwindow,
+ g_return_val_if_fail (window != NULL, 0);
+
+ private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return 0;
+
+ XGetWindowAttributes (gdk_display, private->xwindow,
&attrs);
event_mask = 0;
@@ -1135,9 +1178,16 @@ void
gdk_window_set_events (GdkWindow *window,
GdkEventMask event_mask)
{
+ GdkWindowPrivate *private;
long xevent_mask;
int i;
+ g_return_if_fail (window != NULL);
+
+ private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
+
xevent_mask = StructureNotifyMask;
for (i = 0; i < nevent_masks; i++)
{
@@ -1145,7 +1195,7 @@ gdk_window_set_events (GdkWindow *window,
xevent_mask |= event_mask_table[i];
}
- XSelectInput (gdk_display, ((GdkWindowPrivate *)window)->xwindow,
+ XSelectInput (gdk_display, private->xwindow,
xevent_mask);
}
@@ -1164,6 +1214,8 @@ gdk_window_add_colormap_windows (GdkWindow *window)
toplevel = gdk_window_get_toplevel (window);
toplevel_private = (GdkWindowPrivate*) toplevel;
window_private = (GdkWindowPrivate*) window;
+ if (window_private->destroyed)
+ return;
if (!XGetWMColormapWindows (toplevel_private->xdisplay,
toplevel_private->xwindow,
@@ -1211,6 +1263,8 @@ gdk_window_shape_combine_mask (GdkWindow *window,
window_private = (GdkWindowPrivate*) window;
pixmap_private = (GdkWindowPrivate*) mask;
+ if (window_private->destroyed)
+ return;
XShapeCombineMask (window_private->xdisplay,
window_private->xwindow,
@@ -1228,6 +1282,8 @@ gdk_dnd_drag_addwindow (GdkWindow *window)
g_return_if_fail (window != NULL);
window_private = (GdkWindowPrivate *) window;
+ if (window_private->destroyed)
+ return;
if (window_private->dnd_drag_enabled == 1 && gdk_dnd.drag_really == 0)
{
@@ -1253,6 +1309,8 @@ gdk_window_dnd_drag_set (GdkWindow *window,
g_return_if_fail (window != NULL);
window_private = (GdkWindowPrivate *) window;
+ if (window_private->destroyed)
+ return;
window_private->dnd_drag_enabled = drag_enable ? 1 : 0;
@@ -1309,8 +1367,9 @@ gdk_window_dnd_drop_set (GdkWindow *window,
int i;
g_return_if_fail (window != NULL);
-
window_private = (GdkWindowPrivate *) window;
+ if (window_private->destroyed)
+ return;
window_private->dnd_drop_enabled = drop_enable ? 1 : 0;
if (drop_enable)
@@ -1357,6 +1416,8 @@ gdk_window_dnd_data_set (GdkWindow *window,
window_private = (GdkWindowPrivate *) window;
g_return_if_fail (window_private->dnd_drag_accepted != 0);
+ if (window_private->destroyed)
+ return;
/* We set the property on our window... */
gdk_property_change (window, window_private->dnd_drag_data_type,
@@ -1405,7 +1466,11 @@ gdk_window_add_filter (GdkWindow *window,
GList *tmp_list;
GdkEventFilter *filter;
- private = (GdkWindowPrivate *)window;
+ g_return_if_fail (window != NULL);
+
+ private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
tmp_list = private->filters;
while (tmp_list)
@@ -1432,7 +1497,8 @@ gdk_window_remove_filter (GdkWindow *window,
GList *tmp_list;
GdkEventFilter *filter;
- private = (GdkWindowPrivate *)window;
+ g_return_if_fail (window != NULL);
+ private = (GdkWindowPrivate*) window;
tmp_list = private->filters;
while (tmp_list)
@@ -1455,7 +1521,14 @@ void
gdk_window_set_override_redirect(GdkWindow *window,
gboolean override_redirect)
{
+ GdkWindowPrivate *private;
XSetWindowAttributes attr;
+
+ g_return_if_fail (window != NULL);
+ private = (GdkWindowPrivate*) window;
+ if (private->destroyed)
+ return;
+
attr.override_redirect = (override_redirect == FALSE)?False:True;
XChangeWindowAttributes(gdk_display,
((GdkWindowPrivate *)window)->xwindow,