winemac: Disable moving or resizing windows when cursor clipping is in effect.
Many games clip the cursor to the client area of the window. However, on OS X, the resizing controls extend into that client area. So, it's possible that while playing, the user might unintentionally click in the resizing area and drag, resizing the window.
This commit is contained in:
parent
979c4498df
commit
ef4677106a
|
@ -97,6 +97,8 @@ @interface WineApplicationController : NSObject <NSApplicationDelegate>
|
||||||
@property (readonly, copy, nonatomic) NSEvent* lastFlagsChanged;
|
@property (readonly, copy, nonatomic) NSEvent* lastFlagsChanged;
|
||||||
@property (readonly, nonatomic) BOOL areDisplaysCaptured;
|
@property (readonly, nonatomic) BOOL areDisplaysCaptured;
|
||||||
|
|
||||||
|
@property (readonly) BOOL clippingCursor;
|
||||||
|
|
||||||
+ (WineApplicationController*) sharedController;
|
+ (WineApplicationController*) sharedController;
|
||||||
|
|
||||||
- (void) transformProcessToForeground;
|
- (void) transformProcessToForeground;
|
||||||
|
|
|
@ -100,6 +100,8 @@ @implementation WineApplicationController
|
||||||
@synthesize cursorFrames, cursorTimer, cursor;
|
@synthesize cursorFrames, cursorTimer, cursor;
|
||||||
@synthesize mouseCaptureWindow;
|
@synthesize mouseCaptureWindow;
|
||||||
|
|
||||||
|
@synthesize clippingCursor;
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (self == [WineApplicationController class])
|
if (self == [WineApplicationController class])
|
||||||
|
@ -1354,6 +1356,16 @@ - (void) updateCursorClippingState
|
||||||
[self deactivateCursorClipping];
|
[self deactivateCursorClipping];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) updateWindowsForCursorClipping
|
||||||
|
{
|
||||||
|
WineWindow* window;
|
||||||
|
for (window in [NSApp windows])
|
||||||
|
{
|
||||||
|
if ([window isKindOfClass:[WineWindow class]])
|
||||||
|
[window updateForCursorClipping];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) startClippingCursor:(CGRect)rect
|
- (BOOL) startClippingCursor:(CGRect)rect
|
||||||
{
|
{
|
||||||
CGError err;
|
CGError err;
|
||||||
|
@ -1372,6 +1384,7 @@ - (BOOL) startClippingCursor:(CGRect)rect
|
||||||
clippingCursor = TRUE;
|
clippingCursor = TRUE;
|
||||||
cursorClipRect = rect;
|
cursorClipRect = rect;
|
||||||
[self updateCursorClippingState];
|
[self updateCursorClippingState];
|
||||||
|
[self updateWindowsForCursorClipping];
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1384,6 +1397,7 @@ - (BOOL) stopClippingCursor
|
||||||
|
|
||||||
clippingCursor = FALSE;
|
clippingCursor = FALSE;
|
||||||
[self updateCursorClippingState];
|
[self updateCursorClippingState];
|
||||||
|
[self updateWindowsForCursorClipping];
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,4 +88,6 @@ - (void) postBroughtForwardEvent;
|
||||||
|
|
||||||
- (WineWindow*) ancestorWineWindow;
|
- (WineWindow*) ancestorWineWindow;
|
||||||
|
|
||||||
|
- (void) updateForCursorClipping;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -628,7 +628,8 @@ - (void) dealloc
|
||||||
|
|
||||||
- (BOOL) preventResizing
|
- (BOOL) preventResizing
|
||||||
{
|
{
|
||||||
return ([self styleMask] & NSResizableWindowMask) && (disabled || !resizable || maximized);
|
BOOL preventForClipping = cursor_clipping_locks_windows && [[WineApplicationController sharedController] clippingCursor];
|
||||||
|
return ([self styleMask] & NSResizableWindowMask) && (disabled || !resizable || maximized || preventForClipping);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) adjustFeaturesForState
|
- (void) adjustFeaturesForState
|
||||||
|
@ -659,8 +660,15 @@ - (void) adjustFeaturesForState
|
||||||
[self setContentMinSize:savedContentMinSize];
|
[self setContentMinSize:savedContentMinSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allow_immovable_windows)
|
if (allow_immovable_windows || cursor_clipping_locks_windows)
|
||||||
[self setMovable:!disabled && !maximized];
|
{
|
||||||
|
if (allow_immovable_windows && (disabled || maximized))
|
||||||
|
[self setMovable:NO];
|
||||||
|
else if (cursor_clipping_locks_windows && [[WineApplicationController sharedController] clippingCursor])
|
||||||
|
[self setMovable:NO];
|
||||||
|
else
|
||||||
|
[self setMovable:YES];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) adjustFullScreenBehavior:(NSWindowCollectionBehavior)behavior
|
- (void) adjustFullScreenBehavior:(NSWindowCollectionBehavior)behavior
|
||||||
|
@ -1494,6 +1502,11 @@ - (void) postBroughtForwardEvent
|
||||||
macdrv_release_event(event);
|
macdrv_release_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) updateForCursorClipping
|
||||||
|
{
|
||||||
|
[self adjustFeaturesForState];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ---------- NSWindow method overrides ----------
|
* ---------- NSWindow method overrides ----------
|
||||||
|
|
|
@ -147,6 +147,7 @@
|
||||||
extern int left_option_is_alt DECLSPEC_HIDDEN;
|
extern int left_option_is_alt DECLSPEC_HIDDEN;
|
||||||
extern int right_option_is_alt DECLSPEC_HIDDEN;
|
extern int right_option_is_alt DECLSPEC_HIDDEN;
|
||||||
extern int allow_immovable_windows DECLSPEC_HIDDEN;
|
extern int allow_immovable_windows DECLSPEC_HIDDEN;
|
||||||
|
extern int cursor_clipping_locks_windows DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
extern int macdrv_start_cocoa_app(unsigned long long tickcount) DECLSPEC_HIDDEN;
|
extern int macdrv_start_cocoa_app(unsigned long long tickcount) DECLSPEC_HIDDEN;
|
||||||
extern void macdrv_window_rejected_focus(const struct macdrv_event *event) DECLSPEC_HIDDEN;
|
extern void macdrv_window_rejected_focus(const struct macdrv_event *event) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -55,6 +55,7 @@ int right_option_is_alt = 0;
|
||||||
BOOL allow_software_rendering = FALSE;
|
BOOL allow_software_rendering = FALSE;
|
||||||
BOOL disable_window_decorations = FALSE;
|
BOOL disable_window_decorations = FALSE;
|
||||||
int allow_immovable_windows = TRUE;
|
int allow_immovable_windows = TRUE;
|
||||||
|
int cursor_clipping_locks_windows = TRUE;
|
||||||
HMODULE macdrv_module = 0;
|
HMODULE macdrv_module = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +176,9 @@ static void setup_options(void)
|
||||||
if (!get_config_key(hkey, appkey, "AllowImmovableWindows", buffer, sizeof(buffer)))
|
if (!get_config_key(hkey, appkey, "AllowImmovableWindows", buffer, sizeof(buffer)))
|
||||||
allow_immovable_windows = IS_OPTION_TRUE(buffer[0]);
|
allow_immovable_windows = IS_OPTION_TRUE(buffer[0]);
|
||||||
|
|
||||||
|
if (!get_config_key(hkey, appkey, "CursorClippingLocksWindows", buffer, sizeof(buffer)))
|
||||||
|
cursor_clipping_locks_windows = IS_OPTION_TRUE(buffer[0]);
|
||||||
|
|
||||||
if (appkey) RegCloseKey(appkey);
|
if (appkey) RegCloseKey(appkey);
|
||||||
if (hkey) RegCloseKey(hkey);
|
if (hkey) RegCloseKey(hkey);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue