summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Peter Staplin <gps@Georges-Workstation.local>2008-09-19 21:28:46 -0600
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-09-21 17:40:41 -0700
commit7fa6fc5ad0b12bc52a1c22906709fbb003782d11 (patch)
tree3090f69039f8678bdecb54636201f180130b37ba
parentf67490ceb5b9ddf25e734cc331705103599f3ed8 (diff)
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. (cherry picked from commit adf339d8f948fc1e308dbcae38fcfce504b5b0ab)
-rw-r--r--hw/xquartz/pbproxy/x-selection.m89
1 files changed, 56 insertions, 33 deletions
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index fec67c85a..2f35fcd1c 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];
}