Commit Graph

59 Commits (8283abdb789703b6070d2d7d23349d3f89fe873d)

Author SHA1 Message Date
Ryan C. Gordon e3f4ca0d71 configure/cmake/x11: Removed SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 test.
This was the only thing that made SDL_config.h generate differently between
32 and 64-bit versions of Linux, so instead we force a function cast in our
X11 code to match our dynamic loader version, which removes the compile error
on some machines that prompted this test in the first place.

Xlib never wrote to this data, so if you're on an older Xlib where this param
wasn't const, your data should still be intact when we force the caller to
think it was actually const after all.

Fixes Bugzilla #1893.
2015-06-08 01:13:51 -04:00
Ryan C. Gordon 753f95c5dd VS2005 tweaks (thanks, Ozkan!).
Fixes Bugzilla #2895.

His notes:

The following trivial changes make SDL2 tree (mostly) compatible with Visual
Studio 2005:

* SDL_stdlib.c: Similar to VS2010 and newer, VS2005 also generates memcpy(),
  (it also generates memset(), see below), so propagate the #if condition to
  cover VS2005.

* SDL_pixels.c (SDL_CalculateGammaRamp): VS2005 generates a memset() call for
  gamma==0 case, so replace the if loop with SDL_memset().

* SDL_windowsvideo.h: Include msctf.h only with VS2008 and newer, otherwise
  include SDL_msctf.h

* SDL_windowskeyboard.c: Adjust the #ifdefs so that SDL_msctf.h inclusion is
  always recognized correctly.
2015-06-07 19:58:42 -04:00
Ryan C. Gordon 141ac2b59d Backed out changeset c6d43e08be34
This caused Bugzilla #2963, so we'll find a better solution.
2015-06-07 17:59:31 -04:00
Ryan C. Gordon 8a85084fc1 RPi: Patched to compile without OpenGL (thanks, Simon!), other cleanups.
Fixes Bugzilla #3003.
2015-06-06 22:45:22 -04:00
Philipp Wiesemann fd8b7c1ca3 Fixed comments at conditional compilation macros. 2015-06-05 19:41:18 +02:00
Ryan C. Gordon 360d05bf72 X11: Fixed SelectionRequest replies for target TARGETS.
Fixes Google Chrome, etc, freezing up when SDL owns the clipboard selection
and actually sends thems the correct text for pasting. Confirmed working with
Unicode strings in UTF-8 format.

There were a few tweaks in this patch, but the specific fix is that
event.xselection.target in the SelectionNotify event we send back in reply
must be set to the same atom as the request ("TARGETS" in this case), and
we failed to do that in this special case. Things that don't ask for a target,
like the Gnome Terminal app, worked fine because they don't ask for TARGETS
and just go right to asking for a UTF8_STRING, and Mozilla apparently just
was more liberal in what they accepted in reply.

Chrome would reject our wrong reply and freeze up waiting for a valid one.
Someone should fix that in Chrome, too.  :)

Fixes Bugzilla #2926.
2015-06-04 15:41:39 -04:00
Ryan C. Gordon 96aef8cbca X11: Fixed compiler warnings in DEBUG_XEVENTS sections. 2015-06-04 10:59:02 -04: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
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 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 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 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 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
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 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
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 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
Ryan C. Gordon 80cfccbf8d Back out changeset b80349dd6d40.
This change didn't do what I thought it did, sorry.
2015-05-26 22:57:42 -04:00
Ryan C. Gordon c69a559239 X11: generate clipboard update events (thanks, "chw"!).
Partially fixes Bugzilla #2266.
2015-05-26 21:29:45 -04:00
Ryan C. Gordon cc493d7195 X11: use XA_STRING for text SDL puts on the clipboard (thanks, "chw"!).
Partially fixes Bugzilla #2266.
2015-05-26 21:26:27 -04:00
Alex Szpakowski 262e8ef3f0 Mac: Send a window resize event when the window's backing scale factor changes.
The backing scale factor can change when the window moves between retina and non-retina displays.

The only other way to detect such a change is to compare the output of SDL_GL_GetDrawableSize or SDL_GetRendererOutputSize every frame, which is less than desirable, especially since the necessary app logic is likely already being executed when a window resize event is received.
2015-05-26 21:51:47 -03:00
Ryan C. Gordon be89fa09ef Reset the keyboard state when launching a message box (thanks, Sean!).
Otherwise, pressed keys get stuck.

Fixes Bugzilla #2776.
2015-05-26 20:49:27 -04:00
Ryan C. Gordon 41908548b9 Windows: Alt-F4 hotkey should be checked on keydown, not keyup (thanks, Matt!).
Fixes Bugzilla #2780.
2015-05-26 20:40:00 -04:00
Alex Baines ae6555dff8 Pump IBus events after X events. 2015-05-26 20:22:14 -04:00
Alex Szpakowski a4f0daedae EGL: OpenGL ES 3.0 contexts can now be created without the EGL_KHR_create_context extension.
Fixes bugzilla #2994.
2015-05-26 19:34:56 -03:00
Ryan C. Gordon 80916e01f3 Cocoa: Fixed relative mouse mode when app loses/regains focus (thanks, Eric!).
Fixes Bugzilla #2718.
2015-05-26 11:38:04 -04:00
Ryan C. Gordon b11b3493b9 Windows: don't beep on Alt-* key combos (Thanks, historic_bruno!).
Fixes Bugzilla 2669.
2015-05-26 11:08:30 -04:00
Ryan C. Gordon bb437f0233 Cocoa: report SDL_WINDOWEVENT_EXPOSED events to the app (thanks, David!).
Fixes Bugzilla #2644.
2015-05-26 11:01:19 -04:00
Ryan C. Gordon 22704ac2df Cocoa: don't fail outright if we see an unknown display format.
Just treat it as ARGB8888.
2015-05-26 09:55:41 -04:00
Ryan C. Gordon aba4d78384 Don't look for (and fail without) glGetIntegerv() until we need to.
Fixes Bugzilla #2615.
2015-05-26 10:25:15 -04:00
Sam Lantinga 2c4a6ea0a2 Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Victor Luchits afc97cbd5d Fix duplicate raw mouse events with XInput2
Make XGrabPointer calls in X11_SetWindowGrab and X11_CaptureMouse
consistent by passing False to owner_mask along with proper event_mask.
2015-05-14 14:40:56 +03:00
Alex Szpakowski 240a3fbffe iOS: Added support for SDL_DisableScreenSaver and SDL_EnableScreenSaver. 2015-05-16 16:55:56 -03:00
Philipp Wiesemann a54d038b64 Emscripten: Fixed wrong source comment and updated web link. 2015-05-16 21:15:27 +02:00
Sam Lantinga 1c6ea0f226 Added a userdata parameter to SDL_SetWindowsMessageHook() 2015-05-13 22:39:32 -07:00
Sam Lantinga 7de242e72c Added SDL_SetWindowsMessageHook() to facilitate full IME support on Windows 2015-05-13 22:39:20 -07:00
Alex Szpakowski f1a7c00d06 Refactored SDL_EGL_CreateContext: It now supports context flags and OpenGL ES 3+ contexts, and its behavior more closely matches the GLX and WGL context creation code.
Improved the code style consistency of SDL_egl.c.

Fixes bugzilla #2865.
2015-05-11 21:03:36 -03:00