winemac: Properly ignore attempts to set a window's shape to its current shape.
NSBezierPath doesn't override the -isEqual: method to actually compare paths, so it just falls back to object identity which, in our case, makes paths seem like they're never equal. Also, memcmp()-ing the rectangle array is almost certainly faster than any general test for equality between two paths.
This commit is contained in:
parent
170d80dc90
commit
31d7f61cc3
|
@ -44,6 +44,7 @@ @interface WineWindow : NSPanel <NSWindowDelegate>
|
|||
pthread_mutex_t* surface_mutex;
|
||||
|
||||
NSBezierPath* shape;
|
||||
NSData* shapeData;
|
||||
BOOL shapeChangedSinceLastDraw;
|
||||
|
||||
BOOL colorKeyed;
|
||||
|
|
|
@ -182,6 +182,7 @@ @interface WineWindow ()
|
|||
@property (nonatomic) pthread_mutex_t* surface_mutex;
|
||||
|
||||
@property (copy, nonatomic) NSBezierPath* shape;
|
||||
@property (copy, nonatomic) NSData* shapeData;
|
||||
@property (nonatomic) BOOL shapeChangedSinceLastDraw;
|
||||
@property (readonly, nonatomic) BOOL needsTransparency;
|
||||
|
||||
|
@ -540,7 +541,7 @@ @implementation WineWindow
|
|||
|
||||
@synthesize disabled, noActivate, floating, fullscreen, fakingClose, latentParentWindow, hwnd, queue;
|
||||
@synthesize surface, surface_mutex;
|
||||
@synthesize shape, shapeChangedSinceLastDraw;
|
||||
@synthesize shape, shapeData, shapeChangedSinceLastDraw;
|
||||
@synthesize colorKeyed, colorKeyRed, colorKeyGreen, colorKeyBlue;
|
||||
@synthesize usePerPixelAlpha;
|
||||
@synthesize imeData, commandDone;
|
||||
|
@ -634,6 +635,7 @@ - (void) dealloc
|
|||
[latentChildWindows release];
|
||||
[latentParentWindow release];
|
||||
[shape release];
|
||||
[shapeData release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -1401,7 +1403,6 @@ - (void) checkTransparency
|
|||
- (void) setShape:(NSBezierPath*)newShape
|
||||
{
|
||||
if (shape == newShape) return;
|
||||
if (shape && newShape && [shape isEqual:newShape]) return;
|
||||
|
||||
if (shape)
|
||||
{
|
||||
|
@ -2379,8 +2380,14 @@ void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count)
|
|||
|
||||
OnMainThread(^{
|
||||
if (!rects || !count)
|
||||
{
|
||||
window.shape = nil;
|
||||
window.shapeData = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t length = sizeof(*rects) * count;
|
||||
if (window.shapeData.length != length || memcmp(window.shapeData.bytes, rects, length))
|
||||
{
|
||||
NSBezierPath* path;
|
||||
unsigned int i;
|
||||
|
@ -2389,6 +2396,8 @@ void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count)
|
|||
for (i = 0; i < count; i++)
|
||||
[path appendBezierPathWithRect:NSRectFromCGRect(rects[i])];
|
||||
window.shape = path;
|
||||
window.shapeData = [NSData dataWithBytes:rects length:length];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue