winemac: Implement support for WS_DISABLED windows.

This commit is contained in:
Ken Thomases 2013-01-11 06:18:05 -06:00 committed by Alexandre Julliard
parent bd08cecbb6
commit 064186e739
4 changed files with 81 additions and 2 deletions

View File

@ -22,4 +22,9 @@
@interface WineWindow : NSPanel <NSWindowDelegate>
{
NSUInteger normalStyleMask;
BOOL disabled;
}
@end

View File

@ -60,6 +60,8 @@ @interface WineContentView : NSView
@interface WineWindow ()
@property (nonatomic) BOOL disabled;
+ (void) flipRect:(NSRect*)rect;
@end
@ -77,6 +79,8 @@ - (BOOL) isFlipped
@implementation WineWindow
@synthesize disabled;
+ (WineWindow*) createWindowWithFeatures:(const struct macdrv_window_features*)wf
windowFrame:(NSRect)window_frame
{
@ -90,6 +94,9 @@ + (WineWindow*) createWindowWithFeatures:(const struct macdrv_window_features*)w
backing:NSBackingStoreBuffered
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. */
[window setHidesOnDeactivate:NO];
@ -115,12 +122,33 @@ + (void) flipRect:(NSRect*)rect
rect->origin.y = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - NSMaxY(*rect);
}
- (void) adjustFeaturesForState
{
NSUInteger style = normalStyleMask;
if (self.disabled)
style &= ~NSResizableWindowMask;
if (style != [self styleMask])
[self setStyleMask:style];
if (style & NSClosableWindowMask)
[[self standardWindowButton:NSWindowCloseButton] setEnabled:!self.disabled];
if (style & NSMiniaturizableWindowMask)
[[self standardWindowButton:NSWindowMiniaturizeButton] setEnabled:!self.disabled];
}
- (void) setWindowFeatures:(const struct macdrv_window_features*)wf
{
[self setStyleMask:style_mask_for_features(wf)];
normalStyleMask = style_mask_for_features(wf);
[self adjustFeaturesForState];
[self setHasShadow:wf->shadow];
}
- (void) setMacDrvState:(const struct macdrv_window_state*)state
{
self.disabled = state->disabled;
}
/* Returns whether or not the window was ordered in, which depends on if
its frame intersects any screen. */
- (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next
@ -171,13 +199,22 @@ - (BOOL) setFrameIfOnScreen:(NSRect)contentRect
return on_screen;
}
- (void) setDisabled:(BOOL)newValue
{
if (disabled != newValue)
{
disabled = newValue;
[self adjustFeaturesForState];
}
}
/*
* ---------- NSWindow method overrides ----------
*/
- (BOOL) canBecomeKeyWindow
{
return YES;
return !self.disabled;
}
- (BOOL) canBecomeMainWindow
@ -247,6 +284,21 @@ void macdrv_set_cocoa_window_features(macdrv_window w,
});
}
/***********************************************************************
* macdrv_set_cocoa_window_state
*
* Update a Cocoa window's state.
*/
void macdrv_set_cocoa_window_state(macdrv_window w,
const struct macdrv_window_state* state)
{
WineWindow* window = (WineWindow*)w;
OnMainThread(^{
[window setMacDrvState:state];
});
}
/***********************************************************************
* macdrv_set_cocoa_window_title
*

View File

@ -125,11 +125,17 @@
unsigned int shadow:1;
};
struct macdrv_window_state {
unsigned int disabled:1;
};
extern macdrv_window macdrv_create_cocoa_window(const struct macdrv_window_features* wf,
CGRect frame) DECLSPEC_HIDDEN;
extern void macdrv_destroy_cocoa_window(macdrv_window w) DECLSPEC_HIDDEN;
extern void macdrv_set_cocoa_window_features(macdrv_window w,
const struct macdrv_window_features* wf) DECLSPEC_HIDDEN;
extern void macdrv_set_cocoa_window_state(macdrv_window w,
const struct macdrv_window_state* state) DECLSPEC_HIDDEN;
extern void macdrv_set_cocoa_window_title(macdrv_window w, const UniChar* title,
size_t length) DECLSPEC_HIDDEN;
extern int macdrv_order_cocoa_window(macdrv_window w, macdrv_window prev,

View File

@ -73,6 +73,18 @@ static void get_cocoa_window_features(struct macdrv_win_data *data,
}
/***********************************************************************
* get_cocoa_window_state
*/
static void get_cocoa_window_state(struct macdrv_win_data *data,
DWORD style, DWORD ex_style,
struct macdrv_window_state* state)
{
memset(state, 0, sizeof(*state));
state->disabled = (style & WS_DISABLED) != 0;
}
/***********************************************************************
* get_mac_rect_offset
*
@ -268,12 +280,16 @@ static void set_cocoa_window_properties(struct macdrv_win_data *data)
{
DWORD style, ex_style;
struct macdrv_window_features wf;
struct macdrv_window_state state;
style = GetWindowLongW(data->hwnd, GWL_STYLE);
ex_style = GetWindowLongW(data->hwnd, GWL_EXSTYLE);
get_cocoa_window_features(data, style, ex_style, &wf);
macdrv_set_cocoa_window_features(data->cocoa_window, &wf);
get_cocoa_window_state(data, style, ex_style, &state);
macdrv_set_cocoa_window_state(data->cocoa_window, &state);
}