Commit graph

49 commits

Author SHA1 Message Date
Sam Lantinga cc1f9eb983 Use Apple's nomenclature for macOS and iOS
Fixes https://github.com/libsdl-org/SDL/issues/6621
2022-11-25 16:00:06 -08:00
slime 52f4cc843d Remove SDL_SetWindowBrightness and SDL_SetWindowGammaRamp. 2022-11-25 13:28:56 -08:00
Steven Noonan 3d8a7e4c15
cocoa: implement GL_GetDrawableSize for OpenGL ES 2022-11-10 18:06:12 -08:00
Steven Noonan 0644042eb8
egl: implement public functions to obtain internal EGL handles
These functions allow applications to call EGL functions against the SDL
EGL context. For example, applications can use an EGL API loader via
SDL_EGL_GetCurrentDisplay and SDL_EGL_GetProcAddress, and can call
functions such as eglQuerySurface against the internal EGLSurface and
EGLDisplay.
2022-11-10 18:06:11 -08:00
Steven Noonan 5a7c20b945
hints: replace SDL_HINT_VIDEO_X11_FORCE_EGL with platform-agnostic SDL_HINT_VIDEO_FORCE_EGL
This adds support for forcing the use of EGL on Windows and MacOS. The
SDL_HINT_VIDEO_X11_FORCE_EGL hint is retained for backwards
compatibility but is now deprecated.
2022-11-10 18:06:10 -08:00
Steven Noonan 019e9d4c92 SDL_cocoavideo.m: add missing SDL_cocoaopengles.h include 2022-10-24 10:38:36 -07:00
Noel Berry 00452e47fa
Adding SDL_GetWindowSizeInPixels for window size in pixels (#6112) 2022-08-24 11:25:13 -07:00
Ryan C. Gordon bdc7f958fd cocoa: Added hint to treat MacBook trackpads as touch devices, not mice.
Fixes #5511.
2022-08-10 00:42:31 -04:00
Ryan C. Gordon 20a76b0e3e
video: removed unused devindex argument from bootstrap's create method. 2022-07-26 00:19:52 -04:00
Alex Szpakowski f871c178b9 macOS: remove dead code for supporting 10.6 at runtime. 2022-05-10 14:04:14 -07:00
Alex Szpakowski ec8fa57750 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.
2022-05-09 21:53:40 -07:00
Sam Lantinga 7e636b03cc Removed log message length limitation for Apple platforms
This works in conjunction with https://github.com/libsdl-org/SDL/pull/5584
2022-04-29 10:16:14 -07:00
Mirko Galimberti 76afb8583b Introduces Cocoa_GetWindowDisplayIndex. This enable a proper management for dpi when switching between retina and non-retina displays. 2022-04-26 09:51:31 -07:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sam Lantinga 4db546b092 Implemented SDL_SetWindowMouseRect() on macOS 2021-11-08 20:35:56 -08:00
Cacodemon345 19dee1cd16
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
2021-10-21 17:37:20 -07:00
Cameron Gutman 6f684f674e 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.
2021-07-29 19:06:43 -07:00
Ethan Lee 56b77b12bc cocoa: Implement FlashWindow 2021-06-24 13:08:26 -07:00
Francesco Abbate 0dd7024d55 Modifies WaitEvent and WaitEventTimeout to actually wait instead of polling
When possible use native os functions to make a blocking call waiting for
an incoming event. Previous behavior was to continuously poll the event
queue with a small delay between each poll.

The blocking call uses a new optional video driver event,
WaitEventTimeout, if available. It is called only if an window
already shown is available. If present the window is designated
using the variable wakeup_window to receive a wakeup event if
needed.

The WaitEventTimeout function accept a timeout parameter. If
positive the call will wait for an event or return if the timeout
expired without any event. If the timeout is zero it will
implement a polling behavior. If the timeout is negative the
function will block indefinetely waiting for an event.

To let the main thread sees events sent form a different thread
a "wake-up" signal is sent to the main thread if the main thread
is in a blocking state. The wake-up event is sent to the designated
wakeup_window if present.

The wake-up event is sent only if the PushEvent call is coming
from a different thread. Before sending the wake-up event
the ID of the thread making the blocking call is saved using the
variable blocking_thread_id and it is compared to the current
thread's id to decide if the wake-up event should be sent.

Two new optional video device methods are introduced:

WaitEventTimeout
SendWakeupEvent

in addition the mutex

wakeup_lock

which is defined and initialized but only for the drivers supporting the
methods above.

If the methods are not present the system behaves as previously
performing a periodic polling of the events queue.

The blocking call is disabled if a joystick or sensor is detected
and falls back to previous behavior.
2021-06-04 13:50:50 -07:00
Joseph Lyncheski a0a5da5d91 Add SDL_SetWindowAlwaysOnTop() 2021-04-20 08:45:28 -07:00
Sam Lantinga cef198c9cb Fixed bug 5524 - Pass NSString to NSLog()
Hiroyuki Iwatsuki

If you pass the C string directly to NSLog(), it will be garbled with Japanese and probably other language strings, or no log will be output at all.

NSLog("Hello, World!"); // => "Hello, World!"
NSLog("こんにちは、世界!"); // => No output...

Therefore, you need to convert the string to an NSString before passing it to NSLog().

NSString *str = [NSString stringWithUTF8String:"こんにちは、世界!"];
NSLog(@"%@", str); // => "こんにちは、世界!"

Thank you.
2021-02-10 10:22:18 -05:00
Cameron Gutman a0d3c6c63c Rename SetWindowGrab() to SetWindowMouseGrab() 2021-02-10 10:22:16 -05:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga cb36189692 Fixed bug 5235 - All internal sources should include SDL_assert.h
Ryan C. Gordon

We should really stick this in SDL_internal.h or something so it's always available.
2020-12-09 07:16:22 -08:00
M Stoeckl 052a13738d Merge VideoBootStrap::available into VideoBootStrap::create
The two are only ever called together, and combining them makes it possible
to eliminate redundant symbol loading and redundant attempts to connect
to a display server.
2020-07-12 19:11:15 -04:00
Ryan C. Gordon a791689086 metal: Added some support interfaces to Apple's Metal API (thanks, Caleb!).
Caleb Cornett's comments:

"A few weeks ago, Alex added a partial Metal API to SDL2:

https://hg.libsdl.org/SDL/rev/22c8e7cd8d38

I noticed it was missing a few features that would help Metal become a
first-class citizen in SDL, so I went ahead and wrote them! Here are the new
APIs:

1. SDL_WINDOW_METAL flag for SDL_CreateWindow(). This allows the programmer
to specify that they intend to create a window for use with SDL_MetalView.
The flag is used to ensure correct usage of the API and to prevent
accidentally defaulting to OpenGL on iOS.

2. SDL_Metal_GetLayer(). This function takes a SDL_MetalView and returns a
pointer to the view's backing CAMetalLayer. This simplifies things
considerably, since in the current version of the SDL_Metal API the
programmer is required to bridge-cast a SDL_MetalView handle to an NSView or
UIView (depending on the platform) and then extract the layer from there.
SDL_Metal_GetLayer automatically handles all of that, making the operation
simple and cross-platform.

3. SDL_Metal_GetDrawableSize(). This function already exists in the current
SDL_Metal API (and is used behind-the-scenes for SDL_Vulkan_GetDrawableSize
on Apple platforms) but was not publicly exposed. My patch exposes this
function for public use. It works just like you'd expect.

Tested on macOS 10.14 and iOS 12.4."

Fixes Bugzilla #4796.
2020-04-10 00:37:35 -04:00
Sam Lantinga a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Alex Szpakowski aebaa316c7 Add public APIs for creating a Metal view attached to an SDL window. Add SDL_metal.h. 2019-08-05 12:35:32 -03:00
Ethan Lee bf9bf602e7 Copypaste SDL_NSLog to UIKit backend, document it as such 2019-07-17 23:20:57 -04:00
Ryan C. Gordon d3bedda4df cocoa: Patched to compile and also handle possible malloc failure. 2019-06-18 16:53:49 -04:00
Sam Lantinga 5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Ryan C. Gordon 1fb20f0ab9 cocoa: Put a mutex around GL_SwapBuffers.
Prevents deadlock when swapping two different GL contexts on two different
threads at the same time on macOS 10.14 ("Mojave").

Fixes Bugzilla #4278.
2018-10-18 23:38:27 -04:00
Ryan C. Gordon e061a92dc9 Some drag'and'drop improvements.
First: disable d'n'd events by default; most apps don't need these at all, and
if an app doesn't explicitly handle these, each drop on the window will cause
a memory leak if the events are enabled. This follows the guidelines we have
for SDL_TEXTINPUT events already.

Second: when events are enabled or disabled, signal the video layer, as it
might be able to inform the OS, causing UI changes or optimizations (for
example, dropping a file icon on a Cocoa app that isn't accepting drops will
cause macOS to show a rejection animation instead of the drop operation just
vanishing into the ether, X11 might show a different cursor when dragging
onto an accepting window, etc).

Third: fill in the drop event details in the test library and enable the
events in testwm.c for making sure this all works as expected.
2018-08-02 16:03:47 -04:00
Sam Lantinga e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Sam Lantinga 57ebc72714 Fixed bug 3975 - Add GLES2 support for macOS via ANGLE library
Andrey

Seems latest google angle library successfully built & tested under macOS'es.

https://github.com/google/angle

We need to use GLES2 to implement true cross-platform code.
2017-12-04 20:35:01 -08:00
Sam Lantinga 50efbda736 Fixed mingw Windows build, since SDL_vulkan_internal.h includes windows.h 2017-08-28 00:43:14 -07:00
Sam Lantinga ce2b16445e Be clear that disabling Vulkan surface support disables the entire SDL Vulkan integration 2017-08-28 00:11:38 -07:00
Ryan C. Gordon 25e3a1ec90 vulkan: Initial Vulkan support!
This work was done by Jacob Lifshay and Mark Callow; I'm just merging it
into revision control.
2017-08-27 22:15:57 -04:00
Sam Lantinga 45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga 1b689c335c Fixed bug 3503 - osx builds don't run on 10.6 as of rev. 10651
Ozkan Sezer

With rev. 10651, i.e. http://hg.libsdl.org/SDL/rev/747a6a795b21 ,
SDL2 - OS X builds fail to run on 10.6 (my setup: i686 / 10.6.8)
because the symbol _IOPMAssertionCreateWithDescription is missing.
The SDK listing it for 10.7+ does seem correct.  Reverting r10651
and rebuilding makes it to function again.
2016-12-01 11:52:47 -08:00
Ryan C. Gordon d1c35febce macOS: removed deprecated UpdateSystemActivity() call.
The non-deprecated approach (IOPMAssertion) already exists in SDL, and is
available in Mac OS X 10.6 and later (although it was incorrectly listed as
10.7 and later in SDL). Since SDL now requires 10.6 or later, this is no
longer conditionally used.
2016-11-25 00:13:13 -05:00
Sam Lantinga 36e40d30fc Fixed bug 2923 - Add SDL_PIXELFORMAT_RGBA32 for byte-wise 32bit RGBA data
Daniel Gibson

Ok, I followed the simple approach of just making SDL_PIXELFORMAT_RGBA32 an alias of SDL_PIXELFORMAT_RGBA8888/SDL_PIXELFORMAT_ABGR8888, depending on endianess. And I did the same for SDL_PIXELFORMAT_ARGB32, .._BGRA, .._ABGR.

SDL_GetPixelFormatName() will of course return SDL_PIXELFORMAT_RGBA8888 (or SDL_PIXELFORMAT_ABGR8888) instead of SDL_PIXELFORMAT_RGBA32, but as long as that's mentioned in the docs it shouldn't be a problem.
2016-10-11 23:19:05 -07:00
Sam Lantinga 27d4f09929 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints 2016-10-07 23:40:44 -07:00
Ryan C. Gordon 4f4c4b629f Added SDL_SetWindowResizable(). (thanks, Ethan!) 2016-09-29 22:52:41 -04:00
Ryan C. Gordon 416d046663 Mac: Implemented SDL_GetDisplayDPI (thanks, Kirill!).
Fixes Bugzilla #3223.
2016-01-07 14:02:37 -05:00
Ryan C. Gordon 3bdaf4c611 Added SDL_SetWindowOpacity() and SDL_GetWindowOpacity().
This is currently implemented for X11, Cocoa, Windows, and DirectFB.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2016-01-05 02:46:10 -05:00
Ryan C. Gordon c3114975db Added SDL_GetDisplayUsableBounds(). 2016-01-04 23:52:40 -05:00
Sam Lantinga 42065e785d Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Philipp Wiesemann 0e45984fa0 Fixed crash if initialization of EGL failed but was tried again later.
The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly
uninitialized data structure if loading the library first failed. A later try to
use EGL then skipped initialization and assumed it was previously successful
because the data structure now already existed. This led to at least one crash
in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was
dereferenced to make a call to eglBindAPI().
2015-06-21 17:33:46 +02:00