xserver: Branch 'xorg-server-1.4-apple'

George Peter Staplin gstaplin at kemper.freedesktop.org
Fri Sep 19 20:33:31 PDT 2008


 hw/xquartz/pbproxy/x-selection.m |   89 ++++++++++++++++++++++++---------------
 1 file changed, 56 insertions(+), 33 deletions(-)

New commits:
commit adf339d8f948fc1e308dbcae38fcfce504b5b0ab
Author: George Peter Staplin <gps at Georges-Workstation.local>
Date:   Fri Sep 19 21:28:46 2008 -0600

    XQuartz: pbproxy: Fix a bug that occured when a PICT format was available.
    We may need another branch to convert a PICT to a PNG or JPEG.  For now
    TIFF works well in all of the test image copying apps when converted to
    PNG or JPEG with an NSBitmapImageRep class.

diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index fec67c8..2f35fcd 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -58,6 +58,7 @@
  * TODO:
  * 1. finish handling these pbproxy control knobs.
  * 2. handle  MULTIPLE - I need to study the ICCCM further.
+ * 3. Handle PICT images properly.
  */
 
 // These will be set by X11Controller.m once this is integrated into a server thread
@@ -550,11 +551,14 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 	    ++count;
 	}
 
-	if ([pbtypes containsObject:NSTIFFPboardType] 
-	    || [pbtypes containsObject:NSPICTPboardType])
+	/* TODO add the NSPICTPboardType back again, once we have conversion
+	 * functionality in send_image.
+	 */
+
+	if ([pbtypes containsObject:NSTIFFPboardType]) 
 	{
-	    /* We can convert a TIFF or PICT to a PNG or JPEG. */
-	    DB ("NSTIFFPboardType or NSPICTPboardType\n");
+	    /* We can convert a TIFF to a PNG or JPEG. */
+	    DB ("NSTIFFPboardType\n");
 	    list[count] = atoms->image_png;
 	    ++count;
 	    list[count] = atoms->image_jpeg;
@@ -702,6 +706,7 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
     NSArray *pbtypes;
     NSString *type = nil;
     NSBitmapImageFileType imagetype = /*quiet warning*/ NSPNGFileType; 
+    NSData *data;
 
     TRACE ();
 
@@ -714,8 +719,11 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 	if ([pbtypes containsObject:NSTIFFPboardType])
 	    type = NSTIFFPboardType;
 
-	if ([pbtypes containsObject:NSPICTPboardType])
+	/* PICT is not yet supported by pbproxy. 
+	 * The NSBitmapImageRep doesn't support it. 
+	else if ([pbtypes containsObject:NSPICTPboardType])
 	    type  = NSPICTPboardType;
+	*/
     }
 
     if (e->target == atoms->image_png)
@@ -724,40 +732,55 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 	imagetype = NSJPEGFileType;
         
 
-    if (type)
+    if (nil == type) 
     {
-	NSData *data;
-	data = [_pasteboard dataForType:type];
+	[self send_reply:&reply];
+	return;
+    }
 
-	if (data)
+    data = [_pasteboard dataForType:type];
+
+    if (nil == data)
+    {
+	[self send_reply:&reply];
+	return;
+    }
+	 
+    if (NSTIFFPboardType == type)
+    {
+	NSBitmapImageRep *bmimage = [[NSBitmapImageRep alloc] initWithData:data];
+	NSDictionary *dict;
+	NSData *encdata;
+
+	if (nil == bmimage) 
 	{
-	    NSBitmapImageRep *bmimage = [[NSBitmapImageRep alloc] initWithData:data];
+	    [self send_reply:&reply];
+	    return;
+	}
+
+	DB ("have valid bmimage\n");
+	
+	dict = [[NSDictionary alloc] init];
+	encdata = [bmimage representationUsingType:imagetype properties:dict];
+	if (encdata)
+	{
+	    NSUInteger length;
+	    const void *bytes;
 	    
-	    if (bmimage) 
-	    {
-		NSDictionary *dict;
-		NSData *encdata;
-		
-		dict = [[NSDictionary alloc] init];
-		encdata = [bmimage representationUsingType:imagetype properties:dict];
-		if (encdata)
-		{
-		    NSUInteger length;
-		    const void *bytes;
-
-		    length = [encdata length];
-		    bytes = [encdata bytes];
-		    		    
-		    XChangeProperty (x_dpy, e->requestor, e->property, e->target,
-				     8, PropModeReplace, bytes, length);
+	    length = [encdata length];
+	    bytes = [encdata bytes];
 		
-		    reply.xselection.property = e->property;
-		    
-		    DB ("changed property for %s\n", XGetAtomName (x_dpy, e->target));
-		}
-	    }
+	    XChangeProperty (x_dpy, e->requestor, e->property, e->target,
+				 8, PropModeReplace, bytes, length);
+	    
+	    reply.xselection.property = e->property;
+	    
+	    DB ("changed property for %s\n", XGetAtomName (x_dpy, e->target));
 	}
-    }
+	[dict release];
+	[bmimage release];
+    } 
+
     [self send_reply:&reply];
 }
 


More information about the xorg-commit mailing list