Commit 31d7f61c authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

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.
parent 170d80dc
......@@ -44,6 +44,7 @@
pthread_mutex_t* surface_mutex;
NSBezierPath* shape;
NSData* shapeData;
BOOL shapeChangedSinceLastDraw;
BOOL colorKeyed;
......
......@@ -182,6 +182,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
@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 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
@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 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
[latentChildWindows release];
[latentParentWindow release];
[shape release];
[shapeData release];
[super dealloc];
}
......@@ -1401,7 +1403,6 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
- (void) setShape:(NSBezierPath*)newShape
{
if (shape == newShape) return;
if (shape && newShape && [shape isEqual:newShape]) return;
if (shape)
{
......@@ -2379,9 +2380,15 @@ 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];
}
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment