]> Pileus Git - ~andy/gtk/blobdiff - gdk/x11/gdkwindow-x11.c
nparams for selection_get should be 3, not 2. [ From Damon Chaplin
[~andy/gtk] / gdk / x11 / gdkwindow-x11.c
index 72a56d85843f7bdd6fe0e68699400946ef3eae05..56e8cdfb81c01f71f3c0388c69860f12b4f1d420 100644 (file)
 #include "gdkinput.h"
 #include "gdkprivate.h"
 #include "MwmUtil.h"
-#include <stdlib.h>
-#include <stdio.h>
+
+#if HAVE_CONFIG_H
+#  include <config.h>
+#  if STDC_HEADERS
+#    include <stdlib.h>
+#    include <stdio.h>
+#    include <string.h>
+#  endif
+#else
+#  include <stdlib.h>
+#  include <stdio.h>
+#endif
+
 
 #ifdef HAVE_SHAPE_EXT
 #include <X11/extensions/shape.h>
 #endif
 
-const int event_mask_table[20] =
+const int gdk_event_mask_table[20] =
 {
   ExposureMask,
   PointerMotionMask,
@@ -56,7 +67,7 @@ const int event_mask_table[20] =
   0,                           /* PROXIMTY_OUT */
   SubstructureNotifyMask
 };
-const int nevent_masks = sizeof(event_mask_table)/sizeof(int);
+const int gdk_nevent_masks = sizeof(gdk_event_mask_table)/sizeof(int);
 
 static gboolean gdk_window_have_shape_ext (void);
 
@@ -266,6 +277,7 @@ gdk_window_new (GdkWindow     *parent,
 
   private->xdisplay = parent_display;
   private->destroyed = FALSE;
+  private->mapped = FALSE;
   private->resize_count = 0;
   private->ref_count = 1;
   xattributes_mask = 0;
@@ -299,10 +311,10 @@ gdk_window_new (GdkWindow     *parent,
   xvisual = ((GdkVisualPrivate*) visual)->xvisual;
 
   xattributes.event_mask = StructureNotifyMask;
-  for (i = 0; i < nevent_masks; i++)
+  for (i = 0; i < gdk_nevent_masks; i++)
     {
       if (attributes->event_mask & (1 << (i + 1)))
-       xattributes.event_mask |= event_mask_table[i];
+       xattributes.event_mask |= gdk_event_mask_table[i];
     }
 
   if (xattributes.event_mask)
@@ -500,6 +512,7 @@ gdk_window_foreign_new (guint32 anid)
   private->ref_count = 1;
   private->window_type = GDK_WINDOW_FOREIGN;
   private->destroyed = FALSE;
+  private->mapped = (attrs.map_state != IsUnmapped);
   private->extension_events = 0;
 
   private->colormap = NULL;
@@ -705,6 +718,7 @@ gdk_window_show (GdkWindow *window)
   private = (GdkWindowPrivate*) window;
   if (!private->destroyed)
     {
+      private->mapped = TRUE;
       XRaiseWindow (private->xdisplay, private->xwindow);
       XMapWindow (private->xdisplay, private->xwindow);
     }
@@ -719,7 +733,10 @@ gdk_window_hide (GdkWindow *window)
 
   private = (GdkWindowPrivate*) window;
   if (!private->destroyed)
-    XUnmapWindow (private->xdisplay, private->xwindow);
+    {
+      private->mapped = FALSE;
+      XUnmapWindow (private->xdisplay, private->xwindow);
+    }
 }
 
 void
@@ -1703,9 +1720,9 @@ gdk_window_get_events      (GdkWindow       *window)
                        &attrs);
 
   event_mask = 0;
-  for (i = 0; i < nevent_masks; i++)
+  for (i = 0; i < gdk_nevent_masks; i++)
     {
-      if (attrs.your_event_mask & event_mask_table[i])
+      if (attrs.your_event_mask & gdk_event_mask_table[i])
        event_mask |= 1 << (i + 1);
     }
 
@@ -1727,10 +1744,10 @@ gdk_window_set_events      (GdkWindow       *window,
     return;
 
   xevent_mask = StructureNotifyMask;
-  for (i = 0; i < nevent_masks; i++)
+  for (i = 0; i < gdk_nevent_masks; i++)
     {
       if (event_mask & (1 << (i + 1)))
-       xevent_mask |= event_mask_table[i];
+       xevent_mask |= gdk_event_mask_table[i];
     }
   
   XSelectInput (gdk_display, private->xwindow, 
@@ -2459,6 +2476,55 @@ gdk_window_merge_child_shapes (GdkWindow *window)
 #endif   
 }
 
+/*************************************************************
+ * gdk_window_is_visible:
+ *     Check if the given window is mapped.
+ *   arguments:
+ *     window: 
+ *   results:
+ *     is the window mapped
+ *************************************************************/
+
+gboolean 
+gdk_window_is_visible (GdkWindow *window)
+{
+  GdkWindowPrivate *private = (GdkWindowPrivate *)window;
+
+  g_return_val_if_fail (window != NULL, FALSE);
+
+  return private->mapped;
+}
+
+/*************************************************************
+ * gdk_window_is_viewable:
+ *     Check if the window and all ancestors of the window
+ *     are mapped. (This is not necessarily "viewable" in
+ *     the X sense, since we only check as far as we have
+ *     GDK window parents, not to the root window)
+ *   arguments:
+ *     window:
+ *   results:
+ *     is the window viewable
+ *************************************************************/
+
+gboolean 
+gdk_window_is_viewable (GdkWindow *window)
+{
+  GdkWindowPrivate *private = (GdkWindowPrivate *)window;
+
+  g_return_val_if_fail (window != NULL, FALSE);
+
+  while (private && (private != &gdk_root_parent))
+    {
+      if (!private->mapped)
+       return FALSE;
+
+      private = (GdkWindowPrivate *)private->parent;
+    }
+
+  return TRUE;
+}
+
 void          
 gdk_drawable_set_data (GdkDrawable   *drawable,
                       const gchar   *key,
@@ -2468,3 +2534,4 @@ gdk_drawable_set_data (GdkDrawable   *drawable,
   g_dataset_set_data_full (drawable, key, data, destroy_func);
 }
 
+