Commit Graph

139 Commits (7738bd9b55c3bc88e0dc4d422aef02570de33b93)

Author SHA1 Message Date
Philipp Wiesemann 7738bd9b55 AIX: Fixed nearly impossible file descriptor leak. 2015-06-04 17:52:51 +02:00
Philipp Wiesemann eab076a7ee Fixed not needed calculation in test program. 2015-06-04 17:52:27 +02:00
Sam Lantinga 38549a7bba Fixed bug 2625 - Direct3D9 with SDL_TEXTUREACCESS_TARGET textures causes an application crash
Roberto

I have debugged the code checking the function calls when Direct3D is the renderer, remember that with software and OpenGL renderers, this issue is not happening.

- Create the texture:
SDL_Texture *pTex = SDL_CreateTexture(pRenderer, iFormat, SDL_TEXTUREACCESS_TARGET, pSurf->w, pSurf->h);

- Update the texture:
SDL_UpdateTexture(pTex, NULL, pSurf->pixels, pSurf->pitch);
  SDL_render.c, SDL_UpdateTexture(): return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
    SDL_render_d3d.c, D3D_UpdateTexture(): if (D3D_UpdateTextureRep(data->device, &texturedata->texture, texture->format, rect->x, rect->y, rect->w, rect->h, pixels, pitch) < 0) {
      SDL_render_d3d.c, D3D_UpdateTextureRep(): if (D3D_CreateStagingTexture(device, texture) < 0) {
        SDL_render_d3d.c, D3D_CreateStagingTexture(): result = IDirect3DDevice9_CreateTexture(..., D3DPOOL_SYSTEMMEM, ...) --> FAIL! with INVALIDCALL code

After checking a bit the Microsoft documentation, I found this:

D3DUSAGE_RENDERTARGET can only be used with D3DPOOL_DEFAULT. (https://msdn.microsoft.com/en-us/library/windows/desktop/bb172625%28v=vs.85%29.aspx)

The call that fails, is using D3DUSAGE_RENDERTARGET with D3DPOOL_SYSTEMMEM which is unsupported, hence the INVALIDCALL return code.
2015-06-04 00:56:11 -07:00
Ryan C. Gordon ba1263cd1d Backout commit 83034612a883
This caused 8-bit modes to be chosen on older OS X releases.

Fixes Bugzilla #3000.
2015-06-04 02:12:06 -04:00
Ryan C. Gordon e8b376c9d5 Linux: Implemented sysfs-based version of SDL_GetPowerInfo().
Fixes Bugzilla #2938.
2015-06-03 13:11:28 -07:00
Ryan C. Gordon 36ecb766c8 Changed a static function to match the naming scheme of rest of source file. 2015-06-01 01:25:22 -04:00
Jason Wyatt cad269bc27 Also set the _NET_WM_NAME. Window managers supporting this will take this value over the value set by XStoreName. This explicitly supports UTF-8 encoding, which fixes corrupt UTF-8 titles in KDE. 2015-05-05 09:16:12 +01:00
Ryan C. Gordon 52df7f5b8f testmessage: Try Unicode chars in the title, too. 2015-05-31 23:53:10 -04:00
Ryan C. Gordon 05e78b3f49 X11: search all XI2 touch devices, not just masters (thanks, Volumetic!).
Otherwise, you won't find touch devices that aren't currently assigned to a
system cursor.
2015-05-31 22:59:59 -04:00
Ryan C. Gordon 554b2b0e36 X11: Fixed message boxes not responding to click on titlebar close button.
The window needs to catch ClientMessage events for one specific window, but
XNextEvent() catches everything, and XWindowEvent doesn't catch ClientMessage,
so we need predicate procedure and XIfEvent() here.

Fixes Bugzilla #2980.
2015-05-31 22:48:26 -04:00
Ryan C. Gordon cb60f2dfc2 testmessage.c should report when message boxes were closed. 2015-05-31 22:27:46 -04:00
Ryan C. Gordon 8bfc622b18 Fixed memory leaks in testfilesystem.c (thanks, Nitz!).
Fixes Bugzilla #2991.
2015-05-31 21:50:50 -04:00
Ryan C. Gordon 7619ad3430 Cocoa: deal with mouse focus when warping the cursor from outside a window.
Otherwise, you might not get appropriate mouse enter/leave events.

Better fix for Bugzilla #2984.
2015-05-31 21:43:36 -04:00
Ryan C. Gordon 5b2ff76c12 Cocoa: send a MOUSEMOTION event when warping cursor from outside the window.
Fixes Bugzilla #2984.
2015-05-31 13:58:36 -04:00
Philipp Wiesemann dbfd4fdd22 Android: Added missing space in three log messages.
Also fixed a typo and changed tag string to constant.
2015-05-31 19:23:16 +02:00
Philipp Wiesemann 551fbf7bea Android: Changed two unknown keys to be consistent with Windows and X11 mapping. 2015-05-31 19:22:42 +02:00
Ryan C. Gordon 80614b27e4 Fixed swizzle of SDL_FillRect() on 24-bit surface (thanks, "nagydavid91"!).
Fixes Bugzilla #2986.
2015-05-31 11:38:10 -04:00
Ryan C. Gordon 1899dfb041 Fixed SDL_ISPIXELFORMAT_ALPHA to check pixel orders that match pixel type.
Otherwise, SDL_PIXELFORMAT_BGR24 is reported as having alpha, because
 its SDL_ARRAYORDER_BGR pixel order uses the same integer value as
 SDL_PACKEDORDER_RGBA, since we weren't checking the pixel type to
 differentiate.

Fixes Bugzilla #2977.
2015-05-31 01:45:20 -04:00
Ryan C. Gordon e58a5c43c4 X11: Fixed high mouse buttons mappings and horizontal wheels (thanks, Daniel!).
Fixes Bugzilla #2472.
2015-05-31 00:58:43 -04:00
Ryan C. Gordon 870df8adab Cocoa: ignore mouseDown events in a window's titlebar.
These events accidentally slipping in sometimes appears to be a bug (or
maybe new behavior) in 10.10, as previous versions of Mac OS X don't appear
to ever trigger this.

Thanks to Paulo Marques for pointing out the fix on the SDL mailing list!

Fixes Bugzilla #2842 (again).
2015-05-31 00:50:30 -04:00
Philipp Wiesemann 8c9571a26b Fixed typo in header file documentation comment. 2015-05-29 22:24:38 +02:00
Ryan C. Gordon f001a00b08 X11: Force the window focus during ShowWindow if there's no window manager.
Fixes Bugzilla #2997.
2015-05-29 15:21:47 -04:00
Sam Lantinga c888183728 Improved fix for bug 2096 - Mapping from scancode to keycode doesn't work for remapped modifier keys
Zack Middleton

The change to the keymap to use SDL_SCANCODE_TO_KEYCODE in SDL_x11keyboard.c causes all SDL scancodes without a Usc4 character to be XOR'd with SDLK_SCANCODE_MASK, but not all key code are suppose to be (as seen in include/SDL_keycodes.h). SDLK_BACKSPACE is not 0x4000002A.

I think the full list of keys affected are return, escape, backspace, tab, and delete.
2015-05-28 19:06:07 -07:00
Sam Lantinga 45f967be8f Fixed building test programs on the iOS simulator 2015-05-28 18:57:57 -07:00
Sam Lantinga da1909755b Fixed clip rectangle calculation when there is a viewport offset 2015-05-28 18:57:10 -07:00
Sam Lantinga 6e67c949c1 Fixed bug 2054 - SDL_GetError: "Unknown touch device"
Volumetric

The "Unknown touch device" message appears because the initial touch device setup loop uses SDL_GetTouch() as a guard for calling SDL_AddTouch().  SDL_GetTouch() will always report "Unknown touch device" since the device hasn't been added yet.  The SDL_GetTouch() call is unnecessary since SDL_AddTouch() calls SDL_GetTouchIndex() to verify that the device hasn't been added yet, and SDL_GetTouchIndex() has the benefit of not reporting an error for a device it can't find.
2015-05-28 12:55:01 -07:00
Sam Lantinga 32d6dcdb47 Fixed bug 2096 - Mapping from scancode to keycode doesn't work for remapped modifier keys
Jacob Lee

If a user has a non-standard keyboard mapping -- say, their caps lock key has been mapped to Ctrl -- then SDL_GetModState() is no longer accurate: it only considers the unmapped keys. This is a regression from SDL 1.2.

I think there are two parts to this bug: first, GetModState should use keycodes, rather than scancodes, which is easy enough.

Unfortunately, on my system, SDL considers Caps Lock, even when mapped as Control, to be both SDL_SCANCODE_CAPSLOCK and SDLK_CAPSLOCK. The output from checkkeys for it is:

INFO: Key pressed :  scancode 57 = CapsLock, keycode 0x40000039 = CapsLock  modifiers: CAPS

Whereas the output for xev is:

KeyPress event, serial 41, synthetic NO, window 0x4a00001,
    root 0x9a, subw 0x0, time 40218333, (144,177), root:(1458,222),
    state 0x10, keycode 66 (keysym 0xffe3, Control_L), same_screen YES,
    XKeysymToKeycode returns keycode: 37
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

I think the problem is that X11_UpdateKeymap in SDL_x11keyboard.c only builds a mapping for keycodes associated with a Unicode character (anything where X11_KeyCodeToUcs returns a value). In the case of caps lock, SDL scancode 57 becomes x11 keycode 66, which becomes x11 keysym 65507(Control_L), which does not have a unicode value.

To fix this, I suspect that SDL needs a mapping of the rest of the x11 keysyms to their corresponding SDL key codes.
2015-05-28 12:48:20 -07:00
Ryan C. Gordon 4d1626d042 Windows SDL_GetBasePath: free string on failure. 2015-05-28 15:36:27 -04:00
Ryan C. Gordon aa43bee434 Windows GetBasePath: fixed reallocation code. 2015-05-28 15:32:45 -04:00
Ryan C. Gordon 566316e052 Windows SDL_GetBasePath: Fixed wrong variable when growing the buffer size. 2015-05-28 15:29:43 -04:00
Sam Lantinga f9abea2061 Fixed bug 2210 - Initializing Video produces unnecessary errors
hiduei

Overview:
Initializing the Video Subsystem causes many errors though everything works as it should.

Steps to Reproduce:
1) Set Loglevel to SDL_LOG_PRIORITY_ERROR

2) Initialize the Video Subsystem (SDL_Init(SDL_INIT_VIDEO))

Actual Results:
Many errors (see attachment) are printed on stderr, then the application continues as expected.

Expected Results:
The errors should have been warnings at most.
2015-05-28 12:31:25 -07:00
Sam Lantinga 6a3ad8a998 Fixed bug 2367 - Bad mouse motion coordinates with two windows where one has changed logical size
Andreas Ragnerstam

I have two windows where one has a renderer where the logical size has been changed with SDL_RenderSetLogicalSize. When I get SDL_MOUSEMOTION events belonging to the non-scaled window these will have been scaled with the factor of the scaled window, which is not expected.

Adding some printf debugging to SDL_RendererEventWatch of SDL_render.c, where (event->type == SDL_MOUSEMOTION), I found that for every mouse motion SDL_RendererEventWatch is called twice and the event->motion.x and event.motion.y are set twice for the event, once for each renderer where only the last one set will be saved to the event struct. This will work fine if both renderers have the same scale, but otherwise the motion coordinates will be scaled for the renderer belonging to another window than the mouse was moved in.

I guess one solution would be to check that window == renderer->window for SDL_MOUSEMOTION events, similar to what is done for when SDL_WINDOWEVENT events.

I get the same error on both X11 and Windows.
The same problem also exists for SDL_MOUSEBUTTONDOWN and SDL_MOUSEBUTTONUP events.
2015-05-28 12:18:05 -07:00
Sam Lantinga bccc2ad09e Fixed compiling and tested on Windows 2015-05-28 12:06:48 -07:00
Ryan C. Gordon 6d1ad3847a Windows GetBasePath should use GetModuleFileNameExW() and check for overflows.
Apparently you might get strange paths from GetModuleFileName(), such as
short path names or UNC filenames, so this avoids that problem. Since you have
to tapdance with linking different libraries and defining macros depending on
what Windows you plan to target, we dynamically load the API we need, which
works on all versions of Windows (on Win7, it'll load a compatibility wrapper
for the newer API location).

What a mess.

This also now does the right thing if there isn't enough space to store the
path, looping with a larger allocated buffer each try.

Fixes Bugzilla #2435.
2015-05-28 01:54:52 -04:00
Ryan C. Gordon 75702ffebc Make sure we have the vsscanf() prototype (thanks, Ozkan!).
issue seen with glibc-2.8.

Fixes Bugzilla #2721.
2015-05-28 14:34:38 -04:00
Sam Lantinga cb24f4de94 Fixed bug 2772 - SDL2 doesn't handle X KeymapNotify events
Jason Wyatt

Currently the keymapnotify event handling is commented out as FIXME in SDL_x11events.c (It looks like this may have functioned SDL1.2).

Not handling this event means that if a window manager shortcut such as ALT+SPACE is used, SDL will send an ALT key down signal, but not an up signal. Also querying SDL about the key state, it believes the ALT key remains pressed.
X passes the events keypress (alt), ?focusout?, ?focusin?, keymapnotify.
2015-05-28 10:44:46 -07:00
David Ludwig a6df21cd00 Partial fix for bug 2726 - Win32 'mouse' events not applying 'SDL_TOUCH_MOUSEID'
This is a Win32-specific fix for bug 2726.  A WinRT fix for this bug was applied
separately, via https://hg.libsdl.org/SDL/rev/91f56dcad879

This fix applies SDL_TOUCH_MOUSEID to 'mouse' events coming from touch devices,
but only when relative-mouse-mode is turned OFF.  This bug is still present
when relative-mouse-mode is ON, however Microsoft does not provide documentation
on whether or not those input events (which come from WM_INPUT) can be
identified as touch-specific or not.  Unofficially, that data might be available
(via GetMessageExtraInfo()), however this patch only uses MS-documented APIs.
2014-12-20 11:45:39 -05:00
Sam Lantinga 719bb6fcee Fixed X11 build, added code to print initial modifiers to checkkeys 2015-05-28 09:52:48 -07:00
Sam Lantinga 0694baf260 Fixed bug 2736 - X11 doesn't set KMOD_NUM and KMOD_CAPS to system state
Zack Middleton

Using X11 (on Debian Wheezy), SDL_GetModState() & KMOD_NUM and KMOD_CAPS are not set to system state (numlock/capslock LEDs). Pressing numlock or capslock toggles the mod state, though if num/caps lock is enabled before starting the program it's still reversed from system state. This makes getting KMOD_NUM and KMOD_CAPS in programs unreliable. This can be seen using the checkkeys test program.

The function that appears to have handle this in SDL 1.2 is X11_SetKeyboardState. The function call is commented out with "FIXME:" in SDL 2.

Using Windows backend through WINE; on first key press if numlock and/or capslock is enabled on system, numlock/capslock SDL_SendKeyboardKey is run and toggles KMOD_NUM/KMOD_CAPS to the correct state. On X11 this does not happen.

The attached patch makes X11 backend set keyboard state on window focus if no window was previously focused. It sets all keys to system up/down state and toggles KMOD_NUM/KMOD_CAPS via SDL_SendKeyboardKey to match system if needed. The patch is based on SDL 1.2's X11_SetKeyboardState.
2015-05-28 09:33:47 -07:00
Sam Lantinga 779d403563 Fixed Windows build 2015-05-28 08:51:59 -07:00
Sam Lantinga 0669a224f5 Fixed bug 2860 - SetProp must be paired with RemoveProp especially for properties added to external windows
Coriiander

Upon creating a window, a window property is added to it through the Win32-function "SetProp". This is done in the SDL-function "SetupWindowData" in file "src\video\windows\SDL_windowswindow.c".

Whenever you call "SetProp" to add a property to a Win32-window, you should also call the Win32-function "RemoveProp" to remove it before destroying that Win32-window.

While you might think that it's ok and that Windows will clean up nicely itself, it is not ok. It is against all Win32-API guidelines and is mostlikely a leak. Especially on external windows (CreateWindowFrom) you want to have things done right, not messy and leaky, affecting some other module. Even if SDL gets shutdown entirely that external window will now forever still have the "SDL_WindowData" prop attached to it.
2015-05-28 08:41:07 -07:00
Ryan C. Gordon 84ce000670 I think this will be the time... 2015-05-28 01:27:24 -04:00
Ryan C. Gordon 7964f3adb2 Still trying to get this to compile... 2015-05-28 01:22:14 -04:00
Ryan C. Gordon cae4fd7fb2 More patching to compile... 2015-05-28 01:16:55 -04:00
Ryan C. Gordon e90f87bab0 Another attempt to get this to compile. 2015-05-28 01:08:33 -04:00
Ryan C. Gordon 4add16943e Patched to compile on MingW.
(I think!)
2015-05-28 01:02:03 -04:00
Ryan C. Gordon 58447b24c1 Move tests from SDL_config higher up in Windows joystick/haptic code.
Fixes Bugzilla #2932.
2015-05-28 00:54:52 -04:00
Ryan C. Gordon 2a75782553 X11: Add Xdbe support to message boxes (thanks, Melker!).
Without this, message boxes with a lot of text will noticibly flicker as
you mouse over buttons.

Fixes Bugzilla #2343.
2015-05-28 00:30:21 -04:00
Ryan C. Gordon bea1854cac Patched to compile on C89 compilers. 2015-05-27 19:00:56 -04:00
Ryan C. Gordon 9c343681c4 Wayland: Avoid NULL dereference after window destruction (thanks, "x414e54"!).
Fixes Bugzilla #2934.
2015-05-27 18:54:06 -04:00