Ken Thomases : winemac: Properly ignore attempts to set a window' s shape to its current shape.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Oct 3 03:04:12 CDT 2014
Module: wine
Branch: master
Commit: 31d7f61cc3525d32c0624564f9ac9033010fb968
URL: http://source.winehq.org/git/wine.git/?a=commit;h=31d7f61cc3525d32c0624564f9ac9033010fb968
Author: Ken Thomases <ken at codeweavers.com>
Date: Thu Oct 2 17:06:19 2014 -0500
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.
---
dlls/winemac.drv/cocoa_window.h | 1 +
dlls/winemac.drv/cocoa_window.m | 25 +++++++++++++++++--------
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h
index 88ef23d..574ff75 100644
--- a/dlls/winemac.drv/cocoa_window.h
+++ b/dlls/winemac.drv/cocoa_window.h
@@ -44,6 +44,7 @@
pthread_mutex_t* surface_mutex;
NSBezierPath* shape;
+ NSData* shapeData;
BOOL shapeChangedSinceLastDraw;
BOOL colorKeyed;
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index d9a421e..35222c1 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -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;
+ at 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,16 +2380,24 @@ void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count)
OnMainThread(^{
if (!rects || !count)
+ {
window.shape = nil;
+ window.shapeData = nil;
+ }
else
{
- NSBezierPath* path;
- unsigned int i;
+ size_t length = sizeof(*rects) * count;
+ if (window.shapeData.length != length || memcmp(window.shapeData.bytes, rects, length))
+ {
+ NSBezierPath* path;
+ unsigned int i;
- path = [NSBezierPath bezierPath];
- for (i = 0; i < count; i++)
- [path appendBezierPathWithRect:NSRectFromCGRect(rects[i])];
- window.shape = path;
+ path = [NSBezierPath bezierPath];
+ for (i = 0; i < count; i++)
+ [path appendBezierPathWithRect:NSRectFromCGRect(rects[i])];
+ window.shape = path;
+ window.shapeData = [NSData dataWithBytes:rects length:length];
+ }
}
});
More information about the wine-cvs
mailing list