Commit 064186e7 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Implement support for WS_DISABLED windows.

parent bd08cecb
...@@ -22,4 +22,9 @@ ...@@ -22,4 +22,9 @@
@interface WineWindow : NSPanel <NSWindowDelegate> @interface WineWindow : NSPanel <NSWindowDelegate>
{
NSUInteger normalStyleMask;
BOOL disabled;
}
@end @end
...@@ -60,6 +60,8 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens) ...@@ -60,6 +60,8 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
@interface WineWindow () @interface WineWindow ()
@property (nonatomic) BOOL disabled;
+ (void) flipRect:(NSRect*)rect; + (void) flipRect:(NSRect*)rect;
@end @end
...@@ -77,6 +79,8 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens) ...@@ -77,6 +79,8 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
@implementation WineWindow @implementation WineWindow
@synthesize disabled;
+ (WineWindow*) createWindowWithFeatures:(const struct macdrv_window_features*)wf + (WineWindow*) createWindowWithFeatures:(const struct macdrv_window_features*)wf
windowFrame:(NSRect)window_frame windowFrame:(NSRect)window_frame
{ {
...@@ -90,6 +94,9 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens) ...@@ -90,6 +94,9 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
backing:NSBackingStoreBuffered backing:NSBackingStoreBuffered
defer:YES] autorelease]; defer:YES] autorelease];
if (!window) return nil;
window->normalStyleMask = [window styleMask];
/* Standardize windows to eliminate differences between titled and /* Standardize windows to eliminate differences between titled and
borderless windows and between NSWindow and NSPanel. */ borderless windows and between NSWindow and NSPanel. */
[window setHidesOnDeactivate:NO]; [window setHidesOnDeactivate:NO];
...@@ -115,12 +122,33 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens) ...@@ -115,12 +122,33 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
rect->origin.y = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - NSMaxY(*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 - (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]; [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 /* Returns whether or not the window was ordered in, which depends on if
its frame intersects any screen. */ its frame intersects any screen. */
- (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next - (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next
...@@ -171,13 +199,22 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens) ...@@ -171,13 +199,22 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
return on_screen; return on_screen;
} }
- (void) setDisabled:(BOOL)newValue
{
if (disabled != newValue)
{
disabled = newValue;
[self adjustFeaturesForState];
}
}
/* /*
* ---------- NSWindow method overrides ---------- * ---------- NSWindow method overrides ----------
*/ */
- (BOOL) canBecomeKeyWindow - (BOOL) canBecomeKeyWindow
{ {
return YES; return !self.disabled;
} }
- (BOOL) canBecomeMainWindow - (BOOL) canBecomeMainWindow
...@@ -248,6 +285,21 @@ void macdrv_set_cocoa_window_features(macdrv_window w, ...@@ -248,6 +285,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 * macdrv_set_cocoa_window_title
* *
* Set a Cocoa window's title. * Set a Cocoa window's title.
......
...@@ -125,11 +125,17 @@ struct macdrv_window_features { ...@@ -125,11 +125,17 @@ struct macdrv_window_features {
unsigned int shadow:1; 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, extern macdrv_window macdrv_create_cocoa_window(const struct macdrv_window_features* wf,
CGRect frame) DECLSPEC_HIDDEN; CGRect frame) DECLSPEC_HIDDEN;
extern void macdrv_destroy_cocoa_window(macdrv_window w) DECLSPEC_HIDDEN; extern void macdrv_destroy_cocoa_window(macdrv_window w) DECLSPEC_HIDDEN;
extern void macdrv_set_cocoa_window_features(macdrv_window w, extern void macdrv_set_cocoa_window_features(macdrv_window w,
const struct macdrv_window_features* wf) DECLSPEC_HIDDEN; 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, extern void macdrv_set_cocoa_window_title(macdrv_window w, const UniChar* title,
size_t length) DECLSPEC_HIDDEN; size_t length) DECLSPEC_HIDDEN;
extern int macdrv_order_cocoa_window(macdrv_window w, macdrv_window prev, extern int macdrv_order_cocoa_window(macdrv_window w, macdrv_window prev,
......
...@@ -74,6 +74,18 @@ static void get_cocoa_window_features(struct macdrv_win_data *data, ...@@ -74,6 +74,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 * get_mac_rect_offset
* *
* Helper for macdrv_window_to_mac_rect and macdrv_mac_to_window_rect. * Helper for macdrv_window_to_mac_rect and macdrv_mac_to_window_rect.
...@@ -268,12 +280,16 @@ static void set_cocoa_window_properties(struct macdrv_win_data *data) ...@@ -268,12 +280,16 @@ static void set_cocoa_window_properties(struct macdrv_win_data *data)
{ {
DWORD style, ex_style; DWORD style, ex_style;
struct macdrv_window_features wf; struct macdrv_window_features wf;
struct macdrv_window_state state;
style = GetWindowLongW(data->hwnd, GWL_STYLE); style = GetWindowLongW(data->hwnd, GWL_STYLE);
ex_style = GetWindowLongW(data->hwnd, GWL_EXSTYLE); ex_style = GetWindowLongW(data->hwnd, GWL_EXSTYLE);
get_cocoa_window_features(data, style, ex_style, &wf); get_cocoa_window_features(data, style, ex_style, &wf);
macdrv_set_cocoa_window_features(data->cocoa_window, &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);
} }
......
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