[PATCH] macdrv: Don't update clipboard if its content didn't change

Ken Thomases ken at codeweavers.com
Mon May 29 23:40:34 CDT 2017


On May 26, 2017, at 1:23 AM, Piotr Caban <piotr at codeweavers.com> wrote:
> 
>> I'll have to run some tests again to see exactly which operations do and don't increment the change count.  I'll let you know what I find.
>> 
>> It may be that your patch is better for the vast majority of the cases such that we should commit it.  We'll just accept incorrect behavior for the (hopefully) rare aberrant uses of the API that I'm concerned about.  Or maybe we can take a belt-and-suspenders approach and check both the change count and the list of types.
> 
> I’ve done some initial testing:
> 
> 	[myPasteboard clearContents];
> clearContent increments the changeCount.
> 
> 	[myPasteboard setString:@"test" forType:NSStringPboardType];
>        NSLog(@"changeCount %ld", [myPasteboard changeCount]);
>        [NSThread sleepForTimeInterval:2];
>        [myPasteboard setString:@"test2" forType:NSStringPboardType];
>        NSLog(@“changeCount %ld", [myPasteboard changeCount]);
> In this case changeCount doesn’t change no matter if other applications read the pasteboard data between setString calls.
> 
> 	[myPasteboard addTypes:[NSArray arrayWithObject:NSRTFPboardType] owner:nil];
>        NSLog(@“addTypes changeCount %ld”, [myPasteboard changeCount]);
>        [myPasteboard setString:rtf forType:NSRTFPboardType];
>        NSLog(@"new data type changeCount %ld", [myPasteboard changeCount]);
> Adding new clipboard format doesn’t change changeCount. Setting value for newly added format also doesn’t change it.
> 
> 	[myPasteboard declareTypes:[NSArray arrayWithObjects:NSStringPboardType, NSURLPboardType, nil] owner:nil];
> declareTypes changes changeCount value.

Thanks for running those tests.  They seem to confirm what I remembered.

Since the vast majority of apps will call -clearContents or -declareTypes:owner: each time they modify the pasteboard, I'm willing to accept a version of this change.  Do you mind restoring the tracking and checking of last_types, so that we grab the Win32 clipboard if either the change count or the available types has changed?

If this approach causes problems in the future, we'll reconsider at that time.

Thanks,
Ken




More information about the wine-devel mailing list