Commit Graph

1530 Commits

Author SHA1 Message Date
Alex Szpakowski
b959be2569 Code style cleanup in the Cocoa and UIKit vulkan files. 2017-08-31 21:26:13 -03:00
Alex Szpakowski
cfd7a7fac6 macOS: Prevent unwanted native fullscreen (Spaces) toggles when the window is in fullscreen or isn't resizable. Fixes bug #3691. 2017-08-31 21:13:32 -03:00
Sam Lantinga
2d10a3f2b9 The dummy video driver check is now covered by explicitly checking for cocoa above. 2017-08-29 22:24:59 -07:00
Sam Lantinga
92bf608527 Fixed bug 3616 - SDL_GL_CreateContext fails with SDL_GL_CONTEXT_DEBUG_FLAG and ANGLE/GLES 2.0
Colin Barrett

Using the pre-built x86 devel libs from here:
https://www.libsdl.org/release/SDL2-devel-2.0.5-VC.zip

If I have:

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);

and I'm using ANGLE/(a GL driver that doesn't provide an ES2 context) such that SDL_EGL_CreateContext is called by SDL_GL_CreateContext, I get the error "Could not create EGL context (context attributes are not supported)" and no context is created.

Looking at the code in SDL_EGL_CreateContext - if gl_config.flags is non-zero, it looks like the code in the section guarded with "#ifdef EGL_KHR_create_context" should be executed - but it apparently isn't.

Is it possible this section hasn't been compiled into the pre-built libraries? If I build SDL2.dll myself using the Visual C++ solution (VS2015 Community Update 3) then the call succeeds as I expect
2017-08-29 22:04:43 -07:00
Sam Lantinga
8fc1fb0805 Fixed bug 3719 - Cocoa - Incorrect window size when leaving fullscreen
bastien.bouclet

When exiting a "fullscreen space" on OS X, windows don't go to their defined "windowed mode size", but go back to their previous size.

Steps to reproduce:
1. Create a windowed mode SDL window
2. Toggle it to fullscreen with the SDL_WINDOW_FULLSCREEN_DESKTOP flag
3. While in fullscreen, change the windowed mode size using SDL_SetWindowSize
4. Toggle the window back to windowed mode

Expected result:
- The window has the size specified during step 3.

Actual result:
- The window has the size specified when creating the window in step 1.

Attached is a minimal reproduction test case.
The attached test case works as expected on X11 and Windows.
2017-08-29 21:42:22 -07:00
Ryan C. Gordon
21e32bac10 egl: Cast to size_t, in case platform's NativeDisplayType isn't a pointer.
(fixes compiler warnings on QNX.)
2017-08-29 16:30:49 -04:00
Sam Lantinga
130138fa59 Fixed bug 3785 - fix windows build after revision 11382
Ozkan Sezer

fix windows build after revision 11382: commit 2026e42e377a renamed
_SDL_msctf_h to SDL_msctf_h_ . SDL_windowskeyboard.c relies on that
macro, so update it accordingly.
2017-08-28 22:44:48 -07:00
Sam Lantinga
8ac85744cd Fixed Vulkan configure check for Android and added one for Mac OS X 2017-08-28 22:36:45 -07:00
Sam Lantinga
90b38a5d61 Fixed bug 3786 - building against a Mac OS X SDK < 10.11 fails since the vulkan merge
Ozkan Sezer

Since the Vulkan merge, building against a Mac OS X SDM older than
10.11 fails in SDL_cocoametalview.m because Metal.framework is not
present. There is no conditional compiling in SDL_cocoametalview.m
either, so --disable-video-vulkan doesn't help with anything. (The
configury doesn't check darwin for x86_64 either, but it's another
story.)

I cross-build against 10.8 SDK on linux using clang-3.4.2 and this
is a problem for me.  Will this be fixed?
2017-08-28 22:13:45 -07:00
Sam Lantinga
1067b528d3 Fixed building with an older Mac OS X SDK 2017-08-28 20:52:05 -07:00
Sam Lantinga
9341589925 Removed unneeded Vulkan symbol definitions 2017-08-28 13:40:32 -07:00
Sam Lantinga
0560544d1c Fixed 3783 - Default libGL path for directFB on Linux differs from x11 path
Clayton Craft

The default path used by directfb for libGL is different than the default path used by x11 in SDL2:

./src/video/directfb/SDL_DirectFB_opengl.c:
path = "libGL.so";

./src/video/x11/SDL_x11opengl.c:
#define DEFAULT_OPENGL  "libGL.so.1"

On at least one distro (Alpine Linux), libGL.so is not created (or more accurately the symlink to libGL.so.1 is not created). For consistency, the 'path' variable in SDL_DirectFB_opengl.c should patch the DEFAULT_OPENGL in SDL_x11opengl.c ("libGL.so.1")
2017-08-28 09:51:25 -07:00
Sam Lantinga
959ae9019d Instantiate the CAMetalLayer so SDL_Vulkan_CreateSurface() doesn't fail
Error message was:
[mvk-info] MoltenVK version 0.18.2. Vulkan version 1.0.51.
[***MoltenVK ERROR***] VK_ERROR_INITIALIZATION_FAILED: On-screen rendering requires a view that is backed by a layer of type CAMetalLayer.
2017-08-28 02:17:29.579 testvulkan[95627:1716939] ERROR: SDL_Vulkan_CreateSurface(): vkCreateMacOSSurfaceMVK failed: VK_ERROR_INITIALIZATION_FAILED
2017-08-28 02:30:41 -07:00
Sam Lantinga
ff8d2e1493 Fixed build when Wayland is dynamically loaded 2017-08-28 01:42:18 -07:00
Sam Lantinga
edaa0ef53f Fixed analyzer warning "Call to 'calloc' has an allocation size of 0 bytes" 2017-08-28 00:54:02 -07:00
Sam Lantinga
3c7f9d692a Fixed redefinition of typedef warnings and errors on BSD 2017-08-28 00:51:14 -07:00
Sam Lantinga
50efbda736 Fixed mingw Windows build, since SDL_vulkan_internal.h includes windows.h 2017-08-28 00:43:14 -07:00
Sam Lantinga
0d011ec66d Renaming of guard header names to quiet -Wreserved-id-macro 2017-08-28 00:22:23 -07:00
Sam Lantinga
ce2b16445e Be clear that disabling Vulkan surface support disables the entire SDL Vulkan integration 2017-08-28 00:11:38 -07:00
Sam Lantinga
5cd1a95910 Fixed Android build with Vulkan support 2017-08-27 23:53:09 -07:00
Sam Lantinga
0cebef607b Fixed code style for new Vulkan API functions 2017-08-27 23:39:55 -07:00
Sam Lantinga
37ce9f2773 Fixed typedef redefinition errors when including both SDL_vulkan.h and vulkan.h
You should always include vulkan/vulkan.h first, then include SDL_vulkan.h
2017-08-27 23:13:15 -07:00
Sam Lantinga
9da4717d12 Fixed Windows warning 2017-08-27 22:36:03 -07:00
Sam Lantinga
82ffabc86a Fixed Android build 2017-08-27 22:34:15 -07:00
Ryan C. Gordon
c722e58d1f vulkan: Include a copy of vulkan.h and vk_platform.h.
Now we can provide Vulkan support in the build even if the build box doesn't
have a Vulkan SDK, since we dynamically link to the library anyhow.
2017-08-27 23:25:12 -04:00
Ryan C. Gordon
25e3a1ec90 vulkan: Initial Vulkan support!
This work was done by Jacob Lifshay and Mark Callow; I'm just merging it
into revision control.
2017-08-27 22:15:57 -04:00
Sam Lantinga
003d491f86 Fixed bug 3724 - Allow Angle Static Link
Carlos

We would like to add a switch (define) that allows us to compile Angle statically with SDL. That is, getting rid of the OpenGL DLL. Usually you need OpenGL to be loaded dynamically as DLL because implementation is provided by the system but no need with Angle.

Only 2 files need modification and it shouldn't affect current behaivor:
include/SDL_egl.h and src/video/SDL_egl.c, as in here

https://github.com/native-toolkit/sdl/pull/10/files

The flag name could be SDL_VIDEO_STATIC_ANGLE (instead of NATIVE_TOOLKIT_STATIC_ANGLE) as discussed here https://github.com/native-toolkit/sdl/pull/10

We have tested this with both Windows and UWP, using NME engine (https://github.com/haxenme/nme).

Releated issue: https://bugzilla.libsdl.org/show_bug.cgi?id=1820
2017-08-27 19:05:57 -07:00
Ryan C. Gordon
73f866cf0a windows: Attempt to make Visual Studio not hardcode a call to memset(). 2017-08-25 15:16:39 -04:00
Ryan C. Gordon
e58c7920bf x11: Patched to compile with DEBUG_XEVENTS defined. 2017-08-25 12:51:42 -04:00
Ethan Lee
685890a229 Fix KHR_no_error support 2017-08-24 22:57:42 -04:00
Ryan C. Gordon
d8fc70ea1e opengl: add support for GL_KHR_no_error.
This is completely untested!

Fixes Bugzilla #3721.
2017-08-24 21:30:53 -04:00
Brandon Schaefer
17453d495a x11: Move screen_w/h inside the only ifdef they are referenced in to avoid compiler warnings 2017-08-21 23:44:46 -07:00
Brandon Schaefer
a6dc4ed568 kmsdrm: Remove moved file 2017-08-21 17:22:00 -07:00
Brandon Schaefer
1171718473 kmsdrm: Cleanup unused headers, rename SDL_kmsdrmevents_c.h -> SDL_kmsdrmevents.h 2017-08-21 17:20:50 -07:00
Sam Lantinga
834ab350e5 Fixed bug 3644 - Wayland touch event support
Moritz Bitsch

Attached is a small patch which enables multitouch events on Wayland.
2017-08-21 11:19:38 -07:00
Ryan C. Gordon
f5a38f234b x11: specify event mask for buttons when grabbing pointer (thanks, Stas!).
This fixes a strange corner case (notes appended below), and should be
safe to do anyhow.

Fixes Bugzilla #3674.

"I did more tests.
It appears the bug only happens if there is
another window on the screen that has "always
on top" property. For me it is xawtv - it is
always opened in a screen corner. Closing
xawtv or removing "always on top" property
from it makes the problem to go away.
Plus, it doesn't appear like the buttons are
not delivered at all. It appears that instead
the button presses are delivered on some mouse
positions, but not delivered when you move the
mouse to other part of the window... So this is
really weird and is likely somewhere deep in the
Xorg.
Maybe somehow it happens that the cursor is
actually above the xawtv window, but, because
my app uses grab, it is not visible there, and
in that case the events are not delivered to
my app?
But with my patch the button events are
always delivered flawlessly, it seems.

Hmm, and that indeed seems to explain my problem:
if the mask is set properly and my app uses
grab, then, even if the mouse is above some
other window, the events would still be delivered
to the grabbing app, which is what actually wanted
because my app uses relative mouse mode, so it
doesn't know the pointer can cross some other window
(my app draws the pointer itself).
So my current theory is that my patch only enforces
the mouse grab, which otherwise can be tricked by
some other window preventing the button events
delivery (but motion events are still delivered
via xinput2, which makes it all look very obscure)."
2017-08-21 00:42:06 -04:00
Ryan C. Gordon
5574b43376 x11: Pass generic XEvents by pointer instead of copying to stack for XInput2. 2017-07-31 12:22:18 -04:00
Ryan C. Gordon
01e0d8fc85 opengl: Add support for [GLX|WGL]_ARB_create_context_robustness.
This patch was originally written by Marc Di Luzio for glX and enhanced by
Maximilian Malek for WGL, etc. Thanks to both of you!

Fixes Bugzilla #3643.
Fixes Bugzilla #3735.
2017-08-19 15:02:03 -04:00
Alex Szpakowski
3d0f521be5 iOS 10: Work around screen bounds orientation bug. Fixes bugs #3465 and #3505. 2017-08-18 23:23:30 -03:00
Alex Szpakowski
a0a09f646c Improve iOS keyboard demo code a bit. 2017-08-15 22:53:57 -03:00
Alex Szpakowski
2e4248ed44 Address a compiler warning. 2017-08-15 18:29:47 -03:00
Sam Lantinga
e83764a5e0 Fixed bug 2137 - SDL Message Boxes don't cope with fixed width fonts (in windows at least)
Pegasus Epsilon

With the system dialog font set to Arial or Tahoma or another variable-width font, everything works just as expected. When using a fixed-width font, like Courier or DejaVu Sans Mono, the text gets cut off. Example screenshots attached.
2017-08-14 23:45:06 -07:00
Sam Lantinga
1d0584d558 Hopefully fixed Wayland build 2017-08-14 21:35:16 -07:00
Sam Lantinga
a4cfa93670 Fixed bug 2293 - Precise scrolling events
Martijn Courteaux

I implemented precise scrolling events. I have been through all the folders in /src/video/[platform] to implement where possible. This works on OS X, but I can't speak for others. Build farm will figure that out, I guess. I think this patch should introduce precise scrolling on OS X, Wayland, Mir, Windows, Android, Nacl, Windows RT.

The way I provide precise scrolling events is by adding two float fields to the SDL_MouseWheelScrollEvent datastructure, called "preciseX" and "preciseY". The old integer fields "x" and "y" are still present. The idea is that every platform specific code normalises the scroll amounts and forwards them to the SDL_SendMouseWheel function. It is this function that will now accumulate these (using a static variable, as I have seen how it was implemented in the Windows specific code) and once we hit a unit size, set the traditional integer "x" and "y" fields.

I believe this is pretty solid way of doing it, although I'm not the expert here.

There is also a fix in the patch for a typo recently introduced, that might need to be taken away by the time anybody merges this in. There is also a file in Nacl which I have stripped a horrible amount of trailing whitespaces. (Leave that part out if you want).
2017-08-14 21:28:04 -07:00
Sam Lantinga
fb835f9e3b Fixed bug 2330 - Debian bug report: SDL2 X11 driver buffer overflow with large X11 file descriptor
manuel.montezelo

Original bug report (note that it was against 2.0.0, it might have been fixed in between):  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=733015

--------------------------------------------------------
Package: libsdl2-2.0-0
Version: 2.0.0+dfsg1-3
Severity: normal
Tags: patch

I have occasional crashes here caused by the X11 backend of SDL2. It seems to
be caused by the X11_Pending function trying to add a high number (> 1024)
file descriptor to a fd_set before doing a select on it to avoid busy waiting
on X11 events. This causes a buffer overflow because the file descriptor is
larger (or equal) than the limit FD_SETSIZE.

Attached is a possible workaround patch.

Please also keep in mind that fd_set are also used in following files which
may have similar problems.

src/audio/bsd/SDL_bsdaudio.c
src/audio/paudio/SDL_paudio.c
src/audio/qsa/SDL_qsa_audio.c
src/audio/sun/SDL_sunaudio.c
src/joystick/linux/SDL_sysjoystick.c


--------------------------------------------------------

On Tuesday 24 December 2013 00:43:13 Sven Eckelmann wrote:
> I have occasional crashes here caused by the X11 backend of SDL2. It seems
> to be caused by the X11_Pending function trying to add a high number (>
> 1024) file descriptor to a fd_set before doing a select on it to avoid busy
> waiting on X11 events. This causes a buffer overflow because the file
> descriptor is larger (or equal) than the limit FD_SETSIZE.


I personally experienced this problem while hacking on the python bindings
package for SDL2 [1] (while doing make runtest). But it easier to reproduce in
a smaller, synthetic testcase.
2017-08-14 20:22:19 -07:00
Sam Lantinga
aebe17d34f Fixed bug 2344 - CHECK_WINDOW_MAGIC should include __FILE__ and __LINE__
Martin Gerhardy

just for easier debugging issues in the own code...

SDL_CreateRenderer should maybe also use this macro

Ryan C. Gordon

I'll go one better: it should have an SDL_assert().
2017-08-14 16:34:54 -07:00
Sam Lantinga
f142a7961e Fixed bug 2441 - SDL_DuplicateSurface
Rainer Deyke

I've written a small patch that adds a small SDL_DuplicateSurface function to SDL.  I've written the function as part of a larger (as yet unfinished) patch, but I think this function is useful enough that it merits inclusion in SDL on its own.
2017-08-14 13:37:14 -07:00
Sam Lantinga
362d549690 Fixed bug 2500 - X11: SDL tries (and fails) to hide foreign windows
Alvin

I'm interested in this bug as well. I have experienced it when trying to embed an SDL_Window into a FLTK application. To do this, I create a FLTK window (window inside a window - think video player) and then use SDL_CreateWindowFrom() on the inner most window's Xlib Window*. After which, I create a renderer.

In my situation I am using the FLTK GUI toolkit.

What I have experienced is that the SDL_CreateRender() will recreate the window in order to properly setup OpenGL capability. As part of this process, the window is hidden and a call is executed that waits indefinitely for an acknowledgement that the window was indeed unmapped. This is where my program hangs.

Please correct me if I am wrong, but should SDL2 not make Xlib calls that effect the Xlib Window in this situation (e.g. When SDL_CreateWindowFrom() is used)? The toolkit being used typically assumes responsibility and, I presume, tracks all Xlib Windows it creates.

On line src/video/SDL_video.c:1372 the comment associated with setting SDL_WINDOW_FOREIGN reads:

  /* Can't destroy and re-create foreign windows, hrm */

Since I do not know the reason for hiding the window in the first place, the attached patch simply does not wait for a response when X11_XWithdrawWindow() and X11_XMapRaised() are issued by X11_HideWindow() and X11_ShowWindow(), respectively. I presume that the GUI toolkit (GTK, FLTK, etc.) has or will consume the acknowledging event as it is managing the Xlib Window (or it thinks it is).

I have tested the patch against hg 5c645d037de2 and I have successfully tested:
* Embedding the SDL_Window inside a FLTK application.
* Calling SDL_SetWindowSize() when FLTK resizes the window (e.g. dragging cursor on the edge of the window).
* Filling the renderer's default target blue and drawing a red fill square at the centre (exciting, I know!)
* Calling SDL_Quit() when the application terminates

I do not receive any Xlib erorr messages (BadWindow, etc.) in any of those situations.
2017-08-14 10:28:47 -07:00
Sam Lantinga
de91b1248f Fixed bug 3745 - specify SDLCALL as the calling convention for API callbacks
Patches contributed by Ozkan Sezer
2017-08-14 06:28:21 -07:00
Sam Lantinga
eb06aba8ae Fixed bug 3742 - minor warning fixes 2017-08-13 21:16:58 -07:00
Sam Lantinga
3cae0c38d2 Fixed bug 3746 - remove SDLCALL attribute from SDL_BlitFunc() funcptr
Ozkan Sezer

The attached patch removes SDLCALL attribute from SDL_BlitFunc() funcptr.

As far as I can see, *SDL_BlitFunc() is completely internal to SDL with
no specific calling convention requirements.  The actual functions assigned
to SDL_BlitFunc seem to not have any calling conventions specified. So,
easy solution is simply removing the strict calling convention from the
type.
2017-08-13 21:09:00 -07:00
Sam Lantinga
e54eede265 Provide the correct state of the on-screen keyboard to the API (patch from Sylvain) 2017-08-13 21:05:15 -07:00
Sam Lantinga
6ee661398d Fixed bug 3235 - Make the Android window creation similar to iOS' window creation
Sylvain

Here's a patch.
It tries to get the hint first. Resizable will allow any orientation. Otherwise it uses width/height window.

setOrientation method is splitted in static and non-static, so that it can be overloaded in a user subclass.

Some artefact observed :
surfaceChanged() can be called twice at the beginning. When the phone starts in portrait and run a landscape application.
2017-08-13 20:55:59 -07:00
Sam Lantinga
6ef1a25d18 Fixed bug 3751 - DirectFB linux_input disabled by default
Clayton Craft

linux_input module is disabled by default, despite the comments in source code that it is otherwise:

src/video/directfb/SDL_DirectFB_video.c:
    devdata->use_linux_input = readBoolEnv(DFBENV_USE_LINUX_INPUT, 0);       /* default: on */

src/video/directfb/SDL_DirectFB_video.h:
    #define DFBENV_USE_LINUX_INPUT      "SDL_DIRECTFB_LINUX_INPUT"      /* Default: on  */

When using the directfb driver, the linux_input module is suppressed unless the SDL app is started with "SDL_DIRECTFB_LINUX_INPUT=1" set in the environment. I recall seeing at one point that the directfb folks recommended using linux_input over the other input drivers, but I am having trouble locating this recommendation. In any case, I believe that this should really be defaulted to 'on' since it's vastly superior to the other dfb input drivers!
2017-08-13 20:51:08 -07:00
Sam Lantinga
78865effb5 Fixed compiler warning 2017-08-13 20:38:06 -07:00
Sam Lantinga
c87e1d525c Fixed bug 2841 - Hint to set resource id for window icon
Alexey

Seems to be a missing functionality. I want to set an icon from RC file. I cant pass MAKEINTRESOURCE(X) string to SDL_RegisterApp() cause string returned by MAKEINTRESOURCE string is not actually a string and SDL_strlen will crash. Moreover LoadImage seems to be loading wrong icon size. LoadIcon seems to be fine.
2017-08-13 14:15:52 -07:00
Ryan C. Gordon
18cceb5ce0 x11: Patched to compile. 2017-08-13 01:00:01 -04:00
Ryan C. Gordon
0a1b905b6c x11: Fix message box titles with Unicode chars on some window managers.
Fixes Bugzilla #2971.
2017-08-13 00:58:23 -04:00
Alex Szpakowski
9be597a0d6 iOS: Fix app orientation when creating a landscape fullscreen window with the device currently in portrait orientation. 2017-08-12 22:16:04 -03:00
Sam Lantinga
059d9e4627 Fixed bug 2950 - wrong axes values are set on joystick initialization
Edward Rudd

Device: Logitech Rumble Gamepad F510 in Xinput mode.

Upon opening the joystick the values of the axes are queried via PollAllValues are not actually set on the device all the time.

This can easily be seen in the testjoystick or testgamecontroller test programs,as the testjoystick shows all axes in the center until one 'tickles' the triggers., and the testgamecontroller will show the triggers as 'on' until on 'tickles' the triggers.

Upon further research the culprit is the SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS hint. In the default value events are ignored until there is an active window, Thus in cases where the joystick system is initialized and controllers opened before the initial window is created & focuses, the initial values will be incorrect.

Here is my current workaround in the game I'm working on porting..

SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
SDL_GameController* gamepad = SDL_GameControllerOpen(index);
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
2017-08-12 17:41:59 -07:00
Sam Lantinga
7bab2913c2 Fixed Windows build 2017-08-12 17:01:14 -07:00
Sam Lantinga
05facb3d4e Fixed bug 2979 - SDL_ConvertSurface does not convert color keys consistently
Edmund Horner

When a 16-bit "565 format" surface has a colour key set, it will blit with correct transparency.  If, however, it has its colour key set then is converted to a 32-bit ARGB format surface, the colour key in the converted image will not necessarily be the same pixel value as the transparent pixels.  It may not blit correctly, because the colour key does not match the right pixels.

In my case, with an image using 0xB54A for transparency, the colour key was converted to 180,170,82; but the corresponding pixels (with the same original value) were converted to 180,169,82.  Blitting the converted image did not use transparency where expected.

I have attached a test case.  The bug has been replicated on both x86_64 Linux (SDL 2.0.2), and 32-bit MS C++ 2010 on Windows (SDL 2.0.0).
2017-08-12 16:59:00 -07:00
Sam Lantinga
d226594fcc Workaround for bug 3049 - SDL_Init(SDL_INIT_VIDEO) - XDM authorization key matches an existing client!
malferit

Hello, I began a little program with SDL2 on Linux in C, and when I call SDL_Init(SDL_INIT_VIDEO) I get an error and this is printed in the console:

XDM authorization key matches an existing client!

I searched through Internet, and found that some people suggest to run 'xhost +' or to specify this in /etc/X11/xdm/xdm-config:

DisplayManager*authName:        MIT-MAGIC-COOKIE-1

I don't think an end user needs to know that...

But what bothered me is that first I started this little program in Pascal using the Freepascal compiler and it works. In freepascal you only use some thin header bindings in Pascal and then it links with the dynamic SDL library, so I don't understood why it worked with Freepascal and not in C.

I run ldd to the two generated applications:

Application in C:

	linux-gate.so.1 (0xffffe000)
	libSDL2-2.0.so.0 => /usr/lib/libSDL2-2.0.so.0 (0xb76ac000)
	libpthread.so.0 => /lib/libpthread.so.0 (0xb766e000)
	libc.so.6 => /lib/libc.so.6 (0xb74e2000)
	libm.so.6 => /lib/libm.so.6 (0xb74a0000)
	libdl.so.2 => /lib/libdl.so.2 (0xb749a000)
	librt.so.1 => /lib/librt.so.1 (0xb7491000)
	/lib/ld-linux.so.2 (0xb77b3000)

Application compiled with Freepascal:

	linux-gate.so.1 (0xffffe000)
	libSDL2-2.0.so.0 => /usr/lib/libSDL2-2.0.so.0 (0xb762a000)
	libX11.so.6 => /usr/lib/libX11.so.6 (0xb74f3000)
	libc.so.6 => /lib/libc.so.6 (0xb7367000)
	libm.so.6 => /lib/libm.so.6 (0xb7325000)
	libdl.so.2 => /lib/libdl.so.2 (0xb731f000)
	libpthread.so.0 => /lib/libpthread.so.0 (0xb7305000)
	librt.so.1 => /lib/librt.so.1 (0xb72fc000)
	libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb72dc000)
	libXau.so.6 => /usr/lib/libXau.so.6 (0xb72d9000)
	libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb72d3000)
	/lib/ld-linux.so.2 (0xb7755000)

It seems that Freepascal is linking with libX11, libxcb, libXau and libXdmcp .

Linking my C application with libxcb solved the problem (linking with libXau and/or libXdmcp without libxcb didn't work). Linking with X11 links all the other libraries and works as well.

So I fill this bug report mainly to let you know about this. I don't know if it is a problem that can be solved on the libSDL side or not, but at least I hope it will help.

Hi, some tests:

1. Disabled XDM. Login in console and running 'startx'. The program works without having to link with X11.

2. Enabled XDM. Added 'DisplayManager*authName: MIT-MAGIC-COOKIE-1' to /etc/X11/xdm/xdm-config.The program works without having to link with X11.

3. Enabled XDM without 'DisplayManager*authName: MIT-MAGIC-COOKIE-1' in /etc/X11/xdm/xdm-config . I get the authentication error unless I link with X11.
2017-08-12 16:48:46 -07:00
Sam Lantinga
45cec28bc4 Fixed bug 3058 - Slight mistake in GetWindowStyle in SDL_windowswindow.c
Coriiander

There's a slight mistake in the function "GetWindowStyle" found in file "SDL_windowswindow.c".

When a window is marked to be resizable, the resizable style is being added regardless of whether the window has a border or not. While for some arcane, hidden semantics this can be ok, it's still inconsistent in this case.
2017-08-12 16:44:00 -07:00
Sam Lantinga
e3f3a757f3 Fixed bug 3158 - SDL display window scrambled over VNC
Witek Jachimczyk

I'm using SDL to develop a video viewer for MATLAB.  The window is scrambled while using thightVNC with its default mode of RGB656.

SDL does not correctly recognize the pixel mode.


I found a solution for this problem.  The solution involves modifying
SDL/src/video/SDL_pixels.c

Adding the following "if statement" under case 16: of SDL_MasksToPixelFormatEnum resolves the issue:

        if (Rmask == 0x003F &&
            Gmask == 0x07C0 &&
            Bmask == 0xF800 &&
            Amask == 0x0000) {
            return SDL_PIXELFORMAT_RGB565;
        }

I hope that this helps someone.  I took me a while to figure it out.
2017-08-12 16:02:33 -07:00
Sam Lantinga
4a9c6f0a14 Fixed bug 3173 - SDL_GL_GetAttribute overwrites error code from SDL_GL_GetProcAddress
Yann Dirson

When SDL_GL_GetProcAddress returns in error, the cause of the error is overwritten
in GL_GL_GetAttribute, reporting to the user "Failed getting OpenGL glGetString entry point", whereas the original "OpenGL library not loaded" never makes it
to the user.

Pushed a fix to:
f94cb13708


Note that the "OpenGL library not loaded" error looks like no root cause either,
and I'm still puzzled by the code path used: I'm forcing opengles2 renderer on
the x11 video driver on a rpi2, as in https://bugzilla.libsdl.org/3169, and although I now know that I must force the use of the RPI video driver instead
of the x11 one, I suspect even more accurate info can be given to user.
2017-08-12 15:55:54 -07:00
Sam Lantinga
1a5441451c Fixed bug 3309 - SDL_ConvertSurface adds AlphaMod when input surface has ColorKey
Sylvain

Let's you have a SDL_Surface that has ColorKey, but no Alpha Modulation.
When this surface is duplicated with SDL_ConvertSurface function, the result has ColorKey and Alpha Modulation (BLEND, and Opaque 255).

I think SDL_ConvertSurface should strictly keeps the input format.


example
=======

SDL_Surface *input; // ... Set up a surface with ColorKey and no AlphaMod

SDL_Surface *output = SDL_ConvertSurface(input, input->format, input->flags);

// "output" surface has a ColorKey but *also* AlphaMod (BLEND, and Opaque 255).
2017-08-12 15:21:26 -07:00
Sam Lantinga
47c2c7d585 Cleaned up WindowsScanCodeToSDLScanCode() so VKeytoScancode() always takes precedence for the keys it handles and the rest of the logic is easier to read. 2017-08-12 12:56:28 -07:00
ouned
34769abd46 prefer virtual keycodes over scancodes for extended keys 2017-06-03 09:13:08 +02:00
Sam Lantinga
c086251266 Fixed bug 3128 - Removing all the static variables from android SDLActivity and accompanying JNI calls.
owen

I removed all the static variables from SDLActivity.java

Updated all the SDL_android.c jni calls as well

I added a new function to SDL_android.c/ h
void Android_JNI_SeparateEventsHint(const char* c);

This is called by SDL_androidtouch.c so that this TU doesn't need to call any JNI functions.
2017-08-12 12:24:59 -07:00
Sam Lantinga
78c84e7029 Fixed part of bug 3227 - patch for multiple buttons at the same time not working
Philipp Wiesemann

There is another problem with the current implementation which maybe should be fixed first (to prevent some work). It was written as if it would get the number of a button from the Java side but actually it gets the state of all buttons. That is why it should not work if more than one button is pressed at once.
2017-08-12 08:06:16 -07:00
Sam Lantinga
b425050baf Fixed compiler warnings on Visual Studio 2013 2017-08-12 00:04:46 -07:00
Sam Lantinga
79a846d486 Fixed bug 3334 - SDL_ShowMessageBox uses wrong index and accesses un-allocated memory
romain.lacroix

For the windows implementation of SDL_ShowMessageBox() : ./src/video/windows/SDL_windowsmessagebox.c:345 WIN_ShowMessageBox()

The implementation in 2.0.4 uses "button index" for parameter "id" of function AddDialogButton().

It then expects the value provided in param wParam of function MessageBoxDialogProc() to be a valid index of a button.

It uses this value to index in the array of buttons when DialogBoxIndirect() returns (line 474 : *buttonid = buttons[which].buttonid;)

However, when dismissing this box with Escape, the return value of DialogBoxIndirect will be SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT (=2) which is not always a valid index of array buttons.

When the array buttons has a length less or equal than 2, the memory access is invalid; I can see that the value written to *buttonId is uninitialized memory (random value).

The fix I propose : use value "buttonid" (field of button) for parameter "id" of AddDialogButton(), then copy return value of DialogBoxIndirect() in *buttonid. This way, we will not use an out-of-bounds index in array buttons.
2017-08-11 19:42:39 -07:00
Sam Lantinga
1da252c2d8 Fixed crash in bug 3367 - RGBA_FROM_PIXEL macro can't handle SDL_PIXELFORMAT_ARGB2101010
Simon Hug

The RGBA_FROM_PIXEL macro in src/video/blit.h [1] is not designed to work with more than 8 bits per channel and the ARGB2101010 format makes it read outside of the array bounds causing access violations. This can happen during blitting with the BlitNtoNPixelAlpha and SDL_Blit_Slow functions.

When SDL_InitFormat tries to calculate the loss of the channels [2], the Uint8 will wrap around and it will end up at 254 for the 10-bit channels. Clearly way over the 9 entries of the SDL_expand_byte array. (Not that a signed integer would help.) Then the macro tries to access the lookup table with the channel value which could be up to 1023. If the previous indirection didn't cause an access violation this one will.

I guess it's not worth modifying this macro for a format that only a few will use. It will only make the other blitters slower. I don't have good ideas to solve this issue.

Attached is a test case that does three blits. A copy one that work and the two that use the functions mentioned above.

[1] https://hg.libsdl.org/SDL/file/cd1994d4f3c6/src/video/SDL_blit.h#l303
[2] https://hg.libsdl.org/SDL/file/cd1994d4f3c6/src/video/SDL_pixels.c#l540
2017-08-11 18:56:41 -07:00
Sam Lantinga
96305832bc Fixed bug 3702 - Clear error messages of SDL_LoadObject for optional libraries
Simon Hug

Some code in SDL loads libraries with SDL_LoadObject to get more information or use newer APIs. SDL_LoadObject may fail, set an error message and SDL will continue with some fallback code. Since SDL will overwrite the error or exit the function with a return value that indicates success, the error form SDL_LoadObject for the optional stuff might as well be cleared right away.
2017-08-11 10:21:19 -07:00
Sam Lantinga
6e1b11bae4 Fixed bug 3714 - Windows: SDL_WINDOW_FULLSCREEN_DESKTOP broken on 3 monitor setup w/ DPI scaling
Eric Wasylishen 2017-07-26 18:42:58 UTC
I set up an (admittedly exotic) 3-monitor setup, and when I enter fullscreen-desktop on the middle display (#2), the SDL window is off center. (covers half of monitor #2 and most of monitor #3).

The displays are arranged from left to right:

Display #1 (main): 2880x1800, 200% scaling
Display #2: 1920x1200, 150% scaling
Display #3: 1920x1080, 100% scaling

SDL display bounds:
INFO: Bounds: 1440x900 at 0,0
INFO: Bounds: 1281x801 at 1921,0  (these are incorrect)
INFO: Bounds: 1920x1080 at 4800,0

Correct bounds reported by calling EnumDisplayMonitors and printing the LPRECT param of the callback:
1440x900 at (0, 0)
1280x800 at (2880, 0)
1920x1080 at (4800, 0)

It seems like you need 3 displays to reproduce this, and the left two need DPI scaling, and the 3rd display needs to have a different scale factor than the others.

Related: https://bugzilla.libsdl.org/show_bug.cgi?id=3709

SDL: current hg (11235:6a587b9e0ec8)
Windows 10, Version 10.0.15063 Build 15063
Tested with testdraw2 and testgl2, and pressing alt+enter to enter fullscreen desktop.

This patch reworks SDL_windowsmodes.c to use EnumDisplayMonitors instead of EnumDisplayDevices, so we always have an HMONITOR for each SDL display.

With access to an HMONITOR, we can get the monitor bounds in virtual screen coordinates the proper way, by calling GetMonitorInfo. (whereas the original code was doing some calculations - e.g. "data->DeviceMode.dmPosition.x * data->ScaleX" - to try to get virtual screen coordinates. These worked in simple cases, but failed in more complex cases like this bug)

The one potential problem with my patch is, the ChangeDisplaySettingsEx docs say that you're supposed to get the display name from EnumDisplayDevices, but I'm getting the display name from GetMonitorInfo now.
2017-08-11 10:18:45 -07:00
Sam Lantinga
a05522a089 Fixed bug 3723 - Possible double free in kmsdrm init code on certain errors
Simon Hug

KMSDRM_VideoInit allocates and frees some connectors and encoders but doesn't set the pointer to NULL after freeing. The cleanup code at the end may free one of those garbage pointer should an error happen in the initialization.
2017-08-11 10:05:45 -07:00
Sam Lantinga
843293bed0 Fixed bug 3701 - WM_TOUCH message may cause calls to null if touch functions are not properly loaded
Simon Hug

When WIN_WindowProc processes the WM_TOUCH message, it doesn't check if the touch functions have been properly loaded and may call a NULL pointer. It's probably an extremely rare case, but here's a patch that adds some checks anyway.
2017-08-09 20:26:16 -07:00
Ryan C. Gordon
69092c7e47 haiku: Fixed compiler warning. 2017-08-09 18:30:48 -04:00
Ryan C. Gordon
a412ba0d75 haiku: Patched SDL_bopengl.cc to compile on x86-64 Haiku.
Fixes Bugzilla #3729.
2017-08-09 01:01:41 -04:00
Ryan C. Gordon
d5215d9df9 Fixed up some compile warnings and errors on x86-64 Haiku. 2017-08-09 00:56:05 -04:00
Philipp Wiesemann
27de835dd2 emscripten: Fixed compiler warnings about integer to pointer conversions.
Found by buildbot.
2017-08-05 22:10:55 +02:00
Philipp Wiesemann
711df8a989 emscripten: Fixed compiling without OpenGL support. 2017-08-05 22:10:48 +02:00
Philipp Wiesemann
f216b446aa kmsdrm: Fixed crashes if allocating memory failed. 2017-08-05 22:10:36 +02:00
Philipp Wiesemann
b8a7dd7788 nacl: Fixed freeing static memory on video quit. 2017-08-05 22:10:25 +02:00
Philipp Wiesemann
1f698469ae mir: Removed unnecessary function declaration. 2017-08-05 22:10:15 +02:00
Philipp Wiesemann
4723943bc3 kmsdrm: Fixed compiling without OpenGL support. 2017-08-04 23:00:47 +02:00
Sam Lantinga
cc5ceb1165 Temporary hack to fix bug 3725 - Call made to glGetString before context creation
This breaks bugs 2570, 3145
2017-08-04 13:06:56 -07:00
Brandon Schaefer
86e95a607b kmsdrm: Fix tearing in neverputt/ball
https://gfycat.com/FatalFarawayHeron
2017-08-02 17:45:15 -07:00
Brandon Schaefer
fca91451ba kmsdrm: Fix leaking SDL_VideoDevice* 2017-08-02 13:51:14 -07:00
Sam Lantinga
082f32d198 Fixed bug 3722 - Fall back to xinerama/xvidmode if xrandr modes initialization fails
Levi Bard

In some environments, xrandr modes initialization can fail even though xrandr support is present and of a sufficient version.
(The one I encountered was an AWS instance running a virtual display)

The attached patch allows SDL to keep trying other methods if xrandr modes initialization fails (still subject to SDL_VIDEO_X11_REQUIRE_XRANDR).
2017-08-02 10:28:13 -07:00
Sam Lantinga
4be066707d Fixed potential free of uninitialized memory (thanks Simon!) 2017-08-02 10:24:47 -07:00
Sam Lantinga
56363ebf61 Fixed bug 3690 - SDL2 KMS/DRM render context support
Manuel

The attached patch adds support for KMS/DRM context graphics.

It builds with no problem on X86_64 GNU/Linux systems, provided the needed libraries are present, and on ARM GNU/Linux systems that have KMS/DRM support and a GLES2 implementation.
Tested on Raspberry Pi: KMS/DRM is what the Raspberry Pi will use as default in the near future, once the propietary DispmanX API by Broadcom is overtaken by open graphics stack, it's possible to boot current Raspbian system in KMS mode by adding "dtoverlay=vc4-kms-v3d" to config.txt on Raspbian's boot partition.
X86 systems use KMS right away in every current GNU/Linux system.

Simple build instructions:

$./autogen.sh
$./configure --enable-video-kmsdrm
$make
2017-08-02 10:22:48 -07:00
Ryan C. Gordon
2ffd6d0208 x11: Make a separate unmapped window to own clipboard selections.
Now the clipboard isn't lost if you destroy a specific SDL_Window, as it
works on other platforms. You will still lose the clipboard data on
SDL_Quit() or process termination, but that's X11 for you; run a
Clipboard Manager daemon.

Fixes Bugzilla #3222.
Fixes Bugzilla #3718.
2017-07-31 13:49:22 -04:00
Sam Lantinga
997c69b9ef Fixed bug 3697 - Main thread gets stuck on left mouse down
Eric Wasylishen

I think I found a better fix.

The problem with https://hg.libsdl.org/SDL/rev/ebdc0738b1b5 is setting the styleMask to 0 clears the NSWindowStyleMaskFullScreen bit, which then confuses Cocoa later when you try to leave fullscreen. Instead I'm just clearing the NSWindowStyleMaskResizable bit, although SetWindowStyle(window, NSWindowStyleMaskFullScreen); seems to also work.
2017-08-01 20:16:10 -07:00
Sam Lantinga
6391cc3fef Backed out changeset ebdc0738b1b5 for bug 3697
Eric Wasylishen

Unfortunately this commit seems to have broken exiting desktop-fullscreen.
- Launch testgl2.
- Press alt+enter to go fullscreen-desktop
- Press alt+enter again. The spinning cube will freeze, and the window stays fullscreen desktop.
2017-08-01 20:09:23 -07:00
Sam Lantinga
e10a98d2ad Fixed bug 3720 - SDL_GL_GetAttribute doesn't check for initialized video driver
Simon Hug

SDL_GL_GetAttribute doesn't check if a video driver has been initialized and will access the SDL_VideoDevice pointer, which is NULL at that point.

I think all of the attributes require an initialized driver, so a simple NULL check should fix it. Patch is attached.
2017-07-31 12:57:15 -07:00
Brandon Schaefer
b0b481d709 [mir] Same no need to wrap this, which is already being done 2017-07-27 08:03:11 -07:00
Brandon Schaefer
ecf9f6a13e [mir] Point to SDL_EGL_UnloadLibrary vs doing it our selfs 2017-07-26 18:10:45 -07:00
Ryan C. Gordon
03eaddcad4 Fixed compiler warnings on QNX. 2017-07-23 19:25:16 -04:00
Sam Lantinga
67754af887 Fixed build on older Mac OS X SDKs 2017-07-21 17:28:47 -07:00
Sam Lantinga
177f19aff0 Fixed bug 3410 - SDL_WINDOW_HIDDEN flag is inaccurate.
Jason Wyatt

After hiding the window, SDL_WINDOW_HIDDEN/SDL_WINDOW_SHOWN flags on a window are correctly updated. However on the next SDL_PumpEvents, they are set incorrectly.

This appears to be because X11_GetNetWMState does not check whether the _NET_WM_STATE property exists (it shouldn't on unmapped windows, see https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.html#idm140130317598336). This results in an empty list of atoms for the state, which would imply that the window is not hidden.

(Seen on Fedora 24, Gnome)

--

Dan Ginsburg

More details on my proposed patch: I am on Kubuntu 16.04.2.  I ran into this same bug, but with Jason's patch I found that actualType != None was true so the SDL_WINDOW_HIDDEN would still not be set.  My fix instead is to explicitly check for whether the window is unmapped rather than relying on the returned values in XGetWindowProperty.
2017-07-20 10:52:43 -07:00
Sam Lantinga
2008d86696 Fixed bug 3703 - Missing media keys support on Amazon Fire TV remote control
Holger Schemel

Summary: This patch adds support for key events for the "rewind" and "fast forward" media keys on the Amazon Fire TV remote control.

How to reproduce the problem: Run Android build of SDL2 application on the Amazon Fire TV (tested with "stick" version) and log key events.

Expected behaviour: Every key pressed on the Fire TV remote control should result in a corresponding key event (pressed/released).

Observed behaviour: Of the bottom row of buttons on the Fire TV remote control, only the "play/pause" (middle) button generates a key event, while the "rewind" (left) and "fast forward" (right) buttons to not generate any event at all.

The attached patch adds support for these two missing buttons/keys.

Note 1: Some missing definitions were added for the already existing key codes SDL_SCANCODE_APP1 and SDL_SCANCODE_APP2 (to keep up the correct order of enumerations / array positions when adding the two new key codes).

Note 2: Definitions in "scancodes_linux.h" and "scancodes_xfree86.h" (to also add support for these keys on other platforms) were added without testing. However, I was unable to find corresponding definitions for these two media keys for Windows and Mac OS X.

Note 3: I have also updated the (broken) link to the USB usage page standard PDF document (comment in "include/SDL_scancode.h").
2017-07-20 10:46:38 -07:00
Alex Szpakowski
01050d4ed1 iOS: Use modern replacements for deprecated functions, when available. 2017-07-15 17:41:58 -03:00
Alex Szpakowski
efe179cdfe macOS: Fix compilation when using 10.11 or earlier to build. 2017-07-14 17:42:11 -03:00
Alex Szpakowski
562473c1f4 macOS: Address more compiler warnings when building with a recent deployment target. 2017-07-13 23:09:37 -03:00
Alex Szpakowski
bc3ede1ed0 macOS: Replace uses of deprecated Cocoa enum names with modern/consistent equivalents. 2017-07-13 22:59:02 -03:00
Alex Szpakowski
e0ea4da4ae Fix a potential crash in macOS 10.7 and earlier. 2017-07-12 21:32:10 -03:00
Alex Szpakowski
8292d73ebb macOS: Expose more display modes on retina screens. Fixes an issue found in BZFlag. 2017-07-12 21:28:32 -03:00
Sam Lantinga
74ca16547c Fixed bug 3699 - Shaped windows are distorted unless width is divisible by 8
Bogomancer

On X11, windows created using the shaped window API appear distorted unless the width of the shape surface is divisible by 8.

Steps to reproduce:

    1) Use your favorite image editor to resize one of the images in test/shapes/ to a width that's not a multiple of 8.
    2) Compile and run test/testshape.c on the image you edited.
    3) The shaped window will appear twisted and distorted.

It appears the bug was not caught sooner because all the test images are either 640 or 256 pixels wide.

I tracked down the bug to SDL_CalculateShapeBitmap() in SDL_shape.c. The shape surface is reduced to a 1-bit-per-pixel mask, but the original code doesn't take into account that X11 apparently wants each scanline to begin on a new byte.
2017-07-11 08:16:00 -07:00
Sam Lantinga
37722d01a8 Fixed bug 3697 - Main thread gets stuck on left mouse down
Amruth Raj

- My app runs in full screen to play video(I use SDL_WINDOW_FULLSCREEN_DESKTOP)
- Cmd-tab to go out of full screen to another app
- Cmd-tab again to get back to my app
- Press left mouse button at one of the edges of the screen, don't release yet.
After this point the main thread is stuck until I release the left mouse button and hence video rendering doesn't happen anymore.

On debugging more, I see that thread 0 is stuck as shown below with sendEvent processing left mouse down. It comes out only after it receives a left mouse up. There are some frames below which show NSWindowResizing, but my window flag doesn't have SDL_WINDOW_RESIZABLE set.

Thread 0:: CrBrowserMain Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fffbe13d34a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fffbe13c797 mach_msg + 55
2 com.apple.CoreFoundation 0x00007fffa889d434 __CFRunLoopServiceMachPort + 212
3 com.apple.CoreFoundation 0x00007fffa889c8c1 __CFRunLoopRun + 1361
4 com.apple.CoreFoundation 0x00007fffa889c114 CFRunLoopRunSpecific + 420
5 com.apple.HIToolbox 0x00007fffa7dfdebc RunCurrentEventLoopInMode + 240
6 com.apple.HIToolbox 0x00007fffa7dfdcf1 ReceiveNextEventCommon + 432
7 com.apple.HIToolbox 0x00007fffa7dfdb26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
8 com.apple.AppKit 0x00007fffa6396a54 _DPSNextEvent + 1120
9 com.apple.AppKit 0x00007fffa6b127ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
10 com.apple.AppKit 0x00007fffa66f568d +[NSWindow(NSWindowResizing) _mouseHysteresisCheck:withExpiration:andDistance:finalMouseLocation:] + 525
11 com.apple.AppKit 0x00007fffa65eedb5 -[NSWindow(NSWindowResizing) _hitTestWithHysteresisCheck:forEvent:allowWindowDragging:] + 394
12 com.apple.AppKit 0x00007fffa6c8f0db -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 1873
13 com.apple.AppKit 0x00007fffa6c8ca6c -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 1942
14 com.apple.AppKit 0x00007fffa6c8bf0a -[NSWindow(NSEventRouting) sendEvent:] + 541
15 org.libsdl.SDL2 0x000000010d46d74a -[SDLWindow sendEvent:] + 90
16 com.apple.AppKit 0x00007fffa6b10681 -[NSApplication(NSEvent) sendEvent:] + 1145
17 org.libsdl.SDL2 0x000000010d46532b -[SDLApplication sendEvent:] + 139
18 org.libsdl.SDL2 0x000000010d466b2f Cocoa_PumpEvents + 495
19 org.libsdl.SDL2 0x000000010d44c1d5 SDL_PumpEvents_REAL + 53
20 org.libsdl.SDL2 0x000000010d44c2f5 SDL_WaitEventTimeout_REAL + 53
21 org.libsdl.SDL2 0x000000010d44c2b7 SDL_PollEvent_REAL + 23
22 org.libsdl.SDL2 0x000000010d51bb24 SDL_PollEvent + 36
23 libTest.dylib 0x000000010cf3e0e8 SDLEventProcessor::processEvents(int) + 568
24 Test 0x000000010cde6bba BrowserApp::RunAppMessageLoop(BAInstData*, CefStringBase, CefStringBase) + 810
25 Test 0x000000010ce04bbc main + 17980
26 libdyld.dylib 0x00007fffbe016235 start + 1

I further noticed that while entering full screen in SDL_cocoawindow.m NSResizableWindowMask is set. If I clear it inside windowDidEnterFullScreen, then, the issue doesn't repro.

This is discussed at https://discourse.libsdl.org/t/main-thread-gets-stuck-on-left-mouse-down/22753/3 and thanks to Eric for the pointers.
2017-07-10 17:07:19 -07:00
Philipp Wiesemann
c3bf69ca4b haiku: Fixed compiling without OpenGL support. 2017-07-07 23:00:22 +02:00
Ryan C. Gordon
c80c3419aa x11: pass a long to XChangeProperty, not an int.
The Xlib documentation demands that 32-bit values here be passed in a long,
even when long itself isn't a 32-bit value. Otherwise libx11 might read
memory incorrectly.

Fixes Bugzilla #3692.
2017-07-04 20:44:07 -04:00
Philipp Wiesemann
e6583300e6 haiku: Fixed using wrong constant for internal error handling.
SDL_CreateWindow() worked because ENOMEM is negative on Haiku.
2017-07-02 22:46:23 +02:00
Ryan C. Gordon
200f782cab qnx: fixed potential buffer overflow. 2017-07-01 19:52:12 -04:00
Ryan C. Gordon
22241ed0b0 Support for QNX 7.0 (thanks, Elad!).
Fixes Bugzilla #3686.
2017-07-01 17:50:47 -04:00
Philipp Wiesemann
b1fbab50c5 haiku: Fixed memory leak if destroying window. 2017-07-01 23:01:57 +02:00
Philipp Wiesemann
944e06e67c winrt: Fixed SDL include. 2017-06-24 23:45:44 +02:00
Philipp Wiesemann
267dca13fa haiku: Removed unused internal function.
Its functionality is already in SDL_GL_GetAttribute().
2017-06-18 23:00:42 +02:00
Philipp Wiesemann
90488d6c29 haiku: Added support for some values set with SDL_GL_SetAttribute(). 2017-06-17 22:30:28 +02:00
Philipp Wiesemann
0b750cd9d5 pandora: Fixed compile error. 2017-06-16 23:30:38 +02:00
Philipp Wiesemann
fa73685df8 directfb: Fixed quitting keyboard twice.
SDL_VideoQuit() already calls SDL_KeyboardQuit().
2017-06-16 23:30:30 +02:00
Philipp Wiesemann
a4db3dbe64 nacl: Fixed unnecessary large input text array. 2017-06-16 23:30:13 +02:00
Sam Lantinga
9085c7b311 Get the parent of non-SDL-created windows, for completeness 2017-06-16 11:14:08 -07:00
Sam Lantinga
1b5614b3f5 Clean up parent window when destroying a window 2017-06-16 10:50:29 -07:00
Sam Lantinga
0a75192d85 Implemented SDL_WINDOW_SKIP_TASKBAR on Windows 2017-06-16 09:10:13 -07:00
Philipp Wiesemann
60c0f7e243 Fixed SDL_GetWindowWMInfo() returning success on three unsupported platforms. 2017-06-15 23:30:29 +02:00
Philipp Wiesemann
5b75e9033f directfb: Fixed comment. 2017-06-11 22:30:49 +02:00
Philipp Wiesemann
fbd30c363d Fixed missing error messages for SDL_GetWindowWMInfo(). 2017-06-11 22:30:39 +02:00
Philipp Wiesemann
c609d856ff directfb: Fixed crash if creating renderer.
SDL_GetWindowWMInfo() currently expects SDL to be 2.0.6 but SDL is still 2.0.5.
2017-06-11 22:30:24 +02:00
Ryan C. Gordon
3c955d0540 syswm: prevent buffer overflow if SDL and app have different config headers.
This only affects Wayland and DirectFB, as a Unix system generally has X11
support. Other platforms also have different sizes for the C union in
question, but are likely the only target for that platform, etc.

Apps that might run on Wayland or DirectFB will need to be compiled against
new headers from an official 2.0.6 release, or be prepared to force the x11
target, or not use SDL_GetWindowWMInfo().

Fixes Bugzilla #3428.
2017-06-11 00:50:26 -04:00
Alex Szpakowski
bb100d3bab Expose display refresh rate on iOS/tvOS 10.3+. 2017-06-10 21:29:37 -03:00
Ryan C. Gordon
599d9ba198 emscripten: listen for pointerlockchange events on the #document specifically. 2017-06-05 21:30:25 -04:00
Philipp Wiesemann
4b47fa38c3 Removed duplicate includes. 2017-06-04 23:15:47 +02:00
Philipp Wiesemann
248410dded Fixed SDL_GL_SetSwapInterval() returning success on two unsupported platforms. 2017-06-04 23:15:13 +02:00
Philipp Wiesemann
2113208d98 haiku: Fixed missing title bar for windows with decorations.
B_BORDERED_WINDOW_LOOK has a border but no title bar.
2017-06-03 23:00:50 +02:00
Philipp Wiesemann
63b3e06f75 Corrected names of header file guards. 2017-06-03 23:00:15 +02:00
Philipp Wiesemann
00394996eb Fixed crash if calling SDL_CreateShapedWindow() on unsupported platforms. 2017-06-02 22:15:12 +02:00
Bastien Bouclet
545fba7886 x11: Don't send duplicate events when reconciling the keyboard state
Failing to check if a key was known to be pressed by SDL was causing
SDL_SendKeyboardKey to send duplicate key pressed events with the repeat
property set to true.

Fixes Bugzilla #3637.
2017-04-22 19:53:52 +02:00
Philipp Wiesemann
1b9dc59918 haiku: Fixed SDL_SetClipboardText() putting random data in clipboard. 2017-05-28 21:50:11 +02:00
Ryan C. Gordon
de52dc2948 haiku: Correctly set keyboard focus (thanks, Kai!).
The message sent upon the window being activated or deactivated, to trigger
the call to SDL_SetKeyboardFocus was missing a mandatory parameter. So
keyboard focus was never properly set.

Fixes Bugzilla #3658.
2017-05-28 15:36:09 -04:00
Ryan C. Gordon
b3f94acbf9 linux: Simplify D-Bus interface, remove lots of boilerplate. 2017-05-28 07:11:52 -04:00
Philipp Wiesemann
604a4b1b30 haiku: Fixed SDL_SetClipboardText() allocating too much memory and cutting text.
It allocated pointers instead of chars and passed a wrong size to SDL_strlcpy().
2017-05-27 23:30:21 +02:00
Ryan C. Gordon
6fbde875e2 code style: wrap a single-statement if in braces. 2017-05-27 00:33:26 -04:00
Ryan C. Gordon
3fbd21ce40 windows: msgboxes should specify a parent HWND if possible (thanks, Ismael!).
This lets them be properly modal.

Fixes Bugzilla #3650.
2017-05-27 00:30:06 -04:00
Philipp Wiesemann
90ed3daa3e Changed messages about not recognized keys to include discourse link. 2017-05-26 22:45:52 +02:00
Philipp Wiesemann
759319729c emscripten: Fixed compiling on C89 compilers. 2017-05-26 22:45:40 +02:00
Philipp Wiesemann
1e13d93fea directfb: Changed internal function to be static. 2017-05-25 23:01:34 +02:00
Philipp Wiesemann
6c0aea4270 wayland: Fixed freeing memory of SDL_malloc() with plain free(). 2017-05-25 23:00:58 +02:00
Philipp Wiesemann
c66f0471e1 Removed unused internal window shape functions. 2017-05-25 23:00:43 +02:00
Charlie Birks
126e5a1dbf Emscripten: Prevent default on arrow keys 2017-05-24 14:04:39 +01:00
Patrick Monaghan
f839b209b9 Emscripten: fixed incorrect conversion of touch motion events to mouse motion events 2017-05-24 14:04:25 +01:00
Philipp Wiesemann
bf8ccf08bb Removed redundant mouse clean up on quit for some platforms.
SDL_MouseQuit() already frees cursors and sets fields to NULL.
2017-05-19 23:30:59 +02:00
Sam Lantinga
772407627b Fixed restoring a window that was maximized then minimized, then restored. 2017-05-16 17:48:57 -07:00
Sam Lantinga
ccf0566ca4 SDL - add SDL_WINDOW_VULKAN and make Android_CreateWindow only create an EGLSurface when SDL_WINDOW_VULKAN is not present. This makes it so the ANativeWindow* can be used with vkCreateAndroidSurfaceKHR, otherwise it will fail because having both an EGLSurface and VkSurfaceKHR attached to a window is not allowed according to the Vulkan spec:
"In particular, only one VkSurfaceKHR can exist at a time for a given window. Similarly, a native window cannot be used by both a VkSurfaceKHR and EGLSurface simultaneously"

CR: SamL
2017-05-16 06:30:39 -07:00
Philipp Wiesemann
df4cf79d42 directfb: Fixed compiler warnings about undefined functions. 2017-05-13 23:00:53 +02:00
Philipp Wiesemann
29222db7f6 emscripten: Fixed not removing pointer lock event callback. 2017-05-13 23:00:35 +02:00
Philipp Wiesemann
cc5b4f450a emscripten: Changed internal functions to be static. 2017-05-12 23:01:17 +02:00
Philipp Wiesemann
ce01128adf Fixed warnings about shadowed global variable.
Found by buildbot.
2017-05-12 23:01:04 +02:00
Philipp Wiesemann
87e0d812dd directfb: Removed duplicate comment. 2017-05-12 23:00:40 +02:00
Philipp Wiesemann
61c326e12b directfb: Fixed typo in log message. 2017-05-11 23:00:39 +02:00
Philipp Wiesemann
75c0d1ef6d directfb: Fixed compiler warnings about unused variables. 2017-05-11 23:00:21 +02:00
Sam Lantinga
8b7ae35356 Fixed build error on Linux 2017-05-09 03:19:58 -07:00
Sam Lantinga
9ac3bb7011 Added support for mixing Qt and SDL on iOS
You should call SDL_SetMainReady(), and then customize the QIOSApplicationDelegate like this, in your application code:

/* Additional support for applications mixing Qt and SDL */
@interface QIOSApplicationDelegate : UIResponder <UIApplicationDelegate>
@end

extern "C"
{
void SDL_OnApplicationWillResignActive();
void SDL_OnApplicationDidEnterBackground();
void SDL_OnApplicationWillEnterForeground();
void SDL_OnApplicationDidBecomeActive();
}

@interface QIOSApplicationDelegate (SDL)

- (void)applicationWillResignActive:(UIApplication*)application;
- (void)applicationDidEnterBackground:(UIApplication*)application;
- (void)applicationWillEnterForeground:(UIApplication*)application;
- (void)applicationDidBecomeActive:(UIApplication*)application;

@end

@implementation QIOSApplicationDelegate (SDL)

- (void)applicationWillResignActive:(UIApplication*)application
{
    SDL_OnApplicationWillResignActive();
}

- (void)applicationDidEnterBackground:(UIApplication*)application
{
    SDL_OnApplicationDidEnterBackground();
}

- (void)applicationWillEnterForeground:(UIApplication*)application
{
    SDL_OnApplicationWillEnterForeground();
}

- (void)applicationDidBecomeActive:(UIApplication*)application
{
    SDL_OnApplicationDidBecomeActive();
}

@end // QIOSApplicationDelegate
2017-05-09 10:10:42 -07:00
Philipp Wiesemann
b7b919078f haiku: Changed internal function to be static. 2017-05-07 21:02:31 +02:00
Philipp Wiesemann
3ed2f0ca10 haiku: Fixed unlocking clipboard twice. 2017-05-07 21:02:16 +02:00
Philipp Wiesemann
4466b93141 haiku: Fixed comment. 2017-05-06 21:46:11 +02:00
Philipp Wiesemann
34747107fe mir: Fixed memory leak if system cursor id is unknown. 2017-05-06 21:46:00 +02:00
Philipp Wiesemann
34d9c5213c emscripten: Fixed return type in event callback declaration. 2017-05-06 21:45:43 +02:00
Ryan C. Gordon
ce2998b8b9 cocoa: Don't crash on messagebox keypress without a successful SDL_Init(). 2017-05-02 21:46:28 -04:00
Ryan C. Gordon
619ab7a22d haiku: Various fixes from haikuports.
Based on patch here:

https://github.com/haikuports/haikuports/blob/master/media-libs/libsdl2/patches/libsdl2-2.0.5.patchset
2017-05-01 18:39:05 -04:00
Philipp Wiesemann
444c47a1b8 windows: Changed six internal functions to be static. 2017-04-29 22:50:35 +02:00
Joshua Granick
1286a7d23e windows: Add SDL_WINDOW_ALWAYS_ON_TOP support. 2017-04-20 21:31:44 -04:00
Ryan C. Gordon
93a6191cdc emscripten: keep track of pointer lock losses and maybe regrab pointer later.
If an Emscripten app is in relative mouse mode and the user presses Escape
(or whatever is appropriate), then the pointer lock is broken by the browser.

This keeps track of those losses, and next time the user presses a mouse
button down on the canvas, if the app is still meant to be in relative mouse
mode, we will attempt to regrab the pointer.

This makes it much more seamless for things like first-person shooters, and
the app doesn't need any manual intervention.
2017-04-20 13:00:54 -04:00
Philipp Wiesemann
2bf79c2e0e mir: Fixed typo in error messages. 2017-04-09 23:00:54 +02:00
Drew Bliss
a4dbf56574 Fix divide-by-zero when videodata->ime_candpgsize is zero. We're seeing this happen in Dota in the wild. 2017-04-06 13:27:51 -07:00
Drew Bliss
66555f6115 SDL - attempt to fix https://github.com/ValveSoftware/Dota-2/issues/1199 of mouse not locking in Dota. This fix is proposed by Ryan Gordon (increase timeout in X11_SetWindowGrab from 250ms to 5000ms). I'm going to integrate to source2 and ship it to dota customers. If it works, SamL will upsteam it to SDL. 2017-04-06 13:27:48 -07:00
Sam Lantinga
5789da67cf Fixed bug 1859 - No SDL_VIDEORESIZE event generated when the window manager sets the window size.
Samuel Hopkins

Just confirming that the patch from Andreas (attachment 1715 [details]) works for me under SDL 2.0.3 with xmonad.

Stas Sergeev

Confirming that the patch in this ticket fixes the full-screen switching for dosemu2 on ubuntu-16.04. Note that I am not using xmonad, so this bug appears to be generic.
2017-04-03 13:32:53 -07:00
Philipp Wiesemann
1517ba7285 PSP: Fixed error messages. 2017-04-02 21:33:54 +02:00
Philipp Wiesemann
f96cdca4e7 Mir: Changed two internal functions to be static. 2017-04-02 21:33:42 +02:00
Philipp Wiesemann
266816b4aa Removed newlines from error messages. 2017-03-26 21:00:19 +02:00
Brandon Schaefer
c35f46d03c mir: Set the max/min w/h vs just setting the window w/h 2017-03-18 13:57:57 -07:00
Sam Lantinga
22161480ee Compile fix for android.
"ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]"

Moving some variable declarations to the top of Android_SetScreenResolution()
2017-03-14 07:22:08 -07:00
Philipp Wiesemann
72fdf62980 Mir: Fixed crash if creating default cursor failed.
Found by Cppcheck.
2017-03-04 23:05:32 +01:00
Ryan C. Gordon
6aa17426a6 video: Don't compile isAtLeastGL3() if we don't have OpenGL support _at all_. 2017-03-03 16:38:45 -05:00
Ryan C. Gordon
ca0bf151d5 Fix some more compiler warnings on armcc. 2017-03-03 16:38:17 -05:00
Ryan C. Gordon
d526b8a1e9 Some patches to make SDL compile with armcc (ARM's C compiler). 2017-03-02 13:33:04 -05:00
Brandon Schaefer
94a69443c7 mistake: Revert the files that I did not mean to commit 2017-03-01 15:05:54 -08:00
Brandon Schaefer
7bbb13ea59 * Some refactoring and bug fixes. Thanks Micha? Kuchta! 2017-03-01 14:50:59 -08:00
Ryan C. Gordon
bc8778854e raspberrypi: RPI_Destroy() should free the SDL_VideoDevice and its driverdata. 2017-02-28 19:48:52 -05:00
Brandon Schaefer
5a47ee0365 mir: Get ready for Mir 1.0, clean up deprecations. Thanks Micha? Kuchta! 2017-02-27 12:20:16 -08:00
Philipp Wiesemann
e5d9b25d8c Fixed comment style. 2017-02-26 21:20:39 +01:00
Ryan C. Gordon
07519a6b95 Removed a bunch of unnecessary #ifdefs. 2017-02-26 00:40:04 -05:00
Charlie Birks
0d647d35b0 Emscripten: implement custom cursors 2017-02-17 10:13:17 +00:00
Charlie Birks
33bddcfda2 Emscripten: refactor cursor handling 2017-02-17 10:13:12 +00:00
Charlie Birks
613955b4f2 Emscripten: only update pixel ratio if HiDPI is enabled 2017-02-17 10:13:07 +00:00
Ryan C. Gordon
70c0400b12 windows: Try to unify all the GUID comparison code into a core helper function.
There are likely several more I missed.
2017-02-13 17:00:46 -05:00
Sam Lantinga
cf31ea1478 Fixed bug 3583 - X11 touch device can be permanently lost
Volumetric

In X11 the SDL error "Unknown touch device" can occur after which the application stops recognizing touch events. For a kiosk-type application this results in a hang as far as the user is concerned. This is reproducible on HP Z220/Z230/Z240 workstations by swapping USB cables for a while and it also occurs with no physical changes, probably due to USB device power management. A workaround is to make SDL re-enumerate the touch devices like it does at startup. A patch is attached.
2017-02-11 11:14:48 -08:00
Sam Lantinga
9171f71dbe Fixed warning in Android build 2017-02-10 09:41:16 -08:00
Sam Lantinga
da30992d47 Fixed bug 3577 - Can't set minimal size (message box appears instead) if maximal size wasn't declared (i.e. unlimited) 2017-02-02 00:41:58 -08:00
Sam Lantinga
52e9c42df9 Fixed Windows build 2017-01-28 14:35:35 -08:00
Sam Lantinga
869b7fe314 Fixed bug 3550 - No mouse move messages send while over the titlebar and windows edges
Matthew

Its possible to set SDL_CaptureMouse() so you continue receiving mouse input while the mouse is outside your window. This works however There is then a gap where no messages send, which is when the mouse is hovering the title bar and the window edges.
2017-01-28 11:17:10 -08:00
R?mi Verschelde
c3eea703ee Use a stronger X font definition for X11_MessageBox on UTF-8
X11 seemed to be confused by the broad definition, so WEIGHT_NAME,
SLANT and SETWIDTH_NAME were defined, thus fixing the font lookup
on some systems (tested on Mageia 6 with X11 1.19.1).

Fixes bug 3571.
2017-01-28 10:54:12 +01:00
Sam Lantinga
0090a33805 Return an error if trying to set a window minimum size larger than the maximum size, or vice versa 2017-01-27 21:16:38 -08:00
Philipp Wiesemann
4f981df37f Haiku: Fixed memory leak if creating framebuffer failed. 2017-01-22 22:15:36 +01:00
Philipp Wiesemann
800a9e84f4 Fixed compiler warning about returning a value in a void function. 2017-01-21 22:00:56 +01:00
Sam Lantinga
95defd6620 Use icon width * sizeof(Uint32) instead of icon pitch when copying to icon resource data 2017-01-17 21:18:31 -08:00
Sam Lantinga
341d1ff920 Fixed comment 2017-01-13 11:37:12 -08:00
Sam Lantinga
a52d48c5ab Fixed bugs 2570, 3145, improved OpenGL ES context support on Windows and X11
Mark Callow

The attached patch does the following for the X11 and Windows platforms, the only ones where SDL attempts to use context_create_es_profile:

- Adds SDL_HINT_OPENGL_ES_DRIVER by which the application can
  say to use the OpenGL ES driver & EGL rather than the Open GL
  driver. (For bug #2570)
- Adds code to {WIN,X11}_GL_InitExtensions to determine the maximum
  OpenGL ES version supported by the OpenGL driver (for bug #3145)
- Modifies the test that determines whether to use the OpenGL
  driver or the real OpenGL ES driver to take into account the
  hint, the requested and supported ES version and whether ES 1.X
  is being requested. (For bug #2570 & bug #3145)
- Enables the testgles2 test for __WINDOWS__ and __LINUX__ and adds
  the test to the VisualC projects.

With the fix in place I have run testdraw2, testgl and testgles2 without any issues and have run my own apps that use OpenGL, OpenGL ES 3 and OpenGL ES 1.1.
2017-01-10 08:54:33 -08:00
Sam Lantinga
4e9c9fce13 Fixed bug 3100 - SetSwapInterval should now be enabled for ANGLE/EGL
Mark Logan 2015-08-24 15:57:50 UTC
In SDL_windowsopengles.c, WIN_GLES_SetSwapInterval is as follows:

WIN_GLES_SetSwapInterval(_THIS, int interval)
{
    /* FIXME: This should call SDL_EGL_SetSwapInterval, but ANGLE has a bug that prevents this
     * from working if we do (the window contents freeze and don't swap properly). So, we ignore
     * the request for now.
     */
    SDL_Log("WARNING: Ignoring SDL_GL_SetSwapInterval call due to ANGLE bug");
    return 0;
}

With a recent version of ANGLE (early July) calling SDL_EGL_SetSwapInterval with a D3D11 backend appears to work just fine. I am working on testing this with D3D9.

--

Alex Szpakowski

I found the bug, it was fixed in 2013. https://bugs.chromium.org/p/angleproject/issues/detail?id=481

In my opinion it should be safe to unconditionally use SetSwapInterval now. Anyone who encounters the bug should update their ANGLE to a version less than 3 years old, especially since they'd be using a SDL version that's 3+ years newer than their ANGLE version.
2017-01-09 10:10:33 -08:00
Sam Lantinga
c16dd74f3b Check the return value of SDL_EVDEV_Init() 2017-01-08 18:32:20 -08:00
Ryan C. Gordon
13f2e54295 x11: make the X11 target work on macOS with Xquartz. 2017-01-07 19:55:29 -05:00
Ryan C. Gordon
61a3ba303c Replaced a few single-line "//" comments. 2017-01-07 17:09:14 -05:00
Sam Lantinga
e25f4e507d Really fixed blit issue for capehill 2017-01-07 16:51:48 -08:00
Sam Lantinga
d024c724d1 Fixed signedness issue when blitting on a big endian platform, as reported by capehill
For example, if sR is 0 and dR is 255, we will get -255*sA casted to an unsigned value. Basically results are quite large numbers instead of the expected 0-255 range.
2017-01-05 08:16:39 -08:00
Ryan C. Gordon
9d04205263 x11: deal with xrandr display size in millimeters being zero.
Xquartz on macOS reports a zero size, which leads to a division by zero here.
2017-01-04 09:33:47 -05:00
Sam Lantinga
d359180040 Fixed bug 3519 - SDL_GetDisplayMode fails to report mode.format when using Wayland backend
Ryan C. Gordon

Kristian says you can't do it with Wayland, and that going forward, it'll just handle whatever you throw at it anyhow.

https://twitter.com/hoegsberg/status/816148272402165761

So I say we mark it SDL_PIXELFORMAT_RGB888, which is what my X11 display currently reports, and leave it at that.
2017-01-03 00:44:05 -08:00
Sam Lantinga
18d9b23c65 Fixed bug 3539 - SDL2, missing MIR LDFLAGS
Gianfranco

Hello, this is the failure I got

https://launchpadlibrarian.net/300679206/buildlog_ubuntu-zesty-amd64.libsdl2_2.0.5+dfsg1-2ubuntu1_BUILDING.txt.gz

  LTLINK build/libSDL2.la
build/.libs/SDL_mirvideo.o: In function `MIR_InitDisplayFromOutput':
././src/video/mir/SDL_mirvideo.c:258: undefined reference to `mir_output_get_current_mode'
collect2: error: ld returned 1 exit status
2017-01-02 10:30:32 -08:00
Sam Lantinga
67ed894353 Fixed bug 3529 - SDL_EGL_UnloadLibrary is not called at all on SDL_Quit
kaisyu

In case of OpenGLES, the sequences of loading and unloading driver library should be like that:

SDL_Init
  ...
  SDL_GL_LoadLibrary
    SDL_EGL_LoadLibrary
...
SDL_Quit
  ...
  SDL_GL_UnloadLibrary
    SDL_EGL_UnloadLibrary
...


However, according to my test results, the varible '_this->gl_config.driver_loaded' does not allow 'SDL_GL_UnloadLibrary' to call 'SDL_EGL_UnloadLibrary'.
2017-01-01 19:10:36 -08:00
David Ludwig
0cfa0aa11c improved SDL_GetError() output generated by EGL code
This change attempts to report the EGL error codes generated by SDL's calls
into EGL, along with the name of the EGL function that failed.
2016-12-29 11:49:18 -05:00
Sam Lantinga
45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
49225f5f04 We don't currently support blitting to < 8 bpp surfaces, return an error instead of corrupting memory in that case. 2016-12-31 18:11:19 -08:00
Sam Lantinga
7f2068daca Fixed bug 3541 - DisplayIndex out of bounds in SDL_SetWindowPosition
Intellectual Kitty

In SDL_video.c, on line #1756, in SDL_SetWindowPosition (from today's distribution, 12-31-2016, https://hg.libsdl.org/SDL/shortlog/bf19e0c84483):

        if (displayIndex > _this->num_displays) {

should be:

        if (displayIndex >= _this->num_displays) {
2016-12-31 10:30:07 -08:00
Ryan C. Gordon
7c31636666 x11: Don't loop forever if the X server refuses a pointer grab. 2016-12-26 23:02:14 -05:00
Sam Lantinga
b4e069e7f8 Fixed bug 3517 - Compiler warnings with gcc -Wstrict-prototypes
felix

Compiling even a simple SDL2 'hello world' program with gcc -Wstrict-prototypes (GCC 6.2.1) results in warnings like:

/usr/include/SDL2/SDL_gamecontroller.h:143:1: attention : function declaration isn't a prototype [-Wstrict-prototypes]
 extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings();
 ^~~~~~

It seems there is a missing 'void' between the parentheses.
2016-12-26 02:12:21 -08:00
Alex Szpakowski
fd85f5748d Mac: back out commit 3e9b2ae41adf. It causes significant overhead on many GPUs. 2016-12-23 22:49:37 -04:00
Alex Szpakowski
d719374cb9 Mac: Fix over-saturated colors on P3 displays (e.g. the 2016 MBPs). 2016-12-23 22:08:18 -04:00
Alex Szpakowski
eda74fda96 tvOS: Expose remote swipe gestures as arrow key presses (thanks oviano!) 2016-12-18 13:05:14 -04:00
Alex Szpakowski
787a54c84b iOS bug #3377: work around bugs in some third party iOS libraries (e.g. Google admob) where they assume the optional UIApplicationDelegate ?window? property always exists and will crash if it doesn?t. 2016-12-18 12:28:28 -04:00
Ryan C. Gordon
f50a04009c windows: add whitespace to fix macro preprocessing issue (thanks, Sven!).
Apparently without a space here, "fastbuild -cache" breaks.
2016-12-13 00:22:42 -05:00
Sam Lantinga
e81bf12b85 Fixed edid parsing code for older gcc compilers
Ozkan Sezer

This adds the name 'ad' to two unnamed unions in edid.h
and adjusts edid-parse.c for it.  Nameless unions are not supported in
ancient gcc, which I happened to use on one of my ancient setups.
2016-12-12 09:18:42 -08:00
Sam Lantinga
8414c3d4ae Fixed ABI, don't change the return type of SDL_GL_SwapWindow() 2016-12-11 12:01:44 -08:00
Sam Lantinga
6211668e9f Fixed creating a renderer on the dummy driver on Mac OS X 2016-12-11 12:01:01 -08:00
Sam Lantinga
cb5a0b0f6a Fixed crash when creating a dummy window on Mac OS X 2016-12-11 11:45:33 -08:00
Sam Lantinga
454d9cb96d PP_OK isn't available in the NaCl build environment on buildbot. It's defined as 0 2016-12-09 05:19:31 -08:00
Sam Lantinga
97d05b0da8 Fixed a bunch of SwapWindow calls that needed their return value updated 2016-12-09 05:12:27 -08:00
Sam Lantinga
7a39681ea5 Fixed X11 OpenGL ES build 2016-12-09 05:04:18 -08:00
Sam Lantinga
fed8cbcdb6 Fixed build for EGL platforms 2016-12-09 05:00:35 -08:00
Sam Lantinga
524bf3c282 Fixed bug 3513 - SDL_GL_SwapWindow does not return error status
Return an error code from SDL_GL_SwapWindow(), like the other SDL APIs.
2016-12-09 01:47:43 -08:00
Sam Lantinga
26f05ecb4d Fixed missing prototypes on Android, patch from Sylvain 2016-12-02 02:25:12 -08:00
Sam Lantinga
84c0780e25 Fixed bug 3305 - Fixed TextInput status when the keyboard was dismissed with the dismiss key on the iPad
Diego

I was previously unaware that rotating the device to a different orientation when the keyboard is shown causes a keyboardWillHide followed by a keyboardWillShow notification. The previous patch would then mistakenly StopTextInput when rotating. This patch fixes that by checking if the device is rotating before stopping text input.
2016-12-02 02:21:35 -08:00
Sam Lantinga
1b689c335c Fixed bug 3503 - osx builds don't run on 10.6 as of rev. 10651
Ozkan Sezer

With rev. 10651, i.e. http://hg.libsdl.org/SDL/rev/747a6a795b21 ,
SDL2 - OS X builds fail to run on 10.6 (my setup: i686 / 10.6.8)
because the symbol _IOPMAssertionCreateWithDescription is missing.
The SDK listing it for 10.7+ does seem correct.  Reverting r10651
and rebuilding makes it to function again.
2016-12-01 11:52:47 -08:00
Sam Lantinga
4905cd9c09 Fixed bug 3340 - SDL_BlitScaled causes access violation in some cases.
Simon Hug

The SDL_BlitScaled function runs into an access violation for specific blit coordinates and surface sizes. The attached testcase blits a 800x600 surface to a 1280x720 surface at the coordinates -640,-345 scaled to 1280x720. The blit function that moves the data then runs over and reads after the pixel data from the src surface causing an access violation.

I can't say where exactly it goes wrong, but I think it could have something to do with the rounding in SDL_UpperBlitScaled. final_src.y is 288 and final_src.h is 313. Together that's 601, which I believe is one too much, but I just don't know the code enough to make sure that's the problem.

Sylvain

I think this patch fix the issue, but maybe it's worth re-writing "SDL_UpperBlitScaled" using SDL_FRect.
2016-11-30 22:06:05 -08:00
Sam Lantinga
7f764bd8d3 once more - iterating on this is annoying 2016-11-26 10:26:36 -08:00
Sam Lantinga
51ccc9ed8c if the tap is explicitly disabled by code or by another program, let it remain disabled! this is different than the automatic "event tap was too slow therefore we stopped processing it" timeout which we want to re-enable after. 2016-11-26 10:26:32 -08:00
Sam Lantinga
25f54f0f4f tap should default to disabled, not enabled 2016-11-26 10:26:26 -08:00
Sam Lantinga
354a8f276e SDL for Mac - only enable global event tap when actually necessary (app has focus and has requested relative mouse mode or has asked for a mouse grab). in other situations the event tap impacts system performance and battery life with no benefit. 2016-11-26 10:26:22 -08:00
Ryan C. Gordon
d1c35febce macOS: removed deprecated UpdateSystemActivity() call.
The non-deprecated approach (IOPMAssertion) already exists in SDL, and is
available in Mac OS X 10.6 and later (although it was incorrectly listed as
10.7 and later in SDL). Since SDL now requires 10.6 or later, this is no
longer conditionally used.
2016-11-25 00:13:13 -05:00
Ryan C. Gordon
fb5fd67ccb Fixed all known static analysis bugs, with checker-279 on macOS. 2016-11-24 21:41:09 -05:00
Ryan C. Gordon
e93e91f0b5 Pacify some GCC strict-aliasing compiler warnings. 2016-11-23 21:52:48 -05:00
Ryan C. Gordon
232ae68864 Still more compiler warning fixes for various platforms. 2016-11-23 17:20:28 -05:00
Sam Lantinga
3615633571 Renaming of guard header names to quiet -Wreserved-id-macro
Patch contributed by Sylvain
2016-11-20 21:34:54 -08:00
Sam Lantinga
4a089ca1c8 Fixed bug 3486 - Can't get HINSTANCE of my window
realitix

SDL2 allows to create widow and to get information through SDL_SysWMinfo.
But it misses something, with Vulkan, you need the HWND and HINSTANCE of the window for Win32 system.
Sadly, SDL2 provides only HWND but not HINSTANCE.

In some context, it can be difficult to get the HINSTANCE, indeed, I'm using pySDL2 (Python) and I can only access properties that SDL2 gives me.
I have to use a dirty trick like that to get the HINSTANCE:  (https://raw.githubusercontent.com/bglgwyng/pyVulkan/master/examples/win32misc.py)
2016-11-20 21:18:55 -08:00
Philipp Wiesemann
a49ac09c02 Windows: Fixed crash if using current SDL_GetWindowWMInfo() from older programs. 2016-11-18 00:06:09 +01:00
Philipp Wiesemann
d05a39d0a6 Wayland: Fixed file descriptor leaks if device was not initialized. 2016-11-18 00:05:54 +01:00
Philipp Wiesemann
c345126266 Emscripten: Fixed handling of deactivated mouse events.
SDL_GetEventState() was called with a button state instead of an event type.
2016-11-18 00:05:28 +01:00
Philipp Wiesemann
6fe15d6347 Wayland: Fixed memory leak if output retrieval failed.
Found by Cppcheck.
2016-11-16 22:09:40 +01:00
Sam Lantinga
818d1d3e80 Fixed bug 1646 - Warnings from clang with -Weverything 2016-11-15 01:30:08 -08:00
Sam Lantinga
0d24495b15 Removed unused constants
Except for SDL_bmp.c where they are historically interesting and I've left them in.
2016-11-15 01:24:58 -08:00
Thomas Perl
acce865911 [qtwayland] Set orientation and window flags via SDL hints 2016-11-13 10:39:04 +01:00
Sam Lantinga
009a3f5aa6 Fixed bug 3490 - Build failure with --enable-video-directfb
felix

Building SDL 2.0.5, or even the Mercurial snapshot (r10608) with GCC 6.2.1 and --enable-video-directfb generates a number of compiler diagnostics and fails.
2016-11-15 01:14:30 -08:00
Sam Lantinga
57d01d7d67 Patch from Sylvain to fix clang warnings 2016-11-13 22:57:41 -08:00
Sam Lantinga
74e1dd4c6f Define _GNU_SOURCE when building SDL 2016-11-11 13:14:00 -08:00
Ryan C. Gordon
2898ada338 wayland: fixed compiler warning about pipe2(). 2016-11-10 12:07:34 -05:00
Sam Lantinga
d780031277 Fixed bug 3476 - round() needs _GNU_SOURCE on some old systems
Ozkan Sezer

On systems with old glibc, such mine with glibc-2.8, the following warning
is issued and is fixed easily by defining _GNU_SOURCE:

/home/me/SDL2-2.0.5/src/video/x11/SDL_x11modes.c: In function 'CalculateXRandRRefreshRate':
/home/me/SDL2-2.0.5/src/video/x11/SDL_x11modes.c:263: warning: implicit declaration of function 'round'
/home/me/SDL2-2.0.5/src/video/x11/SDL_x11modes.c:263: warning: incompatible implicit declaration of built-in function 'round'
2016-11-06 09:30:06 -08:00
Sam Lantinga
d767a450dc Fixed 2942 - Wayland: Drag and Drop / Clipboard
x414e54

I have implemented Drag and Drop and Clipboard support for Wayland.

Drag and dropping files from nautilus to the testdropfile application seems to work and also copy and paste.
2016-11-06 08:34:27 -08:00
Philipp Wiesemann
5819923212 WinRT: Corrected header file guard comment. 2016-11-05 21:22:58 +01:00
Sam Lantinga
baadd54686 Fixed text input events with UIM
Alex Baines

I realized overnight that my patch probably broke text input events with UIM, and I confirmed that it does. Can't believe I overlooked that... I've been making stupid mistakes in these patches recently, sorry.

Anyway, *this* one seems to fix it properly. Knowing my luck it probably breaks something else.
2016-11-02 02:56:54 -07:00
Alex Baines
8eb762769e Skip duplicate key events sent by IMEs like uim. 2016-11-01 17:38:05 +00:00
Sam Lantinga
d0c8bf7f0b Patch from Tapani P?lli to fix a memory leak in X11_InitKeyboard
Patch uses XkbFreeKeyboard to free the memory returned by XkbGetMap.
Earlier implementation called XkbFreeClientMap which frees all the maps
but not data->xkb structure itself, XkbFreeKeyboard will free maps and
the structure.
2016-11-01 10:48:59 -07:00
Sam Lantinga
a1f427651d Patch from Tapani P?lli to fix a memory leak in X11_GL_CreateContext 2016-11-01 10:46:47 -07:00
Alex Baines
5fe984978c Fix double events / no repeat flag on key events when built withoutibus/fcitx
Uses XkbSetDetectableKeyRepeat, and falls back to forcing @im=none if it's not
supported.
2016-10-28 01:28:58 +01:00
Sam Lantinga
39ba2ab835 Fixed NULL pointer dereference, thanks Ozkan Sezer 2016-10-22 17:53:03 -07:00
Sam Lantinga
5b14a943a8 Fixed bug 3466 - Can't build 2.0.5 on ppc64
/home/fedora/SDL2-2.0.5/src/video/SDL_blit_N.c: In function 'calc_swizzle32':
/home/fedora/SDL2-2.0.5/src/video/SDL_blit_N.c:127:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
     const vector unsigned char plus = VECUINT8_LITERAL(0x00, 0x00, 0x00, 0x00,
     ^
2016-10-22 11:01:55 -07:00
Sam Lantinga
8a73f7e893 Fixed bug 3461 - Implement TEXTINPUT events for Haiku
Kai Sterker

Apparently, SDL2 on Haiku does not generate SDL_TEXTINPUT events.
Attached is a patch that adds this functionality.

Tested with SDLs own checkkeys program and different keymaps as well as my own SDL application and German keyboard layout to verify it generates the expected input.
2016-10-19 20:42:22 -07:00
Sam Lantinga
6d67c98e70 Fixed crash on Mac OS X 10.10 and earlier 2016-10-19 20:39:12 -07:00
Sam Lantinga
012217f069 Fixed bug 3369 - RaspberryPI ability to specify a Dispmanx layer
Albert Casals

On a RaspberryPI, it might become convenient to specify the Dispmanx layer SDL uses.
Currently, it is hardcoded to be 10000 to sit above most applications.

This can be specially useful when integrating other graphical apps and frameworks like OMXplayer, QT5 etc.. in order to have more flexibility on their Z-order.
2016-10-18 23:24:49 -07:00
Sam Lantinga
267207ffca Worked around a crash on Mac OS X 10.10 and earlier, thanks to Eric Wasylishen. 2016-10-18 23:12:45 -07:00
Sam Lantinga
5af67f49f4 Fixed bug 3458 - x11: reset deadkeys in StartTextInput/StopTextInput
Eric Wasylishen

The patch makes StartTextInput/StopTextInput call Xutf8ResetIC ( https://www.x.org/releases/X11R7.5/doc/man/man3/XmbResetIC.3.html ) on the XIC of all SDL windows.

This fixes my use case in Quakespasm (Ubuntu 16.04, system keyboard layout set to German. Type the '^' dead key, which opens Quakespasm's developer console and calls SDL_StartTextInput, then press 'e'. I expect the dead key to be ignored.)

Also, here is a patch for sdl2's "checkkeys" for testing this: https://bugzilla-attachments.libsdl.org/attachment.cgi?id=2451
2016-10-17 21:37:26 -07:00
Csongor Szabo
01f6273675 emscripten: check if device pixel ratio has changed 2016-10-14 17:06:28 +01:00
Sam Lantinga
d5ddb3cb91 Fixed bug 3453 - First mouse button input after a drag and drop event is ignored
Olav Sorensen

After a drag and drop event, any following mouse button input (down/up) doesn't generate an event. Clicking any mouse button a *second* time generates an event like it should.

Further investigation shows that the new SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH logic also causes this issue in other cases, like the first time you open the program and click the mouse.
2016-10-14 08:40:21 -07:00
Sam Lantinga
824ecc8f7a Fixed processing mouse and keyboard events in hatari, which uses the old SDLMain.m without creating an SDLApplication instance 2016-10-14 08:15:39 -07:00
Sam Lantinga
063f752e0d Fixed bug 3328 - Race condition in Wayland_VideoInit
Robert Folland

When running this little test program with SDL2 on Wayland it often crashes in SDL_Init.

From a backtrace it is apparent that there is a race condition in creating a xkb_context_ref. Sometimes it is 0x0.

By moving the relevant lines higher up in Wayland_VideoInit (in SDL2-2.0.4/src/video/wayland/SDL_waylandvideo.c:302) this seems to get fixed.

I moved the call to WAYLAND_xkb_context_new() up to before the call to WAYLAND_wl_display_connect().

Here is the test program (just a loop of init and quit), and a backtrace from gdb:

#include <cstdio>
#include <stdlib.h>
#include <SDL2/SDL.h>
#include <unistd.h>
#include <iostream>

int main(int argc, char **argv)
{
    int count = atoi(argv[1]);

    for (int i = 0; i < count; i++) {
        std::cout << "Init " << i << std::endl;
        if (SDL_Init(SDL_INIT_VIDEO) < 0) {
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                         "Couldn't initialize SDL: %s\n",
                         SDL_GetError());
            return 1;
        }
        std::cout << "Quit" << std::endl;
        SDL_Quit();
    }
    return 0;
}


Init 12
Quit
Init 13

Program received signal SIGSEGV, Segmentation fault.
xkb_context_ref (ctx=ctx@entry=0x0) at src/context.c:156
156         ctx->refcnt++;
(gdb) bt
#0  xkb_context_ref (ctx=ctx@entry=0x0) at src/context.c:156
#1  0x00007ffff5e1cd4c in xkb_keymap_new (ctx=0x0, format=XKB_KEYMAP_FORMAT_TEXT_V1, flags=flags@entry=XKB_KEYMAP_COMPILE_NO_FLAGS) at src/keymap-priv.c:65
#2  0x00007ffff5e1c6cc in xkb_keymap_new_from_buffer (ctx=<optimized out>,
    buffer=0x7ffff7fd5000 "xkb_keymap {\nxkb_keycodes \"(unnamed)\" {\n\tminimum = 8;\n\tmaximum = 255;\n\t<ESC>", ' ' <repeats 16 times>, "= 9;\n\t<AE01>", ' ' <re
peats 15 times>, "= 10;\n\t<AE02>", ' ' <repeats 15 times>, "= 11;\n\t<AE03>", ' ' <repeats 15 times>, "= 12;\n\t<AE04>", ' ' <repeats 12 times>..., length=48090,
    format=<optimized out>, flags=<optimized out>) at src/keymap.c:191
#3  0x00007ffff7b8ea4e in keyboard_handle_keymap (data=0x6169b0, keyboard=<optimized out>, format=<optimized out>, fd=5, size=48091)
    at /home/vlab/abs/sdl2/src/SDL2-2.0.4/src/video/wayland/SDL_waylandevents.c:269
#4  0x00007ffff64501f0 in ffi_call_unix64 () from /usr/lib/libffi.so.6
#5  0x00007ffff644fc58 in ffi_call () from /usr/lib/libffi.so.6
#6  0x00007ffff665be3e in wl_closure_invoke (closure=closure@entry=0x61f000, flags=flags@entry=1, target=<optimized out>, target@entry=0x616d20,
    opcode=opcode@entry=0, data=<optimized out>) at src/connection.c:949
#7  0x00007ffff6658be0 in dispatch_event (display=<optimized out>, queue=<optimized out>) at src/wayland-client.c:1274
#8  0x00007ffff6659db4 in dispatch_queue (queue=0x617398, display=0x6172d0) at src/wayland-client.c:1420
#9  wl_display_dispatch_queue_pending (display=0x6172d0, queue=0x617398) at src/wayland-client.c:1662
#10 0x00007ffff665a0cf in wl_display_roundtrip_queue (display=0x6172d0, queue=0x617398) at src/wayland-client.c:1085
#11 0x00007ffff7b8faa0 in Wayland_VideoInit (_this=<optimized out>) at /home/vlab/abs/sdl2/src/SDL2-2.0.4/src/video/wayland/SDL_waylandvideo.c:302
#12 0x00007ffff7b7aed6 in SDL_VideoInit_REAL (driver_name=<optimized out>, driver_name@entry=0x0) at /home/vlab/abs/sdl2/src/SDL2-2.0.4/src/video/SDL_video.c:513
#13 0x00007ffff7ae0ee7 in SDL_InitSubSystem_REAL (flags=16416) at /home/vlab/abs/sdl2/src/SDL2-2.0.4/src/SDL.c:173
#14 0x0000000000400b24 in main (argc=2, argv=0x7fffffffebb8) at vplay-init.cpp:13
(gdb)
2016-10-13 04:54:43 -07:00
Sam Lantinga
f94bd05736 Fixed bug 3451 - Raspberry Pi Raspbian SDL_assert triggered sometimes at RPI_WarpMouseGlobal
Eric wing

Sometimes an SDL_assert triggers at RPI_WarpMouseGlobal
src/video/raspberry/SDL_rpimouse.c:232 'update'.

It doesn't always reproduce, but it seems to happen when you really bog down the system and the event loop can't update for awhile.


The first time I hit this, I wasn't even using the mouse. I don't call any warp mouse functions either.


I can usually reproduce with a simple program that runs an expensive blocking CPU series of functions which blocks the main loop until complete (can be up to 10 seconds).

Sometimes this assertion gets triggered after that. I'm not sure if
they are related or coincidental.


Disabling the SDL_asserts when compiling SDL will avoid this problem. I actually haven't seen any problems with the mouse when I do this.

On a Raspberry Pi 2 running Raspbian Jessie.
2016-10-13 04:53:01 -07:00
Sam Lantinga
3a77b42de7 Fixed build warning 2016-10-12 18:45:56 -07:00
Philipp Wiesemann
f6bcfa0175 X11: Fixed compile warning about unused variable. 2016-10-12 23:38:31 +02:00
Sam Lantinga
36e40d30fc Fixed bug 2923 - Add SDL_PIXELFORMAT_RGBA32 for byte-wise 32bit RGBA data
Daniel Gibson

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

SDL_GetPixelFormatName() will of course return SDL_PIXELFORMAT_RGBA8888 (or SDL_PIXELFORMAT_ABGR8888) instead of SDL_PIXELFORMAT_RGBA32, but as long as that's mentioned in the docs it shouldn't be a problem.
2016-10-11 23:19:05 -07:00
Alex Baines
d9e3972acb Fix invalid read from poor setlocale usage. 2016-10-03 15:31:11 +01:00
Steffen Pankratz
aae28e3ec1 Fixed bug 3096 - SDL_BlitSurface with overlapping source and destination 2016-10-10 18:28:05 +02:00
Sam Lantinga
42f85aa29e Fixed building and using fcitx IME support on Linux 2016-10-08 11:30:07 -07:00
Sam Lantinga
27d4f09929 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints 2016-10-07 23:40:44 -07:00
Sam Lantinga
808c75d1cf Fixed bug 2824 - Add Fcitx Input Method Support
Weitian Leung

Just moved ibus direct call to SDL_IME_* related functions, and adds fcitx IME support (uses DBus, too),
enable with env: SDL_IM_MODULE=fcitx (ibus still the default one)
2016-10-07 18:57:40 -07:00
Alex Baines
752931d85e Improve X11 key handling when XKB isn't available + add xvnc scancodes.
Based on a patch by Bill Lash (see bug 3094).
2016-10-03 11:35:34 +01:00
Bill Lash
cceca2ac99 Additional patch to correct the number key assignments, and add assignments for keys that were missed 2015-08-15 00:25:52 -05:00
Sam Lantinga
eea76fc199 Fixed bug 3063 - Wayland: SDL resizes EGL surface to 0x0.
x414e54

Wayland will sometimes send empty resize events (0 width and 0 height) to the client. I have not worked out the exact conditions a client would receive these but I can assume it might be if the window is offscreen or not mapped yet.

This causes issues with some SDL clients as they receive the 0x0 event and unexpected resize event or might not request to resize back to the correct size.

As per the wl_shell Wayland spec configure events are only a suggestion and the client is free to ignore or pick a different size (this is how min/max and fixed aspect ratio is supped to be implemented).

A patch is attached but is just the first iteration and I will fix any issues such as checking for FULLSCREEN/MAXIMIZED or RESIZABLE flags unless someone else fixes this first.

I have update to take into account non resizable and fullscreen windows. Also adding in maximize/restore and title functions for Wayland.
2016-10-07 18:11:03 -07:00
Sam Lantinga
62b9e1c797 Fixed bug 3061 - Selecting the dummy video driver on Mac OS X results in an error
Darren Kulp

The dummy video driver is not available on Mac OS X if SDL_VIDEO_OPENGL is set at library compilation time.

In src/video/SDL_video.c, there is a compile-time check in SDL_CreateWindow() for (SDL_VIDEO_OPENGL && __MACOSX__). When it succeeds, SDL_WINDOW_OPENGL is always requested. Since the dummy video driver does not supply an OpenGL implementation, the error "No OpenGL support in video driver" is supplied to the user, and SDL_CreateWindow() is exited early.
2016-10-07 18:09:09 -07:00
Sam Lantinga
8b64a78da9 Fixed bug 2956 - De-reference videodata without NULL check in X11_DispatchEvent(_THIS) function 2016-10-07 17:26:25 -07:00
Sam Lantinga
d2676c2985 Fixed bug 2924 - SDL_CreateRGBSurface[From] versions that take SDL_PIXELFORMAT enum
Daniel Gibson

Currently, SDL_CreateRGBSurface() and SDL_CreateRGBSurfaceFrom() take Uint32 masks for RGBA to "describe" the Pixelformat of the surface.
Internally those value are only used to map to one of the SDL_PIXELFORMAT_* enum values that are used for further processing.

I think it would be both handy and more efficient to be able to specify SDL_PIXELFORMAT_* yourself without using SDL_PixelFormatEnumToMasks() to create masks first, so I implemented functions that do that:
SDL_CreateRGBSurfaceWithFormat() and SDL_CreateRGBSurfaceWithFormatFrom() which are like the versions without "WithFormat" but instead of taking 4 Uint32s for R/G/B/A masks, they take one for a SDL_PIXELFORMAT_* enum value.

Together with https://bugzilla.libsdl.org/show_bug.cgi?id=2923 creating a SDL_Surface* from RGBA data (e.g. from stb_image)  is as easy as
  surf = SDL_SDL_CreateRGBSurfaceWithFormat(0, w, h, bppToUse*8, SDL_PIXELFORMAT_RGBA32);
2016-10-07 17:04:58 -07:00
Sam Lantinga
dac3892816 Fixed bug 2832 - Inverted arrow-key navigation in MessageBox
Jan Hellwig

On Windows, you are able to navigate between the buttons on a MessageBox that was created using SDL_ShowMessageBox using the arrow keys. However, if you press the left arrow key, the selection jumps to the button on the right of the currently selected one (and vice versa).

This can be fixed by reversing the order in which the buttons are added to the dialog.

The attached patch files fixes this problem. However the first press of an arrow key leads to the selection of the leftmost or rightmost button on the MessageBox, not to the selection of the button left/right of the one that is selected by default.
2016-10-07 16:19:50 -07:00
Sam Lantinga
f674f2311a Fixed bug 2808 - Fix SDL reporting wrong window size on resume
Jonas Kulla

At startup time, the single android window is assigned a "windowed" (window->windowed.{w,h}) size based on the current orientation of the mobile device; this size is never updated throughout the lifetime of the app.

This becomes problematic when the app is paused and then resumed in an orientation that it did not start up in. Eventually, 'SDL_OnWindowRestored()' is called, which calls 'SDL_UpdateFullscreenMode()'. This function is very problematic because it is written with a desktop monitor in mind: it tries to find a matching display mode for the windowed size, doesn't find any, and finally applies the windowed size as the fullscreen one. In the end, the windowed size is reported in a RESIZED event, which doesn't correspond to the actual surface size.

To see this in action: Start an orientation aware SDL app in eg. portrait mode, suspend the app, put the device into landscape orientation and resume the app. It will erroneously render in portrait mode (until the device is rotated again).
2016-10-07 15:21:19 -07:00
Sam Lantinga
5d5127c4a0 Fixed compiler warning - this should have been a const char pointer 2016-10-04 03:38:39 -07:00
Sam Lantinga
351adf156a Fixed bug 2157 - Caps Lock key produces key down & key up events while key is still pressed.
Tim McDaniel

Using checkkeys test app:
* Press and hold Caps Lock key.
* checkkeys reports a CapsLock key pressed event and a CapsLock key released event.
* Release Caps Lock key.
* checkkeys reports no further events.

This patch fixes OSX Caps Lock up/down event detection by installing a HID callback.
2016-10-04 02:11:52 -07:00
Alex Szpakowski
8500de8fa5 Fix tabs -> spaces 2016-10-01 19:16:46 -03:00
Alex Szpakowski
f0539aa25e Fix bug 3436 - SDL_RaiseWindow not working on windows 2016-10-01 19:12:58 -03:00
Sam Lantinga
d2c8c5094c Fixed build for X11 2016-10-01 14:54:05 -07:00
Sam Lantinga
fa0f417631 Fixed build warnings and errors 2016-10-01 14:48:18 -07:00
Sam Lantinga
fae5d0eab3 Fixed bug 3107 OSX - Process events in SDLApplication to fix integration with CEF.
John Wordsworth

While attempting to integrate CEF (Browser) into an SDL application, we noticed that there were problems on OS X where approximately 50% of the input events were essentially being lost - even when we were using off-screen rendering in CEF and passing through input events manually.

It appears that this problem has been around for a while (see: http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=11141).

Please consider the following patch that fixes this issue. Instead of processing events directly after calling [NSApp nextEventMatchingMask:...] we now pass these events down to NSApp, for processing by an overloaded sendEvent: method. Chromium also forwards events to NSApp in the same way, which means we don't miss events, even if they were originally dequeued by CEF.
2016-10-01 14:34:52 -07:00
Sam Lantinga
359f59aef5 Fixed bug 3130 - Spacebar not responding
Alex Baines

Make sure group is valid before passing it to XkbKeysymToKeycode.
2016-10-01 14:22:10 -07:00
Magnus Bjerke Vik
555e6c9686 Fix SDL not resizing window when Android screen resolution changes 2016-10-01 14:18:29 -07:00
Sam Lantinga
0250eb3c4f Fixed bug 3134 - CalculateXRandRRefreshRate() returns incorrect refresh rate due to floating point truncation.
Michael

In SDL_x11modes.c the CalculateXRandRRefreshRate() function performs integer math on values that may return fractional results. This causes a value that would be calculated as 59.99972... to be returned as 59. In Linux the xrandr command returns 60Hz for this particular display mode yet SDL returns 59Hz.

I suggest this function be updated to correctly round the result of the calculation instead of truncating the result.
2016-10-01 14:16:04 -07:00
Alex Baines
7543092add Call setlocale + XSetModifiers before XOpenIM, Work around ibus+xim duplicate events. 2015-09-30 04:16:09 +01:00
Sam Lantinga
da6197c5a8 Fixed 3149 - Mouse Pointer Raspberry Pi corrupt when moving over screen edges
Patrick Gutlich

The mouse cursor gets corrupted when the mouse moves over the screen edges (right and bottom) a weird type of scaling seems to occur and you end up with a blank square.
2016-10-01 13:59:59 -07:00
Sam Lantinga
473051f6bb Fixed bug 3159 - SDL_blit_slow with BLENDING does not work
Fritzor

Source Suface is ABGR and Destination Surface is ABGR. We use software blending. In the Switch-Case statement for SDL_COPY_BLEND (Line 126) the alpha-channel is not calculated like in every SDL_blit_auto - function. So if the destination Surface has alpha - channel of zero the resulting surface has zero as well.
Add:  ?dstA = srcA + ((255 - srcA) * dstA) / 255;? to code and everything is okay.
2016-10-01 13:40:01 -07:00
Sam Lantinga
f4b26cd8e0 Removed carriage returns from previous patch 2016-10-01 13:16:31 -07:00
Sam Lantinga
7b0ccd32e5 Fixed bug 3405 - Wrong default icon size on windows systems
Evgeny Vrublevsky

Original code in the video/windows/SDL_windowsevents.c registers obsolete WNDCLASS (not WNDCLASSEX). As the result only one icon size is used as the small and normal icons. Also original code doesn't specify required size of an icon. As the result when 256x256 icon is available, the program uses it as a default icon, and it looks ugly.

We have to use WNDCLASSEX and load icons with proper sizes which we can get using GetSystemMetrics.

Better idea. We could use the first icon from resources, like the Explorer does. Patch is included. It also correctly loads large and small icons, so it will look nice everywhere.
2016-10-01 13:14:51 -07:00
Sam Lantinga
765d8bea01 Fixed bug 3305 - Fixed TextInput status when the keyboard was dismissed with the dismiss key on the iPad
Diego

The keyboard on iPads has a dismiss button that hides the keyboard. When the keyboard was hidden using that button, instead of the return key, SDL was still reporting IsTextInputActive as true. This patch adds an extra SDL_StopTextInput when iOS reports the keyboard will hide.
2016-10-01 12:46:36 -07:00
Ethan Lee
c3e48e71b4 Force WM_PAINT events on window resize 2016-04-12 10:45:56 -04:00
Sam Lantinga
0b576962ca Reset dead keys when the SDL window loses focus, so dead keys pressed in SDL applications don't affect text input into other applications. 2016-10-01 12:17:42 -07:00
Sam Lantinga
1e6e595484 Fixed bug 3332 - Win32: reset deadkeys in StartTextInput/StopTextInput
Eric Wasylishen

The bug here is that a dead keys pressed before calling SDL_StartTextInput() carries over into future text input, so the next key pressed will have the deadkey applied to it.

This in undesirable, imho, and doesn't occur on OS X (haven't check Linux or elsewhere). It's causing a problem for Quakespasm on German keyboard layouts, where we use the ^ deadkey to toggle the console (which enables/disables text input), and ^ characters are showing up in the TEXTINPUT events.
2016-10-01 11:54:02 -07:00
Sam Lantinga
9fff05f8d6 Fixed bug 3352 - Adding alpha mask support to SDL_SaveBMP_RW
Simon Hug

The current SDL_SaveBMP_RW function that saves surfaces to a BMP uses an old bitmap header which doesn't officially support alpha channels. Applications just ignore the byte where the alpha is stored. This can easily be extended by using a newer header version and setting the alpha mask.

The attached patch has these changes:

- Extending the description of the function in the SDL_surface.h header with the supported formats.
- Refining when surfaces get stored to a 32-bit BMP. (Must have bit depth of 8 or higher and must have an alpha mask or colorkey.)
- Fixing a small bug that saves 24-bit BGR surfaces with a colorkey in a 24-bit BMP.
- Adding code that switches to the bitmap header version 4 if the surface has an alpha mask or colorkey. (I chose version 4 because Microsoft didn't lose its documentation behind a file cabinet like they did with version 3.)
- Adding a hint that can disable the use of the version 4 header. This is for people that need the legacy header or like the old behavior better. (I'm not sure about the hint name, though. May need changing if there are any rules to that.)
2016-10-01 11:29:13 -07:00
Sam Lantinga
fd1d692bef Fixed bug 3368 - SDL_Blit_Slow doesn't ignore alpha values in colorkey comparison
Simon Hug

When the SDL_Blit_Slow function compares the pixel to the color key it does so without removing the alpha component from the pixel value and the key. This is different from the optimized 32-bit blitters which create a rgb mask and apply it to both to filter the alpha out. SDL_Blit_Slow will only skip the pixels with the exact alpha value of the key instead of all pixels with the same color.

The attached test case blits a surface with a color key and prints the pixel values to the console. The third row is expected to be skipped.
2016-10-01 10:46:10 -07:00
Ryan C. Gordon
e64c5186e2 windows: Removed hardcoded "1" for mouse clickthrough hint. 2016-09-29 23:42:18 -04:00
Ryan C. Gordon
f10db4071d haiku: Patched to compile. 2016-09-29 23:15:56 -04:00
Ryan C. Gordon
f2fcd324c5 windows: fix borderless windows at desktop resolution (thanks, Evgeny!).
Fixes Bugzilla #3404.
2016-09-29 23:12:58 -04:00
Ryan C. Gordon
b2510d9cbc x11: fixed incorrect SDL_GetWindowPosition() after resize (thanks, Jason!).
Fixes Bugzilla #3272.
2016-09-29 23:01:43 -04:00
Ryan C. Gordon
4f4c4b629f Added SDL_SetWindowResizable(). (thanks, Ethan!) 2016-09-29 22:52:41 -04:00
Sam Lantinga
67bdbcca44 Implemented SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH on X11 2016-09-29 16:05:29 -07:00
Sam Lantinga
d285af2a96 Added Windows support for SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH 2016-09-29 14:48:33 -07:00
Sam Lantinga
a13da2faa7 Generalized the hint for whether the application gets a mouse event when clicking on the window to activate it, and is now named SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH.
The behavior is defined to not receive the click event, and this hint allows you to override that.
2016-09-29 13:34:49 -07:00
Sam Lantinga
8ddb4328b5 When clicking on a window to give it focus, don't pass the mouse click to the application. 2016-09-29 03:59:04 -07:00
Alex Szpakowski
f31c7086d8 Enable SDL_LoadObject on iOS 8+ and tvOS. 2016-09-25 15:02:06 -03:00
Alex Szpakowski
77bacfd72d tvOS launch images are now properly supported. 2016-09-25 11:46:25 -03:00
Alex Szpakowski
40ecac8e60 Don't try to load a launch storyboard on tvOS (it doesn't use them). 2016-09-25 00:21:12 -03:00
Alex Szpakowski
666d3fecc8 iOS/tvOS: Try to load the launch screen as a storyboard. Xcode 8 compiles it as a storyboard instead of a nib. 2016-09-24 23:33:49 -03:00
Alex Szpakowski
9165ba7ebd iOS/tvOS: Always send SDL_WINDOWEVENT_FOCUS_GAINED when a window is created on the main screen (fixes bug #3395). 2016-09-24 20:12:57 -03:00
Alex Szpakowski
450fa8cdf9 Use OS-provided click counts on macOS and iOS for mouse press and release events. 2016-09-24 18:46:34 -03:00
Alex Szpakowski
bac5394127 Fix mouse wheel events on macOS 10.12 (thanks Eric Wasylishen!)
Fixes bug #3432
2016-09-24 13:28:40 -03:00
Brandon Schaefer
89c538a4e3 Mir: Add gamma support set/get. Still need one more function to complete the set 2016-09-21 18:23:59 -07:00
Brandon Schaefer
a729c4f97a Mir: Add fixme (waiting for a public api to be added) 2016-09-21 16:28:23 -07:00
Brandon Schaefer
705ecf78f5 [Mir] Move to the new MirDisplayConfig API 2016-09-21 15:57:15 -07:00
Sam Lantinga
29214826ec Fixed warning with Xcode 7.3.0 2016-09-16 22:27:58 -07:00
Alex Szpakowski
4bcce330d1 tvOS: Add drop-file support 2016-09-15 21:49:29 -03:00
Alex Szpakowski
f050576665 Initial Apple TV / tvOS support.
The Apple TV remote is currently exposed as a joystick with its touch surface treated as two axes. Key presses are also generated when its buttons and touch surface are used.

A new hint has been added to help deal with deciding whether to background the app when the remote's menu button is pressed: SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS.
2016-09-13 22:18:06 -03:00
Alex Szpakowski
86708c3cd8 Enable more compiler warnings in the Xcode projects (based on Xcode 8's suggestion), made some integer downcasts explicit. 2016-09-13 19:51:10 -03:00
Sam Lantinga
00791f3a87 Only prevent the default browser event handling when the specific event types aren't disabled by the user, patch contributed by Jonas Platte 2016-09-13 00:09:21 -07:00
Charlie Birks
993dd83510 Add mapping for media keys 2016-09-13 00:04:00 -07:00
Alon Zakai
1b6565fcb7 use Module.createContext for 2D rendering in emscripten 2016-09-13 00:03:59 -07:00
Alon Zakai
bec5573476 add some detail to fullscreen workaround comment; version 6
Conflicts:
	version.txt
2016-09-13 00:03:58 -07:00
Charlie Birks
405d64b207 only unset fullscreen flags if fullscreen failed 2016-09-13 00:03:56 -07:00
Charlie Birks
c68cac89df use screen resolution instead of canvas size 2016-09-13 00:03:55 -07:00
Boris Gjenero
791b946a42 Fix full screen mode in Firefox, which was broken by 9d4beb2 2016-09-13 00:03:54 -07:00
Boris Gjenero
b71208d452 Support SDL_SetWindowTitle() via Module['setWindowTitle']() 2016-09-13 00:03:53 -07:00
Jukka Jyl?nki
7cf44f1b4a Remove unused variable warning from Emscripten build in Emscripten_HandleFullscreenChange(). 2016-09-13 00:03:51 -07:00
Boris Gjenero
b54eb82c67 Unpress all keys on blur to avoid stuck keys 2016-09-13 00:03:49 -07:00
Boris Gjenero
a0a75f384f Listen for blur and focus events on window instead of canvas
Blur and focus events were not arriving for the canvas in
Firefox 35 and Chrome 40.
2016-09-13 00:03:48 -07:00
Boris Gjenero
3e5c4cec94 Mouse events use CSS coordinates, so don't scale by pixel_ratio 2016-09-13 00:03:46 -07:00
Boris Gjenero
a20c40c494 Accumulate subpixel mouse motion so motion is not lost.
Previously when the canvas was scaled up and the pointer was locked,
motion corresponding to less than one pixel was lost. Therefore,
slow mouse motion resulted in no motion. This fixes that.
2016-09-13 00:03:45 -07:00
TelpeNight
443998ff33 Fix of mouse events in browser without pointer locks 2016-09-13 00:03:44 -07:00
Alon Zakai
2b367cb6b0 optimize Emscripten_UpdateWindowFramebuffer
- avoid creating contexts and images all the time
 - use set and then fix alpha directly
2016-09-13 00:03:43 -07:00
Charlie Birks
98ec844388 send mouse move on enter/leave 2016-09-13 00:03:39 -07:00
Charlie Birks
a2ef0db8a8 listen for mouse up on document (fixes mouseup outside canvas) 2016-09-13 00:03:37 -07:00
Charlie Birks
cd05184f9b use SDL_SetMouseFocus 2016-09-13 00:03:36 -07:00
Sam Lantinga
bdca510fd6 simplify fullscreen handling using new fullscreen_strategy api, patch contributed by Charlie Birks 2016-09-13 00:03:28 -07:00
Charlie Birks
be08cc61f9 use css size for touch normalisation 2016-09-12 23:58:08 -07:00
Sam Lantinga
1096f32309 Reverted previous commit which breaks game controller input processing. 2016-09-09 15:12:09 -07:00
Sam Lantinga
61c0f2cf64 Suggestion from Apple: use kCFRunLoopCommonModes which does more complete event processing 2016-09-08 20:38:23 -07:00
Ryan C. Gordon
da1e3d6938 emscripten: special case to make SDL_ShowSimpleMessageBox() work.
Browsers don't have the functionality to fully support the generic
SDL_ShowMessageBox(), but this handles the likely most-common case.

Without this, you'd return immediately with a proper error result and no UI,
but probably no one checks that for SDL_ShowSimpleMessageBox. And if they
did: what would they do to handle this anyhow?

We'd need to lobby for an HTML spec of some sort that allows customizable
message boxes--that block!--to properly support SDL message boxes on
Emscripten, but this is probably Good Enough for now.
2016-09-06 13:13:03 -04:00
Sam Lantinga
f11a440999 wayland: Add support for relative mouse mode, by Jonas ?dahl <jadahl@gmail.com>
Generate the C protocol files from the protocol XML files installed by
wayland-protocols, and use them to implement support for relative pointer
motions and pointer locking.

Note that at the time, the protocol is unstable and may change in the future.
Any future breaking changes will, however, fail gracefully and result in no
regressions compared to before this patch.
2016-09-01 01:26:56 -07:00
Jonas ?dahl
19d3500ae1 wayland: Build own version of core protocol
Since we are loading shared objects dynamically, build our own version of the
core protocol symbols, so that we in the future can include protocol
extensions.
2016-06-23 18:39:05 +08:00
Bastien Nocera
736a624df0 Wayland: Set "class" for each window we create
This will be used by Wayland compositors to match the application ID and
.desktop file to the SDL window(s).

Applications can set the SDL_VIDEO_WAYLAND_WMCLASS environemnt variable
early in the process to override using the binary name as a fallback.

Note that we also support the SDL_VIDEO_X11_WMCLASS in the Wayland
backend so that if a program correctly associated the desktop file with
the window under X11, only a newer SDL would be needed for it to work
under Wayland.

https://bugzilla.libsdl.org/show_bug.cgi?id=3376
2016-09-01 01:22:58 -07:00
David Ludwig
f5d43cf912 WinRT: added an extra NULL pointer check for SDL_*ScreenSaver() backend code 2016-08-31 12:52:55 -04:00
Brandon Schaefer
ebb058910d Mir: Add mouse grab support (requires mir 0.24) 2016-08-30 12:58:00 -07:00
Philipp Wiesemann
cf28727f89 Android: Fixed missing mouse motion events while button down (thanks, Sylvain!).
Happened for real mouse if SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH was active.

Fixes Bugzilla #3313.
2016-08-30 21:14:52 +02:00
David Ludwig
5020fe8fdb WinRT: added SDL_*ScreenSaver() support; fixed crash when restoring app from screensaver 2016-08-29 20:27:21 -04:00
Ryan C. Gordon
5bcf1d256b cocoa: Fixed incorrect autorelease, noted by static analysis. 2016-08-28 19:06:31 -04:00
Ryan C. Gordon
2da1ec8354 Merge audio capture work back into the mainline. 2016-08-28 13:36:13 -04:00
David Ludwig
5150eb361f WinRT: fixed bug where Win10 GameBar, when shown + hidden, might not restore a cursor's hidden state
The repro steps were this:
1. run an sdl2 winrt/uwp app, on Win10, v10.0.10586.0 or higher
2. hide the cursor, via a call to SDL_ShowCursor(0)
3. make the Win10 game bar appear, by pressing the Windows + G hotkey
4. observe that the mouse cursor appears, in order to interact with the
   game bar (this is expected behavior)
5. make the Win10 game bar disappear, either by pressing the Windows + G hotkey
   again, or clicking somewhere in the app

EXPECTED RESULT: cursor disappears, as game bar disappears

ACTUAL RESULT: cursor didn't always disappear
2016-08-20 13:46:45 -04:00
Ryan C. Gordon
d05ae1941c emscripten: send fake mouse events for touches, like other targets do.
(This really should be handled at the higher level and not in the individual
targets, but this fixes the immediate bug.)
2016-08-12 19:59:00 -04:00
Ryan C. Gordon
6f4bcd2498 audio: Renamed some internal driver symbols in various targets. 2016-08-11 22:22:09 -04:00
Philipp Wiesemann
82c94a3f79 PSP: Fixed memory leak if video init failed. 2016-08-03 22:32:20 +02:00
Philipp Wiesemann
9f97ee8a85 WinRT: Removed not needed SDL_zerop() after SDL_calloc().
SDL_calloc() already sets memory to zero.
2016-08-03 22:32:02 +02:00
Philipp Wiesemann
8d6cbdd235 Pandora: Fixed memory leak in video implementation. 2016-07-20 21:00:52 +02:00
Philipp Wiesemann
53ac57128b Pandora: Fixed compile warnings in video implementation (thanks, Bombo!).
Fixes Bugzilla #2734.
2016-07-20 21:00:36 +02:00
Philipp Wiesemann
562926cdda Pandora: Fixed SDL version in debug output. 2016-07-19 21:02:09 +02:00
Philipp Wiesemann
d478f26ef4 Updated comments in video implementations. 2016-07-18 22:03:47 +02:00
Philipp Wiesemann
c8cd5c559a Pandora: Fixed compile error in video implementation (thanks, Bombo!).
Partially fixes Bugzilla #2734.
2016-07-18 22:02:17 +02:00
Brandon Schaefer
eadb30cd6f MIR: Fix system cursors. Been broken since custom cursor support was added! 2016-07-13 07:07:08 -07:00
Philipp Wiesemann
495057b04b Android: Added new key codes from API 24. 2016-07-09 22:06:00 +02:00
Alex Szpakowski
d0bd0e4855 iOS: Fix an OpenGL ES error when rotating the device if MSAA is used (thanks Cole Campbell!)
Fixes bug #3378.
2016-07-02 13:38:31 -03:00
Philipp Wiesemann
6ec5e64056 Fixed freeing strings created by strdup() with SDL_free().
This only worked on platforms where SDL_free() wraps free().
2016-06-28 21:08:23 +02:00
Philipp Wiesemann
2f016cf88d Mac: Fixed crash if SDL_GetDisplayDPI() got NULL pointers for output parameters. 2016-06-26 21:08:57 +02:00
Brandon Schaefer
4a339a46ec MIR: Add better error handling for a failed connection 2016-06-08 08:01:21 -07:00
Brandon Schaefer
f0708fc9dd MIR: Support relative mouse mode 2016-06-07 09:01:23 -07:00
Alex Szpakowski
ea2f5e5930 Windows: Fix other window positions/sizes being changed when exiting exclusive fullscreen (bug #3315, thanks Simon Hug!) 2016-05-23 15:29:25 -03:00
Alex Szpakowski
0a4085a048 Mac: Fix a crash when SDL is compiled with SDL_MAC_NO_SANDBOX enabled, by increasing the stack size of the mouse tap thread back to OS X' default of 512 KB. 2016-05-21 12:09:23 -03:00
Alex Szpakowski
4a468739f8 Removed Mac OS 10.5 support (bug #3137). Also fixed a warning about deprecated Carbon code when using SDL_audio (bug #3127, thanks Dominik!) 2016-05-21 00:20:52 -03:00
Philipp Wiesemann
d4140ca473 Windows: Fixed missing error message if SDL_GetDisplayDPI() failed. 2016-05-20 22:15:58 +02:00
Philipp Wiesemann
d7b9d321fa X11: Fixed typos in error messages and source comments. 2016-05-20 22:15:28 +02:00
Philipp Wiesemann
81235118ab X11: Fixed missing error message if SDL_GetDisplayDPI() failed. 2016-05-20 22:14:40 +02:00
David Ludwig
441359bd5a WinRT: workaround a possible Windows bug, whereby hiding cursors, disables mouse-moved events
This workaround, unfortunately, requires that apps directly link to a set of
Win32-style cursor resource files (that contain a transparent cursor image).
Copies of suitable resource files are in src/core/winrt/, and should be
included directly in an app's MSVC project.

A rough explanation of this workaround/hack, and why it's needed (and
seemingly can't be done through programmatic means), is in this change's code.
2016-05-14 23:29:49 -04:00
Philipp Wiesemann
e964d00f64 X11: Fixed SDL_GL_GetSwapInterval() returning -1 if interval is unknown.
It should return 0 as a safe default if the interval can not be determined.
2016-05-11 21:11:12 +02:00
Philipp Wiesemann
748b05289c EGL: Fixed SDL_GL_GetSwapInterval() returning -1 on error.
It should return 0 as a safe default on errors. -1 is returned for late swaps.
2016-05-11 21:10:41 +02:00
Philipp Wiesemann
bf7a76155e Fixed missing error message if SDL_GetDisplayDPI() is unsupported. 2016-05-10 21:14:36 +02:00
David Ludwig
52fec6aff0 WinRT: allow on-screen keyboard to be shown via SDL APIs, Win10/UWP only 2016-05-07 21:41:59 -04:00
Alex Szpakowski
b15efce277 Cocoa mouse code: Replaced NSPointInRect with NSMouseInRect (thanks Eric Wasylishen!) Fixes bug #3312. 2016-05-01 21:41:30 -03:00
Alex Szpakowski
d383502657 Mac: replaced a deprecated CGSetLocalEventsSuppressionInterval call that I missed in commit 2f72bdfee9bb 2016-05-01 19:51:10 -03:00
Philipp Wiesemann
31cbb34ec9 Wayland: Removed not needed including and setting of errno.
One internal function was setting errno on error but it was not read afterwards.
2016-04-14 21:11:43 +02:00
David Ludwig
caf152def7 WinRT: build/link fix 2016-04-13 21:59:50 -04:00
Ryan C. Gordon
9b4db2b8aa Patched to compile on various platforms. 2016-04-12 18:11:36 -04:00
Ryan C. Gordon
c61675dc5d threads: Move SDL's own thread creation to a new internal API.
This allows us to set an explicit stack size (overriding the system default
and the global hint an app might have set), and remove all the macro salsa
for dealing with _beginthreadex and such, as internal threads always set those
to NULL anyhow.

I've taken some guesses on reasonable (and tiny!) stack sizes for our
internal threads, but some of these might turn out to be too small in
practice and need an increase. Most of them are simple functions, though.
2016-04-12 16:45:10 -04:00
Alex Szpakowski
34f095e098 iOS: Fixed SDL_GL_CreateContext crashing instead of returning null when a GLES3 context is requested on iOS 6 and older. 2016-04-10 22:07:10 -03:00
Alex Szpakowski
6cfa71a10e iOS: Also do the Dictation crash workaround before executing the animation callback. 2016-04-02 13:21:01 -03:00
Alex Szpakowski
88372277b7 Add a new hint SDL_HINT_MAC_MOUSE_FOCUS_CLICKTHROUGH, which allows mouse click events to occur when clicking to focus a window in Mac OS X.
Fixes bug #3300.
2016-04-02 11:54:05 -03:00
Alex Szpakowski
5520ed9cc2 iOS: Workaround for a crash after Dictation is used. 2016-04-01 19:18:50 -03:00
Philipp Wiesemann
12c78c5ca5 PSP: Fixed missing error message for unsupported SDL_CreateWindowFrom(). 2016-04-01 21:11:31 +02:00
Philipp Wiesemann
a9edc5137e Wayland: Fixed missing error message if creating a custom cursor failed.
SDL_GetError() returned no error message because it was written to stderr only.
2016-03-28 21:03:04 +02:00
Alex Szpakowski
08488e6d34 Mac: avoid calling CGSetLocalEventsSuppressionInterval, it was deprecated in OS X 10.6. 2016-03-20 15:35:34 -03:00
Philipp Wiesemann
35da130828 Wayland: Fixed crash if memory mapping failed while creating a custom cursor. 2016-03-16 22:09:39 +01:00
Philipp Wiesemann
fa77df4e91 Wayland: Fixed storing a theme cursor which is never used in video data. 2016-03-16 22:09:23 +01:00
Sam Lantinga
a29a925d7e Pick up new display mode information after a mode change (Windows only right now). 2016-03-11 08:33:47 -08:00
Philipp Wiesemann
19f18558ac Emscripten: Deactivated custom cursor support because it created system cursors. 2016-03-11 22:10:35 +01:00
Philipp Wiesemann
676041aa16 Wayland: Fixed drawing created cursors without transparency. 2016-03-11 22:10:15 +01:00
Philipp Wiesemann
167dd4a1fa Wayland: Fixed showing created cursors incorrectly before the first redraw. 2016-03-11 22:09:50 +01:00
Philipp Wiesemann
0c923fda0b WinRT: Removed dead code and fixed memory leak if allocation for driver failed. 2016-03-10 21:00:44 +01:00
Ryan C. Gordon
f647dfe874 x11: Fix a few more XMoveWindow() calls to adjust for border size.
Also, fix my inability to do basic math ('+' should have been '-').
2016-03-04 19:41:16 -05:00
Ryan C. Gordon
02f49fdb53 x11: Deal with window borders better.
- Cache the _NET_FRAME_EXTENTS data locally, so we don't have to query
the X server for them (instead, we update our cached data when PropertyNotify
events alert us to a change).

- Use our cached extents for X11_GetWindowBordersSize(), so it's a fast call.

- Window position was meant to refer to the client area, not the window
decorations, so adjust appropriately when getting/setting the position.
2016-03-04 18:47:19 -05:00
Philipp Wiesemann
05b6ca3c35 Raspberry: Fixed crash if memory allocation for cursor failed. 2016-03-03 20:12:51 +01:00
Philipp Wiesemann
be34036ed7 Wayland: Fixed fault in event handling which might have caused a crash someday.
Found by Cppcheck.
2016-03-02 20:25:23 +01:00
Philipp Wiesemann
ab8be04310 Wayland: Fixed crash if allocating memory for cursor failed.
Also added missing error message if first allocation failed.
2016-03-02 20:25:09 +01:00
Jonas ?dahl
3a22321d55 wayland: Add wl_proxy_marshal_constructor_versioned sym
wl_proxy_marshal_constructor_versioned was introduce in wayland-client 1.10.
2016-02-17 15:14:20 +08:00
Brandon Schaefer
90ef601d8c Mir: Do not use opengl to find the valid pixel format if we dont use opengl 2016-02-25 10:06:33 -08:00
Philipp Wiesemann
966aa3721b Mir: Replaced memcpy() with SDL_memcpy(). 2016-02-24 21:07:19 +01:00
Philipp Wiesemann
b4b36122a4 Mir: Fixed comment at conditional compilation macro. 2016-02-24 21:06:46 +01:00
Philipp Wiesemann
92209c260d Mir: Fixed crash if allocating memory for cursor failed. 2016-02-22 19:00:22 +01:00
bschaefer
3607d3b756 Fix API/ABI breakage in Mir 0.13/0.14. 2016-02-21 15:19:35 -08:00
Ryan C. Gordon
2436ca200d x11: better fix for the previous commit's fullscreen vs maximized issue. 2016-02-20 01:03:39 -05:00
Ryan C. Gordon
a4627c5eda x11: Don't mess with fullscreen vs maximized window state on unmapped windows. 2016-02-20 00:44:42 -05:00
Ryan C. Gordon
df4be2f200 x11/wayland/mir: Make the dynamic loading macro salsa a little less messy. 2016-02-18 23:27:58 -05:00
Ryan C. Gordon
0e2badc144 x11: Patched to compile with DEBUG_XEVENTS on C89 compilers. 2016-02-12 00:27:21 -05:00
Ryan C. Gordon
45407d0eac x11: Removed an assert.
This assert triggers when run under XMonad. It's safe to pass a zero here
anyhow, as this will still work "well enough" and the original
problem--GNOME printing a warning message--is still fixed because GNOME's
window manager gives us a chance to grab a non-zero user-time value before
this code is run.
2016-02-15 21:49:09 -05:00
Philipp Wiesemann
7da168db0a Fixed spaces in license comments. 2016-02-10 19:31:23 +01:00
Ryan C. Gordon
5ed63ae317 x11: Updated imKStoUCS.* to latest from x.org.
This was a version from XFree86 before now.  :)  Although not much has
changed.
2016-02-08 01:08:21 -05:00
Alex Szpakowski
8e7cd6b5da iOS: Implemented clipboard support. 2016-02-03 20:32:55 -04:00
Alex Szpakowski
325921789a x11: Fix AltGr generating an invalid keycode (bug #3244). Thanks Thomas! 2016-01-31 09:39:42 -04:00
Sam Lantinga
67f9fd2bc4 Fixed creating fullscreen windows on Steam Link 2016-01-22 13:12:16 -08:00
Sam Lantinga
e5d575b933 Expose the EGL display and window for Vivante SDL windows 2016-01-16 21:58:49 -08:00
Philipp Wiesemann
8d035b1aee Android: Added mouse initialization to reset state.
If the app is launched again then the shared object may be reused (on Android).
2016-01-12 22:23:00 +01:00
Philipp Wiesemann
1560351905 Android: Added mapping of mouse forward button and mouse back button. 2016-01-11 20:02:48 +01:00
Alex Szpakowski
87ea39be84 Removed dead code (caught by Clang's static analyzer). 2016-01-09 17:41:09 -04:00
Ryan C. Gordon
ed62033366 x11: make last mouse coords sane upon window entry (thanks, Cengiz!).
(and thanks to Cengiz for many of the previous Unreal-related
patches! They were generically credited to Epic Games, but a large
amount of that work was his contribution.)

Fixes Bugzilla #3067.
2016-01-07 19:58:00 -05:00
Ryan C. Gordon
416d046663 Mac: Implemented SDL_GetDisplayDPI (thanks, Kirill!).
Fixes Bugzilla #3223.
2016-01-07 14:02:37 -05:00
Ryan C. Gordon
49e47688b4 Patched to compile on iOS. 2016-01-05 05:38:55 -05:00
Ryan C. Gordon
eeb899999f Patched to compile. 2016-01-05 05:22:35 -05:00
Ryan C. Gordon
7605ccf68a Use SDL's stdinc functions instead of C runtime calls. 2016-01-05 02:29:16 -05:00
Ryan C. Gordon
dc532c70e8 Added SDL_WINDOWEVENT_TAKE_FOCUS.
This is for corner cases where a multi-window app is activated and wants to
make a decision about where focus should go.

This patch came from Unreal Engine 4's fork of SDL, compliments of Epic Games.
2016-01-05 02:27:50 -05:00
Ryan C. Gordon
aa4952fdef Added SDL_WINDOWEVENT_HIT_TEST.
This lets windows know when they are dropping a mouse event because their
hit test reported something other than SDL_HITTEST_NORMAL. It lets them know
exactly where in the event queue this happened.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2015-04-21 10:10:59 -04:00
Ryan C. Gordon
d4aedf9951 Added SDL_SetWindowModalFor().
This is currently only implemented for X11.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2015-04-21 09:45:58 -04:00
Ryan C. Gordon
e497e46515 Added SDL_SetWindowInputFocus().
This is currently only implemented for X11.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2016-01-05 02:28:56 -05:00
Ryan C. Gordon
3bdaf4c611 Added SDL_SetWindowOpacity() and SDL_GetWindowOpacity().
This is currently implemented for X11, Cocoa, Windows, and DirectFB.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2016-01-05 02:46:10 -05:00
Ryan C. Gordon
5696e88e6b Added SDL_GetWindowBordersSize().
This is currently only implemented for X11.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2016-01-05 02:29:06 -05:00
Ryan C. Gordon
f9af0c0376 x11: Put a matching window_group wmhint on every window created.
This is useful to the Window Manager, so it can know to associate multiple SDL
windows with a single app.
2016-01-05 02:27:26 -05:00
Ryan C. Gordon
8e855f2fbc Added SDL_DROPBEGIN and SDL_DROPCOMPLETE events, plus window IDs for drops.
This allows an app to know when a set of drops are coming in a grouping of
some sort (for example, a user selected multiple files and dropped them all
on the window with a single drag), and when that set is complete.

This also adds a window ID to the drop events, so the app can determine to
which window a given drop was delivered. For application-level drops (for
example, you launched an app by dropping a file on its icon), the window ID
will be zero.
2016-01-05 01:42:00 -05:00
Ryan C. Gordon
f2defe5e11 Added special window type flags.
Specifically: always on top, skip taskbar, tooltip, utility, and popup menu.

This is currently only implemented for X11.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2016-01-05 01:30:40 -05:00
Ryan C. Gordon
f9b7379341 Added SDL_DROPTEXT event, for dragging and dropping string data.
This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
2016-01-05 02:26:45 -05:00
Ryan C. Gordon
c3114975db Added SDL_GetDisplayUsableBounds(). 2016-01-04 23:52:40 -05:00
Ryan C. Gordon
8875a4014f x11: Optimize SDL_GetGlobalMouseState() a little.
Use XInput2 to mark the global mouse state as dirty so we don't have to make
a bunch of roundtrips to the X server when nothing has changed.
2015-04-22 16:50:48 -04:00
Ryan C. Gordon
14e007772a x11: window managers might mark windows as FULLSCREEN _and_ MAXIMIZED.
This patch came from Unreal Engine 4's fork of SDL, compliments of Epic Games.
2015-04-21 10:14:17 -04:00
Ryan C. Gordon
9a7527988a x11: Workaround window managers that mark fullscreen windows as maximized.
This patch came from Unreal Engine 4's fork of SDL, compliments of Epic Games.
2015-04-21 01:22:32 -04:00
Ryan C. Gordon
81209acbd8 x11: Let apps specify that video init should fail if XRandR is unavailable.
Notably: it sets the error string to inform you that your custom SDL is built
without xrandr support, which apparently has been a support issue for
Unreal Engine 4 developers.
2016-01-04 23:44:27 -05:00
Ryan C. Gordon
f9d478b6c3 x11: _NET_WM_PID needs a long, not a pid_t, I think. 2016-01-05 02:40:14 -05:00
Ryan C. Gordon
0c0ce2096c Updated comment: this is the correct way to do fullscreen on X11 now. 2015-04-21 10:19:20 -04:00
Ryan C. Gordon
e0e04542d0 Added a few FIXMEs. 2015-04-21 09:46:48 -04:00
Ryan C. Gordon
15bc7aea64 Mac: allows apps to use OpenGL on a slower, integrated GPU.
This is often useful for SDL apps that aren't meant to be games: the
integrated GPU starts up faster, uses less power, and is often more than
fast enough.

Note that even with this change, the app will still default to the more
powerful, discrete GPU if one is available; an app that prefers the integrated
GPU will still need the NSSupportsAutomaticGraphicsSwitching key properly
set in its Info.plist and Mac OS X 10.7 or later.

https://developer.apple.com/library/mac/qa/qa1734/_index.html
2016-01-04 22:00:04 -05:00
Ryan C. Gordon
7678b1db88 Patch to compile on C89 compilers. 2016-01-04 16:36:42 -05:00
Ryan C. Gordon
6df5e1e535 x11: Support _NET_WM_USER_TIME and give _NET_ACTIVE_WINDOW a valid timestamp.
Fixes Bugzilla #3056.
2016-01-04 16:25:27 -05:00
Ryan C. Gordon
fa8c83c1c1 Remove almost all instances of "volatile" keyword.
As Tiffany pointed out in Bugzilla, volatile is not useful for thread safety:

https://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/

Some of these volatiles didn't need to be, some were otherwise protected by
spinlocks or mutexes, and some got moved over to SDL_atomic_t data, etc.

Fixes Bugzilla #3220.
2016-01-03 06:50:50 -05:00
Sam Lantinga
68a3272852 Fixed sed error on Mac OS X and updated copyright on a few last files 2016-01-02 10:38:51 -08:00
Sam Lantinga
42065e785d Updated copyright to 2016 2016-01-02 10:10:34 -08:00
David Ludwig
44c0b2da87 WinRT: minor code-comment cleanups 2015-12-31 01:54:11 -05:00
David Ludwig
854cf7ac40 Fixed Bug 3215 - Win32: 'fullscreen' app doesn't always extend to top of screen 2015-12-30 12:44:13 -05:00
Philipp Wiesemann
c41feca5de Fixed a crash if creating accelerated renderer after accessing window surface.
Partially fixes Bugzilla #3196.
2015-12-29 19:13:56 +01:00
Ryan C. Gordon
18c7d6df21 XRandR: fixed primary output detection logic (thanks, "winterknight"!).
Fixes Bugzilla #3185.
2015-12-29 02:16:14 -05:00
Ryan C. Gordon
326b357804 Mac: don't ignore mouse clicks on the top pixel of a window (thanks, Joshua!).
Fixes Bugzilla #3190.
2015-12-29 01:09:58 -05:00
Ryan C. Gordon
51c1d69d13 Mac: Whoops, lost legit Caps lock keypress events. Fixed. 2015-12-28 13:30:58 -05:00
Ryan C. Gordon
fd6b435c6a Windows: resync num/caps lock when window is gaining focus. 2015-12-28 13:08:19 -05:00
Ryan C. Gordon
257b7af247 Sync up the caps/numlock state properly without sending key events.
Partially fixes Bugzilla #2736 and #3125.
2015-12-28 13:07:44 -05:00
Ryan C. Gordon
d3b323f89d Mac: Fix keyboard state if capslock was toggled while app wasn't in foreground. 2015-12-27 23:39:43 -05:00
Ryan C. Gordon
2befe01d39 Removed a tabstop. 2015-12-27 18:56:46 -05:00
Ryan C. Gordon
6a2e8a7a90 Win: make sure SDL keyboard state reflects system capslock state at startup. 2015-12-27 18:48:14 -05:00
Ryan C. Gordon
faed05850e Mac: make sure SDL keyboard state reflects system capslock state at startup. 2015-12-27 16:46:12 -05:00
David Ludwig
8281cc72ba WinRT: Fixed bug 3210, "alt-tab doesn't work correctly with full-screened, UWP (Win10 Store) apps" 2015-12-22 00:58:47 -05:00
Alex Szpakowski
4026980917 Cleaned up some code formatting. 2015-12-18 00:49:27 -04:00
Alex Szpakowski
a2235d7b29 Cocoa: Use NSTextInputClient instead of NSTextInput for text input handling. The latter was deprecated in OS X 10.6. 2015-12-10 22:17:22 -04:00
Alex Szpakowski
0c463d770b SDL_GL_GetAttribute: If a GL context isn't active, only return failure when the specified attribute needs an active GL context to be queried. 2015-12-10 20:25:34 -04:00
David Ludwig
976bc9a919 WinRT: build fix for Windows Phone 8.0 2015-12-06 18:48:46 -05:00
David Ludwig
2b48481879 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.0 apps 2015-12-06 18:42:30 -05:00
David Ludwig
a40d49aa1c WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps 2015-12-06 18:33:43 -05:00
David Ludwig
898054a179 WinRT: fixed a build error when compiling Windows 8.1 .dlls 2015-12-06 17:32:33 -05:00
David Ludwig
c8e3bfbf54 WinRT: removed an unused variable from DXGI-based display-detection code 2015-12-06 17:07:37 -05:00
David Ludwig
781455fd8b WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
DXGI fails to report any displays in at least one of the
"Windows App Certification Kit 10.0"'s tests for Store Apps.  This was
causing SDL's video initialization code to fail, when the suspect test
("Direct3D Feature Test") was run, as DXGI was unable to report a
display-output at adapter-index 0, output-index 0.

The workaround that is applied here attempts to detect this case, then
use a hopefully-reasonable alternative means to calculate at least one
display output.
2015-12-06 17:06:40 -05:00
Philipp Wiesemann
57f2f3baf3 Windows: Added missing NULL check after SDL_stack_alloc().
SDL_stack_alloc() might wrap SDL_malloc() which can return NULL.
2015-12-06 17:51:11 +01:00
Philipp Wiesemann
32147ba780 X11: Fixed memory leak when initializing multiple screens. 2015-12-05 17:08:07 +01:00
Alex Szpakowski
6a50d33385 Removed some debug prints. 2015-11-30 03:30:35 -04:00
Alex Szpakowski
9ddc6c3441 Mac: Fixed SDL_SetWindowFullscreen not restoring the window's original size when exiting a Space. 2015-11-30 03:30:07 -04:00
David Ludwig
25abce513d WinRT: added Win10/UWP (Universal Windows Platform) support
"UWP" appears to be Microsoft's new name for WinRT/Windows-Store APIs.

This set of changes updates SDL's WinRT backends to support the Win10 flavor
of WinRT.  It has been tested on Win10 on a desktop.  In theory, it should
also support Win10 on other devices (phone, Xbox One, etc.), however further
patches may be necessary.

This adds:
- a set of MSVC 2015 project files, for use in creating UWP apps
- modifications to various pieces of SDL, in order to compile via MSVC 2015 +
  the Win10 API set
- enables SDL_Window resizing and programmatic-fullscreen toggling, when using
  the WinRT backend
- WinRT README updates
2015-11-29 19:33:11 -05:00
David Ludwig
d07aa877d2 WinRT: minor code cleanup in window-creation code
Window flags can be detected on all WinRT platforms.
2015-11-26 11:15:43 -05:00
David Ludwig
a70fe9a53e WinRT: native windows are inherently resizable (in WinRT 8.x) 2015-11-26 11:09:50 -05:00
David Ludwig
7bd640d5da WinRT: bug-fix, fullscreen mode wasn't getting reported in Windows 8.0 apps
This bug did not occur in Windows 8.1 apps, just Windows 8.0.
2015-11-26 02:37:51 -05:00
David Ludwig
36090f576f WinRT: bug-fix, OpenGLES2 was failing to init, after recent windowing fixes
Some SDL_Window flags were getting lost inside WINRT_UpdateWindowFlags, namely
SDL_WINDOW_OPENGL.
2015-11-26 02:13:15 -05:00
David Ludwig
f520994455 WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees 2015-11-26 01:36:36 -05:00
David Ludwig
623898f70b WinRT: lots of display and windowing related fixes
This change-set fixes a lot of windowing related bugs, especially with
regards to Windows 8.x apps running on Windows 10 (which was the driver for
this work).  The primary fixes include:
* listed display modes were wrong, especially when launching apps into a
  non-fullscreen space
* reported window flags were often wrong, especially on Windows 10
* fullscreen/windowed mode switches weren't failing (they are not
  programmatically possible in Win 8.x apps).
2015-11-26 00:41:39 -05:00
Ryan C. Gordon
5224dfcc9a X11: Let XRandR respect multiple screens (DISPLAY=:0.0 vs :0.1, etc). 2015-11-17 12:15:35 -05:00
Alex Szpakowski
998a54f9c5 Mac: Fix a warning about implicit declaration of SDL_SendKeymapChangedEvent (bug #3167.) 2015-11-14 04:24:39 -04:00
Alex Szpakowski
9c51c4a639 Mac: Detect the d-pad and pause buttons on Steelseries MFi gamepads (bug #3124.) 2015-11-12 22:44:32 -04:00
Alex Szpakowski
7267835842 iOS: Fixed crashes when rotating the screen after destroying a window. 2015-11-12 20:58:11 -04:00
Sam Lantinga
5103ae9fd6 one last SDL fix: restore menu bar if we destroy a fullscreen window without transitioning it back to a non-fullscreen window first 2015-11-09 08:55:07 -08:00
Sam Lantinga
ebfb2ecb68 don't toggle SDL fullscreen state on OSX if we're destroying the window 2015-11-09 08:55:01 -08:00
Sam Lantinga
eeddb7c534 more SDL fullscreen state tracking fixes, don't update fullscreen flags on failure to change fullscreen state 2015-11-09 08:54:56 -08:00
Sam Lantinga
792354d6f0 SDL OSX implementation must account for the fact that going fullscreen can fail. improve the logic around retrying, make a few attempts before failing. 2015-11-09 08:54:49 -08:00
Sam Lantinga
2d884656c4 add hacky support for failed fullscreen transitions. SDL doesn't have the concept of a fullscreen transition that failed. if the user is actively changing spaces while the app goes fullscreen, it fails to go fullscreen; now it will just try again instead of hanging around with the wrong window styles. 2015-11-09 08:54:42 -08:00
Sam Lantinga
38edc1779a Add SDL_HINT_VIDEO_X11_NET_WM_PING to allow disabling
_NET_WM_PING protocol handling in CreateWindow if
desired.
2015-10-27 11:18:04 -07:00
Sam Lantinga
2b0140a91f Add a new SDL_KEYMAPCHANGED SDL event to abstract notification of keyboard layout or input language changes. 2015-10-27 11:17:32 -07:00
Alex Szpakowski
f8824cb99b Mac: Fix returning to the window's Space in OS X 10.11+ when SDL_WINDOW_FULLSCREEN_DESKTOP is used (bug #3152.) 2015-10-23 03:37:53 -03:00
Philipp Wiesemann
86711041f2 Android: Added new key codes without mapping. 2015-10-07 21:16:18 +02:00
Sam Lantinga
5b1741132f Converted tabs to spaces for SDL style 2015-10-06 21:40:50 -07:00
Sam Lantinga
9bd640e1a0 Fixed sending a size event while setting up a window (fix for DOTA 2 on Source 2) 2015-10-06 21:16:21 -07:00
Ryan C. Gordon
c5e68d68e7 Mac: Reset display if going from fullscreen to a fullscreen Space or vice-versa.
Otherwise, bad things happen.
2015-10-06 00:10:54 -04:00
Sam Lantinga
7bc72eaf84 Fixed forcing the window size when creating a non-resizable window on Windows. 2015-10-01 11:21:06 -07:00
Alex Szpakowski
ab2a350033 iOS: show message boxes using the new UIAlertController APIs when supported, rather than the deprecated UIAlertView.
UIAlertController is also supported on tvOS, whereas UIAlertView is not.
2015-09-25 15:17:20 -03:00
Alex Szpakowski
ecfdb10cfa iOS SDL_GL_CreateContext: Clamp the multisample sample count when the requested value is too high, rather than failing to create the context.
This matches the SDL_GL_CreateContext behavior in OS X.
2015-09-15 00:25:07 -03:00
Sam Lantinga
08ce12c4e3 Fixed divide by zero if the application has run out of GDI handles and is trying to show an error dialog 2015-09-14 11:15:25 -07:00
Alex Szpakowski
82c8825cb5 iOS: Added support for force-touch on capable devices. 2015-09-09 19:08:52 -03:00
Alex Szpakowski
6a32ca7a39 Mac: Fixed SDL_SetWindowSize to set the size of the content area of the window, rather than the total size including decorations. 2015-09-09 13:55:11 -03:00
Philipp Wiesemann
212e99633b PSP: Replaced use of SDLKey with SDL_Keycode. 2015-08-24 22:35:01 +02:00
Philipp Wiesemann
991feafa09 PSP: Fixed a syntax error.
Found by Cppcheck.
2015-08-24 22:31:36 +02:00
Ryan C. Gordon
8145760314 X11: Handle keyboard layout changing during app's run on Ubuntu 12.04 (etc).
Fixes Bugzilla #3050 (in addition to Jason Wyatt's patch, prior to this).
2015-08-15 00:36:39 -04:00
Ryan C. Gordon
0d8c3a0b76 Patched to compile. 2015-08-14 23:38:40 -04:00
Ryan C. Gordon
0cf81fbdf9 Minor coding convention fix. 2015-08-14 23:30:46 -04:00
Jason Wyatt
fb37956d9b Supply current group when translating X11 Keycodes to Keysyms. 2015-08-14 16:23:31 +01:00
Ryan C. Gordon
9e2b90e2a4 Cocoa: Keep the window's screen position through SDL_SetWindowSize().
The Y coordinate is flipped in Cocoa, so if you change the height, the window
will move and maybe clip against the screen edge if you don't adjust its Y
coordinate to match.

Possibly fixes Bugzilla #3066.
2015-08-14 01:20:41 -04:00
Ryan C. Gordon
f2f8e6f5ef X11: only send mouse button up events if not a mousewheel "button"
(Brackets in the wrong place, my bad!)
2015-08-13 21:40:32 -04:00
Ryan C. Gordon
874bf86504 X11: Simplified mousewheel event handling.
Under load, this would race and report an incorrect mouse button event instead
of a wheel event.

Fixes Bugzilla #2987.
2015-08-13 17:40:28 -04:00
Ryan C. Gordon
da6f2221e3 X11: isConfigureNotify() isn't used at the moment, comment it out. 2015-08-13 17:37:09 -04:00
Ryan C. Gordon
8a1fd98261 X11: don't block on a ConfigureNotify event during SDL_SetWindowBordered().
Unity's window manager is (legitimately, since it moves the client window's
position) sending one, and SDL was incorrectly trying to mask it out. Other
window managers (KWin, apparently) don't move the window and would hang here
indefinitely.

Fixes Bugzilla #3052.
2015-08-13 14:56:16 -04:00
Ryan C. Gordon
c67213f331 X11: Fixed XRandR display detection.
Previously this only worked on X11 when Xinerama was carrying the weight.

Fixes Bugzilla #3062.
2015-08-07 01:02:35 -04:00
Ryan C. Gordon
ca46804210 X11: Fixed a memory leak when adding duplicate display modes. 2015-08-07 00:59:31 -04:00
andrewb
a702c338f0 Add SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 to SDL so that Reborn can keep running through Alt+F4. 2015-08-03 11:37:03 -07:00
Alex Szpakowski
5a3cc7f580 EGL: Added support for sRGB system framebuffers, when the required EGL extension is present. 2015-08-01 15:16:57 -03:00
Philipp Wiesemann
c57f409fe8 Mac: Fixed check for SDL_HINT_MAC_BACKGROUND_APP. 2015-07-31 20:16:58 +02:00
Alfred Reynolds
0aa2a6df2c SDL
- fix hint check, we want or not and
2015-07-31 09:16:21 -07:00
Sam Lantinga
e93f90ae90 Trivial integer truncation warning fixes. 2015-07-30 10:01:04 -07:00
Alfred Reynolds
628d8edb95 SDL
- add a new SDL_HINT_MAC_BACKGROUND_APP hint, when set or set to 1 don't force the app to be foreground
2015-07-29 17:19:15 -07:00
Alfred Reynolds
5aaf81c84e Fix up monitor enumeration for Windows 8.1 case. 2015-07-29 17:19:13 -07:00
Alfred Reynolds
e09d95c36a Fix SDL_GetWindowPosition to be properly monitor-aware and return the monitor x,y when fullscreened. 2015-07-29 17:19:11 -07:00
Alfred Reynolds
dc2e9ba13b Fix build. 2015-07-29 17:19:04 -07:00
Alfred Reynolds
51c72e10f7 Add X11 implementation of SDL_GetDisplayDPI. 2015-07-29 17:19:02 -07:00
Alfred Reynolds
61c7415071 Add SDL_GetDisplayDPI routine and implement for Windows. 2015-07-29 17:18:56 -07:00
Ryan C. Gordon
f5cf86769a x11: Catch fatal X errors when calling glXMakeCurrent().
In extremely rare cases, probably due to misconfigured drivers, one might
see this happen, and rather than terminate the process, we try to recover
by reporting an error to the app.

Fixes Bugzilla #3068.
2015-07-28 00:12:50 -04:00
Alex Szpakowski
c344b734f4 iOS: Avoid generating an OpenGL error (but still fail to create the context) if the specified MSAA sample count is unsupported. 2015-07-19 19:56:16 -03:00
Alex Szpakowski
6ea942dae3 Added MSAA support for OpenGL ES contexts on iOS.
Note that extra steps must be taken when using glReadPixels to read the contents of the main OpenGL ES framebuffer on iOS, if multisampling is used. See the OpenGL ES section of README-ios.md for details.
2015-07-19 19:44:40 -03:00
Ryan C. Gordon
9d3d643742 Patched to compile on Raspberry Pi. 2015-07-18 00:03:34 -04:00
Ryan C. Gordon
e346f14277 SDL_WarpMouseGlobal() should return non-void.
There are platforms it isn't implemented on (and currently can't be
implemented on!), and there's currently no way for an app to know this.

This shouldn't break ABI on apps that moved to a revision between 2.0.3 and
2.0.4.
2015-07-17 21:03:58 -04:00
Ryan C. Gordon
27055ea0ad X11: center parentless message boxes on the primary display if possible.
This relies on a successful SDL_Init(SDL_INIT_VIDEO) to work, since it's
silly to reproduce all the Xinerama/XRandR code in the message box parts. If
X11 is available but SDL hasn't been initialized, the message box will center
in the primary screen, which will be positioned weirdly on multi-head setups,
but this should fix the most significant common case.
2015-07-14 23:46:35 -04:00
Ryan C. Gordon
0c19501eeb x11: Patched to compile on systems without the Xutf8LookupString() function. 2015-07-11 00:59:56 -04:00
Sam Lantinga
396b3b8992 Better fix for bug 3048, don't crash if the window title is NULL 2015-07-05 15:45:48 -07:00
David Ludwig
d0ba0c1d8a Fixed bug 3048, "Crashes in Cocoa_SetWindowTitle" 2015-07-04 21:04:49 -04:00
Ryan C. Gordon
65a1a3e7e9 Cocoa: support drag-and-drop of multiple objects. 2015-07-04 14:09:09 -04:00
Sam Lantinga
b5c43a88b4 Fixed style 2015-07-03 09:18:14 -07:00
Sam Lantinga
35c4468f9d commit a7d7af2a419b453188ffe87386455fc26c1306fa
Author: Benoit Pierre <benoit.pierre@gmail.com>
Date:   Fri Jul 3 02:17:10 2015 +0200

    fix 14dd48ae5bc43b61b2a0dd0b3177d22edec707ef regression

    The window manager detection code in X11_HasWindowManager does not work
    with Awesome (http://awesome.naquadah.org/). Remove it, and reuse the
    result of the more correct checks in X11_CheckWindowManager.
2015-07-03 09:17:24 -07:00
Sam Lantinga
e8954d5d8c Hack to fix missing window decorations after toggling fullscreen mode in Mac OS X 10.10 2015-06-30 19:30:02 -07:00
Ryan C. Gordon
1e3c28ac64 X11: Added a test for a weird X11 error we get with Xinerama, rarely. 2015-06-30 15:00:48 -04:00
Ryan C. Gordon
20ec137763 X11: Call XRefreshKeyboardMapping() when we get various MappingNotify events.
According to the Xlib docs, you need to do this or Xlib's internal state gets
out of sync.
2015-06-30 14:41:17 -04:00
Ryan C. Gordon
acdb494ffd X11: Don't ignore keyboard mapping changes.
MappingNotify events don't have a window associated with them, so SDL was
dropping these before the point where we would have handled them.
2015-06-30 14:39:39 -04:00
Sam Lantinga
f1b7a8434f Fixed compiling if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM is not defined 2015-06-25 07:17:08 -07:00
Sam Lantinga
3a08b46336 Fixed bug 2834 - Patch to support dead keys on Windows
Elise Maurer

When inputting text, dead-keys are currently not handled correctly on Windows with the latest SDL2 tip as well as the 2.0.3 release.

Using a French AZERTY keyboard, when I type the `^` key followed by `e` key to compose the `` character, I erroneously get two SDL_TEXTINPUT events, one with the `^` character and one with the `e` character.

I've looked at the history for SDL_windowsevents.c and there's been some back-and-forth with several methods for handling text input:

  * r8142 removed any handling of WM_CHAR because keyboard input was being handled through WM_KEYDOWN along with ToUnicode since r7645.

  * But using ToUnicode actually breaks dead-keys (googling for "ToUnicode dead keys" reports many horror stories of people trying to work around that and failing).

  * It seems like r7645 introduced a double-fix: it fixed WM_CHAR to properly handle Unicode, and also (unnecessarily?) added text input handling to WM_KEYDOWN. Later, r8142 removed the WM_CHAR stuff instead of the WM_KEYDOWN stuff.

The attached patch restores handling of text input through WM_CHAR and removes it from WM_KEYDOWN. I've tested it with French, English and Russian layouts and it seems to do its job. Obviously, with such matters, it's still a risky change.
2015-06-25 11:49:48 -07:00
Alfred Reynolds
e4e4e1b82a SDL
- do the scancode to keyboard code lookup for the grave key, so that we can show users the correct keyface for the key, rather than forcing it to "`".  Note that if a game is using SDLK_* for its KB mapping then after this change on some keyboards the top left key will no longer be mapped correctly with the old data.

CR: SamL
2015-06-24 10:56:37 -07:00
Sam Lantinga
b7aa856c8f Fixed bug 3030 - SDL_RecreateWindow fails to restore title, icon, etc.
Adam M.

It loses the title and icon when window recreation fails. For instance, this may happen when trying to create an OpenGL ES window on a system that doesn't support it. But at that point, the title and icon have already been lost.
2015-06-22 23:36:06 -07:00
Philipp Wiesemann
8cea1b986e Windows: Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 19:37:37 +02:00
Philipp Wiesemann
72590685c0 Backed out changeset 4ad56dbf4a6f 2015-06-21 19:36:35 +02:00
Philipp Wiesemann
0e45984fa0 Fixed crash if initialization of EGL failed but was tried again later.
The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly
uninitialized data structure if loading the library first failed. A later try to
use EGL then skipped initialization and assumed it was previously successful
because the data structure now already existed. This led to at least one crash
in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was
dereferenced to make a call to eglBindAPI().
2015-06-21 17:33:46 +02:00