winemac: Fix disabling of resizable windows.

This commit is contained in:
Ken Thomases 2013-05-14 03:35:03 -05:00 committed by Alexandre Julliard
parent 462ad39949
commit 1ac1cd69ad
2 changed files with 43 additions and 10 deletions

View File

@ -26,7 +26,6 @@
@interface WineWindow : NSPanel <NSWindowDelegate>
{
NSUInteger normalStyleMask;
BOOL disabled;
BOOL noActivate;
BOOL floating;

View File

@ -460,7 +460,6 @@ + (WineWindow*) createWindowWithFeatures:(const struct macdrv_window_features*)w
defer:YES] autorelease];
if (!window) return nil;
window->normalStyleMask = [window styleMask];
/* Standardize windows to eliminate differences between titled and
borderless windows and between NSWindow and NSPanel. */
@ -515,22 +514,37 @@ - (void) dealloc
- (void) adjustFeaturesForState
{
NSUInteger style = normalStyleMask;
if (self.disabled)
style &= ~NSResizableWindowMask;
if (style != [self styleMask])
[self setStyleMask:style];
NSUInteger style = [self styleMask];
if (style & NSClosableWindowMask)
[[self standardWindowButton:NSWindowCloseButton] setEnabled:!self.disabled];
if (style & NSMiniaturizableWindowMask)
[[self standardWindowButton:NSWindowMiniaturizeButton] setEnabled:!self.disabled];
if (style & NSResizableWindowMask)
[[self standardWindowButton:NSWindowZoomButton] setEnabled:!self.disabled];
}
- (void) setWindowFeatures:(const struct macdrv_window_features*)wf
{
normalStyleMask = style_mask_for_features(wf);
NSUInteger currentStyle = [self styleMask];
NSUInteger newStyle = style_mask_for_features(wf);
if (newStyle != currentStyle)
{
BOOL showingButtons = (currentStyle & (NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)) != 0;
BOOL shouldShowButtons = (newStyle & (NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)) != 0;
if (shouldShowButtons != showingButtons && !((newStyle ^ currentStyle) & NSClosableWindowMask))
{
// -setStyleMask: is buggy on 10.7+ with respect to NSResizableWindowMask.
// If transitioning from NSTitledWindowMask | NSResizableWindowMask to
// just NSTitledWindowMask, the window buttons should disappear rather
// than just being disabled. But they don't. Similarly in reverse.
// The workaround is to also toggle NSClosableWindowMask at the same time.
[self setStyleMask:newStyle ^ NSClosableWindowMask];
}
[self setStyleMask:newStyle];
}
[self adjustFeaturesForState];
[self setHasShadow:wf->shadow];
}
@ -791,6 +805,18 @@ - (void) setDisabled:(BOOL)newValue
{
disabled = newValue;
[self adjustFeaturesForState];
if (disabled)
{
NSSize size = [self frame].size;
[self setMinSize:size];
[self setMaxSize:size];
}
else
{
[self setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
[self setMinSize:NSZeroSize];
}
}
}
@ -1165,8 +1191,16 @@ - (void)windowDidResignKey:(NSNotification *)notification
- (void)windowDidResize:(NSNotification *)notification
{
macdrv_event* event;
NSRect frame = [self contentRectForFrameRect:[self frame]];
NSRect frame = [self frame];
if (self.disabled)
{
NSSize size = frame.size;
[self setMinSize:size];
[self setMaxSize:size];
}
frame = [self contentRectForFrameRect:frame];
[[WineApplicationController sharedController] flipRect:&frame];
/* Coalesce events by discarding any previous ones still in the queue. */