src/video/cocoa


Log

Author Commit Date CI Message
Ryan C. Gordon 84ad5316 2023-08-01T18:34:03 cocoa: Ignore first mouse motion event after enabling relative mode. Fixes #7918. (cherry picked from commit dc5dda0f311ea596a5152ec2f8f062f9309eb1d9)
Ryan C. Gordon 2afb49ba 2023-06-11T12:43:47 cocoa: Warp mouse to center of window before enabling relative mouse. This prevents the case where the mouse might be at the edge of the window when enabling relative mode, which confuses macOS, at it might believe the user is attempting to resize the window. Fixes #6994.
Sam Lantinga 3f1fd5ab 2023-05-23T10:59:03 Updated source to match SDL function prototype style
Cyril Dubet 7914234b 2023-04-05T01:21:41 Fix key code names for ISO keyboard layouts (cherry picked from commit 60dcaff7eb25a01c9c87a5fed335b29a5625b95b)
Deve 1c2f8252 2023-03-08T23:57:08 Fixed incorrect modifier keys handling on macOS (cherry-picked from commit 45a58b7882a253db29b1b1393bc2a1fe030d5955)
Sam Lantinga f5c0760c 2023-03-08T01:15:21 Disassociate the SDLOpenGLContext from the view before deleting it If we don't do this, the view will be blanked even if another context is current and rendering from that context won't be visible. Fixes https://github.com/libsdl-org/SDL/issues/4986
Sam Lantinga 63e6c19b 2023-03-08T01:13:00 Use SDL_GL_DeleteContext instead of Cocoa_GL_DeleteContext for context cleanup That will make the current context NULL before deleting the context.
Sam Lantinga 031348d3 2023-02-28T09:02:01 Fixed SDL windows getting the maximized state after leaving fullscreen on macOS (cherry picked from commit 2df08fb1b27b721998a1380a2acdbe1494b5591e)
Sam Lantinga 0efb31ef 2023-02-20T10:40:54 cocoa/gles: do not unload EGL when context is destroyed (cherry picked from commit e8091b89830c3b9bb19eff76463a6e2525f05fa5)
Sylvain 17515f4a 2023-02-04T15:51:37 Backport simplify flags PR #7220
Sasha Szpakowski 17ecb11e 2023-02-01T18:56:33 macOS: fix initial Metal drawable size in certain multi-display setups (cherry picked from commit baca26d72701655157c2a1ab678c2d5af0830d53)
Matt Durgavich dfc56cfc 2023-01-05T11:54:27 Fix For issue #6948 (#6991) MessageBoxes attached to a window in macOS should use modal APIs and not use a poll/sleep pattern on the main thread. Sleeping the main thread makes the NSWindow message loop sluggish and interferes with external applications that need to send messages to that window, such as VoiceOver.
Sam Lantinga 0479df53 2023-01-09T09:48:21 Updated copyright for 2023
Ozkan Sezer b990e914 2022-12-02T02:13:59 build fixes after d0bbfdbfb881e5407911d84c12899bd5b442a130
Pierre Wendling d0bbfdbf 2022-12-01T16:07:03 Clang-Tidy fixes (#6725) (cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
Sam Lantinga 7b100001 2022-11-30T15:51:17 Reverted code formatting for Apple platforms We didn't get the merge right, and rather than tease out exactly what happened, I'm just reverting for now.
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
pionere 72484511 2022-11-29T18:43:36 video: fix error messages - do not overwrite error message set by SDL_InitFormat (SDL_AllocFormat) - set proper error message (Cocoa_Metal_CreateView) - protect against allocation failure (UIKit_Metal_CreateView) (cherry picked from commit cf0cb44df88a4293805fdc926880155d58a46bea)
Joshua Root 2df39e64 2022-11-27T11:27:19 Fix build with Xcode < 7 The _Nullable attribute is not available in older versions. (cherry picked from commit 9a64aa6f95298bf459f8b9dca583df7064956cd9)
Ryan C. Gordon 3f5593d6 2022-11-26T13:57:12 cocoa: Patched to compile on macOS SDK < 10.10. Fixes #6586. (cherry picked from commit fa5adcafd52303fde86c64094462303404259d75)
Joshua Root f52e7199 2022-08-28T00:52:19 Check build-time SDK in LoadMainMenuNibIfAvailable Fixes building against OS X 10.7 SDK. (cherry picked from commit f8cebeea599ae65f36d388257a9d9a8ed8ada576)
Joshua Root e12c831b 2022-11-24T06:32:49 SDL_cocoaopengl.h: ensure CVDisplayLinkRef is defined The typedef seems to be pulled in coincidentally with newer SDKs, but older ones need to import the header explicitly. (cherry picked from commit d2910904fb4062c313636c7595e971f1bf248075)
Sam Lantinga 913e403f 2022-11-16T18:03:29 Fixed error message when trying to create an OpenGLES2 renderer on macOS Testing: testsprite2 --renderer opengles2 OpenGLES2 isn't available by default, and we want to see the error "Could not load EGL library"
Ryan C. Gordon 7ebdae5d 2022-11-16T11:45:41 cocoa: Fix OpenGL deprecation warning.
Ryan C. Gordon 7c760f7f 2022-11-16T11:32:08 cocoa: Update CVDisplayLink timing when screen changes. This handles both the window moving to a new display and changing the current display's refresh rate in System Preferences Reference Issue #4918.
Ryan C. Gordon 1fd66cc8 2022-11-16T10:15:21 Revert "cocoa: Backed out CVDisplayLink code for macOS vsync." This reverts commit 04b50f6c6bef67b744b192c78775771b51ff2141. It turns out OpenGL vsync has broken again in macOS 12, so we're reintroducing our CVDisplayLink code to deal with it, again. Reference Issue #4918.
Hubert Maier 5dc93451 2022-11-06T20:49:37 JANITORIAL : Correct some more spelling mistakes (#6489)
Sam Lantinga c2675d74 2022-11-06T10:52:20 Revert "cocoa: Discard the IME Candidate Window immediately when Escape is pressed" This reverts commit 0d76e2a8a1a8e6a2801123587c2205a288d49406, as it introduced other issues: https://github.com/libsdl-org/SDL/pull/6486#issuecomment-1304684865
Edward Li 0d76e2a8 2022-11-06T04:59:02 cocoa: Discard the IME Candidate Window immediately when Escape is pressed
Guldoman 084fa4c3 2022-11-01T10:55:17 cocoa: Reset IME when sending composed text This will send an empty `TEXTEDITING` event that is used to signal the end of the composition.
Ryan C. Gordon 41d38c0f 2022-10-26T09:43:04 shape: More robust handling of failure cases in CreateShaper.
Ryan C. Gordon c8d20f96 2022-10-25T23:13:34 shape: Free platform-specific shaped window data. Fixes #2128.
Steven Noonan d2300516 2022-09-07T06:49:02 cocoa: set sRGB colorspace on nswindow This makes the colorspace match across different graphics APIs. By default, OpenGL was getting a much more saturated colorspace (maybe Display P3?) and it was looking very different from the rendering done by Metal or MoltenVK.
Steven Noonan 019e9d4c 2022-08-25T23:15:58 SDL_cocoavideo.m: add missing SDL_cocoaopengles.h include
Deve 7e108816 2022-10-18T01:07:54 Fixed command modifier on macOS
Deve cdf312c8 2022-10-18T00:48:55 Fixed mouse warp after resizing window on macOS.
Sam Lantinga 91ff8845 2022-10-13T23:56:17 Disable "The key you just pressed is not recognized by SDL." message by default
slime bbeacd72 2022-10-02T22:57:03 Fix some credit comments.
Aaron Barany 5e654a4b 2022-10-01T16:10:46 Fixed Mac compile errors when OpenGL is disabled.
Ryan C. Gordon 57b20e7b 2022-09-27T14:23:42 cocoa: Fix new windows setting SDL_WINDOW_BORDERLESS flag incorrectly. Fixes #6172.
Noel Berry 00452e47 2022-08-24T11:25:13 Adding SDL_GetWindowSizeInPixels for window size in pixels (#6112)
slime b204db1e 2022-08-21T18:06:11 cocoa: change Shape data to use ObjC objects instead of C structs. Fixes #6089
Luke Street 2b93f6e1 2022-05-20T09:55:06 cocoa/uikit: Use VK_EXT_metal_surface in Vulkan_GetInstanceExtensions Replaces VK_MVK_macos_surface and VK_MVK_ios_surface
Luke Street 029a9b2f 2022-05-19T12:57:35 cocoa/uikit: Support VK_EXT_metal_surface Uses VK_EXT_metal_surface (vkCreateMetalSurfaceEXT) when possible, otherwise falls back to the obsoleted VK_MVK_macos_surface and VK_MVK_ios_surface. Fixes #3906
Ryan C. Gordon 26948f01 2022-08-15T20:09:09 cocoa: Make SDL_MinimizeWindow() work with borderless windows. Fixes #6046.
Cameron Gutman 3046d55d 2022-08-12T22:02:26 cocoa: Return an error if GetWindowDisplayIndex() is called too early SDL_CreateWindow() may call GetWindowDisplayIndex() to compute the position of a new window that the caller has requested to be placed on a certain display. Since we haven't fully constructed the window yet, our driverdata will be nil and we will fail to get the NSScreen (which is fine). However, we need to return an error (not 0, which is a valid display index) for SDL_GetWindowDisplayIndex() to know to figure out the display index itself. Fixes positioning new windows on secondary displays when using SDL_WINDOWPOS_CENTERED_DISPLAY() and SDL_WINDOWPOS_UNDEFINED_DISPLAY().
Sam Lantinga 08d17f47 2022-08-12T20:26:23 Removed unused variable
Ryan C. Gordon 3119d58f 2022-08-10T10:48:23 cocoa: Change the new sync_dispatch hint to async_dispatch. This is so the default is safer.
Ryan C. Gordon bdc7f958 2022-08-10T00:41:25 cocoa: Added hint to treat MacBook trackpads as touch devices, not mice. Fixes #5511.
Salman Ahmed b4660e9d 2022-08-10T03:40:00 macOS: Add hint for blocking thread on OpenGL context update dispatch (#5708)
Ryan C. Gordon 56c1481c 2022-08-08T20:33:44 cocoa: Don't mark fullscreen-desktop windows as non-resizable. Otherwise, we can't tile SDL apps in Spaces. Fixes #4883.
Shootfast 60d1944e 2022-07-06T20:12:30 SDL_video: Added SDL_GL_FLOATBUFFERS to allow Cocoa GL contexts to use EDR
Cameron Gutman 8b438f7b 2022-07-31T15:34:03 keyboard: Only send SDL_KEYMAPCHANGED when the keymap actually changes
diddily 1f276a51 2022-07-26T13:30:59 Fix Main Thread Checker warning on macOS Cache off NSWindow's windowNumber in SDL_WindowData on setup and use that in `Cocoa_SendWakeupEvent` to prevent accessing windowNumber off the main thread.
Ryan C. Gordon 218c3dbb 2022-07-26T14:45:26 cocoa: Don't crash if moving a message box created before SDL_Init. Fixes #5928.
Ryan C. Gordon 20a76b0e 2022-07-25T23:06:58 video: removed unused devindex argument from bootstrap's create method.
Sam Lantinga 4d665017 2022-07-24T18:04:26 Fixed building with 10.9 SDK Fixes https://github.com/libsdl-org/SDL/issues/5954
Dean Herbert 6bcde52d 2022-07-24T20:19:16 Further adjust implementation of `Cocoa_GetWindowDisplayIndex` As discussed in PR review, there may be an off-chance that the index returned doesn't match up with SDL's display indexing. This change ensures that the indices match and adds a safety check for off-screen windows.
Dean Herbert ce8aae14 2022-07-13T15:01:55 Fix `Cocoa_GetWindowDisplayIndex` failing and causing a catastrophic crash With the introduction of this function, it is possible that for certain monitor and window configurations, creating an SDL window will cause a native crash. ``` Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000050 Exception Codes: 0x0000000000000001, 0x0000000000000050 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11 Terminating Process: exc handler [56627] VM Region Info: 0x50 is not in any region. Bytes before following region: 140737486737328 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> VM_ALLOCATE 7fffffe75000-7fffffe76000 [ 4K] r-x/r-x SM=ALI Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libSDL2.dylib 0x10247f665 SDL_UpdateFullscreenMode + 357 1 libSDL2.dylib 0x10247ec70 SDL_CreateWindow_REAL + 1504 2 ??? 0x111262de8 ??? 3 ??? 0x110c39fff ??? 4 libcoreclr.dylib 0x101fdf2a9 CallDescrWorkerInternal + 124 ``` Tracking thread from our end: https://github.com/ppy/osu-framework/issues/5190 Regressed with: https://github.com/libsdl-org/SDL/pull/5573 In testing, the window would not find a valid screen if created "hanging" off a primary display with a secondary display below it. In checking why this was the case, the `display_centre` was being calculated with a negative y origin, causing a final negative value falling outside all display bounds: ``` SDL error log [debug]: display_centre.y = -1296 + 1296 / 2 SDL error log [debug]: Display rect 0: 0 0 2560 1440 SDL error log [debug]: Display rect 1: 2560 -625 1080 2560 SDL error log [debug]: Display rect 2: 0 1440 1728 1296 ``` The method that was being used to find the current window using the frame origin/size seems unreliable, so I have opted to replace it with with a tried method (https://stackoverflow.com/a/40891902). Initial testing shows that this works with non-standard DPI screens, but further testing would be appreciated (cc @sezero / @misl6 from the original PR thread).
Sam Lantinga cef1514b 2022-07-17T09:07:04 Fixed some Xcode warnings
rohlem b085c182 2022-07-04T16:38:05 make SDL_SetTextInputRect take a pointer to const The documentation doesn't state that the argument is ever modified, and no implementation does so currently. This is a non-breaking change to guarantee as much to callers.
Pierre Wendling 6c536afd 2022-06-27T15:43:17 Fix C89 declaration for macOS modules. Since Clang 14, `-Wdeclaration-after-statement` is enforced on every standard.
Simon McVittie 412ceb84 2022-05-24T16:27:54 video: Only check major version in SDL_GetWindowWMInfo Since #5602, SDL is intended to have the same ABI across the whole major-version 2 cycle, so we should not check that the minor version matches the one that was used to compile an application. There are two checks that could make sense here. The first check is that the major version matches the expected major version. This is usually unnecessary and is not usually done (if we're calling into the wrong library we'll likely crash anyway), but since we have the information, we might as well continue to use it. The second check is whether the version provided by the caller is equal to or greater than a threshold version at which additional fields were added to the struct. If it is, we should populate those fields; if it is not, then we cannot. This is only useful on platforms where additional fields have genuinely been added during the lifetime of SDL 2, like Windows and DirectFB (but not X11). This commit changes the first check to be consistent about only looking at the minor version, while leaving the second check using SDL_VERSIONNUM (which will be removed or widened in SDL 3, but it's fine for now). Resolves: https://github.com/libsdl-org/SDL/issues/5711 Fixes: cd7c2f1 "Switch versioning scheme to be the same as GLib and Flatpak" Signed-off-by: Simon McVittie <smcv@collabora.com>
Ryan C. Gordon 56665e1d 2022-05-17T12:50:13 cocoa: Try to use better system cursors. These try to pull from the .pdf files that are installed with macOS, which fit our needs better, and fall back to the most reasonable defaults available from NSCursor if we can't load them. Since these are installed under /System, they should be sandbox accessible, and if this totally fails, it should still go on, albeit with a less good cursor. Reference Issue #2123.
Alex Szpakowski e9c7b519 2022-05-16T21:03:41 macOS: Fix reference counts of internal window data. Fixes crashes when destroying or recreating a window (#5664).
Alex Szpakowski f871c178 2022-05-10T17:32:24 macOS: remove dead code for supporting 10.6 at runtime.
Alex Szpakowski ec8fa577 2022-05-07T21:57:23 macOS: always use Objective-C ARC (automatic ref counting). Change Cocoa SDL_VideoData and SDL_WindowData implementations from C structs to Objective-C objects, since bridging between C and ObjC is easier that way.
Sam Lantinga 7e636b03 2022-04-29T10:16:14 Removed log message length limitation for Apple platforms This works in conjunction with https://github.com/libsdl-org/SDL/pull/5584
Mirko Galimberti b293888c 2022-04-26T19:44:34 Fixes an issue introduced via #5573 when building for i686
FriendlyAI 795744fc 2022-01-07T10:11:46 Turn off relative mouse before window checks as well
FriendlyAI e2d268a3 2022-01-06T23:42:44 SDL_cocoamouse.m: SetRelativeMouseMode even if out of focus Should fix #3087
Mirko Galimberti 76afb858 2022-04-25T10:35:56 Introduces Cocoa_GetWindowDisplayIndex. This enable a proper management for dpi when switching between retina and non-retina displays.
Sam Lantinga 8f964576 2022-03-19T11:01:55 Fixed parameter operation ordering for ease of reading
Sam Lantinga 0517b61e 2022-03-19T11:00:00 Relative mouse mode is tied to the window with keyboard focus This isn't obvious, but makes sense when thinking about how games actually use it. This is also in line with how Windows mouse relative mode is implemented. Fixes https://github.com/libsdl-org/SDL/issues/5340
uyjulian a164c9d2 2022-01-04T10:43:34 SDL_cocoawindow.m: update fullscreen toggle when SDL_SetWindowResizable called
Ozkan Sezer ea0bca57 2022-01-11T14:56:56 SDL_cocoamodes.m: fix build against older SDKs. Fixes https://github.com/libsdl-org/SDL/issues/5208
Sam Lantinga 4b38d4c9 2022-01-07T12:37:28 Leave the Metal view active on the window when recreating the Metal renderer Fixes https://github.com/libsdl-org/SDL/issues/5140 Also move the metal tag definition to SDL_syswm.h so it can be used by applications
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Ozkan Sezer 4b112620 2022-01-02T19:11:50 SDL_cocoamodes.m (Cocoa_GetDisplayDPI): fix build using older toolchains Fixes https://github.com/libsdl-org/SDL/issues/5162
shinyquagsire23 6a7b6380 2021-12-28T12:07:56 Fix macOS cursor jumping to corner on first titlebar click
Edward Li a35a7d25 2021-12-25T05:00:26 Fix SigSegV from displayInfoInvalidate when changing resolution
Edward Li 1c41b535 2021-12-25T03:47:59 macOS: Calculate correct DPI by not using backingScaleFactor
Hanseul Jun 66fbf00e 2021-12-09T10:40:18 Temporarily ignore gl_config.driver_loaded check in Cocoa_GLES_SetupWindow.
Cameron Gutman da0f76de 2021-12-07T00:38:46 cocoa: Don't round scroll deltas from trackpads Rounding the scroll deltas from trackpads causes jerky scrolling behavior by artificially amplifying the effects of very small scroll movements. We should only round events from devices with discrete scroll wheels, because we know the smallest unit of movement there is a single tick.
Ryan C. Gordon ceb9e9a8 2021-11-21T00:21:41 cocoa: Removed a debug printf call.
Ryan C. Gordon 18715acb 2021-11-21T00:14:18 cocoa: Position non-left mouse button events in background windows correctly. Fixes #4828.
Sam Lantinga cc094f4d 2021-11-14T20:15:48 Fixed building with the macOS 10.8 SDK
Zack Middleton 1cd3e837 2021-11-14T15:51:38 cocoa: Fix abort on touch event types without a subtype macOS 10.6 has some touch NSEvents which do not have a subtype (Begin/EndGesture, Magnify, Rotate, Swipe) and cause an uncaught exception which triggers SIGABRT and the program exits. As it is, none of the macOS 10.6 touch events are detected as a trackpad (including Gesture due to using different subtypes).
Sam Lantinga 074e613b 2021-11-12T03:03:56 Fixed typo
Sam Lantinga 35d90f17 2021-11-12T03:00:57 Better implementation of SDL_SetWindowMouseGrab() and SDL_SetWindowMouseRect() on macOS
Sam Lantinga fd79607e 2021-11-08T21:34:48 Added SDL_GetWindowMouseRect() Also guarantee that we won't get mouse movement outside the confining area, even if the OS implementation allows it (e.g. macOS)
Sam Lantinga 4db546b0 2021-11-08T20:35:12 Implemented SDL_SetWindowMouseRect() on macOS
Alex Szpakowski ba4ef461 2021-10-23T15:28:13 macOS: Fix implicit integer downcast warnings
Cacodemon345 19dee1cd 2021-10-22T06:37:20 Add SDL_GetWindowICCProfile(). (#4314) * Add SDL_GetWindowICCProfile * Add new SDL display events * Implement ICC profile change event for macOS * Implement ICC profile notification for Windows * Fix SDL_GetWindowICCProfile() for X11 * Fix compile errors
James Howard d9c44b65 2021-10-19T10:49:17 Allow Cocoa_VideoInit to succeed when current display mode has invalid flags This fixes a specific issue seen on macOS 10.14.6 where a DELL E248WFP Display connected to a 2014 Mac Mini with a scaled 1920x1080 resolution selected and SDL_Init(SDL_INIT_VIDEO) failed with the error: "The video driver did not add any displays". The underlying cause was that the current 1080p display mode did not have the flag kDisplayModeSafeFlag, the check for which was added in a963e36, with the idea that certain display modes should not be candidates for switching to in fullscreen exclusive mode. That may well be the right thing to do for filtering down a list of candidate modes, but it doesn't pay to be so picky about the current mode. After all, this current mode was set by System Preferences, the picture does appear correctly on screen, and other non-SDL based applications launch and run correctly in this mode. Therefore the fix is to have GetDisplayMode only filter out a mode based on flags if it's part of a candidate list, but if it's the current mode and it can possibly be converted to an SDL_DisplayMode, do so.
Cameron Gutman 6f684f67 2021-07-29T18:20:36 cocoa: Add keyboard grab support CGSSetGlobalHotKeyOperatingMode() is not a public API, so we will only compile this in if SDL_MAC_NO_SANDBOX=1 is defined during compilation.
Sam Lantinga 51c61d7c 2021-07-27T14:57:18 Run the entire Cocoa messagebox function on the main thread. This fixes bug https://github.com/libsdl-org/SDL/issues/4420
Sam Lantinga dfd3f30e 2021-07-27T14:27:37 Make Cocoa_HandleTitleButtonEvent() static since it's not used anywhere else
Sam Lantinga 88e4755c 2021-07-27T12:43:00 Make sure we don't try to turn on relative mouse mode while clicking on the window title bar. This fixes bug https://github.com/libsdl-org/SDL/issues/4469
Sam Lantinga f1633127 2021-07-24T13:41:55 Added a window flash operation to be explicit about window flash behavior