[gnome-shell] Fix cursor image tracking on 64-bit systems



commit 909ec7a7090efb5b371ffdf5211ca67aab9fc5b3
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat Oct 30 17:28:36 2010 -0400

    Fix cursor image tracking on 64-bit systems
    
    Like all X API, XFixesGetCursorImage returns arrays of 32-bit
    quantities as arrays of long; on 64-bit systems we need to
    convert to an array of 32-bit words before creating a texture
    from the result.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=633591

 src/shell-xfixes-cursor.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/src/shell-xfixes-cursor.c b/src/shell-xfixes-cursor.c
index baf677c..14d2b59 100644
--- a/src/shell-xfixes-cursor.c
+++ b/src/shell-xfixes-cursor.c
@@ -195,11 +195,40 @@ xfixes_cursor_reset_image (ShellXFixesCursor *xfixes_cursor)
 {
   XFixesCursorImage *cursor_image;
   CoglHandle sprite = COGL_INVALID_HANDLE;
+  guint8 *cursor_data;
+  gboolean free_cursor_data;
 
   if (!xfixes_cursor->have_xfixes)
     return;
 
   cursor_image = XFixesGetCursorImage (clutter_x11_get_default_display ());
+
+  /* Like all X APIs, XFixesGetCursorImage() returns arrays of 32-bit
+   * quantities as arrays of long; we need to convert on 64 bit */
+  if (sizeof(long) == 4)
+    {
+      cursor_data = (guint8 *)cursor_image->pixels;
+      free_cursor_data = FALSE;
+    }
+  else
+    {
+      int i, j;
+      guint32 *cursor_words;
+      gulong *p;
+      guint32 *q;
+
+      cursor_words = g_new (guint32, cursor_image->width * cursor_image->height);
+      cursor_data = (guint8 *)cursor_words;
+
+      p = cursor_image->pixels;
+      q = cursor_words;
+      for (j = 0; j < cursor_image->height; j++)
+        for (i = 0; i < cursor_image->width; i++)
+          *(q++) = *(p++);
+
+      free_cursor_data = TRUE;
+    }
+
   sprite = cogl_texture_new_from_data (cursor_image->width,
                                        cursor_image->height,
                                        COGL_TEXTURE_NONE,
@@ -210,7 +239,11 @@ xfixes_cursor_reset_image (ShellXFixesCursor *xfixes_cursor)
 #endif
                                        COGL_PIXEL_FORMAT_ANY,
                                        cursor_image->width * 4, /* stride */
-                                       (const guint8 *) cursor_image->pixels);
+                                       cursor_data);
+
+  if (free_cursor_data)
+    g_free (cursor_data);
+
   if (sprite != COGL_INVALID_HANDLE)
     {
       if (xfixes_cursor->cursor_sprite != NULL)



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