Ken Thomases : winemac: Fix disabling of resizable windows.
Alexandre Julliard
julliard at winehq.org
Tue May 14 15:34:11 CDT 2013
Module: wine
Branch: master
Commit: 1ac1cd69addcfd65ea78a114625488e486929f56
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1ac1cd69addcfd65ea78a114625488e486929f56
Author: Ken Thomases <ken at codeweavers.com>
Date: Tue May 14 03:35:03 2013 -0500
winemac: Fix disabling of resizable windows.
---
dlls/winemac.drv/cocoa_window.h | 1 -
dlls/winemac.drv/cocoa_window.m | 52 ++++++++++++++++++++++++++++++++------
2 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h
index 2d95e1a..21bcf44 100644
--- a/dlls/winemac.drv/cocoa_window.h
+++ b/dlls/winemac.drv/cocoa_window.h
@@ -26,7 +26,6 @@
@interface WineWindow : NSPanel <NSWindowDelegate>
{
- NSUInteger normalStyleMask;
BOOL disabled;
BOOL noActivate;
BOOL floating;
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index ae69479..8ebda3b 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -460,7 +460,6 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
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 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
- (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 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
{
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 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
- (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. */
More information about the wine-cvs
mailing list