[AD] al_set_display_icon on Linux (patch)

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


al_set_display_icon doesn't work in every case on Linux.
Here is a patch that fixes it for me, but I won't commit
it until I can get it verified by someone who knows more
about X than me.


Trent :{)>
Index: src/x/xdisplay.c
===================================================================
--- src/x/xdisplay.c	(revision 12152)
+++ src/x/xdisplay.c	(working copy)
@@ -73,27 +73,17 @@
    // TODO: Is this really freed by XDestroyImage?
    image->data = _AL_MALLOC_ATOMIC(image->bytes_per_line * h);
 
-   // FIXME: Do this properly.
-   ALLEGRO_LOCKED_REGION *lr;
-   lr = al_lock_bitmap(bitmap, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY);
-   if (lr) {
-      const char *src;
-      char *dst;
-      int i;
-
-      src = lr->data;
-      dst = image->data;
-      for (i = 0; i < h; i++) {
-         memcpy(dst, src, w * 4);
-         src += lr->pitch;
-         dst += w * 4;
+   int x, y;
+   for (y = 0; y < h; y++) {
+      for (x = 0; x < w; x++) {
+         ALLEGRO_COLOR pixel;
+         pixel = al_get_pixel(bitmap, x, y);
+         unsigned char r, g, b, a;
+         al_unmap_rgba(pixel, &r, &g, &b, &a);
+	//if (a == 0) { printf("Continuing\n"); continue; }
+         XPutPixel(image, x, y, b | (g << 8) | (r << 16) | (a << 24));
       }
-
-      al_unlock_bitmap(bitmap);
    }
-   else {
-       /* XXX what should we do here? */
-   }
 
    display->icon = XCreatePixmap(system->x11display, display->window,
       bitmap->w, bitmap->h, attributes.depth);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/