]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkwindow.c
Skip insensitive widgets. (#84061)
[~andy/gtk] / gdk / gdkwindow.c
index 37b574e61ce4fb4fe70cba93456d43658157af16..4687626121123fd8cdb6f95eb115baf700d8a8ed 100644 (file)
@@ -44,26 +44,19 @@ struct _GdkWindowPaint
   gint y_offset;
 };
 
-static const GdkPointerHooks default_pointer_hooks = {
-  _gdk_windowing_window_get_pointer,
-  _gdk_windowing_window_at_pointer
-};
-
-const GdkPointerHooks *_gdk_current_pointer_hooks = &default_pointer_hooks;
-
 static GdkGC *gdk_window_create_gc      (GdkDrawable     *drawable,
                                          GdkGCValues     *values,
                                          GdkGCValuesMask  mask);
 static void   gdk_window_draw_rectangle (GdkDrawable     *drawable,
                                          GdkGC           *gc,
-                                         gint             filled,
+                                         gboolean         filled,
                                          gint             x,
                                          gint             y,
                                          gint             width,
                                          gint             height);
 static void   gdk_window_draw_arc       (GdkDrawable     *drawable,
                                          GdkGC           *gc,
-                                         gint             filled,
+                                         gboolean         filled,
                                          gint             x,
                                          gint             y,
                                          gint             width,
@@ -72,7 +65,7 @@ static void   gdk_window_draw_arc       (GdkDrawable     *drawable,
                                          gint             angle2);
 static void   gdk_window_draw_polygon   (GdkDrawable     *drawable,
                                          GdkGC           *gc,
-                                         gint             filled,
+                                         gboolean         filled,
                                          GdkPoint        *points,
                                          gint             npoints);
 static void   gdk_window_draw_text      (GdkDrawable     *drawable,
@@ -240,7 +233,7 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
   drawable_class->draw_lines = gdk_window_draw_lines;
   drawable_class->draw_glyphs = gdk_window_draw_glyphs;
   drawable_class->draw_image = gdk_window_draw_image;
-  drawable_class->_draw_pixbuf = gdk_window_draw_pixbuf;
+  drawable_class->draw_pixbuf = gdk_window_draw_pixbuf;
   drawable_class->get_depth = gdk_window_real_get_depth;
   drawable_class->get_screen = gdk_window_real_get_screen;
   drawable_class->get_size = gdk_window_real_get_size;
@@ -273,7 +266,7 @@ gdk_window_finalize (GObject *object)
        _gdk_window_destroy (window, TRUE);
     }
 
-  g_object_unref (G_OBJECT (obj->impl));
+  g_object_unref (obj->impl);
   obj->impl = NULL;
   
   G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -335,7 +328,7 @@ _gdk_window_destroy_hierarchy (GdkWindow *window,
               private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
               private->bg_pixmap != GDK_NO_BG)
            {
-             gdk_pixmap_unref (private->bg_pixmap);
+             g_object_unref (private->bg_pixmap);
              private->bg_pixmap = NULL;
            }
          
@@ -409,20 +402,19 @@ _gdk_window_destroy (GdkWindow *window,
  * gdk_window_destroy:
  * @window: a #GdkWindow
  *
- * Destroys @window (destroys the server-side resource associated with
- * @window).  Memory allocated for @window may not be freed until all
- * references to @window are dropped. All children of @window are also
- * destroyed.
+ * Destroys the window system resources associated with @window and decrements @window's
+ * reference count. The window system resources for all children of @window are also
+ * destroyed, but the children's reference counts are not decremented.
+ *
+ * Note that a window will not be destroyed automatically when its reference count
+ * reaches zero. You must call this function yourself before that happens.
  *
- * There's normally no need to use this function, window are automatically
- * destroyed when their reference count reaches 0.
- * 
  **/
 void
 gdk_window_destroy (GdkWindow *window)
 {
   _gdk_window_destroy_hierarchy (window, FALSE, FALSE);
-  gdk_drawable_unref (window);
+  g_object_unref (window);
 }
 
 /**
@@ -702,7 +694,7 @@ gdk_window_remove_filter (GdkWindow     *window,
 
 /**
  * gdk_screen_get_toplevel_windows:
- * @screen : The #GdkScreen where the toplevels are located.
+ * @screen: The #GdkScreen where the toplevels are located.
  * 
  * Obtains a list of all toplevel windows known to GDK on the screen @screen.
  * A toplevel window is a child of the root window (see
@@ -712,6 +704,8 @@ gdk_window_remove_filter (GdkWindow     *window,
  * its elements need not be freed.
  * 
  * Return value: list of toplevel windows, free with g_list_free()
+ *
+ * Since: 2.2
  **/
 GList *
 gdk_screen_get_toplevel_windows (GdkScreen *screen)
@@ -900,7 +894,7 @@ gdk_window_paint_init_bg (GdkWindow      *window,
   gdk_gc_set_clip_region (tmp_gc, init_region);
 
   gdk_draw_rectangle (paint->pixmap, tmp_gc, TRUE, 0, 0, -1, -1);
-  gdk_gc_unref (tmp_gc);
+  g_object_unref (tmp_gc);
 }
 
 #ifdef GDK_WINDOWING_X11
@@ -1000,8 +994,8 @@ gdk_window_begin_paint_region (GdkWindow *window,
                             0, 0,
                             old_rect.x - new_rect.x, old_rect.y - new_rect.y,
                              old_rect.width, old_rect.height);
-          gdk_gc_unref (tmp_gc);
-         gdk_drawable_unref (tmp_paint->pixmap);
+          g_object_unref (tmp_gc);
+         g_object_unref (tmp_paint->pixmap);
 
          paint->x_offset = new_rect.x;
          paint->y_offset = new_rect.y;
@@ -1105,7 +1099,7 @@ gdk_window_end_paint (GdkWindow *window)
                      clip_box.y - paint->y_offset,
                      clip_box.x - x_offset, clip_box.y - y_offset,
                      clip_box.width, clip_box.height);
-  gdk_gc_unref (tmp_gc);
+  g_object_unref (tmp_gc);
 
   if (private->paint_stack)
     {
@@ -1119,7 +1113,7 @@ gdk_window_end_paint (GdkWindow *window)
        }
     }
   else
-    gdk_drawable_unref (paint->pixmap);
+    g_object_unref (paint->pixmap);
 
   gdk_region_destroy (paint->region);
   g_free (paint);
@@ -1140,7 +1134,7 @@ gdk_window_free_paint_stack (GdkWindow *window)
          GdkWindowPaint *paint = tmp_list->data;
 
          if (tmp_list == private->paint_stack)
-           gdk_drawable_unref (paint->pixmap);
+           g_object_unref (paint->pixmap);
                  
          gdk_region_destroy (paint->region);
          g_free (paint);
@@ -1265,7 +1259,7 @@ gdk_window_create_gc (GdkDrawable     *drawable,
 static void
 gdk_window_draw_rectangle (GdkDrawable *drawable,
                           GdkGC       *gc,
-                          gint         filled,
+                          gboolean     filled,
                           gint         x,
                           gint         y,
                           gint         width,
@@ -1293,7 +1287,7 @@ gdk_window_draw_rectangle (GdkDrawable *drawable,
 static void
 gdk_window_draw_arc (GdkDrawable *drawable,
                     GdkGC       *gc,
-                    gint         filled,
+                    gboolean     filled,
                     gint         x,
                     gint         y,
                     gint         width,
@@ -1324,7 +1318,7 @@ gdk_window_draw_arc (GdkDrawable *drawable,
 static void
 gdk_window_draw_polygon (GdkDrawable *drawable,
                         GdkGC       *gc,
-                        gint         filled,
+                        gboolean     filled,
                         GdkPoint    *points,
                         gint         npoints)
 {
@@ -1450,7 +1444,7 @@ gdk_window_get_composite_drawable (GdkDrawable *window,
                                          composite_x_offset,
                                          composite_y_offset);
       
-      return GDK_DRAWABLE (g_object_ref (G_OBJECT (window)));
+      return g_object_ref (window);
     }
   
   buffered_region = NULL;
@@ -1500,7 +1494,7 @@ gdk_window_get_composite_drawable (GdkDrawable *window,
                                          composite_x_offset,
                                          composite_y_offset);
 
-      return GDK_DRAWABLE (g_object_ref (G_OBJECT (window)));
+      return g_object_ref (window);
     }
   
   tmp_pixmap = gdk_pixmap_new (window,
@@ -1549,7 +1543,7 @@ gdk_window_get_composite_drawable (GdkDrawable *window,
   *composite_x_offset = x;
   *composite_y_offset = y;
 
-  g_object_unref (G_OBJECT (tmp_gc));
+  g_object_unref (tmp_gc);
   
   return tmp_pixmap;
 }
@@ -1800,7 +1794,7 @@ gdk_window_clear_backing_rect (GdkWindow *window,
   tmp_gc = gdk_window_get_bg_gc (window, paint);
   gdk_draw_rectangle (paint->pixmap, tmp_gc, TRUE,
                      x - paint->x_offset, y - paint->y_offset, width, height);
-  gdk_gc_unref (tmp_gc);
+  g_object_unref (tmp_gc);
 }
 
 /**
@@ -1945,16 +1939,16 @@ gdk_window_draw_pixbuf (GdkDrawable     *drawable,
       if (private->paint_stack)
        {
          GdkWindowPaint *paint = private->paint_stack->data;
-         _gdk_draw_pixbuf (paint->pixmap, gc, pixbuf, src_x, src_y,
-                           dest_x - x_offset, dest_y - y_offset,
-                           width, height,
-                           dither, x_dither - x_offset, y_dither - y_offset);
+         gdk_draw_pixbuf (paint->pixmap, gc, pixbuf, src_x, src_y,
+                          dest_x - x_offset, dest_y - y_offset,
+                          width, height,
+                          dither, x_dither - x_offset, y_dither - y_offset);
        }
       else
-       _gdk_draw_pixbuf (private->impl, gc, pixbuf, src_x, src_y,
-                         dest_x - x_offset, dest_y - y_offset,
-                         width, height,
-                         dither, x_dither, y_dither);
+       gdk_draw_pixbuf (private->impl, gc, pixbuf, src_x, src_y,
+                        dest_x - x_offset, dest_y - y_offset,
+                        width, height,
+                        dither, x_dither, y_dither);
       
       RESTORE_GC (gc);
     }
@@ -1966,16 +1960,16 @@ gdk_window_draw_pixbuf (GdkDrawable     *drawable,
       if (private->paint_stack)
        {
          GdkWindowPaint *paint = private->paint_stack->data;
-         _gdk_draw_pixbuf (paint->pixmap, gc, pixbuf, src_x, src_y,
-                           dest_x - x_offset, dest_y - y_offset,
-                           width, height,
+         gdk_draw_pixbuf (paint->pixmap, gc, pixbuf, src_x, src_y,
+                          dest_x - x_offset, dest_y - y_offset,
+                          width, height,
                            dither, x_dither - x_offset, y_dither - y_offset);
        }
       else
-       _gdk_draw_pixbuf (private->impl, gc, pixbuf, src_x, src_y,
-                         dest_x - x_offset, dest_y - y_offset,
-                         width, height,
-                         dither, x_dither, y_dither);
+       gdk_draw_pixbuf (private->impl, gc, pixbuf, src_x, src_y,
+                        dest_x - x_offset, dest_y - y_offset,
+                        width, height,
+                        dither, x_dither, y_dither);
     }
 }
 
@@ -2117,7 +2111,7 @@ gdk_window_process_updates_internal (GdkWindow *window)
          save_region = _gdk_windowing_window_queue_antiexpose (window, update_area);
       
          event.expose.type = GDK_EXPOSE;
-         event.expose.window = gdk_window_ref (window);
+         event.expose.window = g_object_ref (window);
          event.expose.count = 0;
 
          if (save_region)
@@ -2139,7 +2133,7 @@ gdk_window_process_updates_internal (GdkWindow *window)
 
          if (expose_region != update_area)
            gdk_region_destroy (expose_region);
-         gdk_window_unref (window);
+         g_object_unref (window);
        }
       if (!save_region)
        gdk_region_destroy (update_area);
@@ -2290,12 +2284,12 @@ draw_ugly_color (GdkWindow *window,
   gdk_region_get_clipbox (region, &clipbox);
   
   gdk_draw_rectangle (window,
-                     ugly_gc,
-                     TRUE,
-                     clipbox.x, clipbox.y,
-                     clipbox.width, clipbox.height);
+                     ugly_gc,
+                     TRUE,
+                     clipbox.x, clipbox.y,
+                     clipbox.width, clipbox.height);
   
-  g_object_unref (G_OBJECT (ugly_gc));
+  g_object_unref (ugly_gc);
 }
 
 /**
@@ -2698,33 +2692,6 @@ gdk_window_constrain_size (GdkGeometry *geometry,
   *new_height = height;
 }
 
-/**
- * gdk_set_pointer_hooks:
- * @new_hooks: a table of pointers to functions for getting
- *   quantities related to the current pointer position,
- *   or %NULL to restore the default table.
- * 
- * This function allows for hooking into the operation
- * of getting the current location of the pointer. This
- * is only useful for such low-level tools as an
- * event recorder. Applications should never have any
- * reason to use this facility
- * 
- * Return value: the previous pointer hook table
- **/
-GdkPointerHooks *
-gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks)
-{
-  const GdkPointerHooks *result = _gdk_current_pointer_hooks;
-
-  if (new_hooks)
-    _gdk_current_pointer_hooks = new_hooks;
-  else
-    _gdk_current_pointer_hooks = &default_pointer_hooks;
-
-  return (GdkPointerHooks *)result;
-}
-
 /**
  * gdk_window_get_pointer:
  * @window: a #GdkWindow
@@ -2743,11 +2710,41 @@ GdkWindow*
 gdk_window_get_pointer (GdkWindow        *window,
                        gint              *x,
                        gint              *y,
-                       GdkModifierType *mask)
+                       GdkModifierType   *mask)
 {
-  g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
+  GdkDisplay *display;
+  gint tmp_x, tmp_y;
+  GdkModifierType tmp_mask;
+  GdkWindow *child;
   
-  return _gdk_current_pointer_hooks->get_pointer (window, x, y, mask); 
+  g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
+
+  if (window)
+    {
+      display = gdk_drawable_get_display (window);
+    }
+  else
+    {
+      GdkScreen *screen = gdk_screen_get_default ();
+
+      display = gdk_screen_get_display (screen);
+      window = gdk_screen_get_root_window (screen);
+      
+      GDK_NOTE (MULTIHEAD,
+               g_message ("Passing NULL for window to gdk_window_get_pointer()\n"
+                          "is not multihead safe"));
+    }
+
+  child = display->pointer_hooks->window_get_pointer (display, window, &tmp_x, &tmp_y, &tmp_mask);
+
+  if (x)
+    *x = tmp_x;
+  if (y)
+    *y = tmp_y;
+  if (mask)
+    *mask = tmp_mask;
+
+  return child;
 }
 
 /**
@@ -2757,11 +2754,12 @@ gdk_window_get_pointer (GdkWindow         *window,
  * 
  * Obtains the window underneath the mouse pointer, returning the
  * location of that window in @win_x, @win_y. Returns %NULL if the
- * window under the mouse pointer is not known to GDK (for example,
- * belongs to another application).
+ * window under the mouse pointer is not known to GDK (if the window
+ * belongs to another application and a #GdkWindow hasn't been created
+ * for it with gdk_window_foreign_new())
  *
  * NOTE: For multihead-aware widgets or applications use
- * gdk_screen_get_window_at_pointer() instead.
+ * gdk_display_get_window_at_pointer() instead.
  * 
  * Return value: window under the mouse pointer
  **/
@@ -2769,7 +2767,7 @@ GdkWindow*
 gdk_window_at_pointer (gint *win_x,
                       gint *win_y)
 {
-  return gdk_screen_get_window_at_pointer (gdk_screen_get_default (), win_x, win_y);
+  return gdk_display_get_window_at_pointer (gdk_display_get_default (), win_x, win_y);
 }
 
 /**