diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index 80467fa..62e351c 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -662,11 +662,16 @@ is_pointer_within_shape (GdkDisplay    *display,
       GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
       cairo_region_t *input_shape;
 
-      child->shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
-                                                 child->xid, ShapeBounding);
+      child->shape = NULL;
+      if (gdk_display_supports_shapes (display))
+        child->shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
+                                                   child->xid, ShapeBounding);
 #ifdef ShapeInput
-      input_shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
-                                                child->xid, ShapeInput);
+      input_shape = NULL;
+      if (gdk_display_supports_input_shapes (display))
+        input_shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
+                                                  child->xid, ShapeInput);
+
       if (child->shape && input_shape)
         {
           cairo_region_intersect (child->shape, input_shape);
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 6613801..4111370 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -3894,7 +3894,7 @@ _gdk_x11_xwindow_get_shape (Display *xdisplay,
 			     window,
 			     shape_type, &rn, &ord);
 
-  if (xrl == NULL || rn == 0)
+  if (rn == 0)
     return cairo_region_create (); /* Empty */
 
   if (ord != YXBanded)
@@ -3940,7 +3940,7 @@ gdk_x11_window_get_input_shape (GdkWindow *window)
 {
 #if defined(ShapeInput)
   if (!GDK_WINDOW_DESTROYED (window) &&
-      gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
+      gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
     return _gdk_x11_xwindow_get_shape (GDK_WINDOW_XDISPLAY (window),
                                        GDK_WINDOW_XID (window),
                                        ShapeInput);
