Ken Thomases : winemac: Implement support for WS_DISABLED windows.
Alexandre Julliard
julliard at winehq.org
Fri Jan 11 13:46:58 CST 2013
Module: wine
Branch: master
Commit: 064186e7394ff3070ca13101b974847a67c9e4d1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=064186e7394ff3070ca13101b974847a67c9e4d1
Author: Ken Thomases <ken at codeweavers.com>
Date: Fri Jan 11 06:18:05 2013 -0600
winemac: Implement support for WS_DISABLED windows.
---
dlls/winemac.drv/cocoa_window.h | 5 +++
dlls/winemac.drv/cocoa_window.m | 56 +++++++++++++++++++++++++++++++++++++-
dlls/winemac.drv/macdrv_cocoa.h | 6 ++++
dlls/winemac.drv/window.c | 16 +++++++++++
4 files changed, 81 insertions(+), 2 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h
index 3b9dc90..1edcd9c 100644
--- a/dlls/winemac.drv/cocoa_window.h
+++ b/dlls/winemac.drv/cocoa_window.h
@@ -22,4 +22,9 @@
@interface WineWindow : NSPanel <NSWindowDelegate>
+{
+ NSUInteger normalStyleMask;
+ BOOL disabled;
+}
+
@end
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index 608f750..848e49e 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -60,6 +60,8 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
@interface WineWindow ()
+ at property (nonatomic) BOOL disabled;
+
+ (void) flipRect:(NSRect*)rect;
@end
@@ -77,6 +79,8 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
@implementation WineWindow
+ @synthesize disabled;
+
+ (WineWindow*) createWindowWithFeatures:(const struct macdrv_window_features*)wf
windowFrame:(NSRect)window_frame
{
@@ -90,6 +94,9 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
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 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
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 @@ static BOOL frame_intersects_screens(NSRect frame, NSArray* screens)
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
@@ -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
*
* Set a Cocoa window's title.
diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h
index 4cebcef..e2a735b 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -125,11 +125,17 @@ struct macdrv_window_features {
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,
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index 696941c..8520afa 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -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
*
* 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)
{
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);
}
More information about the wine-cvs
mailing list