early-access version 1667
This commit is contained in:
45
externals/SDL/src/video/cocoa/SDL_cocoawindow.m
vendored
45
externals/SDL/src/video/cocoa/SDL_cocoawindow.m
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "SDL_cocoavideo.h"
|
||||
#include "SDL_cocoashape.h"
|
||||
#include "SDL_cocoamouse.h"
|
||||
#include "SDL_cocoamousetap.h"
|
||||
#include "SDL_cocoaopengl.h"
|
||||
#include "SDL_cocoaopengles.h"
|
||||
|
||||
@@ -161,6 +160,16 @@
|
||||
SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]);
|
||||
NSArray *array = [pasteboard propertyListForType:@"NSFilenamesPboardType"];
|
||||
|
||||
/* Code addon to update the mouse location */
|
||||
NSPoint point = [sender draggingLocation];
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
int x = (int)point.x;
|
||||
int y = (int)(sdlwindow->h - point.y);
|
||||
if (x >= 0 && x < sdlwindow->w && y >= 0 && y < sdlwindow->h) {
|
||||
SDL_SendMouseMotion(sdlwindow, mouse->mouseID, 0, x, y);
|
||||
}
|
||||
/* Code addon to update the mouse location */
|
||||
|
||||
for (NSString *path in array) {
|
||||
NSURL *fileURL = [NSURL fileURLWithPath:path];
|
||||
NSNumber *isAlias = nil;
|
||||
@@ -1099,7 +1108,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
|
||||
x = (int)point.x;
|
||||
y = (int)(window->h - point.y);
|
||||
|
||||
if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
|
||||
if (window->flags & SDL_WINDOW_MOUSE_GRABBED) {
|
||||
if (x < 0 || x >= window->w || y < 0 || y >= window->h) {
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
@@ -1112,13 +1121,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
|
||||
y = window->h - 1;
|
||||
}
|
||||
|
||||
#if !SDL_MAC_NO_SANDBOX
|
||||
CGPoint cgpoint;
|
||||
|
||||
/* When SDL_MAC_NO_SANDBOX is set, this is handled by
|
||||
* SDL_cocoamousetap.m.
|
||||
*/
|
||||
|
||||
cgpoint.x = window->x + x;
|
||||
cgpoint.y = window->y + y;
|
||||
|
||||
@@ -1126,7 +1129,6 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
|
||||
CGAssociateMouseAndMouseCursorPosition(YES);
|
||||
|
||||
Cocoa_HandleMouseWarp(cgpoint.x, cgpoint.y);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1403,7 +1405,10 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, NSView *nsview,
|
||||
{
|
||||
unsigned long style = [nswindow styleMask];
|
||||
|
||||
if (style == NSWindowStyleMaskBorderless) {
|
||||
/* NSWindowStyleMaskBorderless is zero, and it's possible to be
|
||||
Resizeable _and_ borderless, so we can't do a simple bitwise AND
|
||||
of NSWindowStyleMaskBorderless here. */
|
||||
if ((style & ~NSWindowStyleMaskResizable) == NSWindowStyleMaskBorderless) {
|
||||
window->flags |= SDL_WINDOW_BORDERLESS;
|
||||
} else {
|
||||
window->flags &= ~SDL_WINDOW_BORDERLESS;
|
||||
@@ -1809,6 +1814,18 @@ Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
if (on_top) {
|
||||
[nswindow setLevel:NSFloatingWindowLevel];
|
||||
} else {
|
||||
[nswindow setLevel:kCGNormalWindowLevel];
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
|
||||
{ @autoreleasepool
|
||||
@@ -1948,14 +1965,10 @@ Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
Cocoa_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
/* Enable or disable the event tap as necessary */
|
||||
Cocoa_EnableMouseEventTap(mouse->driverdata, grabbed);
|
||||
|
||||
/* Move the cursor to the nearest point in the window */
|
||||
if (grabbed && data && ![data->listener isMoving]) {
|
||||
int x, y;
|
||||
|
||||
Reference in New Issue
Block a user