Commit Graph

1440 Commits

Author SHA1 Message Date
Ryan C. Gordon
39563b7bfa x11: Use XSync when changing window position instead of XFlush.
Attempt to fix regression in Bugzilla #4646.
2020-01-28 13:51:24 -05:00
Ryan C. Gordon
c7e1b289ee cocoa: Fix command line apps' menu bar not working on macOS Catalina.
Fixes Bugzilla #4937.
2020-01-27 17:15:12 -05:00
Ryan C. Gordon
b4c2e29eed video: Added a hint to override the display's usable bounds. 2020-01-27 10:58:30 -05:00
Sam Lantinga
b5e3d264f2 Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds
Protected more code with #ifdefs to reduce the size of minimal shared library builds
2020-01-23 01:00:52 -08:00
Sylvain Becker
55afc281fa Add #define SDL_HAVE_BLIT_N_RGB565 to compile out RGB565 LUT 2020-01-21 22:06:09 +01:00
Sylvain Becker
7df22cf2c2 A few #defines to reduce SDL2 footprint.
Only applied when library is statically linked
2020-01-21 21:33:40 +01:00
Sylvain Becker
005e2dff21 Android: prevents rare crashes when app goes to background or ends.
Make sure the thread is actually paused, and context backep-up, before
SurfaceView is destroyed (eg surfaceDestroyed() actually returns).

Add a timeout when surfaceDestroyed() is called, and check 'backup_done' variable.

It prevents crashes like:

  #00  pc 000000000000c0d0  /system/lib64/libutils.so (android::RefBase::incStrong(void const*) const+8)
  #01  pc 000000000000c7f4  /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::UpdateBufferList(ANativeWindowBuffer*)+284)
  #02  pc 000000000000c390  /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::DequeueBuffer()+240)
  #03  pc 000000000000bb10  /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::GetBuffer(EglSubResource*, EglMemoryDesc*)+64)
  #04  pc 000000000032732c  /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::UpdateResource(EsxContext*)+116)
  #05  pc 0000000000326dd0  /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::GetResource(EsxContext*, EsxResource**, EsxResource**, int)+56)
  #06  pc 00000000002ae484  /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::AcquireBackBuffer(int)+364)
  #07  pc 0000000000249680  /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::Clear(unsigned int, unsigned int, unsigned int, EsxClearValues*)+1800)
  #08  pc 00000000002cb52c  /vendor/lib64/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlClear(EsxDispatch*, unsigned int)+132)
2020-01-17 12:41:54 +01:00
Sylvain Becker
d52ba78b29 Fixed bug 4246 - Android: orientation between portrait<->landscape doesn't work
Improve handling of landscape/portrait orientation. Promote to SCREEN_ORIENTATION_SENSOR_* when needed.
Android window can be somehow resizable.
If SDL_WINDOW_RESIZABLE is set, window size change is allowed, for instance when orientation changes (provided the hint allows it).
2020-01-17 12:04:18 +01:00
Sam Lantinga
a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga
572f4a8509 Fixed bug 4929 - Software renderer produces bugs when optimizations are turned on with Visual C++ 2019
Konrad

I took the liberty of rewriting this function a bit as it seemed to be unnecessary extended with ifs regarding flags (we can check everything in one pass which seem to be the thing which confuses Visual C++ 2019 as well).

Also, I have made CPU features an int instead of uint because if we check it against flags which are all ints it might as well just be int (no signed/unsigned bitwise comparison).
2020-01-16 15:54:20 -08:00
Sam Lantinga
981e0d367c Fixed bug 4903 - Lack of color multiply with alpha (SDL_BLENDMODE_MOD + SDL_BLENDMODE_BLEND) blending mode for all renderers
Konrad

This kind of blending is rather quite useful and in my opinion should be available for all renderers. I do need it myself, but since I didn't want to use a custom blending mode which is supported only by certain renderers (e.g. not in software which is quite important for me) I did write implementation of SDL_BLENDMODE_MUL for all renderers altogether.

SDL_BLENDMODE_MUL implements following equation:

dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
dstA = (srcA * dstA) + (dstA * (1-srcA))

Background:

https://i.imgur.com/UsYhydP.png

Blended texture:

https://i.imgur.com/0juXQcV.png

Result for SDL_BLENDMODE_MOD:

https://i.imgur.com/wgNSgUl.png

Result for SDL_BLENDMODE_MUL:

https://i.imgur.com/Veokzim.png

I think I did cover all possibilities within included patch, but I didn't write any tests for SDL_BLENDMODE_MUL, so it would be lovely if someone could do it.
2020-01-16 08:52:59 -08:00
Dmitry V. Levin
2b1edf4113 X11_InitKeyboard: do not call XAutoRepeatOn unnecessarily
Use XGetKeyboardControl to initialize the current XKeyboardState, and
skip XAutoRepeatOn invocation if global_auto_repeat is AutoRepeatModeOn.

This fixes SDL2 when the X11 client is untrusted.
2020-01-04 11:05:06 -08:00
Dmitry V. Levin
ed514cd0e4 have_mitshm: use XShmQueryExtension to check for MIT-SHM extension
Do not try to guess MIT_SHM extension availability from the string
returned by XDisplayName, use the appropriate API instead.

This fixes SDL2 inside hasher.
2020-01-04 11:03:04 -08:00
Michael Forney
cdbeae521e wayland: support wl_data_device_manager version < 3 2019-12-29 23:10:39 -08:00
Ozkan Sezer
9340cfa9a1 SDL_x11events.c (X11_DispatchEvent): remove FIXME and use SDL_strtokr(). 2019-12-27 23:01:10 +03:00
Sam Lantinga
5e19e66c73 Fixed bug 4914 - Expose SDL_ScaleMode and add SDL_SetTextureScaleMode/SDL_GetTextureScaleMode
Konrad

This was something rather trivial to add, but asked at least several times before (I did google about it as well).

It should be possible to dynamically change scaling mode of the texture. It is actually trivial task, but until now it was only possible with a hint before creating a texture.

I needed it for my game as well, so I took the liberty of writing it myself.

This patch adds following functions:

SDL_SetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode scaleMode);
SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode);

That way you can change texture scaling on the fly.
2019-12-22 13:39:44 -08:00
Sylvain Becker
d004cc7050 Android: same way as in nativePause(), resume events are sent from SDL thread 2019-12-21 22:40:33 +01:00
Sylvain Becker
45a9b5fa2e Android: fix call of glFinish without context.
Message in the log, when going to background:
"call to OpenGL ES API with no current context (logged once per thread)"

Because of SDL_WINDOWEVENT_MINIMIZED is sent from the Java Activity thread.
It calls SDL_RendererEventWatch(), _WindowEvent() and glFinish() without context.

Solution is to move sending of SDL_WINDOWEVENT_MINIMIZED to the SDL thread.
2019-12-21 21:18:02 +01:00
Paul Cercueil
95d40e8a28 kmsdrm: Fix busy-loop within libc's dlopen()
For some obscure reason, the order in which the libdrm/libgbm libraries
are loaded matters.

Without this fix, the first call to check_modesetting() will work and
load then unload all symbols properly, but the second call to this
function will lock up as soon as dlopen() is called on libdrm.

Swapping the order in which the libdrm and libgbm libraries are loaded
is enough to fix (or work around?) this issue.

Fixes #4891:
https://bugzilla.libsdl.org/show_bug.cgi?id=4891

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2019-12-19 21:47:43 -08:00
Sam Lantinga
20daf54fd8 Added new HIDAPI driver files to the Xcode projects 2019-12-19 15:18:50 -08:00
Sam Lantinga
bc430d405c Update for bug 4883 - Add approximation for display DPI on iOS
Aaron Barany

I realized I made a minor mistake in my patch: I changed the constructor prototype for SDL_DisplayData, but didn't update the declaration in the .h file. The compiler and linker don't complain, but it would probably be best to fix in case a later change runs into a problem from the mismatch. I have attached a patch to fix this.
2019-12-16 10:26:36 -08:00
Sam Lantinga
140918bb6f Fixed bug 4883 - Add approximation for display DPI on iOS
Aaron Barany

There appears to be no way to directly access the display DPI on iOS, so as an approximation the DPI for the iPhone 1 is used as a base value and is multiplied by the screen's scale. This should at least give a ballpark number for the various screen scales. (based on https://stackoverflow.com/questions/25756087/detecting-iphone-6-6-screen-sizes-in-point-values it appears that both 2x and 3x are used)

I have updated the patch to use a table of current devices and use a computation as a fallback. I have also updated the fallback computation to be more accurate.
2019-12-08 11:36:40 -08:00
Sam Lantinga
54748a39be Fixed bug 4890 - Add hint for SDL that the graphics context is externally managed
Aaron Barany

Add SDL_HINT_VIDEO_EXTERNAL_CONTEXT hint to notify SDL that the graphics context is external. This disables the automatic context save/restore behavior on Android and avoids using OpenGL by default when SDL_WINDOW_VUKLAN isn't set.

When the application wishes to manage the OpenGL contexts on Android, this avoids cases where SDL unbinds the context and creates new contexts, which can interfere with the application's operation.

When using Vulkan and Metal renderer implementations, this avoids SDL forcing OpenGL to be enabled on certain platforms. While using the SDL_WINDOW_VULKAN flag can be used to achieve the same thing, it also causes Vulkan to be loaded. If the application uses Vulkan directly, this is not necessary, and fails window creation when using Metal due to Vulkan not being present. (assuming MoltenVK isn't installed)
2019-12-08 11:33:06 -08:00
Ryan C. Gordon
597f11e563 cocoa: Patched to compile on older compilers. 2019-12-05 17:27:06 -05:00
Ryan C. Gordon
ca2c8609e1 cocoa: SDL_GetDisplayDPI() should account for Retina displays.
Fixes Bugzilla #4856.
2019-12-04 12:20:24 -05:00
Sam Lantinga
b7576025e3 Fixed bug 4882 - Fix build for iOS when disabling OpenGL
Aaron Barany

Since OpenGL is deprecated on iOS, it is advantageous to be able to remove all OpenGL related code when building SDL for iOS. This patch adds the necessary #if checks to compile in this case.
2019-12-03 22:07:58 -08:00
Alex Smith
e5af951eae Fix sending SDL_WINDOWEVENT_RESTORED after unminimizing windows on X11
SDL_SendWindowEvent will only send a RESTORED event if the window has
the minimized or maximized flag set. However, for a SHOWN event, it
will clear the minimized flag. Since the SHOWN event was being sent
first for a MapNotify event, the RESTORED event would never be sent.
Swapping the SendWindowEvent calls around fixes this.

https://bugzilla.libsdl.org/show_bug.cgi?id=4821
2019-12-02 15:41:25 +00:00
Sam Lantinga
7a3ae59037 Fixed bug 4877 - Add support for loading menus from a nib/xib instead of building a hardcoded minimum set
Eric Shepherd

Currently, SDL on Cocoa macOS creates a rudimentary menu bar programmatically if none is already present when the app is registered during setup.

SDL could be much more easily and flexibly used on macOS if upon finding that no menus are currently in place, it first looked for the application's main menu nib or xib file and, if found, loaded that instead of programmatically building the menus.

This would then let developers simply drop in a nib file with a menu bar defined in it and it would be installed and used automatically.

Attached is a patch that does just this. It changes the SDL_cocoaevents.m file to:

* In Cocoa_RegisterApp(), before calling CreateApplicationMenus(), it calls a new function, LoadMainMenuNibIfAvailable(), which attempts to load and install the main menu nib file, using the nib name fetched from the Info.plist file. If that succeeds, LoadMainMenuNibIfAvailable() returns true; otherwise false.
* If LMMNIA() returns false, CreateApplicationMenus() is called to programmatically build the menus as before.
* Otherwise, we're done, and using the menus from the nib/xib file!

I made these changes to support a project I'm working on, and felt they were useful enough to be worth offering them for uplift. They should have zero impact on existing projects' behavior, but make Cocoa SDL development miles easier.
2019-12-03 07:12:55 -08:00
Gerasim Troeglazov
c8a2ef863e haiku: Disable pointer history
(note from PulkoMandy on Bugzilla #4442 about why this is a desirable patch:
"The event mask: note that the window and GL view run in their own thread
which I don't expect to be too much CPU bound, and will quickly pop these
messages and forward them to the main thread in our SDL code. Therefore the
B_NO_POINTER_HISTORY should be no problem, and is the default on Haiku
anyway (it was not in BeOS, but we changed that and added a
B_FULL_POINTER_HISTORY flag to request the old behavior explicitly). So, this
seems fine.")

Partially fixes Bugzilla #4442.
2019-12-03 02:49:01 -05:00
Sam Lantinga
b1539c4c49 Fixed bug 4819 - Attempting to create an OpenGL ES context with unachievable MSAA parameters under X11 dooms the program
Solra Bizna

I have written a program that, in the event that the user requests more MSAA samples than their hardware supports, attempts to gracefully fall back to the best MSAA available. This code works with my conventional OpenGL renderer, but if I change nothing about the code except to make it request an OpenGL ES profile instead, Xlib kills the program with an error that looks like:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  4 (X_DestroyWindow)
  Resource id in failed request:  0x5c00008
  Serial number of failed request:  188
  Current serial number in output stream:  193

To trigger the bug, attempt to create a window with the SDL_WINDOW_OPENGL flag, with SDL_GL_CONTEXT_PROFILE_MASK set to SDL_GL_CONTEXT_PROFILE_ES, and with SDL_GL_MULTISAMPLESAMPLES set to any unsupported value. SDL_CreateWindow properly returns NULL, but at this point the program is already doomed. Xlib will shortly terminate the program with an error. Calling SDL_CreateWindow again will immediately trigger this termination.

I have attached a skeletal program that reproduces this bug for me. Replacing SDL_GL_CONTEXT_PROFILE_ES with SDL_GL_CONTEXT_PROFILE_COMPATIBILITY avoids the bug (but, obviously, doesn't create an OpenGL ES context).

As I suspected, the problem was with XDestroyWindow being called twice on the same window. The X11_CreateWindow function in src/video/x11/SDL_x11window.c calls SetupWindowData. If initialization fails after that point, XDestroyWindow gets called on the window by a subsequent call to X11_DestroyWindow. But, later in the same function, iff a GLES context is requested and initializing it fails, X11_XDestroyWindow (which wraps XDestroyWindow) is manually called. Shortly after, the intended call to X11_DestroyWindow occurs, which attempts to destroy the same window again. Boom.

(The above confusing summary involves three separate, similarly-named functions: XDestroyWindow, X11_DestroyWindow, X11_XDestroyWindow)

I have attached a simple patch that removes the redundant X11_XDestroyWindow calls. I've tested that XDestroyWindow still gets called for the windows in question, and that it only gets called once.
2019-11-16 22:35:48 -08:00
Cameron Cawley
20ddf45ede Added SDL_PIXELFORMAT_BGR444 2019-11-02 22:58:52 +00:00
EXL
b44fe0f838 haiku: Rename BE_* entities to HAIKU_*
In favor Bugzilla #2349.
Update copyright years to 2019.

Partially fixes Bugzilla #4442.
2019-11-12 17:24:37 -05:00
Peter Kosyh
79510b7569 haiku: mouse->ShowMouse method added
Partially fixes Bugzilla #4442.
2019-11-11 22:22:40 -05:00
Gerasim Troeglazov
95a402d745 haiku: Add support for relative mouse mode.
Partially fixes Bugzilla #4442.
2019-11-11 22:21:17 -05:00
Adrien Destugues
3b516e633b haiku: Fix crash when opening window.
- _num_clips was not set in constructor, so a NULL _clips could be
  mistakenly dereferenced.
- As _clips is accessible outside the class, it is not a good idea to
  free/reallocate it. Try to limit this by reallocating only when it needs to
  grow.

Partially fixes Bugzilla #4442.
2019-11-11 22:14:00 -05:00
Jerome Duval
50806eeea2 haiku: use addr_t instead of size_t for OpenGL dynamic loading.
Partially fixes Bugzilla #4442.
2019-11-11 22:04:10 -05:00
EXL
b22fb9e2ba haiku: Implement message box for Haiku
Add implementation for functions:

SDL_ShowSimpleMessageBox()
SDL_ShowMessageBox()

Add simple customization support also.
Fix build for x86_gcc2.

Partially fixes Bugzilla #4442.
2019-11-11 16:44:40 -05:00
Sylvain Becker
303646a697 Android: some readability: redundant casts, deads stores, redundant control flow 2019-10-31 15:53:10 +01:00
Sylvain Becker
88ba6798e9 Wayland: touch events, use of memory after it is freed 2019-10-30 21:12:36 +01:00
Sylvain Becker
86ae245bc0 Use correct enum: typo in org_kde_kwin_server_decoration_mode
instead of org_kde_kwin_server_decoration_manager_mode
2019-10-30 17:59:20 +01:00
Sylvain Becker
ce308a7841 revert this const parameter for X11 function 2019-10-30 16:33:32 +01:00
Sylvain Becker
f16e51068b Fix const warning in RLE getpix functions 2019-10-30 16:17:59 +01:00
Sylvain Becker
d4a67e2541 Readability: change some pointer parameter to be pointer to const 2019-10-30 16:06:51 +01:00
Sylvain Becker
60d3965ece Readability: remove redundant return, continue, enum declaration 2019-10-30 15:36:17 +01:00
Sylvain Becker
b458d7a28f Readability: remove redundant cast to the same type 2019-10-30 15:13:55 +01:00
Sylvain Becker
56cbe12037 BlitAuto: remove redundant cast to the same type 2019-10-30 14:37:06 +01:00
Sylvain Becker
735691ecd6 Remove nested redundant #ifndef 2019-10-30 14:29:41 +01:00
Sylvain Becker
42153342ab Use fill_function for FillRect SIMD/NEON (bug 4365) 2019-10-29 16:13:41 +01:00
Alex Szpakowski
bda618a2af iOS: remove some unused code, minor code style cleanup. 2019-10-27 11:41:48 -03:00
Alex Szpakowski
df49e2a572 iOS: replace a deprecated function call with a non-deprecated equivalent. 2019-10-27 11:41:11 -03:00
Sylvain Becker
7289e5e215 Android: remove warning in blit_features
"integer constant not in range of enumerated type 'enum blit_features'"
2019-10-27 15:22:28 +01:00
Ryan C. Gordon
c0255be458 x11: check if the X server honored our XMoveWindow() call (thanks, R.E. Rust!).
This can happen if a window is still grabbed when we try to move it, or if
the X11 ecosystem is just in a bad mood, I guess.

This makes sure that SDL will report the correct position for a window;
otherwise, SDL_GetWindowPosition will just report whatever the last
SDL_SetWindowPosition call requested, even if the window didn't actually move.

Fixes Bugzilla #4646.
2019-10-26 23:58:55 -04:00
Alex Szpakowski
a963e36e2d macOS: more robust detection and switching of exclusive-fullscreen display modes (bug #4822). 2019-10-26 15:27:51 -03:00
Ben Avison
72f8044a42 ARM: NEON assembly optimization for SDL_FillRect 2019-10-24 21:17:52 -04:00
Ben Avison
1187b013a5 ARM: NEON assembly optimization for function BlitARGBto565PixelAlpha 2019-10-24 21:17:38 -04:00
Ben Avison
2dfe060564 ARM: NEON assembly optimization for function BlitRGBtoRGBPixelAlpha 2019-10-24 21:17:19 -04:00
Ben Avison
74846657ec ARM: SIMD optimization for 4:4:4:4 to 8:8:8:8 normal blits 2019-10-24 21:15:50 -04:00
Ben Avison
becc649ae2 ARM: assembly optimization for SDL_FillRect 2019-10-24 21:15:35 -04:00
Ben Avison
7ac733f025 ARM: SIMD assembly optimization for BGR-to-RGB 32bpp normal blits 2019-10-24 21:15:21 -04:00
Ben Avison
8425d9d5d0 SDL_blit: use a named enum for required hardware bits in dispatch tables 2019-10-24 21:15:09 -04:00
Ben Avison
0eaa52cedf ARM: SIMD assembly optimization for function BlitARGBto565PixelAlpha 2019-10-24 21:13:56 -04:00
Ben Avison
57723b83e8 ARM: SIMD assembly optimization for function BlitRGBtoRGBPixelAlpha
Much of the heavy lifting of this optimization is lifted from the Pixman
project, which is distributed under an MIT-style license. As far as possible,
these elements have been relicensed to the zlib license.
2019-10-24 21:13:05 -04:00
Alex Szpakowski
59beaccd50 macOS: Expose high dpi-capable display modes on macOS 10.13+.
Fixes an issue in macOS 10.15 where the displayed content would move up after entering, exiting and re-entering exclusive fullscreen when certain display modes were used (bug #4822).
Bug #3949 is also related to this change.
2019-10-24 20:15:54 -03:00
Sylvain Becker
8081f11773 Fixed bug 2014 - Hardcoded srcA value in SDL_Blit_auto.c functions 2019-10-24 18:07:30 +02:00
Sylvain Becker
3a8b899428 Android: remove eglGetProcAdded busted comment (bug #4040) 2019-10-23 11:07:11 +02:00
Sylvain Becker
c9d0e2ae0a Fixed bug 4840 - Read of uninitialized memory in DXGI_LoadDLL (Thanks!) 2019-10-23 09:26:27 +02:00
Sylvain Becker
d5d34de4db Fixed bug 4839 - Read of uninitialized memory in Win32_ResizeWindowShape
(Thanks!)
2019-10-23 09:17:53 +02:00
Sylvain Becker
758badffa5 Fixed bug 4841 - Misplaced parenthesis WIN_WindowProc / WM_ACTIVATE / ClipCursor
(Thanks!)
2019-10-23 08:58:52 +02:00
Sylvain Becker
24bee6e5e2 Add internal function SDL_EGL_GetVersion() 2019-10-18 21:47:30 +02:00
Sam Lantinga
b060b2eadd Fixed whitespace 2019-10-18 08:56:54 -07:00
Sylvain Becker
e5bd20030d Android: enable eglGetProcAddress (bug #4040, bug #4794) 2019-10-18 14:08:07 +02:00
Sylvain Becker
03f27a3a75 Add robustness getting the EGL version (see bug #4040) 2019-10-18 13:27:58 +02:00
Ryan C. Gordon
3ecce84749 egl: adjust how we load symbols in SDL_EGL_GetProcAddress.
Use eglGetProcAddress for everything on EGL >= 1.5. Try SDL_LoadFunction first
for EGL <= 1.4 in case it's a core symbol, and as a fallback if
eglGetProcAddress fails. Finally, for EGL <= 1.4, fallback to
eglGetProcAddress to catch extensions not exported from the shared library.

(Maybe) Fixes Bugzilla #4794.
2019-10-18 00:07:32 -04:00
Sam Lantinga
bf9092cf4a Removed unused variable 2019-10-17 17:47:11 -07:00
Sam Lantinga
1b4de45d05 Fixed bug 4785 - SDL_CreateRGBSurface creates 1-bit surfaces with zero pitch
Sylvain

Seems to be a regression in this commit: https://hg.libsdl.org/SDL/rev/7fdbffd47c0e
SDL_CalculatePitch() was using format->BytesPerPixel, now it uses SDL_BYTESPERPIXEL().

The underlying issue is that "surface->format->BytesPerPixel" is *not* always the same as SDL_BYTESPERPIXEL(format);
BytesPerPixel defined as format->BytesPerPixel = (bpp + 7) / 8;
vs
#define SDL_BYTESPERPIXEL(format)  ... (format & 0xff)

Because of SDL_pixels.h format definitions, one is giving a BytesPP 1, the other 0.
2019-10-16 08:45:54 -07:00
Ryan C. Gordon
ed7483f82c x11: On macOS, look for X11 install in /opt/X11 instead of /usr/X11R6.
This is where Apple installs XQuartz now (and apparently, the compatibility
symlink at /usr/X11R6 can be missing).

Fixes Bugzilla #4706.
2019-10-15 22:36:08 -04:00
Ryan C. Gordon
02a2ec986f video: Make sure SDL_FillRects()'s fill_function isn't used unitialized. 2019-10-15 14:55:09 -04:00
Ryan C. Gordon
9f636be8c0 video: Removed unused variables. 2019-10-15 14:04:43 -04:00
Ryan C. Gordon
e23067eab2 video: speed up SDL_FillRect[s] slightly (thanks, Jakub!).
"This patch does the following:

* Instead of SDL_FillRects calling SDL_FillRect in a loop the opposite
happens -- SDL_FillRect (a specific case) calls SDL_FillRects (a general case)
with a count of 1

* The switch/case block is moved out of the loop -- it modifies the color
once and stores the fill routine in a pointer which is then used throughout
the loop"

Fixes Bugzilla #4674.
2019-10-15 14:03:01 -04:00
Ryan C. Gordon
d5e378d198 cocoa: Implement SDL_WINDOW_ALWAYS_ON_TOP support (thanks, Gabriel!).
Fixes Bugzilla #4809.
2019-10-15 00:59:10 -04:00
Alex Szpakowski
074f6a512d macOS: Fix the initial window background not being black since macOS 10.14.2 or so, when OpenGL is used (bug #4810). Also fixes "CGContext: invalid context 0x0" errors when an OpenGL window is created (bug #4470). 2019-10-14 00:51:53 -03:00
Alex Szpakowski
009226c61e macOS: Fix non-highdpi OpenGL contexts not scaling properly in macOS 10.15 (bug 4810 and 4822). 2019-10-13 21:39:20 -03:00
Alex Szpakowski
f8bdefe1b5 macOS: Fix asserts in SDL_Render's metal scissor code when the window is resized. 2019-10-13 15:18:28 -03:00
Alex Szpakowski
1773da89f9 macOS: Fix a new issue in 10.15 where the window decorations don't always get restored after SDL_SetWindowFullscreen(window, 0). 2019-10-13 12:16:40 -03:00
Sylvain Becker
3b0dcaf474 Fixed bug 4797 - SDL fails to compile with Mesa Master (thanks Michael Olbrich!)
fix building with Mesa 19.2

With Mesa 19.2 building fails with:

/include/GLES/gl.h:63:25: error: conflicting types for 'GLsizeiptr'

The same type is defined in include/SDL_opengl.h for OpenGL and the two
headers should not be included at the same time.
This was just never noticed because the same header guard '__gl_h_' was
used. This was changed in Mesa. The result is this error.

Fix this the same way GLES2 already handles this: Don't include the GLES
header when the OpenGL header was already included.
(https://hg.libsdl.org/SDL/rev/6a3670d6108d)
2019-10-12 18:47:56 +02:00
David Ludwig
c61ca915fb WinRT: fix a link-time error when building UWP + x64 2019-10-02 14:55:02 -04:00
Brandon Schaefer
ee6d504ae9 offscreen: Define missing define on a older EGL for an EXT function which it wont have 2019-09-24 17:49:53 -04:00
Brandon Schaefer
8a41948e7f offscreen: Avoid using EGLDeviceEXT as it causes issues with older platforms, which is just a void* 2019-09-24 17:27:51 -04:00
Brandon Schaefer
68985371a0 offscreen: Add new video driver backend Offscreen
The Offscreen video driver is intended to be used for headless rendering
  as well as allows for multiple GPUs to be used for headless rendering

Currently only supports EGL (OpenGL / ES) or Framebuffers
Adds a hint to specifiy which EGL device to use: SDL_HINT_EGL_DEVICE
Adds testoffscreen.c which can be used to test the backend out
Disabled by default for now
2019-09-24 16:36:48 -04:00
Sylvain Becker
79e388bfd8 Fixed bug 4798 - PNG w/transparency breaks in SDL 2.0.10 but works in SDL 2.0.9 2019-09-10 17:12:34 +02:00
Sam Lantinga
715e070d29 SDL_blit_N.c: Correct vec_perm() application on little-endian 64-bit PowerPC
The LE transformation for vec_perm has an implicit assumption that the
permutation is being used to reorder vector elements (in this case 4-byte
integer word elements), not to reorder bytes within those elements.  Although
this is legal behavior, it is not anticipated by the transformation performed
by the compilers.

This causes pygame-1.9.1 test failure on PPC64LE because blitted pixmaps are
corrupted there due to how SDL uses vec_perm().

From RedHat / Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1392465
Original patch was provided by: Menanteau Guy <menantea@linux.vnet.ibm.com>
2019-09-06 08:50:19 -07:00
Conn O'Griofa
2d37d29183 KMSDRM_GLES_SwapWindow: fix non-vsync case
If KMSDRM_drmModeSetCrtc is called when the swap interval is
set to 0, the driver behaves as though vertical sync is engaged by
limiting framerate to the refresh rate, but performance is much worse
than with vertical sync enabled.

Resolve this issue by ensuring that the Crtc is only set up once,
and KMSDRM_drmModePageFlip is called, albeit without any followup
queueing or waiting for flips.
2019-09-06 08:44:46 -07:00
Ozkan Sezer
8a394209c4 SDL_windowsevents.c: remove isVistaOrNewer (not used since 8cb1dc50bb28) 2019-09-05 20:47:20 +03:00
Sylvain Becker
bf2f4703f2 SDL_windowsmessagebox.c: remove unused variable 2019-09-05 10:49:53 +02:00
Sylvain Becker
1b5e3c19a2 SDL_bmp.c: remove unused variable warnings 2019-09-05 10:08:47 +02:00
Sam Lantinga
e5580e18ba x11: add a hint to force the VisualID used when creating a window. 2019-09-04 09:27:58 -07:00
Sam Lantinga
892c8d5058 Fixed bug 4536 - Heap-Buffer Overflow in SDL_GetRGB pertaining to SDL_pixels.c
Ozkan Sezer

As for the issue: This bmp reports bpp=0, therefore SDL_CalculatePitch()
returns pitch==0, which is then fed to SDL_malloc() (which is malloc())
and malloc(0) returns _something_ which is not NULL but not someting
that we expect..  Then testsprite.c:LoadSprite() accesses the pixels
as *(Uint8*)pixels which valrind reports as:

==15533== Invalid read of size 1
==15533==    at 0x8048C08: LoadSprite (testsprite.c:45)
==15533==    by 0x80492FC: main (testsprite.c:224)
==15533==  Address 0x449e588 is 0 bytes after a block of size 0 alloc'd
==15533==    at 0x40072B2: malloc (vg_replace_malloc.c:270)
==15533==    by 0x4045719: SDL_CreateRGBSurface (SDL_surface.c:126)
==15533==    by 0x40403C1: SDL_LoadBMP_RW (SDL_bmp.c:237)
==15533==    by 0x8048BB2: LoadSprite (testsprite.c:36)
==15533==    by 0x80492FC: main (testsprite.c:224)

Besides, valrind also reports this:
==15533== Conditional jump or move depends on uninitialised value(s)
==15533==    at 0x40403F3: SDL_LoadBMP_RW (SDL_bmp.c:247)
==15533==    by 0x8048BB2: LoadSprite (testsprite.c:36)
==15533==    by 0x80492FC: main (testsprite.c:224)


Easy/quick solution would be early-rejecting a bmp with 0 bpp from SDL_bmp.c:SDL_LoadBMP_RW()
2019-09-03 11:55:20 -07:00
Ozkan Sezer
b21338eb54 SDL_bmp.c: restore most of the original formatting. 2019-09-02 12:35:00 +03:00
Sylvain Becker
6c295129ba LoadBMP: fix some warnings 2019-08-31 22:58:11 +02:00
Sylvain Becker
830979c555 LoadBMP: use code from SDL_image which allows loading compressed BMP files 2019-08-31 22:52:15 +02:00
Sam Lantinga
cc64b369fb Allow mouse messages from Wacom pens, e.g. right click pen buttons, etc. 2019-08-30 15:32:15 -07:00
Sam Lantinga
afb9ff9507 Fixed bug where the Steam overlay would generate an event and stop input processing for the frame. 2019-08-30 08:03:19 -07:00
Ozkan Sezer
9c8e403f6b use 'U' suffix on constants instead of (unsigned int) cast. 2019-08-30 11:35:20 +03:00
Sylvain Becker
d52080c0ab Android: minor warning 2019-08-30 09:00:06 +02:00
Sylvain Becker
70dc8d1648 Android: fix corresponding warnings 2019-08-30 08:55:20 +02:00
Sam Lantinga
13c4d5e7e3 Fixed Windows relative mouse coordinates when capturing the mouse over RDP 2019-08-26 17:43:01 -07:00
Ozkan Sezer
1e47790c8d RPI_FreeCursor: set global_cursor to NULL to prevent double-free (bug 4769) 2019-08-26 18:41:40 +03:00
Alex Szpakowski
dd29abb478 macOS: Use the proper type (NSSize instead of CGSize) for the bounds of metal views. 2019-08-22 19:23:52 -03:00
Alex Szpakowski
79cd6cfc94 iOS: Fix issues with Split VIew on iPad (bugs #4586, #4705). 2019-08-15 19:38:12 -03:00
Sam Lantinga
2a1adf71ab Fixed bug 4747 - [Patch] SDL_ShowMessageBox ignores BUTTON_RETURNKEY_DEFAULT flag
Caleb Cornett

SDL_ShowMessageBox on UIKit doesn't do anything special with buttons that are marked with the flag SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT. According to Apple's documentation on UIAlertController, a button can respond to a return key if it's marked as the preferredAction of the controller. SDL doesn't set a preferredAction currently, so I've attached a patch to fix that.
2019-08-05 23:52:16 -07:00
Sam Lantinga
afdb40af61 Fixed bug 4689 - SDL fails to detect compositor shutdown on Wayland -- program keeps running
M Stoeckl

To reproduce:

1. Run any SDL-based program with a Wayland compositor, orphaning it so that it doesn't have an immediate parent process. (For example, from a terminal, running `supertux2 & disown`.) The program should use the wayland backend, i.e. by setting environment variable SDL_VIDEODRIVER=wayland.
2. Kill the compositor process.

Results:

- The SDL program will keep running.

Expected results:

- The SDL program should close. (What close should mean here, I'm not sure - is injecting an SDL_Quit the appropriate action when a video driver disconnects?)

Build data:

2019-06-22, hg tip (12901:bf8d9d29cbf1), Linux, can reproduce with sway, weston, and other Wayland oompositors.
2019-08-05 23:38:48 -07: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
Alex Szpakowski
f3683d3a09 macOS: fix a typo in touch handling code. 2019-08-04 23:30:55 -03:00
Alex Szpakowski
109cbd6e8b Fix touch-related compile errors on Linux. 2019-08-04 16:56:40 -03:00
Alex Szpakowski
2fb71ac52d Implement touch window IDs on x11/xinput2. 2019-08-04 00:34:23 -03:00
Sam Lantinga
63197c4338 Fix bug where the wrong button was the default in the old message box because buttons were added backwards, breaking the indexing used by GetButtonIndex.
Add messagebox flags to explicilty request left-to-right button order or right-to-left.  If neither is specified it'll be some platform default.
2019-08-02 17:19:50 -07:00
Alex Szpakowski
d5ec735a33 Add a windowID field to SDL_TouchFingerEvent (bug #4331).
This is unimplemented on some platforms and will cause compile errors when building those platform backends for now.
2019-08-01 18:22:12 -03:00
Ozkan Sezer
c37c6cbbca use WIN_IsWindowsVistaOrGreater() from core/windows for isVistaOrNewer 2019-07-31 23:37:02 +03:00
Ozkan Sezer
4953e050f5 use SDL_zeroa at more places where the argument is an array. 2019-07-31 05:11:40 +03:00
Sam Lantinga
97fefd0509 Fixed bug 4538 - validate image size when loading BMP files 2019-07-30 11:00:00 -07:00
Sam Lantinga
31cb854f98 Fixed bug 4745 - 2.0.10 fails to build against macOS 10.11 SDK
Joshua Root

NSEventSubtypeMouseEvent was added in 10.12, so it needs to be defined on 10.11 as well
2019-07-30 10:04:46 -07:00
Ethan Lee
bf9bf602e7 Copypaste SDL_NSLog to UIKit backend, document it as such 2019-07-17 23:20:57 -04:00
Sam Lantinga
e7c2cf107a Fixed bug 4704 - SDL_HINT_ANDROID_SEPERATE_MOUSE_AND_TOUCH on Windows?
superfury

I notice that, somehow, when locking the mouse into place(using SDL_SetRelativeMouseMode), somehow at least the movement information gets through to both mouse movement and touch movement events?

My app handles both, so when moving a touched finger accross the app(using RDP from an Android device) I see the mouse moving inside the app when it shouldn't(meaning that the touch movement is ignored properly by the app(press-location dependant) but the mouse movement is still performed due to the mouse movement events)?
2019-07-15 09:36:53 -07:00
Alex Szpakowski
8fb8adfc90 macOS: Fix SDL_GL_CreateContext/MakeCurrent on non-main threads causing a Main Thread Checker warning when built with Xcode 11 / the macOS 10.15 SDK.
Fixes bug #4714.
2019-07-13 17:04:02 -03:00
Ryan C. Gordon
27ad8e5d72 cocoa: Set keyboard mod state correctly when turning off capslock.
Fixes Bugzilla #4716.
2019-07-11 01:07:14 -04:00
Sylvain Becker
86965eecd3 x11: prevent a synthetic mouse event when using a touchscreen
With multitouch, register to receive XI_Motion (which desctivates MotionNotify),
so that we can distinguish real mouse motions from synthetic one.

(bug 4690)
2019-07-10 10:06:28 +02:00
Ryan C. Gordon
6ef01e5236 x11: set some modality things on message boxes with parent windows. 2019-07-09 17:28:02 -04:00
Cameron Gutman
7e09718dfe Ignore synthetic mouse events generated for touchscreens
Windows generates fake raw mouse events for touchscreens for compatibility
with legacy apps that predate touch support in Windows. We already handle
touch events explicitly, so drop the synthetic events to avoid duplicates.
2019-07-07 11:23:16 -07:00
Ryan C. Gordon
e841b066fd cocoa: Another attempt at mouse vs touch support.
This time, we make anything we think is a MacBook trackpad report its touches
as SDL_MOUSE_TOUCHID, even though they're not _actually_ synthesized events,
and let all mouse input--even if the OS synthesized it from a multitouch
trackpad on our behalf--look like physical input. This is backwards from
reality, but produces the results most apps will expect.

Note that if you have a real touch device that doesn't appear to be the
trackpad, it'll produce real touch events with unique device ids, so it's
not a total loss here, but also note that the way we decide if it was the
trackpad is an imperfect heuristic; it happens to work out right now, but
it's not impossible that a real touchscreen could come to the Mac at some
point and (incorrectly?) call it a "mouse" input, etc.

But for now, good enough.

Fixes Bugzilla #4690.
2019-07-08 13:41:01 -04:00
Ryan C. Gordon
b46c771994 raspberry: Actually commit the whole patch. :) (Thanks, Joe!)
Fixes Bugzilla #4699.
2019-07-02 16:49:35 -04:00
Ryan C. Gordon
d2d06f4443 cocoa: Don't report trackpad mouse events as synthesized touches.
Fixes Bugzilla #4690, sort of. I guess.
2019-07-02 12:29:36 -04:00
Ryan C. Gordon
d2058b45ae raspberry: Fixed missing mouse cursor (thanks, Joe!)
"Starting with changeset 12433, the mouse cursor is not displayed on the
Raspberry Pi platform, due to a bug in the handling of the new
"global_cursor" in RPI_ShowCursor(). Currently, if cursor == global_cursor,
the function immediately returns 0. The function should not return here.
Instead, if cursor == global_cursor, it shouldn't try to hide the current
cursor and update global_cursor = cursor. However, it *should* still continue
through the rest of the function."

Fixes Bugzilla #4699.
2019-07-02 10:26:54 -04:00
Alex Szpakowski
027887da15 iOS: Fix the window size not being set properly when Split View is used on an iPad (bug #4586). 2019-07-01 14:52:56 -03:00
Sylvain Becker
22a2decf64 Android: concurrency issues, make sure Activity is in running State when calling
functions like SDL_CreateWindow, SDL_CreateRenderer, Android_GLES_CreateContext

Bugs 4694, 4681, 4142
2019-06-28 16:38:42 +02:00
Sylvain Becker
aa45af7fcb Android: explicitly expand Android_GLES_MakeCurrent/Android_GLES_CreateContext
from SDL_egl_c.h
2019-06-28 16:05:20 +02:00
Ryan C. Gordon
57e08c27ef cocoa: Check for capslock in -[NSResponder flagsChanged], not with IOKit.
Using IOKit for this pops up a warning at startup on macOS 10.15 ("Catalina"),
asking the user to authorize the app to listen to all keyboard input in the
system, which is unacceptable.

I _think_ we were using IOKit under incorrect presumptions here; the Stack
Overflow link mentioned in it was complaining about not being able to use
flagsChanged to differentiate between left and right mod keys, but that's not
an issue for capslock.

It's also possible this code was trying to deal with capslock changing when
the window didn't have focus, but we handle this elsewhere now, if we didn't
at the time.
2019-06-26 13:21:43 -04:00
Ryan C. Gordon
0beadea574 windows: Call GetWindowText() with the correct parameters (thanks, Zebediah!)
GetWindowText() wants you to tell it the size of the buffer--including the
terminating NULL char--but we weren't counting that last char, losing the
last char of the string in the process. This was only seen with the special
case of SDL_CreateWindowFrom() to use an existing native window, not
the usual SDL_CreateWindow() codepath.

Fixes Bugzilla #4696.
2019-06-26 01:29:01 -04:00
Sam Lantinga
bd95290075 Use SDL C runtime functions 2019-06-19 06:40:50 -07:00
Sylvain Becker
faed7f836d KMSDRM: fix inverted strcmp, remove useless if test (Bug 4624) 2019-06-19 10:11:38 +02:00
Sylvain Becker
5998c51324 KMSDRM: fix compilation on linux, no d_namlen (Bug 4624) 2019-06-19 09:16:53 +02:00
Ryan C. Gordon
d0fa93d63c wayland: Fixed C99-style variable declaration inside for-loop. 2019-06-19 00:52:34 -04:00
Sam Lantinga
99abcbb2bc Fixed bug 4624 - KMS/DRM fails on FreeBSD because /dev/dri/card* nodes are symlinks
Jan Martin Mikkelsen

Patch to scan /dev/dri based on names rather than file type

Loading KMS/DRM on FreeBSD fails because the "available" code in the driver checks for character device nodes under /dev/dri and the /dev/dri/card* files are symlinks rather than device nodes nodes on FreeBSD. The symlink points to /dev/drm/0.

The attached patch counts /dev/dri/card* entries rather than directory entries which are character devices.
2019-06-18 14:15:10 -07: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
3e720d2a80 Fixed potential double-free in mouse cleanup code 2019-06-18 13:41:38 -07:00
Sylvain Becker
e96d4760ac Android: resize with software rendering, reverted again (Bug 4669) 2019-06-18 18:53:58 +02:00
Sylvain Becker
12b92260cc Android: try to fix resize with software rendering (bug 4669) 2019-06-18 18:40:40 +02:00
Sylvain Becker
a55c0e1479 Android: revert previous commit (Bug 4669)
(Refs #1)
2019-06-18 10:23:19 +02:00
Sylvain Becker
f2157b6c25 Fixed bug 4669: Android software renderer, black screen when window resizes
Using the software SDL_Renderer on Android leads to GL errors & black screen when window resizes
2019-06-17 22:31:36 +02:00
Alex Szpakowski
f4625f52f2 iOS: remove some code which could affect the state of UIViews that aren't owned by SDL.
It was originally added to work around an input event problem in the code of a specific app which mixed SDL and native UIViews, but that app solved its problems in a better manner since then.
2019-06-16 13:52:27 -03:00
Ryan C. Gordon
ed8b78d36b cocoa: ignore compiler warnings about OpenGL being deprecated. 2019-06-14 21:18:53 -04:00
Ryan C. Gordon
90e2dc9891 A few minor changes to placate static analysis. 2019-06-14 18:23:51 -04:00
Sam Lantinga
1213fe79d8 Worked around "Undefined symbol: ___isPlatformVersionAtLeast()" link error on Xcode 11 beta 2019-06-14 13:56:42 -07:00
Ryan C. Gordon
d9a2eff26f cocoa: Another attempt at synthesized mouse/touch events. 2019-06-13 21:31:03 -04:00
Ryan C. Gordon
294574647d cocoa: Revised synthesized mouse/touch event strategy.
I _think_ I understand what Sylvain is working on here now, so hopefully I
got this right.

Fixes Bugzilla #4576.

(I think!)
2019-06-13 01:57:13 -04:00
Alex Szpakowski
50f5123190 macOS: Fix the coordinate space of SDL_GetDisplayUsableBounds (thanks Tim!)
Fixes bug #4518.
2019-06-12 19:57:30 -03:00
Alex Szpakowski
74e86a51d8 iOS: Remove didAddSubview override in NSWindow, its code breaks things which rely on focus changing within SDL's UIWindow (bug #4659). 2019-06-12 19:15:56 -03:00
Ryan C. Gordon
32ead2cb46 vulkan: Fixed use-after-free bug. 2019-06-12 15:37:07 -04:00
Sebastian Krzyszkowiak
797b28133c wayland: HiDPI support 2019-06-12 00:55:05 +02:00
Ryan C. Gordon
04b50f6c6b cocoa: Backed out CVDisplayLink code for macOS vsync.
This was to deal with broken vsync support in macOS 10.14, which we assumed
would remain broken indefinitely, but a later 10.14 released fixed it.

This is a loss of late-swap support, but there are several subtle problems
in our CVDiplayLink code that are also evaporating, to be fair.

Fixes Bugzilla #4575.

(Backed out changeset 8760fed23001)
2019-06-11 16:19:01 -04:00
Sam Lantinga
69d27a69cd Fixed bug 4570 - Support Vulkan Portability rather than MoltenVK specifically
Dzmitry Malyshau

Current code, search paths, and error messages are written to only consider MoltenVK on macOS as a Vulkan Portability implementation. It's not the only implementation available to the users. gfx-portability [1] has been shown to run a number of titles well, including Dota2, Dolphin Emulator, and vkQuake3, often out-performing MoltenVK in frame rate and stability (see Dolphin benchmark [2]).

There is no reason for SDL to be that specific, it's not using any MVK-specific functions other than the WSI initialization ("VK_MVK_macos_surface"). gfx-portability exposes this extension as well, and a more generic WSI extension is in process. It would be good if SDL was written in a more generic way that expect a Vulkan Portability library as opposed to MoltenVK specifically.

[1] https://github.com/gfx-rs/portability
[2] https://gfx-rs.github.io/2019/03/22/dolphin-macos-performance.html
2019-06-11 18:13:46 -07:00
Sam Lantinga
aa80d279d3 Fix build with the 10.10 SDK 2019-06-11 08:33:30 -07:00
Ryan C. Gordon
5fb20b3093 video: fixed compiler warning on Visual Studio. 2019-06-11 02:14:59 -04:00
Ryan C. Gordon
399df540e3 windows: Drop WM_ACTIVATE when window is hidden, but only if being activated.
Fixes Bugzilla #4571.
2019-06-11 01:14:24 -04:00
Sylvain Becker
f9a9193e2c Android: add MinimizeWindow function (Bug 4580, 4657)
shouldMinimizeOnFocusLoss is un-activated (return false)
2019-06-10 21:58:03 +02:00
Ryan C. Gordon
781692c03c cocoa: report proper input IDs for mouse/touch events.
Otherwise, we generate incorrect mouse events for MacBook trackpads (which
are also multitouch devices), etc.

Partially fixes Bugzilla #4576.
2019-06-09 19:27:25 -04:00
Sam Lantinga
e43550c039 Fixed bug 4658 - iOS 12 fullscreen flag and SDL_HINT_IOS_HIDE_HOME_INDICATOR not working
Caleb Cornett

On iOS 12, creating a window with the SDL_WINDOW_FULLSCREEN flag does not dim the home indicator or defer system gestures. The same goes for setting the SDL_HINT_IOS_HIDE_HOME_INDICATOR to "2" -- it has no effect at all.

I've tracked down the source of this misbehavior to a timing issue. The initial `setNeedsUpdate...` calls were happening too early and getting applied to the launch screen by mistake. In the attached patch, I've added a call to those functions right after the launch screen is hidden so that they apply to the main view controller instead. This appears to fix the issue, at least on my iPhone 6s Plus.
2019-06-09 14:08:18 -07:00
Sam Lantinga
48ac92af54 Fixed bug 4041 - Android, SDL_Renderer OpenGLES 1 is loading GLESv2 library
Sylvain

On Android, if you set no attribute using SDL_GL_SetAttribute(), and try to create a SDL Render OpenGLES 1:

- it loads first by default GLESv2 libraries
- creates the rendere OpenGLES 1
- recreates the Window to have a context 1.1 ( https://hg.libsdl.org/SDL/file/4db4cfd59470/src/render/opengles/SDL_render_gles.c#l298 )

But it doesn't unload libraries, then reload GLESv1 lib. So the SDL_Renderer OpenGLES 1 is working with GLES 2 libs, which seems inconsistent.


If you, at first, set
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
It will correctly load GLES v1 libraries.

Here's a small patch to reload egl libs when SDL_RecreateWindow() is called.
It fixes the issue, also the case from bug 4042

( SDL_RecreateWindow() is used by SDL_Renderer gl, gles1, gles2. )
2019-06-08 18:40:11 -07:00
Sam Lantinga
2b6473dc05 Fixed bug 4533 - Update ANGLE to load d3dcompiler_47.dll instead of d3dcompiler_46.dll
msmshazan

Update ANGLE Libraries to support d3dcompiler_47.dll since chrome does not ship with d3dcompiler_46.dll and d3dcompiler_43.dll
2019-06-08 15:10:20 -07:00
Ethan Lee
0442d19fc8 cocoa: Fix assert to use SDL_assert 2019-03-04 12:16:43 -05:00
Sam Lantinga
8728ce4448 Fixed bug 4557 - SDL_SIMDAlloc and *Free should be in the public interface
Martin Gerhardy

These functions are really useful and should get exposed imo.
2019-06-08 14:54:37 -07:00
Sam Lantinga
f2c8d8e9c4 Fixed bug 4443 - Incorrect scan code reported for numpad 5
bplu4t2f

When num lock is on, the scancode reported for numpad 5 is SDL_SCANCODE_KP_5, which is correct. However, when num lock is off, windows reports the VK_CLEAR virtual key code, which is incorrectly translated into SDL_SCANCODE_CLEAR inside of the VKeytoScancode(WPARAM vkey) function.
2019-06-08 10:47:43 -07:00
Alex Szpakowski
9b5811592d iOS: return SDL_GetWindowSize from SDL_GL_GetDrawableSize if there's no GLES view in the window (matches the behaviour of SDL_GL_GetDrawableSize on other platforms). Addresses bug #4629. 2019-05-26 18:53:36 -03:00
Sam Lantinga
7ec514d48f Improved iOS Bluetooth keyboard support
* Don't stop text input after the return key is pressed
* Handle arrow and escape keys
2019-05-22 17:39:51 -07:00
Cameron Gutman
9b2202828a Fix use-after-free when pumping the event loop after SDL_DestroyWindow()
Closing the window is asynchronous, but we free the window data immediately,
so we can get an updateLayer callback before the window is really destroyed which
will cause us to access the freed memory.

Clearing the content view will cause it to be immediately released, so no further
updateLayer callbacks will occur.
2019-04-28 17:37:49 -07:00
Sam Lantinga
a4e33b9cc4 Added support for Bluetooth keyboards on iOS
In this case the keyboard is shown and immediately hidden, but we still want to accept text input
2019-05-20 14:31:03 -07:00
Sam Lantinga
582a3c994d Fixed mouse focus for touch events on iOS 2019-05-20 14:08:35 -07:00
Ryan C. Gordon
4bd808346a vulkan: Swapped out a free() that should have been an SDL_free().
Fixes (for real this time!) the Visual Studio builds.
2019-05-20 00:41:18 -04:00
Ryan C. Gordon
ebbb295e85 vulkan: Patched to compile on Visual Studio. 2019-05-19 23:29:50 -04:00
Ryan C. Gordon
d778b26dd1 Patched to compile in C89 mode. 2019-05-19 20:25:02 -04:00
Sam Lantinga
ee0a482a87 Fixed bug 4401 - SDL_GetWindowPosition() wrong after SDL_SetWindowPosition() until window is moved on macOS
Removed incorrect call to SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y);
If the position of the window isn't adjusted in the SetWindowPosition() call, then sending the window event would have no effect because x and y equals the window x and y. If the position of the window is adjusted in the SetWindowPosition() call, then we don't want to clobber it with values that the user passed in.
2019-05-19 11:52:25 -07:00
Sam Lantinga
8dea23c705 Fixed bug 3911 - SYSWM generic X11 events missing event data
Andrei Drexler

For X11 GenericEvents, the associated data is only available between a call to XGetEventData and the matching XFreeEventData, i.e. in X11_HandleGenericEvent. Trying to call XGetEventData a second time on the same event will fail, so an application that wants to inspect XInput2 events (e.g. for stylus pressure) has no way of retrieving its data from queued SYSWM events.

The attached patch (based on SDL-2.0.7-11629) sends SYSWM messages from X11_HandleGenericEvent while the data is still available, allowing client code to register an event filter/watcher and process the event inside the callback.
2019-05-19 10:44:14 -07:00
Wladimir J. van der Laan
29f3445316 video: Add Vulkan support for vivante fb
Vivante drivers use the VK_KHR_display extension for rendering directly
to the frame buffer. This patch adds support to the video driver for
Vulkan rendering using that method.

- Add an utility function SDL_Vulkan_Display_CreateSurface that creates
a surface using this extension. The display to use (if there are
multiple) can be overridden using the environment variable
"SDL_VULKAN_DISPLAY".

- Use this function in a new compilation unit SDL_vivantevideo.c,
which implements the SDL_VIDEO_VULKAN methods of the driver structure.
2019-05-19 10:36:44 -07:00
Sam Lantinga
59da5b7202 [SDL] ios Touch Fix. 2019-05-14 07:55:42 -07:00
Ryan C. Gordon
ba0fc92ded Patched to compile. 2019-05-11 12:41:21 -04:00
Charlie Birks
6eb0521131 Emscripten: Use EMSCRIPTEN_EVENT_TARGET_* 2019-05-09 12:09:45 +01:00
Charlie Birks
4e5b5cba12 Emscripten: Switch from canvas[XY] to target[XY]
Allows mouse/touch events to work on non-default canvases
2019-05-09 12:09:40 +01:00
Charlie Birks
60c48ed787 Emscripten: Store canvas id in WindowData
Also replace all hardcoded uses of "#canvas" or NULL
2019-05-09 12:09:34 +01:00
Sam Lantinga
f0a4fea89f Fixed bug 4608 - Android: not getting SDL_WINDOWEVENT_FOCUS_GAINED on start of our app
Dan Ginsburg

I've seen this on several devices including Moto Z running Android 7 and a Snapdragon 845 running Android 9.

What happens is as follows:

SDLActivity.onWindowFocusChanged(true) happens pretty early on, but it's before we've done SDL_CreateWindow and so Android_Window is 0x0 thus this message does not get sent:

JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeFocusChanged)(
                                    JNIEnv *env, jclass cls, jboolean hasFocus)
{
    SDL_LockMutex(Android_ActivityMutex);

    if (Android_Window) {
        __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeFocusChanged()");
        SDL_SendWindowEvent(Android_Window, (hasFocus ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST), 0, 0);
    }

    SDL_UnlockMutex(Android_ActivityMutex);
}

When the window does get created, in Android_CreateWindow it does this:

 window->flags &= ~SDL_WINDOW_RESIZABLE;     /* window is NEVER resizeable */
    window->flags &= ~SDL_WINDOW_HIDDEN;
    window->flags |= SDL_WINDOW_SHOWN;          /* only one window on Android */
    window->flags |= SDL_WINDOW_INPUT_FOCUS;    /* always has input focus */

    /* One window, it always has focus */
    SDL_SetMouseFocus(window);
    SDL_SetKeyboardFocus(window);

The SDL_SetKeyboardFocus does send an SDL_WINDOWEVENT_FOCUS_GAINED message, but it gets eaten in SDL_SendWindowEvent because we've forced SDL_WINDOW_INPUT_FOCUS beforehand:

 case SDL_WINDOWEVENT_FOCUS_GAINED:
        if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
            return 0;
        }
        window->flags |= SDL_WINDOW_INPUT_FOCUS;
        SDL_OnWindowFocusGained(window);
        break;

I can fix the problem if I comment out this line from Android_CreateWindow:

    window->flags |= SDL_WINDOW_INPUT_FOCUS;    /* always has input focus */

I would propose that as a fix unless there is a reason not to.
2019-04-25 14:17:07 -07:00
Sylvain Becker
2c92c8e85a Android: add static variable initialization in non blocking event loop 2019-04-23 14:24:58 +02:00
Sam Lantinga
cb18117c92 Added a helper function to tell whether or not a window can be minimized 2019-04-22 16:34:42 -07:00
Sam Lantinga
f1b57f3785 Only leave fullscreen mode if we're actually going to minimize 2019-04-22 16:25:49 -07:00
Alex Szpakowski
90b08881ab iOS: Remove code trying to support compilation on the iOS 7 SDK, the deployment target has been set to iOS 8 for years and there's other unconditionally compiled code that depends on newer SDKs so that code is useless. 2019-04-17 20:41:05 -03:00
Alex Szpakowski
9d7b26155a macOS: Fix compilation when using the 10.9 SDK or older. 2019-04-17 20:14:40 -03:00
Sylvain Becker
bd344c2287 Android: when event loop is not blocking in pause, backup EGL context (Bug 4578)
Backup the EGL context when SDL_APP_DIDENTERBACKGROUND has been removed from the
event queue.
2019-04-12 23:15:26 +02:00
Alex Szpakowski
00c824a8b0 Fix disabling OpenGL vsync on macOS 10.14.4+ (bug #4575). 2019-04-10 22:30:58 -03:00
Sam Lantinga
b6f33a6870 https://bugzilla.libsdl.org/show_bug.cgi?id=4577
SDL_GetWindowDisplayMode was returning an incorrect result on iPhone Plus devices (tested on iOS 12.1/12.2).  The problem was that the value returned by UIScreenMode was assumed to be the physical pixels on the display, rather than the scaled retina pixels.  The fix is to use the scale returned by UIScreen.scale rather than the nativeScale.
2019-04-05 07:51:11 -07:00
Sylvain Becker
05333a6e9f Android: add hint SDL_HINT_ANDROID_BLOCK_ON_PAUSE
to set whether the event loop will block itself when the app is paused.
2019-04-05 09:16:30 +02:00
Sylvain Becker
bfdd0b228a Android: remove SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH
java layer runs as if separate mouse and touch was 1,
Use SDL_HINT_MOUSE_TOUCH_EVENTS and SDL_HINT_TOUCH_MOUSE_EVENTS
for generating synthetic touch/mouse events
2019-04-04 17:01:02 +02:00
Sylvain Becker
236b86067f Bug 4576: one more warning 2019-04-02 18:07:27 +02:00
Sylvain Becker
b45abbb2a7 Bug 4576: fix warning and compile 2019-04-02 17:57:27 +02:00
Sylvain Becker
9b3c2258aa Bug 4576: remove touch/mouse duplication for Android 2019-04-02 17:23:55 +02:00
Sylvain Becker
9d28156f12 Bug 4576: remove touch/mouse duplication for IOS 2019-04-02 17:18:47 +02:00
Sylvain Becker
42de5f97cc Bug 4576: remove touch/mouse duplication for WinRT 2019-04-02 17:13:22 +02:00
Sylvain Becker
b086edc915 Bug 4576: remove touch/mouse duplication for Emscripten 2019-04-02 17:10:29 +02:00
Sylvain Becker
b8e5c561d8 Bug 4576: remove touch/mouse duplication for Wayland 2019-04-02 17:07:54 +02:00
Sylvain Becker
1a4c3b57b7 Bug 4576: remove touch/mouse duplication for Windows 2019-04-02 16:58:11 +02:00
Sam Lantinga
b2e76d860f Fixed Windows RT build 2019-03-19 16:52:09 -07:00
Sam Lantinga
de82759c84 Added support for building SDL as a dynamic library on iOS 2019-03-19 07:53:33 -07:00
Sebastian Krzyszkowiak
6311c7cf95 emscripten: force resize event when pixel ratio changes
Without this, applications can't react to changed canvas size on window zoom.
2019-03-16 19:08:59 -07:00
Sam Lantinga
8bc59f87ec Fixed CVE-2019-7635 and bug 4498 - Heap-Buffer Overflow in Blit1to4 pertaining to SDL_blit_1.c
Petr Pisar

The root cause is that the POC BMP file declares 3 colors used and 4 bpp palette, but pixel at line 28 and column 1 (counted from 0) has color number 3. Then when the image loaded into a surface is passed to SDL_DisplayFormat(), in order to convert it to a video format, a used bliting function looks up a color number 3 in a 3-element long color bliting map. (The map obviously has the same number entries as the surface format has colors.)

Proper fix should refuse broken BMP images that have a pixel with a color index higher than declared number of "used" colors. Possibly more advanced fix could try to relocate the out-of-range color index into a vacant index (if such exists).
2019-03-16 18:34:33 -07:00
Sylvain Becker
cbe80d4708 KMSDRM: valid file descriptors could positive or 0. -1 is invalid. (Bug 4530) 2019-03-13 14:54:51 +01:00
Sam Lantinga
82758efc46 [iOS DAC] Fix touch events getting from SDL2 to source2. 2019-03-12 14:45:04 -07:00
Sam Lantinga
d05eec7207 Fixed initial display orientation at Android app start 2019-03-12 14:44:25 -07:00
Sylvain Becker
cddb285cdb Fixed bug 4513 - Wayland, fix crash when remove event is sent (from Sebastian Krzyszkowiak) 2019-03-12 20:04:08 +01:00
Sylvain Becker
7b27594274 KMSDRM: missing return value in VideoInit() (Bug 4530) 2019-03-11 15:27:42 +01:00
Sylvain Becker
3b49ee5261 KMSDRM: change calls free() to SDL_free() (Bug 4529) 2019-03-11 15:22:40 +01:00
Sylvain Becker
2fd4aee149 Un-activate some routine on mips because they are slowers (Bug 4503) 2019-02-23 09:36:56 +01:00
Sylvain Becker
47fb781b94 BlitNtoN BlitNtoNKey: remove non-aligned word read/store (bpp 3<->4) (Bug 4503)
Mips and (old) ARM doesn't allow word read/write when adress isn't 4bytes
aligned. So just remove that.
2019-02-22 09:30:45 +01:00
Ryan C. Gordon
6fbe9e23fa raspberry: expose second display.
This lets apps see and choose between both an HDMI and DSI-connected display,
such as a television and the Pi Foundation's official touchscreen. It only
exposes the second display if the hardware reports that it is connected.
2019-02-19 23:46:54 -05:00
Sylvain Becker
90a075d75f Fix windows build 2019-02-18 22:48:14 +01:00
Sylvain Becker
e9a7b6973a Fix bug 4053: Blit issues on Big Endian CPU 2019-02-18 22:06:53 +01:00
Sam Lantinga
ea4c4cfc28 Fixed bug 4500 - Heap-Buffer Overflow in Map1toN pertaining to SDL_pixels.c
Petr Pisar

The reproducer has these data in BITMAPINFOHEADER:

biSize = 40
biBitCount = 8
biClrUsed = 131075

SDL_LoadBMP_RW() function passes biBitCount as a color depth to SDL_CreateRGBSurface(), thus 256-color pallete is allocated. But then biClrUsed colors are read from a file and stored into the palette. SDL_LoadBMP_RW should report an error if biClrUsed is greater than 2^biBitCount.
2019-02-18 07:50:33 -08:00
Sylvain Becker
afd1b3dae4 Fix invalid memory access and optimise Blit_3or4_to_3or4__*
Fix invalid write at last pixel of the surface:
  when surface has no padding (pitch == w * bpp) and bpp is 3
  with Blit, no colorkey, and NO_ALPHA same or inverse rgb triplet

Optimise by using int32 access:

BGR24 -> ARGB8888 :  faster x1.897875   (362405 -> 190953)
RGB24 -> ABGR8888 :  faster x1.660416   (363304 -> 218803)

ABGR8888 -> RGB24 :  faster x1.686319   (334962 -> 198635)
ARGB8888 -> BGR24 :  faster x1.691868   (324524 -> 191814)
BGR24 -> RGB888 :  faster x1.678459   (326811 -> 194709)
BGR888 -> RGB24 :  faster x1.731772   (327724 -> 189242)
RGB24 -> BGR888 :  faster x1.690989   (328916 -> 194511)
RGB888 -> BGR24 :  faster x1.698333   (326175 -> 192056)
2019-02-17 16:20:23 +01:00
Sylvain Becker
1aa2ad2fe8 Better naming for the blit permutation variables 2019-02-09 17:40:32 +01:00
Sylvain Becker
f6a2ae6007 Faster blit colorkey or not, applied to bpp: 3->4 and 4->3
===== BlitNtoNKey ========
ABGR8888 -> BGR24 :  faster x3   (2168709 -> 562738)
ABGR8888 -> RGB24 :  faster x3   (2165055 -> 567458)

ARGB8888 -> BGR24 :  faster x3   (2169109 -> 564338)
ARGB8888 -> RGB24 :  faster x3   (2165266 -> 567081)

BGR24 -> ABGR8888 :  faster x3   (2997675 -> 891636)
BGR24 -> ARGB8888 :  faster x3   (2985449 -> 892028)
BGR24 -> BGR888 :  faster x3   (2961611 -> 891913)
BGR24 -> BGRA8888 :  faster x3   (3116305 -> 891534)
BGR24 -> BGRX8888 :  faster x3   (3179654 -> 896978)
BGR24 -> RGB888 :  faster x3   (2968191 -> 895112)
BGR24 -> RGBA8888 :  faster x3   (2998428 -> 893147)
BGR24 -> RGBX8888 :  faster x3   (2976529 -> 914853)

BGR888 -> BGR24 :  faster x3   (2161906 -> 563921)
BGR888 -> RGB24 :  faster x3   (2168228 -> 566634)

BGRA8888 -> BGR24 :  faster x4   (2270501 -> 561873)
BGRA8888 -> RGB24 :  faster x3   (2163179 -> 567330)

BGRX8888 -> BGR24 :  faster x3   (2162911 -> 562322)
BGRX8888 -> RGB24 :  faster x3   (2169617 -> 570927)

RGB24 -> ABGR8888 :  faster x3   (2977061 -> 925975)
RGB24 -> ARGB8888 :  faster x3   (2978148 -> 923680)
RGB24 -> BGR888 :  faster x3   (3001413 -> 935074)
RGB24 -> BGRA8888 :  faster x3   (2959003 -> 924096)
RGB24 -> BGRX8888 :  faster x3   (2965240 -> 927100)
RGB24 -> RGB888 :  faster x3   (2983921 -> 926063)
RGB24 -> RGBA8888 :  faster x3   (2963908 -> 925457)
RGB24 -> RGBX8888 :  faster x3   (2967957 -> 931700)

RGB888 -> BGR24 :  faster x3   (2173299 -> 563226)
RGB888 -> RGB24 :  faster x3   (2218374 -> 566164)

RGBA8888 -> BGR24 :  faster x3   (2166355 -> 561381)
RGBA8888 -> RGB24 :  faster x3   (2170322 -> 566729)

RGBX8888 -> BGR24 :  faster x3   (2168524 -> 564072)
RGBX8888 -> RGB24 :  faster x3   (2163680 -> 566956)

===== BlitNtoN ========

BGR24 -> BGRA8888 :  faster x3   (2458958 -> 797557)
BGR24 -> BGRX8888 :  faster x3   (2486085 -> 797745)
BGR24 -> RGBA8888 :  faster x3   (2422116 -> 797637)
BGR24 -> RGBX8888 :  faster x3   (2454426 -> 799085)

BGRA8888 -> BGR24 :  faster x4   (2468206 -> 524486)
BGRA8888 -> RGB24 :  faster x4   (2463581 -> 525561)

BGRX8888 -> BGR24 :  faster x4   (2583355 -> 524468)
BGRX8888 -> RGB24 :  faster x4   (2477242 -> 524284)

RGB24 -> BGRA8888 :  faster x2   (2453414 -> 818415)
RGB24 -> BGRX8888 :  faster x3   (2414915 -> 800863)
RGB24 -> RGBA8888 :  faster x3   (2461114 -> 798148)
RGB24 -> RGBX8888 :  faster x3   (2400922 -> 799203)

RGBA8888 -> BGR24 :  faster x4   (2494472 -> 526428)
RGBA8888 -> RGB24 :  faster x4   (2462260 -> 526791)

RGBX8888 -> BGR24 :  faster x4   (2541115 -> 524390)
RGBX8888 -> RGB24 :  faster x4   (2469059 -> 525416)
2019-02-09 17:20:53 +01:00
Sylvain Becker
604b44f20f Fix wrong access and simplify 2019-02-08 17:15:30 +01:00
Sylvain Becker
5ed30f844d Some simplification of previous commit 2019-02-07 22:45:50 +01:00
Sylvain Becker
5fd228921c Faster blit with CopyAlpha, no ColorKey
Applied to following formats:

ABGR8888 -> BGRA8888 :  faster x3   (2727179 -> 704761)
ABGR8888 -> RGBA8888 :  faster x3   (2707808 -> 705309)

ARGB8888 -> BGRA8888 :  faster x3   (2745371 -> 712437)
ARGB8888 -> RGBA8888 :  faster x3   (2746230 -> 705236)

BGRA8888 -> ABGR8888 :  faster x3   (2745026 -> 707045)
BGRA8888 -> ARGB8888 :  faster x3   (2752760 -> 727373)
BGRA8888 -> RGBA8888 :  faster x3   (2769544 -> 704607)

RGBA8888 -> ABGR8888 :  faster x3   (2725058 -> 706669)
RGBA8888 -> ARGB8888 :  faster x3   (2704866 -> 707132)
RGBA8888 -> BGRA8888 :  faster x3   (2710351 -> 704615)
2019-02-07 22:03:30 +01:00
Sylvain Becker
704e62bbf4 Code factorization of the pixel format permutation 2019-02-07 21:49:24 +01:00
Sylvain Becker
0a007a9bea Fix wrong comment 2019-02-07 18:52:49 +01:00
Sylvain Becker
e5192384d0 Faster blit with no ColorKey
Applied to following formats:

ABGR8888 -> BGRX8888 :  faster x5   (3177493 -> 630439)
ABGR8888 -> RGBX8888 :  faster x5   (3178104 -> 628925)

ARGB8888 -> BGRX8888 :  faster x4   (3141089 -> 629448)
ARGB8888 -> RGBX8888 :  faster x5   (3216413 -> 630465)

BGR888 -> BGRA8888 :  faster x4   (3145403 -> 637701)
BGR888 -> BGRX8888 :  faster x4   (3142106 -> 630144)
BGR888 -> RGBA8888 :  faster x4   (3202685 -> 649384)
BGR888 -> RGBX8888 :  faster x4   (3170617 -> 658670)

BGRA8888 -> BGR888 :  faster x4   (3203308 -> 657697)
BGRA8888 -> RGB888 :  faster x5   (3201475 -> 631747)
BGRA8888 -> RGBX8888 :  faster x5   (3274544 -> 630409)

BGRX8888 -> ABGR8888 :  faster x4   (3149753 -> 638682)
BGRX8888 -> ARGB8888 :  faster x5   (3164101 -> 631273)
BGRX8888 -> BGR888 :  faster x4   (3144454 -> 630712)
BGRX8888 -> RGB888 :  faster x4   (3160490 -> 638047)
BGRX8888 -> RGBA8888 :  faster x5   (3308988 -> 631232)
BGRX8888 -> RGBX8888 :  faster x5   (3216775 -> 638065)

RGB888 -> BGRA8888 :  faster x4   (3143135 -> 655146)
RGB888 -> BGRX8888 :  faster x4   (3141790 -> 653771)
RGB888 -> RGBA8888 :  faster x5   (3214402 -> 637001)
RGB888 -> RGBX8888 :  faster x4   (3143082 -> 630009)

RGBA8888 -> BGR888 :  faster x3   (3157048 -> 920375)
RGBA8888 -> BGRX8888 :  faster x5   (3196692 -> 632996)
RGBA8888 -> RGB888 :  faster x4   (3141570 -> 652151)

RGBX8888 -> ABGR8888 :  faster x5   (3175401 -> 631218)
RGBX8888 -> ARGB8888 :  faster x4   (3144690 -> 639440)
RGBX8888 -> BGR888 :  faster x4   (3144250 -> 630171)
RGBX8888 -> BGRA8888 :  faster x5   (3220321 -> 630731)
RGBX8888 -> BGRX8888 :  faster x4   (3178453 -> 637445)
RGBX8888 -> RGB888 :  faster x5   (3203623 -> 632596)
2019-02-07 18:51:14 +01:00
Sylvain Becker
7372295ec9 Faster blit when using No Alpha or Set Alpha, + ColorKey
Applied to following formats:

ABGR8888 -> BGRX8888 :  faster x4   (2794295 -> 610587)
ABGR8888 -> RGB888 :  faster x4   (2835693 -> 615561)
ABGR8888 -> RGBX8888 :  faster x4   (2880475 -> 610479)

ARGB8888 -> BGR888 :  faster x4   (2802718 -> 610702)
ARGB8888 -> BGRX8888 :  faster x4   (2792481 -> 606311)
ARGB8888 -> RGBX8888 :  faster x4   (2821621 -> 624745)

BGR888 -> ARGB8888 :  faster x4   (2791705 -> 637889)
BGR888 -> BGRA8888 :  faster x4   (2793195 -> 652299)
BGR888 -> BGRX8888 :  faster x4   (2800713 -> 609326)
BGR888 -> RGB888 :  faster x4   (2812260 -> 610471)
BGR888 -> RGBA8888 :  faster x4   (2792327 -> 629288)
BGR888 -> RGBX8888 :  faster x4   (2799224 -> 607073)

BGRA8888 -> BGR888 :  faster x4   (2800520 -> 606897)
BGRA8888 -> RGB888 :  faster x4   (2825274 -> 616156)
BGRA8888 -> RGBX8888 :  faster x4   (2812530 -> 610340)

BGRX8888 -> ABGR8888 :  faster x4   (2793940 -> 628596)
BGRX8888 -> ARGB8888 :  faster x4   (2822686 -> 638899)
BGRX8888 -> BGR888 :  faster x4   (2818141 -> 613659)
BGRX8888 -> RGB888 :  faster x4   (2929017 -> 611794)
BGRX8888 -> RGBA8888 :  faster x4   (2799709 -> 629750)
BGRX8888 -> RGBX8888 :  faster x4   (2911010 -> 605640)

RGB888 -> ABGR8888 :  faster x4   (2800671 -> 631542)
RGB888 -> BGR888 :  faster x4   (2802644 -> 604461)
RGB888 -> BGRA8888 :  faster x4   (2801919 -> 628729)
RGB888 -> BGRX8888 :  faster x4   (2938244 -> 604135)
RGB888 -> RGBA8888 :  faster x4   (2912447 -> 642185)
RGB888 -> RGBX8888 :  faster x4   (2831676 -> 634293)

RGBA8888 -> BGR888 :  faster x4   (2928896 -> 614960)
RGBA8888 -> BGRX8888 :  faster x4   (2821422 -> 608146)
RGBA8888 -> RGB888 :  faster x4   (2825927 -> 617184)

RGBX8888 -> ABGR8888 :  faster x4   (2803852 -> 654129)
RGBX8888 -> ARGB8888 :  faster x4   (2923615 -> 642644)
RGBX8888 -> BGR888 :  faster x4   (2806523 -> 610447)
RGBX8888 -> BGRA8888 :  faster x4   (2813388 -> 630305)
RGBX8888 -> BGRX8888 :  faster x4   (2800052 -> 607881)
RGBX8888 -> RGB888 :  faster x4   (2807722 -> 610263)
2019-02-07 17:52:28 +01:00
Sylvain Becker
bb9a9080dc Fix pointer warnings 2019-02-07 16:13:25 +01:00
Sylvain Becker
3543a44ae4 Faster blit when using CopyAlpha + ColorKey
Applied to following formats:

ABGR8888 -> ARGB8888 :  faster x7   (3959672 -> 537227)
ABGR8888 -> BGRA8888 :  faster x7   (4008716 -> 532064)
ABGR8888 -> RGBA8888 :  faster x7   (3998576 -> 530964)

ARGB8888 -> ABGR8888 :  faster x7   (3942420 -> 532503)
ARGB8888 -> BGRA8888 :  faster x7   (3995382 -> 527722)
ARGB8888 -> RGBA8888 :  faster x7   (4259330 -> 543033)

BGRA8888 -> ABGR8888 :  faster x7   (4110411 -> 529402)
BGRA8888 -> ARGB8888 :  faster x7   (4071906 -> 538393)
BGRA8888 -> RGBA8888 :  faster x6   (4038320 -> 585141)

RGBA8888 -> ABGR8888 :  faster x7   (3937018 -> 534127)
RGBA8888 -> ARGB8888 :  faster x7   (3979577 -> 537810)
RGBA8888 -> BGRA8888 :  faster x7   (3975656 -> 528355)
2019-02-07 15:12:17 +01:00
Sylvain Becker
670f3d3327 Fixed bug 4484 - use SIMD aligned memory for SDL_Surface
Surfaces are allocated using SDL_SIMDAlloc()
They are marked with SDL_SIMD_ALIGNED flag to appropriatly free them with SDL_SIMDFree()
(Flag is cleared when pixels is free'd in RLE, in case user would hijack the pixels ptr)

When providing its own memory pointer (SDL_CreateRGBSurfaceFrom()) and clearing
SDL_PREALLOC  to delegate to SDL the memory free, it's the responsability of the user
to add SDL_SIMD_ALIGNED or not, whether the pointer has been allocated with SDL_malloc() or
SDL_SIMDAlloc().
2019-02-04 09:11:07 +01:00
Sylvain Becker
9292dc7ca1 Fix include path compilation 2019-02-04 08:43:37 +01:00
Sylvain Becker
9a98dcc516 Rename surface aligned memory flag to SDL_SIMD_ALIGNED 2019-02-04 08:34:24 +01:00
Sylvain Becker
e5d194e902 Add SDL_MEMALIGNED flag for SDL_Surface using aligned memory.
If an SDL_Surface has an aligned memory pointers, it should be freed
using SDL_SIMDFree() (will be used by SDL_ttf).
2019-01-31 11:45:31 +01:00
Sylvain Becker
7b8bac5958 Add fast paths in BlitNtoNKey
All following conversions are faster (with colorkey, but no blending).
(ratio isn't very accurate)

ABGR8888 -> BGR888 :  faster x9   (2699035 -> 297425)

ARGB8888 -> RGB888 :  faster x8   (2659266 -> 296137)

BGR24 -> BGR24 :  faster x5   (2232482 -> 445897)
BGR24 -> RGB24 :  faster x4   (2150023 -> 448576)

BGR888 -> ABGR8888 :  faster x8   (2649957 -> 307595)

BGRA8888 -> BGRX8888 :  faster x9   (2696041 -> 297596)

BGRX8888 -> BGRA8888 :  faster x8   (2662011 -> 299463)
BGRX8888 -> BGRX8888 :  faster x9   (2733346 -> 295045)

RGB24 -> BGR24 :  faster x4   (2154551 -> 485262)
RGB24 -> RGB24 :  faster x4   (2149878 -> 484870)

RGB888 -> ARGB8888 :  faster x8   (2762877 -> 324946)

RGBA8888 -> RGBX8888 :  faster x8   (2657855 -> 297753)

RGBX8888 -> RGBA8888 :  faster x8   (2661360 -> 296655)
RGBX8888 -> RGBX8888 :  faster x8   (2649287 -> 308268)
2019-01-30 22:50:20 +01:00
Sylvain Becker
cd25c83aad Fix blit with blending (Blit_A) to RGB332 which has no palette 2019-01-30 17:16:08 +01:00
Sylvain Becker
5b07148f73 Fixed failing SDL_ConvertSurface() when blit has failed.
Some blit combination are not supported (eg ARGB8888 -> SDL_PIXELFORMAT_INDEX1MSB)
So prevent SDL_ConvertSurface from creating a broken surface, which cannot be blitted
2019-01-30 16:36:47 +01:00
Sylvain Becker
a052d81bdf Add explicit unsigned int and char types in (for bug 4290) 2019-01-30 15:31:07 +01:00
Sylvain Becker
1128d57316 Fixed bug 4290 - add fastpaths for format conversion in BlitNtoN
All following conversion are faster (no colorkey, no blending).
(ratio isn't very accurate)

ABGR8888 -> ARGB8888 :  faster x6   (2655837 -> 416607)
ABGR8888 -> BGR24 :  faster x7   (2470117 -> 325693)
ABGR8888 -> RGB24 :  faster x7   (2478107 -> 335445)
ABGR8888 -> RGB888 :  faster x9   (3178524 -> 333859)

ARGB8888 -> ABGR8888 :  faster x6   (2648366 -> 406977)
ARGB8888 -> BGR24 :  faster x7   (2474978 -> 327819)
ARGB8888 -> BGR888 :  faster x9   (3189072 -> 326710)
ARGB8888 -> RGB24 :  faster x7   (2473689 -> 324729)

BGR24 -> ABGR8888 :  faster x6   (2268763 -> 359946)
BGR24 -> ARGB8888 :  faster x6   (2306393 -> 359213)
BGR24 -> BGR888 :  faster x6   (2231141 -> 324195)
BGR24 -> RGB24 :  faster x4   (1557835 -> 322033)
BGR24 -> RGB888 :  faster x6   (2229854 -> 323849)

BGR888 -> ARGB8888 :  faster x8   (3215202 -> 363137)
BGR888 -> BGR24 :  faster x7   (2474775 -> 347916)
BGR888 -> RGB24 :  faster x7   (2532783 -> 327354)
BGR888 -> RGB888 :  faster x9   (3134634 -> 344987)

RGB24 -> ABGR8888 :  faster x6   (2229486 -> 358919)
RGB24 -> ARGB8888 :  faster x6   (2271587 -> 358521)
RGB24 -> BGR24 :  faster x4   (1530913 -> 321149)
RGB24 -> BGR888 :  faster x6   (2227284 -> 327453)
RGB24 -> RGB888 :  faster x6   (2227125 -> 329061)

RGB888 -> ABGR8888 :  faster x8   (3163292 -> 362445)
RGB888 -> BGR24 :  faster x7   (2469489 -> 327127)
RGB888 -> BGR888 :  faster x9   (3190526 -> 326022)
RGB888 -> RGB24 :  faster x7   (2479084 -> 324982)
2019-01-30 15:23:33 +01:00
Charlie Birks
6d89a7bc71 Emscripten: remove GLES_DeleteContext implementation
It was calling glClear without a context. The issue it was trying to
solve was actually that after destroying a window and creating a new one
, the contents of the old window were preserved. This no longer happens
since we resize the window to nothing on destroy.
2019-01-29 12:19:32 +00:00
Charlie Birks
04b1494cf8 Emscripten: resize canvas to 0x0 in DestroyWindow
Closest we can get to actually destroying it
2019-01-29 12:19:23 +00:00
Charlie Birks
d60546aaa8 Emscripten: don't zero the display mode before adding it 2019-01-29 12:19:06 +00:00
Charlie Birks
4a2888af10 Emscripten: use UTF8ToString instead of Pointer_stringify 2019-01-29 12:19:03 +00:00
Charlie Birks
8dab9c956f Emscripten: Use set_canvas_element_size
This will be needed for supporting multiple canvases and set_canvas_size
is deprecated anyway.
2019-01-29 12:18:56 +00:00
kichikuou
ed66a430c9 Emscripten: Do not consume mouseup event outside of the canvas 2019-01-29 12:14:54 +00:00
Sylvain Beucler
2838abb5b2 Emscripten: fix duplicate mousebuttonup/mousebuttondown events when touch events are disabled 2019-01-29 12:14:44 +00:00
Charlie Birks
1767d09187 Emscripten: use a fake size for external sizing check
The check would fail if the canvas happened to be the correct size
already. (#66, mentioned in #58)
2019-01-29 12:14:41 +00:00
Charlie Birks
80d690a2a0 Emscripten: reset fullscreen_window when leaving fullscreen
If the browser left fullscreen mode by the user pressing ESC, the next
call to SDL_SetWindowFullscreen(1) will fail as it thinks the window is
already fullscreen. (#65)
2019-01-29 12:14:33 +00:00
Sylvain Becker
d984f323fc Fixed bug 3827 - issue with MapRGB, palette and colorkey
For palette surface, SDL_MapRGB() returns different values whether colorkey is
set or not.
2019-01-21 19:53:06 +01:00
Sylvain Becker
2bd26b8da8 Fixed bug 3827 - issue with MapRGB, palette and colorkey
For a palettized surface, prevent SDL_MapRGB() value to change whether colorkey is set or not.
2019-01-21 18:45:15 +01:00
Sam Lantinga
61827c6d1a Fixed compiler warning on Android 2019-01-20 12:02:12 -08:00
Sylvain Becker
e5f8801f55 Android: prevent concurrency in Android_SetScreenResolution() when exiting
by checking Android_Window validity

- SDLThread: user application is exiting:
    SDL_VideoQuit() and clearing SDL_GetVideoDevice()

- ActivityThread is changing orientation/size
    surfaceChanged() > Android_SetScreenResolution() > SDL_GetVideoDevice()

- Separate function into Android_SetScreenResolution() and Android_SendResize(),
    formating, and mark Android_DeviceWidth/Heigh as static
2019-01-17 11:05:05 +01:00
Sylvain Becker
e994be5833 Android: move static variable isPaused/isPausing to SDL_VideoData structure
- remove unneed check to Android_Window->driverdata
- add window check into context_backup/restore
2019-01-16 10:31:51 +01:00
Sylvain Becker
dc263450ff Android: create Pause/ResumeSem semaphore at higher level than CreateWindow()
- If you call onPause() before CreateWindow(), SDLThread will run in infinite loop in background.

- If you call onPause() between a DestroyWindow() and a new CreateWindow(), semaphores are invalids.

SDLActivity.java: the first resume() starts the SDLThread, don't call
nativeResume() as it would post ResumeSem. And the first pause would
automatically be resumed.
2019-01-14 23:33:48 +01:00
Sylvain Becker
955d87894b Android/openslES: set audio in paused/resumed state for Android event loop
And also in "stopped" state before closing the device.
2019-01-14 12:33:29 +01:00
Sam Lantinga
fb8cb95fbc Fixed compiler warning 2019-01-12 12:12:43 -08:00
Sylvain Becker
7a1d1baefc Android: add name for Touch devices and simplification, from bug 3958 2019-01-10 21:40:57 +01:00
Sylvain Becker
02f292eb13 Android: add some SetError for Android_SetWindowFullscreen
First error could happen if Android_SetWindowFullscreen somehow gets
called between SurfaceDestroyed() and SurfaceCreated()

Second error should not happen has native_window validity is guaranteed.
(It would happens previously with error -19)
2019-01-09 22:49:49 +01:00
Sylvain Becker
1803944bb2 Android: concurrency issue for Android_SetWindowFullscreen()
It accesses data->native_window, which can be changed by onNativeSurfacedChanged().

Currently, Android_SetWindowFullscreen() may access data->native_window after it
has been released, and before a new reference is acquired.

(can be reproduced by adding some SDL_Delay() in onNativeSurfacedChanged and
Android_SetWindowFullscreen() ).
2019-01-09 15:18:41 +01:00
Sylvain Becker
462e62e154 Android: better fix for bug 3186. Run those commands from SDL thread. 2019-01-06 20:25:54 +01:00
Sylvain Becker
e4f558a50c Android: un-needed check of "isPausing" and minor typos 2019-01-05 22:46:52 +01:00
Sylvain Becker
35722b6423 Android: fix wrong state after immediate sequence pause() / resume() / pause()
It may happen to have the sequence pause()/resume()/pause(), before polling
any events.

Before, it ends in 'resumed' state because as the check is greedy.
Now, always increase the Pause semaphore, and stop at each pause.
It ends in 'paused' state.

Related to bug 3250: set up a reconfiguration of SurfaceView holder.
Turn the screen off manually before the app starts
(repro rate is not 100%..)
2019-01-05 22:27:25 +01:00
Sam Lantinga
d4c0f498db Fixed bug 4255 - SDL_GetGlobalMouseState() returns incorrect Y on secondary display
Julian Raschke

I use an open Mac laptop with an additional external monitor. The coordinate spaces from SDL_GetGlobalMouseState() and SDL_GetWindowPosition() match on the primary display, but not on the secondary display.

Cocoa window coordinates are vertically flipped in relation to the primary display:

https://github.com/spurious/SDL-mirror/blob/release-2.0.8/src/video/cocoa/SDL_cocoawindow.m#L219-L222

However, Cocoa_GetGlobalMouseState inverts the cursor Y coordinate per-display:

https://github.com/spurious/SDL-mirror/blob/release-2.0.8/src/video/cocoa/SDL_cocoamouse.m#L320-L323

Suggested fix: Replace the for-loop with this simpler calculation:

    *x = (int) cocoaLocation.x;
    *y = (int) (CGDisplayPixelsHigh(kCGDirectMainDisplay) - cocoaLocation.y);
2019-01-04 22:09:38 -08:00
Sam Lantinga
5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Sylvain Becker
2a885eb036 Android: fixed immediate transition to pause and resume.
"Pause" transition will add events:
 SDL_WINDOWEVENT_ENTER
 SDL_WINDOWEVENT_FOCUS_LOST
 SDL_WINDOWEVENT_MINIMIZED
 SDL_APP_WILL ENTER BACKGROUND
 SDL_APP_DID ENTER BACKGROUND

"Resume" transition will add events:
 SDL_APP_WILL ENTER FOREGROUND
 SDL_APP_DID ENTER FOREGROUND
 SDL_WINDOWEVENT_FOCUS_GAINED
 SDL_WINDOWEVENT_RESTORED

If Android application doesn't empty the event loop in between, it enters in
"paused" state when SDL_WINDOWEVENT_RESTORED is fetched.

See bug 3250 for pratical case.
2019-01-04 23:39:27 +01:00
Sylvain Becker
cf12234454 Android: make Android_PumpEvents() more readable
No behavior change in this commit.
2019-01-04 23:11:21 +01:00
Sylvain Becker
ca184ac386 Android: concurrency issue with egl_surface EGL_BAD_SURFACE - (bug 4142)
Occurs when application goes to background:
- Java activity is destroying SurfaceView holder and "egl_surface" (in onNativeSurfaceDestroyed())
- While native thread is in Android_GLES_SwapWindow(), prepared to call SDL_EGL_SwapBuffers()

The error is "call to eglSwapBuffers failed, reporting an error of EGL_BAD_SURFACE"

It an be reproduced easily by adding a SDL_Delay(100) at the begining of SDL_EGL_SwapBuffers(),
and putting the application into background.
2019-01-03 23:22:50 +01:00
Sylvain Becker
2e19343df6 Android: use Mutex instead of Semphore for bug 4142 2019-01-03 20:18:29 +01:00
Sylvain Becker
23478642bd Android: prevent the error message from SDL_EGL_CreateSurface() to be masked. 2019-01-03 16:22:33 +01:00
Sylvain Becker
cc8f1136b6 Fixed bug 4142 - Concurrency issues in Android backend
Use a semaphore to prevent concurrency issues between Java Activity and Native thread code, when using 'Android_Window'.
(Eg. Java sending Touch events, while native code is destroying the main SDL_Window. )
2019-01-03 14:18:06 +01:00
Sylvain Becker
d11f7615fa Android: minor preparation for bug 4142 (concurrency issues) 2019-01-03 13:38:33 +01:00
Sylvain Becker
5dc25fef3b Android: preparation bug 4142, reduce usage of global variable Android_Window 2019-01-03 13:14:16 +01:00
Sylvain Becker
a95f91bcea Fixed bug 3250 - Wrong backbuffer pixel format on Android, keep getting RGB_565
Use the egl format to reconfigure java SurfaceView holder format.
If there is a change, it triggers a surfaceDestroyed/Created/Change sequence.
2019-01-02 18:06:33 +01:00
Ryan C. Gordon
13869f194c cocoa: Implement OpenGL swap interval support with CVDisplayLink.
Not only does this fix macOS 10.14 ("Mojave")'s broken NSOpenGLCPSwapInterval
support, it also lets us implement "adaptive vsync" on macOS!

CVDisplayLink is supported back to macOS 10.4 ("Tiger"), so we just use it
universally without version checks and dump NSOpenGLCPSwapInterval, Mojave or
not.
2018-12-16 01:03:17 -05:00
Sylvain Becker
1ed6021960 Fixed bug 4426 - allows re-creation of software renderer
Switching between renderers "software -> opengl -> opengles2 -> software" fails.

"opengl -> opengles2" calls SDL_RecreateWindow() and frees "window->surface"
without marking it as "surface_invalid".
2018-12-15 16:21:24 +01:00
Sam Lantinga
bd08d72dec Fixed building with the 10.10 SDK 2018-12-11 20:04:10 -08:00
Sam Lantinga
1c9595b16f Fixed bug 4415 - SDL menu bar is nonstandard on Mac
foo.null

I'm on macOS 10.14 and I think I'm using or around SDL 2.0.9. This is about the menu bar that SDL sets up which looks like:

<App Name> <Window> <View>

1. View menu never proceeds after the Window menu in any Mac application (it is always before).
2. For SDL, the only purpose of the View menu is for a single fullscreen menu item, which is not justifiable enough to reserve space for a menu. The View menu should thus be removed, and the full screen menu item should be added at the end inside of Window's menu. See built in apps like Dictionary, Chess, App Store (on 10.14) that do this.
3. SDL should add a "Close" menu item to the Window's submenu, and it should be the first item. Its key equivalent should map to command w. Without this, you cannot close the game window via this shortcut, and you cannot close the app's About window via this shortcut.
4. Apps typically use "Enter Full Screen" or "Exit Full Screen" depending on context, not "Toggle Full Screen" which is less user friendly -- I personally care about this point the least.
2018-12-08 11:06:40 -08:00
Brandon Schaefer
f9192ab8fc wayland: Do not try to lock on an invalid pointer
This happens if you try to lock the pointer and (caps & WL_SEAT_CAPABILITY_POINTER) is false
Leading to input->pointer being NULL which ends up bringing the wayland client down (at lease on weston)
2018-12-06 10:39:33 -05:00
Sylvain Becker
252dc85e95 Fix warnings detected on Android build 2018-12-06 09:22:00 +01:00
Ryan C. Gordon
2878d4f80c egl: Don't force X11 support when testing for EGL.
Fixes building Wayland support on embedded systems without X11.

(TODO: maybe move the EGL test out of the X11 tests at some point, too.)
2018-12-05 16:53:15 -05:00
Ryan C. Gordon
bd3ee07c83 wayland: Send SDL_TOUCH_MOUSEID mouse events for touches. 2018-12-05 16:49:38 -05:00
Ryan C. Gordon
65a7c98c6f directfb: Updated render backend to new internal API.
Totally untested, beyond it now compiles again. Probably needs some fixes.

Fixes Bugzilla #4405.
2018-12-02 02:33:06 -05:00
Sergey Zhuravlevich
583f61b202 kmsdrm: Check for resources when validating KMSDRM device in check_modesetting.
Fixes Bugzilla #4403.
2018-12-01 16:31:56 -05:00
Sergey Zhuravlevich
b3ac87d559 kmsdrm: uninitialized KMSDRM fixes
* Search for valid encoder in connector when it doesn't have an
   encoder ID set.

 * Search for valid CRTC in resources and encoder's possible CRTCs
   when encoder doesn't have one set.

 * Select default mode if CRTC doesn't have a valid one.

 * Pick current_mode's W/H/Refresh Rate basing on current and
   valid CRTC mode, not the saved one.
2018-12-01 13:09:00 -05:00
Ryan C. Gordon
c4bc59a50e Patched to compile on Linux with --disable-threads.
Fixes Bugzilla #4393.
2018-12-01 10:36:26 -05:00
Sam Lantinga
a95291c9c8 Fixed the hotspot for cursors on Raspberry Pi 2018-11-27 11:16:04 -08:00
Sam Lantinga
aea483577a Fixed bug changing cursors on Raspberry Pi 2018-11-27 10:20:29 -08:00
Sebastian Krzyszkowiak
5f98051457 wayland: ask xdg-decoration protocol extension to use server-side decorations if possible. 2018-11-04 21:08:40 +01:00
Sam Lantinga
5c5ba0e331 Fixed bug 4394 - Crash in SDL_PumpEvents() after SDL_DestroyWindow()
Cameron Gutman

After updating to SDL 2.0.9, I got a user report that my app was crashing when closing a SDL_WINDOW_FULLSCREEN window to return to my Qt-based UI. It looks like the dead SDL window is getting a spurious updateLayer call which is causing SDL to dereference a null SDL_WindowData pointer.

For some reason, this only happens when using SDL_WINDOW_FULLSCREEN and not windowed or SDL_WINDOW_FULLSCREEN_DESKTOP. I was also unsuccessful in my attempt to get a simple reproducer for this crash. The Session.cpp code is available 688c4a90d9/app/streaming/session.cpp but I slightly modified it (adding a SDL_PumpEvents() call at 1179 to immediately trigger the issue, otherwise it happened when Qt next pumped the event loop).

The crashing line is:

    NSMutableArray *contexts = data->nscontexts;
2018-11-19 21:35:59 -08:00
Alex Szpakowski
c525ff354d cocoa: fix building with the macOS 10.7 SDK (thanks Riccardo!)
Fixes bug #4368
2018-11-10 20:56:23 -04:00
Alex Szpakowski
5029d50ea8 Add SDL_TouchDeviceType enum and SDL_GetTouchDeviceType(SDL_TouchID id).
Touch device types include SDL_TOUCH_DEVICE_DIRECT (a touch screen with window-relative coordinates for touches), SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE (a trackpad-style device with absolute device coordinates), and SDL_TOUCH_DEVICE_INDIRECT_RELATIVE (a trackpad-style device with screen cursor-relative coordinates).

Phone screens are an example of a direct device type. Mac trackpads are the indirect-absolute touch device type. The Apple TV remote is an indirect-relative touch device type.
2018-11-10 16:15:48 -04:00
Sam Lantinga
9665a50891 Added Vulkan headers version 1.1.91
Downloaded from https://github.com/KhronosGroup/Vulkan-Headers
2018-11-06 16:57:07 -08:00
Sebastian Krzyszkowiak
48917e0e70 wayland: fix resizing and fullscreen toggling
For starters, we need to correctly respond to 0,0 configure after unsetting
fullscreen. Also, turns out that there should be no drawing calls at all
in between eglSwapBuffers and wl_egl_window_resize, as otherwise EGL can
already allocate a wrongly sized buffer for a next frame, so handle those
together.
2018-11-07 01:08:35 +01:00
Ryan C. Gordon
bc57ac27f9 mir: Removed mir client support.
Fixes Bugzilla #4288.
2018-11-02 21:34:17 -04:00
Ryan C. Gordon
4659e73892 merge fallout: Patched to compile, fixed some compiler warnings, etc. 2018-11-01 12:31:45 -04:00
Ryan C. Gordon
62494a2e27 Merge SDL-ryan-batching-renderer branch to default. 2018-10-31 15:03:41 -04:00
Ryan C. Gordon
a5ebd4d775 wayland: ask KDE protocol extension to use server-side decorations if possible. 2018-10-29 10:14:59 -04:00
Sam Lantinga
aeee424f65 Fixed bug 4349 - SDL_CreateWindow fails with KMS/DRM after upgrading Mesa to 18.2.3
Rainer Sabelka

After I did an upgrade of my arch Linux installation (resulting in an update of Mesa to version 18.2.3), all my SDL2 applications which use the KMS/DRM driver stopped working.
Reason: Creating a Window with SDL_CreateWindow failed because the call to EGL
eglCreateWindowSurface() returns an error "EGL_BAD_MATCH".
After investigating with the debugger I figured, that the configuration, which has been selected from the output of eglChooseConfig(), has an "EGL_NATIVE_VISUAL_ID" which does not match the "format" of the underlying gbm surface.

The attached patch fixes the problem. It does so, by mimicking Weston's behavior.
All configurations returned from eglChooseConfig() which have an visual_id different from the gbm format are discarded, and only from the remaining ones the "best" match is selected.
2018-10-31 15:16:51 -07:00
Micha? Janiszewski
91820998fc Add and update include guards
Include guards in most changed files were missing, I added them keeping
the same style as other SDL files. In some cases I moved the include
guards around to be the first thing the header has to take advantage of
any possible improvements compiler may have for inclusion guards.
2018-10-28 21:36:48 +01:00
Ryan C. Gordon
1ec56f7302 x11: Fixed incorrect function signature for XkbSetDetectableAutoRepeat.
It needs to use Bool (which is an int) and not BOOL (which is CARD8), which
causes problems on platforms with different byte order and alignment, etc.

Fixes Bugzilla #4326.
2018-10-20 21:35:48 -04: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
cad0a2f730 cocoa: Fix OpenGL rendering on macOS 10.14 ("Mojave").
Fixes Bugzilla #4272.
(transplanted from 54729119b348e8a4a916192d1d6cb8d115656255)
2018-10-18 12:05:05 -04:00
Ryan C. Gordon
072e17bf98 cocoa: GL_GetDrawableSize only uses -[NSView convertRectToBacking] for highDPI.
On Mojave, this will report large numbers for retina displays in fullscreen
mode, which isn't how it works on previous versions.
(transplanted from c6c1731780e2bef94f944a4795e2dfbba46d9500)
2018-10-18 11:59:48 -04:00
Ryan C. Gordon
b262b0ebc9 Small stack allocations fall back to malloc if they're unexpectedly large. 2018-10-22 20:50:32 -04:00
Ryan C. Gordon
22475bf3f0 cocoa: Force an OpenGL context update when the window becomes key.
Fixes missing rendering on macOS 10.14 ("Mojave").

Fixes Bugzilla #4272.
(transplanted from aee4797c84ef90464e270b1f6095a6dd7ce280c1)
2018-09-26 20:10:32 -04:00
Sam Lantinga
404ba5eea8 Fixed bug 4229 - Add support for ABGR format in DirectFB renderer
Alexandre

DirectFB supports 32-bit ABGR pixel format via DSPF_ABGR, but SDL doesn't map SDL_PIXELFORMAT_ABGR8888 to DSPF_ABGR.

A patch is attached and should add support for ABGR pixel format devices.
2018-08-28 13:37:11 -07:00
Sam Lantinga
a1ca84411e Update the cursor clipping each frame, in case it was stolen by another application. 2018-08-26 20:37:23 -07:00
Sam Lantinga
15b3794f11 Only reset the clip rect if it's currently the rect we previously clipped.
This prevents us from clearing the clip rect globally when another application has set it.

There's also an experimental change to regularly update the clip rect for a window defensively, in case someone else has reset it. It works well, but I don't know if it's cheap enough to call as frequently as it would be called now, and might have other undesirable side effects.

Also fixed whitespace and SDL coding style
2018-08-26 10:34:23 -07:00
Jeremy Ong
a794126d56 vulkan: SDL_Vulkan_GetInstanceExtensions should accept a NULL window.
Fixes Bugzilla #4235.
2018-08-24 09:49:48 -04:00
Thomas Perl
84e7832018 Fix "unresponsible application" issues in Wayland
Polling without wl_display_flush() never responds to ping requests.
In that case ping-pong works only on other events, such as user input
or on frame swapped.

From https://git.merproject.org/mer-core/libsdl/merge_requests/3
Original author: Alexander Akulich <a.akulich@omprussia.ru>
2018-08-23 14:47:38 +02:00
Ryan C. Gordon
f677377339 cocoa: Fix OpenGL rendering on macOS 10.14 ("Mojave").
Fixes Bugzilla #4272.
2018-10-18 12:05:05 -04:00
Ryan C. Gordon
eac3fd28d8 cocoa: GL_GetDrawableSize only uses -[NSView convertRectToBacking] for highDPI.
On Mojave, this will report large numbers for retina displays in fullscreen
mode, which isn't how it works on previous versions.
2018-10-18 11:59:48 -04:00
Ryan C. Gordon
dae4a01361 x11: Don't hardcode limit on lines of text in message boxes.
Plus other text parsing fixes.

Fixes Bugzilla #4306.
2018-10-15 00:46:43 -04:00
Alex Szpakowski
e2ad654f2e iOS: Don't ignore the requested alpha bit size when determining whether to use an RGBA8 backbuffer. 2018-10-14 17:26:10 -03:00
Charlie Birks
cd63709ed8 Emscripten: Load eglQueryString and eglGetError
This prevents an assertion on context creation failure (calling a null
function pointer).
2018-10-13 17:18:59 +01:00
Alex Szpakowski
d8022d19b4 macOS: Fixed MoltenVK dynamic library loading code. 2018-10-12 23:23:52 -03:00
Alex Szpakowski
d9094421e1 metal: Fix high dpi and resizing on macOS, and clean up iOS code. Fixes bug #4250. 2018-10-12 17:55:42 -03:00
Cameron Gutman
eff5f65096 Implement SuspendScreenSaver for Win32
Creating a full-screen SDL renderer on Windows will keep the screensaver
suspended by DirectX, as is default for full-screen DX applications. However,
for applications that render in windowed-mode, the screensaver will
still kick in, even if SDL_DisableScreenSaver() is called or
SDL_HINT_VIDEO_ALLOW_SCREENSAVER is set to 0 (default). Implementing
a SuspendScreenSaver() function for Win32 fixes this behavior.
2018-10-09 23:01:43 -07:00
Ryan C. Gordon
88b3252555 kmsdrm: find available card if called without index.
This work was done by Michael Grzeschik, I just cleaned up the patch a little.

Fixes Bugzilla #4241.
2018-10-09 00:27:55 -04:00
Sam Lantinga
4d771c598a Don't flash the navigation bar when destroying a fullscreen SDL window 2018-10-08 12:49:25 -07:00
Sam Lantinga
3ac9e2aa4e Fixed bug 4296 - kmsdrm video driver leaks 1 bo in KMSDRM_GLES_SetupCrtc()
Icenowy Zheng

One front buffer is locked in GLES_SetupCrtc() and overrides the next_bo just locked in KMSDRM_GLES_SwapWindow, then the next_bo gets lost and is not released even when quitting the video.

It may leads to problems with GLES drivers that doesn't clean up GBM correctly if there's any bo left (e.g. the Mali Utgard r6p2 blob). In the case of Mali Utgard r6p2 blob, the DRM device file is still hold by the blob, and if you try to SDL_Quit to let another program to run (this is done by EmulationStation), the new program will fail to open DRM device.
2018-10-05 17:06:05 -07:00
Ryan C. Gordon
367f9b915c wayland: Fixed missing window sizing events.
Fixes Bugzilla #4242.
2018-10-05 17:24:03 -04:00
Sam Lantinga
6e35e42145 Working on bug 3921 - Add some Fastpath to BlitNtoNKey and BlitNtoNKeyCopyAlpha
Sylvain

I did various benches. with clang 6.0.0 on linux, and ndk-r16b on android (NDK_TOOLCHAIN_VERSION=clang).

- still see a x10 speed factor.
- with duff_loops, it does not use vectorisation (but doesn't seem to be a problem).

on linux my patch is already at full speed on -O2, whereas the duff_loops need -O3 (200 ms at -03, and 300ms at -02).

I realized that on Android, I had a slight variation which fits best.
both on linux with -O2 and -O3, and on android with 02/03 and armeabi-v7a/arm64.

Here's the patch.
2018-10-01 14:43:03 -07:00
Ozkan Sezer
922623e1b6 SDL_blit_N.c (BlitNtoNKeyCopyAlpha): fix -Wshadow warnings by adding _
suffix to the temp Pixel local in the DUFFS_LOOP.
SDL_blit.h (ASSEMBLE_RGB):  add _ prefix to temp Pixel locals to avoid
  any possible shadowings.


The warnings were like the following:

In file included from src/video/SDL_blit_N.c:26:0:
src/video/SDL_blit_N.c: In function 'BlitNtoNKeyCopyAlpha':
src/video/SDL_blit_N.c:2421:24: warning: declaration of 'Pixel' shadows a previous local [-Wshadow]
                 Uint32 Pixel = ((*src32 & rgbmask) == ckey) ? *dst32 : *src32;
                        ^
src/video/SDL_blit.h:475:21: note: in definition of macro 'DUFFS_LOOP8'
     case 0: do {    pixel_copy_increment; /* fallthrough */             \
                     ^
src/video/SDL_blit_N.c:2419:13: note: in expansion of macro 'DUFFS_LOOP'
             DUFFS_LOOP(
             ^
src/video/SDL_blit_N.c:2399:12: warning: shadowed declaration is here [-Wshadow]
     Uint32 Pixel;
            ^
2018-10-01 21:29:11 +03:00
Sam Lantinga
088070e5a8 Moved display orientation handling on iOS out to a separate function for Qt apps 2018-08-22 23:47:29 -07:00
Sam Lantinga
f225af0c1e Added SDL_GetDisplayOrientation() to get the display orientation, and added a new event SDL_DISPLAYEVENT to notify the application when the orientation changes.
Documented the values returned by the accelerometer and gyroscope sensors
2018-08-22 21:48:28 -07:00
Sam Lantinga
6f758ad25f Moved SDL_IsTablet() to a cross-platform API function 2018-08-21 20:03:54 -07:00
Sam Lantinga
109544ca04 Add SDL_IsTablet() to Android and iOS SDL. 2018-08-21 11:23:47 -07:00
Ryan Speets
aeea6b9b1f Emscripten: Fixed SDL_SYSTEM_CURSOR_SIZEALL 2018-08-18 12:30:04 +01:00
Ryan C. Gordon
941c5b4760 haiku: Rename internal functions from BE_* to HAIKU_*
Fixes Bugzilla #2349.
2018-08-07 18:07:11 -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
Ryan C. Gordon
8f0cc4a4b7 Backed out changeset 2e42ec46061e.
This change isn't correct. See comments in Bugzilla #4183.
2018-07-22 19:42:08 -04:00
Ryan C. Gordon
862aa4b47d windows: Fixed some Visual Studio warnings about shadowed variables.
Fixes Bugzilla #4118.
2018-07-22 19:28:27 -04:00
Marc Di Luzio
c3178e67ca Ensure we still clear the X locale modifiers even if not compiled with ibus or fcitx support 2018-07-12 16:52:45 +01:00
Ozkan Sezer
013b146de9 SDL_windowstaskdialog.h (struct _TASKDIALOGCONFIG): make unions anonymous
otherwise build fails. (at least with my VS2005. and the code accesses the
arms of the unions anonymously anyway.)
2018-06-30 20:55:51 +03:00
Ryan C. Gordon
7c2028f8e9 Attempt to fix "cast from pointer to integer of different size" warnings. 2018-06-29 16:56:11 -04:00
Ryan C. Gordon
5a8ecf4e79 yuv: Patched to make static analysis happy (warned about unused variable). 2018-06-25 13:14:52 -04:00
Ryan C. Gordon
c8ac909674 wayland: Implemented xdg-wm-base support.
This is just in parity with the existing zxdg-shell-unstable-v6 code. Making
the Wayland target robust (and uh, with title bars) is going to take a lot
of work on top of this.
2018-06-24 22:42:36 -07:00
Sam Lantinga
95579f5f19 Fixed bug 4220 - SDL_GL_CONTEXT_DEBUG_FLAG can fail silently on some Android devices 2018-10-01 09:40:58 -07:00
Alex Szpakowski
fb485986eb macOS: Fix a crash when the video subsystem quits, if SDL_MAC_NO_SANDBOX was defined when SDL was compiled. 2018-09-30 11:26:41 -03:00
Sam Lantinga
74638ea3c5 Ensure we wait on the surface resize before returning from setting fullscreen mode. 2018-09-28 20:39:57 -07:00
Sam Lantinga
7df0f4fdac Fixed bug 4277 - warnings patch
Sylvain

Patch a few warnings when using:
-Wmissing-prototypes -Wdocumentation -Wdocumentation-unknown-command

They are automatically enabled with -Wall
2018-09-27 14:56:29 -07:00
Ryan C. Gordon
7689162ca0 cocoa: Force an OpenGL context update when the window becomes key.
Fixes missing rendering on macOS 10.14 ("Mojave").

Fixes Bugzilla #4272.
2018-09-26 20:10:32 -04:00
Sam Lantinga
55b24b93b4 Fixed bug 4265 - SDL window falls to the bottom of the screen when dragged down and stuck there
Alexei

On WM_WINDOWPOSCHANGED event, WIN_UpdateClipCursor() is called. SDL_WINDOW_INPUT_FOCUS is set even when the mouse pointer is not inside the SDL window and therefore ClipCursor(&rect) is called. When dragging the window and rect.bottom=800 (i.e. the bottom edge of the screen) the SDL window is clipped to the bottom of the screen and it is not possible to move it back to the center of the screen.
2018-09-26 11:17:43 -07:00
Sam Lantinga
ef34704875 Fixed bug 4264 - SDL_CreateTextureFromSurface generates error message but returns ok
Anthony @ POW Games

SDL_CreateTextureFromSurface makes an internal call to SDL_GetColorKey which can return an error and spams the error log with "Surface doesn't have a colorkey" even though the original function didn't return an error.
2018-09-24 16:41:55 -07:00
Sam Lantinga
5febdfcece Fixed whitespace 2018-09-24 11:49:25 -07:00
Sam Lantinga
6b3e893105 Added hints SDL_HINT_MOUSE_DOUBLE_CLICK_TIME and SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS to allow tuning double-click sensitivity.
Also increased the default double-click radius to 32 pixels to be more forgiving for touch interfaces
2018-09-14 19:26:26 -07:00
Sam Lantinga
0b3a350c90 Fixed Chinese IME support (thanks ???!) 2018-09-10 23:01:33 -07:00
Sam Lantinga
af823cc1d9 Fixed building on tvOS 2018-09-10 23:00:09 -07:00
Ryan C. Gordon
59574fe2f0 x11: Normalize x11xinput2 touch x to be 1.0 at width (thanks, Zach!).
"Applications (such as SDL's testgesture) do "event.tfinger.x * window_width"
to find window coord. Currently the X11 XInput2 backend expects application
to do "event.tfinger.x * (window_width-1)" instead.

X11 XInput2 touch events are normalized so x is 1.0 at "width - 1" but other
SDL backends appear to have x be 1.0 at "width". Same issue for touch event
y with regards to height."

Fixes Bugzilla #4183.
2018-06-24 13:57:22 -04:00
Tomeu Vizoso
fe6828272a egl: Don't change context when deleting current.
If we change the current context behind the app's back, those tracking
the current context to minimize context changes are going to get
confused.

This brings the EGL backend in line with the GLX one.

Fixes Bugzilla #4199.
2018-06-14 06:12:12 +00:00
Sam Lantinga
88dfa46644 Use a blank cursor instead of PointerIcon.TYPE_NULL since that shows the default cursor on Samsung DeX 2018-06-18 13:14:04 -07:00
Sam Lantinga
4a4bac95eb Deal with fullscreen limitations under windowed Android environments (Chromebook, DeX, etc.) (Thanks Rachel!) 2018-06-12 13:22:58 -07:00
Sam Lantinga
fe196db774 Track android device panel width & height as well as window surface & height.
Expand SDLActivity::SDLSurface::surfaceChanged() callback to grab the panel width and height at the same time and pass that along to the native code. Only works on API 17+. Duplicates surface dimensions whenever it fails.

Add Android_DeviceWidth/Android_DeviceHeight globals to native code.
Disambiguate Android_ScreenWidth/Android_ScreenHeight -> Android_SurfaceWidth/Android_SurfaceHeight
Use device width/height for all display mode settings.
2018-06-07 17:07:03 -07:00
Sam Lantinga
2dedbc7262 Add Android support for relative mouse mode to SDL. 2018-06-05 12:46:11 -07:00
Sam Lantinga
9d6ac3deff Fix creating a minimized window in SDL to not cause focus to be stolen (because ShowWindow( hwnd, SW_MINIMIZE ) would be called after creation, thus changing focus to the prior window based on some per-app list in windows, rather than the window being created with WS_MINIMIZED to start with).
This means we have to consider SDL_WINDOW_MINIMIZED a window creation flag, but on non-windows platforms we just remove it and let the normal FinishWindowCreation re-apply and do the minimize as I have no idea what is right on them or if anything should change.

CR: Phil
2018-06-05 12:46:09 -07:00
Ryan C. Gordon
3d3870982c metal: contrary to documentation, we need to set the drawableSize explicitly.
Fixes Bugzilla #4149.
2018-05-27 20:30:03 -04:00
Sam Lantinga
999af8099b Merged latest changes from Steam Link app 2018-05-18 13:09:30 -07:00
Sam Lantinga
a4d0571e4a Reverted change for bug 4152 - restrict the win10 mouse bug workaround to win10 v1709 only
Daniel Gibson

Sorry, but it seems like Microsoft didn't fix the issue properly.

I just updated my Win10 machine, it now is Version 1803, Build 17134.1

I tested with SDL2 2.0.7 (my workaround was released with 2.0.8) and still got
lots of events that directly undid the prior "real" events - just like before.
(See simple testcase in attachement)
By default it sets SDL_HINT_MOUSE_RELATIVE_MODE_WARP - which triggered (and on my machine still triggers) the buggy behavior. You can start it with -raw, then it'll not set that hint and the events will be as expected.
The easiest way to see the difference is looking at the window title, which shows accumulated X and Y values: If you just move your mouse to the right, in -raw mode the number just increases. In non-raw mode (using mouse warping) it stays around 0.

I also had a WinAPI-only testcase: https://gist.github.com/DanielGibson/b5b033c67b9137f0280af9fc53352c68
It just calls SetCursorPos(320,240); on each WM_MOUSEMOVE event, and it also
logs all those events to a mouseevents.log textfile.
This log indeed looks a bit different since the latest Win10 update: It seems like all those events with x=320 y=240 do arrive - but only after I stopped moving the mouse - even though the cursor seems to be moved back every frame (or so).
So moving the mouse to the right gives X coordinates like
330, 325, 333, 340, 330, ...
and then when stopping movement I get lots of events with X coordinate 320
2018-05-07 20:10:12 -07:00
Sam Lantinga
606c5a585c Fixed bug 4152 - Windows 10 v1803 update seems to have fixed the jumping mouse bug (see bug #3931.) 2018-05-05 10:27:53 -07:00
Sam Lantinga
386790efbf Improved error messages when Vulkan isn't configured (thanks Daniel Gibson!) 2018-04-23 22:29:14 -07:00
Ryan C. Gordon
2df59062dc wayland: zxdg_shell_v6 needs a configure event before using a surface at all.
Fixes Bugzilla #4109.
Fixes Bugzilla #4119.
2018-04-15 17:42:09 -04:00
Sam Lantinga
6a0ef0cdbc SDL:
On Windows, have SDL_ShowWindow() not activate the window if the window has the WS_EX_NOACTIVATE window flag.
2018-04-09 10:37:31 -07:00
Sam Lantinga
4d78a99544 Fixed bug where an SDL window that was activated while hidden could never be shown.
Test code:
{
	SDL_Window *win = SDL_CreateWindow( "Dummy", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 128, 128, SDL_WINDOW_HIDDEN );
	SDL_SysWMinfo info;
	SDL_VERSION( &info.version );
	SDL_GetWindowWMInfo( win, &info );
	SetActiveWindow( info.info.win.window );
	{
		DWORD then = SDL_GetTicks();
		while ( ( SDL_GetTicks() - then ) < 3000 )
		{
			SDL_Event evt;
			SDL_PollEvent( &evt );
		}
		SDL_ShowWindow( win );

		then = SDL_GetTicks();
		while ( ( SDL_GetTicks() - then ) < 3000 )
		{
			SDL_Event evt;
			SDL_PollEvent( &evt );
		}
	}
	SDL_DestroyWindow( win );
}
2018-03-26 12:38:29 -07:00
Sam Lantinga
e14278ef6f Fixed bug 3804 - Message box on Windows truncates button ID
Simon Hug

I just wanted to fix a simple compiler warning in SDL_ShowMessageBox on Windows (which Sam fixed recently) and ended up finding some issues.

Attached patch fixes these issues:

- Because Windows only reports the lower 16 bits of the control identifier that was pushed, the button IDs used by SDL (C type int, most likely 32 bits) can get cut off.

- The documentation states (somewhat ambiguously) that the button ID will be -1 if the dialog was closed, but the current code sets 0. For SDL 2.1, I think this should be a return code of SDL_ShowMessageBox itself. That will free up the button ID and it seems a more appropriate place for signaling this event.

- Ampersands in controls will create mnemonics on Windows (underlined letters that, if combined with the Alt key, will push the button). I was thinking of adding a hint or flag to let the users enable it, but that might have unexpected results.

- When the size of the text gets calculated, it doesn't use the same parameters as the static control. This can cut off text or wrap it weirdly.

- On Windows, the Tab key is used to switch between control groups and sometimes between buttons in dialogs. This didn't seem to work correctly.

Attached patch also adds:

- Icons. Just the system ones that can be loaded with the ordinals IDI_ERROR, IDI_WARNING and IDI_INFORMATION.

- A button limit of 2^16 - 101.

- Some more specific error messages, but they never reach the user because how SDL_ShowMessageBox handles them if an implementation returns with an error.
2018-03-24 10:26:40 -07:00
Sam Lantinga
f536fbea71 Reimplemented Android cursor API support using reflection so it builds with older SDKs 2018-03-16 11:08:53 -07:00
Sam Lantinga
e20d4173bf Added Android custom cursor implementation
This is commented out in SDLActivity.java, with the note #CURSORIMPLEENTATION because it requires API 24, which is higher than the minimum required SDK
2018-03-15 18:22:48 -07:00
Sam Lantinga
cc7b2fc512 Temporary fix for bug 3432 - macOS 10.12: small scrolls (1 wheel notch) don't generate events
Eric Wasylishen

This bug was reintroduced by https://hg.libsdl.org/SDL/rev/fcf24b38a28a

The steps to reproduce are the same: run the "testrelative" SDL demo with "--info all",
connect a USB mouse with a scroll wheel, and roll the scroll wheel one "notch". You'll get log output like:

testdraw2[1644:67222] INFO: SDL EVENT: Mouse: wheel scrolled 0 in x and 0 in y (reversed: 1) in window 1

As far as I can tell macOS doesn't have an API for getting the number of "wheel notches"; I get a deltaY of 0.100006 for one "notch", and it's heavily accelerated (if you roll the wheel quickly you'll get large deltas). So NSEvent's deltaY is only meant to be used for scrolling a scroll view, with the given distance in points, not something like selecting an item in a game.

Here's a temporary patch that at restores the foor/ceil in Cocoa_HandleMouseWheel.
Not ideal, but at least it restores the ability to scroll one notch of a mousewheel.
2018-03-10 21:13:50 -08:00
Sam Lantinga
2419d26724 Progress fixing bug 4100 - errors and warnings after changeset 11917
Ozkan Sezer 2018-03-02 20:02:37 UTC
http://hg.libsdl.org/SDL/rev/d702b0c54e52 resulted in an error and
two warnings when compiled with mingw.

1.  Error from SDL_windowstaskdialog.h:
In file included from src/video/windows/SDL_windowsmessagebox.c:29:0:
src/video/windows/SDL_windowstaskdialog.h:23:54: error: expected ')' before 'HWND'

This is fixed by removing unnecessary annotations:

2.  Warning from SDL_assert.c:
src/SDL_assert.c: In function 'SDL_ExitProcess':
src/SDL_assert.c:138:1: warning: 'noreturn' function does return

Indeed ExitProcess() is prototyped with DECLSPEC_NORETURN, but
TerminateProcess() is not.  This can be rectified by adding an
exit() call in there. Do NOTE, however, that requires building
with a libc:

3.  Warning from SDL_windowsmessagebox.c:
src/video/windows/SDL_windowsmessagebox.c: In function 'WIN_ShowMessageBox':
src/video/windows/SDL_windowsmessagebox.c:513:9: warning: 'nCancelButton' may be used uninitialized in this function

My lazy solution was manually initializing nCancelButton to 0.
2018-03-02 22:53:25 -08:00
Sam Lantinga
ac2d1f6773 Fixed setting the layer drawable size
Without this change the drawable had a size of 0 and the metal renderer asserted because the projection matrix wasn't set.
2018-03-02 12:08:18 -08:00
Ryan C. Gordon
cef1c1c2ee windows: Restore patches for Task Dialogs and TerminateProcess().
2.0.8 has shipped, these can live in revision control now!
2018-03-02 14:10:25 -05:00
Ryan C. Gordon
3537c3e7a9 Back out Task Dialog and TerminateProcess patches for 2.0.8.
These can return to revision control once we ship.
2018-02-28 10:39:41 -05:00
Ryan C. Gordon
6a1cfccef8 windows: dos2unix'd messagebox code, and (hopefully) fixed on MingW. 2018-02-28 02:14:15 -05:00
Ryan C. Gordon
a749035f10 windows: Message boxes use Task Dialogs if possible (thanks, Jack!).
This lets the message box have an icon. Unless the app has opted-in to using
the v6 common controls, though, this will fall back to the usual SDL message
boxes.
2018-02-28 01:54:22 -05:00
Mark Callow
be6ca785e3 Support official Vulkan SDK for macOS.
This tries to load vulkan.framework or libvulkan.1.dylib before MoltenVK.framework
or libMoltenVK.dylib. In the previous version, layers would not work for applications
run-time loading the default library.
2018-02-25 23:02:09 -08:00
Sam Lantinga
849d042fa4 Fixed bug 4091 - Undefined references to Android audio functions when SDL_AUDIO_DISABLED is on
Manuel Sabogal

If SDL is compiled with the Audio subsystem disabled there are some undefined references to the functions ANDROIDAUDIO_ResumeDevices and ANDROIDAUDIO_PauseDevices in the file src/video/android/SDL_androidevents.c.
2018-02-24 08:58:22 -08:00
Brandon Schaefer
0626486e2e Backout the vulkan change in d449dea10fc8 breaks Mir builds 2018-02-23 19:12:04 -05:00
Brandon Schaefer
e17c3219d3 mir: Disable Mir by default as Mir supports Wayland clients
Also remove enabling VK support for Mir
2018-02-23 11:24:26 -05:00
Ryan C. Gordon
ac309df7b4 vulkan: Possibly fix a compiler warning (-Wstrict-prototypes). 2018-02-21 22:27:09 -05:00
Mark Callow
69958441be Fix high-dpi support on macOS and simplify it and iOS variant.
The detault drawableSize for a CAMetalLayer is its bounds x its scale.
So it is sufficient to set the *layer's* scale to the desired value.
2018-02-21 09:58:21 -08:00
Ryan C. Gordon
2ea4419a57 yuv: patched to compile. 2018-02-17 20:18:48 -05:00
Ryan C. Gordon
7c0c2c22a8 yuv: fixed variable declaration shadowing warnings.
Fixes Bugzilla #4062.
2018-02-17 20:10:13 -05:00
Ryan C. Gordon
6867f6189f video: put a spinlock around a global linked list.
This should only contend if you're allocating or freeing surfaces from
multiple threads at once, and then just for a short time.

Fixes Bugzilla #4084.
2018-02-16 14:56:28 -05:00
Sam Lantinga
8ddebfa06e Fixed bug 4085 - X11: Allow configuring _NET_WM_BYPASS_COMPOSITOR through SDL hints
Callum McGing

This patch allows the user to disable the behaviour that blocks the compositor through a new hint: SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR. This allows tools or other windowed applications to behave properly under KWin.
2018-02-16 10:23:10 -08:00
Sam Lantinga
5abd7d16d7 Don't attempt WM_NCCALCSIZE adjustment when in fullscreen window transition 2018-02-13 22:58:20 -08:00
sezero
40b27fd51b revert the recent typecast assignment changes (see bug #4079)
also change the void* typedefs for the two vulkan function
pointers added in vulkan_internal.h  into generic function
pointer typedefs.
2018-02-12 17:00:00 +03:00
sezero
8a1ae708d4 kill C99'ism in SDL_waylandvulkan.c 2018-02-12 10:00:00 +03:00
Sam Lantinga
6e01fbb763 On Android show the system UI when an SDL window is windowed, hide the system UI when it's fullscreen, like we do on iOS.
We're increasing the Android SDK minimum version to API 19, this doesn't increase the minimum target API, which is API 14.
2018-02-11 18:23:37 -08:00
Sam Lantinga
873141acb1 ISO C correct fix for casting void* to function pointer 2018-02-11 15:29:36 -08:00
Ryan C. Gordon
882215e138 vulkan: Fix assignment of vkGetInstanceProcAddr on Windows.
"*(void**)pfn = LoadAddress()" would cast the NULL pointer in pfn to a
void**, and then dereference it, which wasn't what we wanted. Replaced with
a clearer cast operation.
2018-02-11 18:16:01 -05:00
Sam Lantinga
7b50aee932 Fixed min/max window size handling for borderless resizable windows 2018-02-08 18:07:14 -08:00
Sam Lantinga
940933d892 Fixed bug 4054 - Raspberry Pi refresh rate detection
Viacheslav Slavinsky

SDL_rpivideo driver has 60 frames per second hardcoded in it, this is a problem for games that need to keep pace using VSYNC. I believe that I have found a solution to this. It is based on code in tvservice.c in rpi userland:

a1b89e91f3/host_applications/linux/apps/tvservice/tvservice.c (L433)
2018-02-07 15:05:30 -08:00
Guillermo A. Amaral
bd0def06ee Set rpath instead of changing environment for RPi
Credit goes to Adrian Perez de Castro for the improvement.

Signed-off-by: Guillermo A. Amaral <g@maral.me>
2018-02-07 14:12:26 -08:00
Ryan C. Gordon
cd53220749 wayland: Add support for xdg-shell protocol (unstable v6).
This is meant to be the desktop-enhanced version of wl_shell. Right now we
just match what the existing wl_shell code does, but there are other areas of
functionality available to us now, that we can fill in later.

This uses the "unstable" API, since this is what ships in Ubuntu 17.10 (as
part of Wayland 1.10), but Wayland 1.12 promotes this to stable with extremely
minor changes. We will add support for the stable version when it makes sense
to do so.
2018-02-07 13:13:55 -05:00
Sam Lantinga
73c26c204c Send Apple TV remote input as key events unless it's opened as a joystick, to match Android behavior. 2018-02-06 16:43:31 -08:00
Sam Lantinga
f59b9c8b13 Replaced SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS with SDL_HINT_TV_REMOTE_AS_JOYSTICK which controls whether remotes on iOS and Android are interpreted as joysticks (the default) or as return/escape/arrow keys. 2018-02-06 15:03:38 -08:00