Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
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 62f18a8
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 229 deletions.
1 change: 1 addition & 0 deletions configure.in
Expand Up @@ -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]]]),
Expand Down
1 change: 1 addition & 0 deletions include/SDL_config.h.in
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions include/SDL_config_macosx.h
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/video/x11/SDL_x11dyn.h
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/video/x11/SDL_x11events.c
Expand Up @@ -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,
Expand Down Expand Up @@ -563,7 +567,7 @@ X11_PumpEvents(_THIS)
XResetScreenSaver(data->display);
data->screensaver_activity = now;
}
}
}

/* Keep processing pending events */
while (X11_Pending(data->display)) {
Expand Down
8 changes: 8 additions & 0 deletions src/video/x11/SDL_x11keyboard.c
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/video/x11/SDL_x11sym.h
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/video/x11/SDL_x11xinput2.c
Expand Up @@ -210,6 +210,7 @@ X11_InitXinput2Multitouch(_THIS) {
}
}
}
XIFreeDeviceInfo(info);
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions test/Makefile.in
Expand Up @@ -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)
Expand Down

0 comments on commit 62f18a8

Please sign in to comment.