[gnome-shell] Use MetaRectangle for allocated returns



commit ab0d57d6cae6afa75ad25068365214ae9584f587
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Fri Jul 2 13:17:02 2010 -0400

    Use MetaRectangle for allocated returns
    
    The conversion of GdkRectangle to a typedef for cairo_rectangle_int_t
    in GTK+-3 makes it no longer a proper boxed type (it's still registered
    boxed, but gobject-introspection doesn't know that.) So, switch to using
    MetaRectangle, which is now registered as a boxed type by Mutter.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=621845

 src/shell-global.c |   29 ++++++++++++++---------------
 src/shell-global.h |    4 ++--
 2 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/src/shell-global.c b/src/shell-global.c
index fa3f922..94b57c5 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -1141,7 +1141,7 @@ shell_global_create_root_pixmap_actor (ShellGlobal *global)
  *
  * Gets a list of the bounding boxes of the active screen's monitors.
  *
- * Return value: (transfer full) (element-type GdkRectangle): a list
+ * Return value: (transfer full) (element-type Meta.Rectangle): a list
  * of monitor bounding boxes.
  */
 GSList *
@@ -1152,17 +1152,11 @@ shell_global_get_monitors (ShellGlobal *global)
   MetaRectangle rect;
   int i;
 
-  g_assert (sizeof (MetaRectangle) == sizeof (GdkRectangle) &&
-            G_STRUCT_OFFSET (MetaRectangle, x) == G_STRUCT_OFFSET (GdkRectangle, x) &&
-            G_STRUCT_OFFSET (MetaRectangle, y) == G_STRUCT_OFFSET (GdkRectangle, y) &&
-            G_STRUCT_OFFSET (MetaRectangle, width) == G_STRUCT_OFFSET (GdkRectangle, width) &&
-            G_STRUCT_OFFSET (MetaRectangle, height) == G_STRUCT_OFFSET (GdkRectangle, height));
-
   for (i = meta_screen_get_n_monitors (screen) - 1; i >= 0; i--)
     {
       meta_screen_get_monitor_geometry (screen, i, &rect);
       monitors = g_slist_prepend (monitors,
-                                  g_boxed_copy (GDK_TYPE_RECTANGLE, &rect));
+                                  meta_rectangle_copy (&rect));
     }
   return monitors;
 }
@@ -1176,11 +1170,12 @@ shell_global_get_monitors (ShellGlobal *global)
  *
  * Return value: the bounding box of the primary monitor
  */
-GdkRectangle *
+MetaRectangle *
 shell_global_get_primary_monitor (ShellGlobal  *global)
 {
   GdkScreen *screen = shell_global_get_gdk_screen (global);
-  GdkRectangle rect;
+  GdkRectangle gdk_rect;
+  MetaRectangle rect;
   gint primary = 0;
 
   /* gdk_screen_get_primary_monitor is only present in gtk-2.20+
@@ -1211,9 +1206,13 @@ shell_global_get_primary_monitor (ShellGlobal  *global)
   primary = gdk_screen_get_primary_monitor (screen);
 #endif
 
-  gdk_screen_get_monitor_geometry (screen, primary, &rect);
+  gdk_screen_get_monitor_geometry (screen, primary, &gdk_rect);
+  rect.x = gdk_rect.x;
+  rect.y = gdk_rect.y;
+  rect.width = gdk_rect.width;
+  rect.height = gdk_rect.height;
 
-  return g_boxed_copy (GDK_TYPE_RECTANGLE, &rect);
+  return meta_rectangle_copy (&rect);
 }
 
 /**
@@ -1225,7 +1224,7 @@ shell_global_get_primary_monitor (ShellGlobal  *global)
  *
  * Return value: the bounding box of the focus monitor
  */
-GdkRectangle *
+MetaRectangle *
 shell_global_get_focus_monitor (ShellGlobal  *global)
 {
   MetaScreen *screen = shell_global_get_screen (global);
@@ -1247,12 +1246,12 @@ shell_global_get_focus_monitor (ShellGlobal  *global)
           if (rect.x <= wrect.x && rect.y <= wrect.y &&
               rect.x + rect.width > wrect.x &&
               rect.y + rect.height > wrect.y)
-            return g_boxed_copy (GDK_TYPE_RECTANGLE, &rect);
+            return meta_rectangle_copy (&rect);
         }
     }
 
   meta_screen_get_monitor_geometry (screen, 0, &rect);
-  return g_boxed_copy (GDK_TYPE_RECTANGLE, &rect);
+  return meta_rectangle_copy (&rect);
 }
 
 /**
diff --git a/src/shell-global.h b/src/shell-global.h
index a801238..1dd0be8 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -81,8 +81,8 @@ void shell_global_format_time_relative_pretty (ShellGlobal *global, guint delta,
 ClutterActor *shell_global_create_root_pixmap_actor (ShellGlobal *global);
 
 GSList       *shell_global_get_monitors        (ShellGlobal  *global);
-GdkRectangle *shell_global_get_primary_monitor (ShellGlobal  *global);
-GdkRectangle *shell_global_get_focus_monitor   (ShellGlobal  *global);
+MetaRectangle *shell_global_get_primary_monitor (ShellGlobal  *global);
+MetaRectangle *shell_global_get_focus_monitor   (ShellGlobal  *global);
 
 void shell_global_get_pointer (ShellGlobal         *global,
                                int                 *x,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]