Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

1.Fixed a memory leak inside XInput2 code

2.Replaced XKeycodeToKeysym with XkbKeycodeToKeysym since XKeycodeToKeysym is deprecated in newer X11 version
3.Rewrote testime.c since it was disabled after SDL_compat.c removal
4.Take into account common arguments also in testrelative.c
  • Loading branch information
zenios committed May 31, 2012
1 parent df23240 commit 62f18a8592a4e09a3903e332ffd33280a9f949f2
@@ -1111,6 +1111,7 @@ XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,i
AC_MSG_RESULT($have_const_param_XextAddDisplay)

AC_CHECK_LIB(X11, XGetEventData, AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS, 1, [Have XGenericEvent]))
AC_CHECK_LIB(X11, XkbKeycodeToKeysym, AC_DEFINE(SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM, 1, [Have XkbKeycodeToKeysym]))

AC_ARG_ENABLE(video-x11-xcursor,
AC_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [[default=yes]]]),
@@ -271,6 +271,7 @@
#undef SDL_VIDEO_DRIVER_X11_XVIDMODE
#undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS
#undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY
#undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM

#undef SDL_VIDEO_RENDER_D3D
#undef SDL_VIDEO_RENDER_OGL
@@ -146,6 +146,7 @@
#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1
#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1

#ifndef SDL_VIDEO_RENDER_OGL
#define SDL_VIDEO_RENDER_OGL 1
@@ -27,6 +27,10 @@
#include <X11/Xutil.h>
#include <X11/Xatom.h>

#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
#include <X11/XKBlib.h>
#endif

/* Apparently some X11 systems can't include this multiple times... */
#ifndef SDL_INCLUDED_XLIBINT_H
#define SDL_INCLUDED_XLIBINT_H 1
@@ -265,7 +265,11 @@ X11_DispatchEvent(_THIS)
if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN) {
int min_keycode, max_keycode;
XDisplayKeycodes(display, &min_keycode, &max_keycode);
#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
keysym = XkbKeycodeToKeysym(display, keycode, 0, 0);
#else
keysym = XKeycodeToKeysym(display, keycode, 0);
#endif
fprintf(stderr,
"The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n",
keycode, keycode - min_keycode, keysym,
@@ -563,7 +567,7 @@ X11_PumpEvents(_THIS)
XResetScreenSaver(data->display);
data->screensaver_activity = now;
}
}
}

/* Keep processing pending events */
while (X11_Pending(data->display)) {
@@ -151,7 +151,11 @@ X11_KeyCodeToSDLKey(Display *display, KeyCode keycode)
unsigned int ucs4;
int i;

#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
keysym = XkbKeycodeToKeysym(display, keycode, 0, 0);
#else
keysym = XKeycodeToKeysym(display, keycode, 0);
#endif
if (keysym == NoSymbol) {
return SDLK_UNKNOWN;
}
@@ -232,7 +236,11 @@ X11_InitKeyboard(_THIS)
SDL_GetDefaultKeymap(keymap);
for (i = min_keycode; i <= max_keycode; ++i) {
KeySym sym;
#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
sym = XkbKeycodeToKeysym(data->display, i, 0, 0);
#else
sym = XKeycodeToKeysym(data->display, i, 0);
#endif
if (sym != NoSymbol) {
SDL_Keycode key;
printf("code = %d, sym = 0x%X (%s) ", i - min_keycode,
@@ -132,6 +132,14 @@ SDL_X11_SYM(Bool,XGetEventData,(Display* a,XGenericEventCookie* b),(a,b),return)
SDL_X11_SYM(void,XFreeEventData,(Display* a,XGenericEventCookie* b),(a,b),)
#endif

#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
#if NeedWidePrototypes
SDL_X11_SYM(KeySym,XkbKeycodeToKeysym,(Display* a,unsigned int b,int c,int d),(a,b,c,d),return)
#else
SDL_X11_SYM(KeySym,XkbKeycodeToKeysym,(Display* a,KeyCode b,int c,int d),(a,b,c,d),return)
#endif
#endif

#if NeedWidePrototypes
SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,unsigned int b,int c),(a,b,c),return)
#else
@@ -210,6 +210,7 @@ X11_InitXinput2Multitouch(_THIS) {
}
}
}
XIFreeDeviceInfo(info);
#endif
}

@@ -105,8 +105,8 @@ testthread$(EXE): $(srcdir)/testthread.c
testiconv$(EXE): $(srcdir)/testiconv.c
$(CC) -o $@ $? $(CFLAGS) $(LIBS)

testime$(EXE): $(srcdir)/testime.c
$(CC) -o $@ $? $(CFLAGS) $(LIBS) @SDL_TTF_LIB@
testime$(EXE): $(srcdir)/testime.c $(srcdir)/common.c
$(CC) -o $@ $(srcdir)/testime.c $(srcdir)/common.c $(CFLAGS) $(LIBS) @SDL_TTF_LIB@

testjoystick$(EXE): $(srcdir)/testjoystick.c
$(CC) -o $@ $? $(CFLAGS) $(LIBS)

0 comments on commit 62f18a8

Please sign in to comment.