]> Pileus Git - ~andy/gtk/commitdiff
Add new GdkPaintable interface which implementation objects can implement
authorAnders Carlsson <andersca@imendio.com>
Mon, 10 Apr 2006 19:43:08 +0000 (19:43 +0000)
committerAnders Carlsson <andersca@src.gnome.org>
Mon, 10 Apr 2006 19:43:08 +0000 (19:43 +0000)
2006-04-11  Anders Carlsson  <andersca@imendio.com>

        * gdk/gdkinternals.h:
        * gdk/gdkwindow.c:
        (_gdk_paintable_get_type):
        (gdk_window_begin_paint_region):
        (gdk_window_end_paint):
        (gdk_window_process_updates):
        (gdk_window_invalidate_maybe_recurse):
        Add new GdkPaintable interface which implementation objects can
        implement in order to override gdk painting functions.

ChangeLog
ChangeLog.pre-2-10
gdk/gdkinternals.h
gdk/gdkwindow.c

index 9350d857686c0d2533e34a3830c57906dad4ee0f..01bfa8b40315184af5d13e9c3e74ad97a7f4c2f2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-04-11  Anders Carlsson  <andersca@imendio.com>
+
+        * gdk/gdkinternals.h:
+        * gdk/gdkwindow.c:
+        (_gdk_paintable_get_type):
+        (gdk_window_begin_paint_region):
+        (gdk_window_end_paint):
+        (gdk_window_process_updates):
+        (gdk_window_invalidate_maybe_recurse):
+        Add new GdkPaintable interface which implementation objects can 
+        implement in order to override gdk painting functions.
+
 2006-04-10 Vladimer Sichinava  <vlsichinava@gmail.com>
 
         * configure.in: Added "ka" (Georgian) to ALL_LINGUAS
index 9350d857686c0d2533e34a3830c57906dad4ee0f..01bfa8b40315184af5d13e9c3e74ad97a7f4c2f2 100644 (file)
@@ -1,3 +1,15 @@
+2006-04-11  Anders Carlsson  <andersca@imendio.com>
+
+        * gdk/gdkinternals.h:
+        * gdk/gdkwindow.c:
+        (_gdk_paintable_get_type):
+        (gdk_window_begin_paint_region):
+        (gdk_window_end_paint):
+        (gdk_window_process_updates):
+        (gdk_window_invalidate_maybe_recurse):
+        Add new GdkPaintable interface which implementation objects can 
+        implement in order to override gdk painting functions.
+
 2006-04-10 Vladimer Sichinava  <vlsichinava@gmail.com>
 
         * configure.in: Added "ka" (Georgian) to ALL_LINGUAS
index d3c1fbad572c6461e841fd7b055ae195f2af9f75..1c279f4ec3606c77122dac3be8dc654e7b2c1806 100644 (file)
@@ -337,6 +337,32 @@ void _gdk_windowing_window_destroy_foreign (GdkWindow *window);
 void _gdk_windowing_display_set_sm_client_id (GdkDisplay  *display,
                                              const gchar *sm_client_id);
 
+#define GDK_TYPE_PAINTABLE            (_gdk_paintable_get_type ())
+#define GDK_PAINTABLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_PAINTABLE, GdkPaintable))
+#define GDK_IS_PAINTABLE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_PAINTABLE))
+#define GDK_PAINTABLE_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDK_TYPE_PAINTABLE, GdkPaintableIface))
+
+typedef struct _GdkPaintable        GdkPaintable;
+typedef struct _GdkPaintableIface   GdkPaintableIface;
+
+struct _GdkPaintableIface
+{
+  GTypeInterface g_iface;
+  
+  void (* begin_paint_region) (GdkPaintable *paintable,
+                              GdkRegion    *region);
+  void (* end_paint)          (GdkPaintable *paintable);
+
+  void (* invalidate_maybe_recurse) (GdkPaintable *paintable,
+                                    GdkRegion    *region,
+                                    gboolean    (*child_func) (GdkWindow *, gpointer),
+                                    gpointer      user_data);
+  void (* process_updates)          (GdkPaintable *paintable,
+                                    gboolean      update_children);
+};
+
+GType _gdk_paintable_get_type (void) G_GNUC_CONST;
+
 /* Implementation types */
 GType _gdk_window_impl_get_type (void) G_GNUC_CONST;
 GType _gdk_pixmap_impl_get_type (void) G_GNUC_CONST;
index f49281e4d331e427454fccb772e576058840871a..4b234a33ad55df8b6caf295479a32fb513bbc4df 100644 (file)
@@ -192,6 +192,30 @@ static void gdk_window_clear_backing_rect (GdkWindow *window,
 
 G_DEFINE_TYPE (GdkWindowObject, gdk_window_object, GDK_TYPE_DRAWABLE);
 
+GType
+_gdk_paintable_get_type (void)
+{
+  static GType paintable_type = 0;
+
+  if (!paintable_type)
+    {
+      static const GTypeInfo paintable_info =
+      {
+       sizeof (GdkPaintableIface),  /* class_size */
+       NULL,                        /* base_init */
+       NULL,                        /* base_finalize */
+      };
+
+      paintable_type = g_type_register_static (G_TYPE_INTERFACE,
+                                              g_intern_static_string ("GdkPaintable"),
+                                              &paintable_info, 0);
+
+      g_type_interface_add_prerequisite (paintable_type, G_TYPE_OBJECT);
+    }
+
+  return paintable_type;
+}
+
 static void
 gdk_window_object_init (GdkWindowObject *window)
 {
@@ -936,6 +960,13 @@ gdk_window_begin_paint_region (GdkWindow *window,
   if (GDK_WINDOW_DESTROYED (window))
     return;
 
+  if (GDK_IS_PAINTABLE (private->impl) &&
+      GDK_PAINTABLE_GET_IFACE (private->impl)->begin_paint_region) 
+    {
+      GDK_PAINTABLE_GET_IFACE (private->impl)->begin_paint_region (GDK_PAINTABLE (private->impl), region);
+      return;
+    }
+
   gdk_region_get_clipbox (region, &clip_box);
 
   paint = g_new (GdkWindowPaint, 1);
@@ -997,6 +1028,13 @@ gdk_window_end_paint (GdkWindow *window)
   if (GDK_WINDOW_DESTROYED (window))
     return;
 
+  if (GDK_IS_PAINTABLE (private->impl) &&
+      GDK_PAINTABLE_GET_IFACE (private->impl)->end_paint) 
+    {
+      GDK_PAINTABLE_GET_IFACE (private->impl)->end_paint (GDK_PAINTABLE (private->impl));
+      return;
+    }
+
   if (private->paint_stack == NULL)
     {
       g_warning (G_STRLOC": no preceding call to gdk_window_begin_paint_region(), see documentation");
@@ -2287,6 +2325,16 @@ flush_all_displays (void)
   g_slist_free (displays);
 }
 
+/* Currently it is not possible to override
+ * gdk_window_process_all_updates in the same manner as
+ * gdk_window_process_updates and gdk_window_invalidate_maybe_recurse
+ * by implementing the GdkPaintable interface.  If in the future a
+ * backend would need this, the right solution would be to add a
+ * method to GdkDisplay that can be optionally
+ * NULL. gdk_window_process_all_updates can then walk the list of open
+ * displays and call the mehod.
+ */
+
 /**
  * gdk_window_process_all_updates:
  *
@@ -2350,6 +2398,13 @@ gdk_window_process_updates (GdkWindow *window,
   g_return_if_fail (window != NULL);
   g_return_if_fail (GDK_IS_WINDOW (window));
   
+  if (GDK_IS_PAINTABLE (private->impl) &&
+      GDK_PAINTABLE_GET_IFACE (private->impl)->process_updates)
+    {
+      GDK_PAINTABLE_GET_IFACE (private->impl)->process_updates (GDK_PAINTABLE (private->impl), update_children);
+      return;
+    }
+  
   if (private->update_area && !private->update_freeze_count)
     {      
       gdk_window_process_updates_internal (window);
@@ -2479,6 +2534,14 @@ gdk_window_invalidate_maybe_recurse (GdkWindow *window,
   if (private->input_only || !GDK_WINDOW_IS_MAPPED (window))
     return;
 
+  if (GDK_IS_PAINTABLE (private->impl) &&
+      GDK_PAINTABLE_GET_IFACE (private->impl)->invalidate_maybe_recurse)
+    {
+      GDK_PAINTABLE_GET_IFACE (private->impl)->invalidate_maybe_recurse (GDK_PAINTABLE (private->impl), region,
+                                                                        child_func, user_data);
+      return;
+    }
+
   visible_region = gdk_drawable_get_visible_region (window);
   gdk_region_intersect (visible_region, region);