termux-packages/x11-packages/sdl/SDL-1.2.15_src_video_x11_SD...

119 lines
3.9 KiB
Diff
Raw Normal View History

2018-09-10 00:42:26 +02:00
diff -uNr SDL-1.2.15/src/video/x11/SDL_x11events.c SDL-1.2.15.mod/src/video/x11/SDL_x11events.c
--- SDL-1.2.15/src/video/x11/SDL_x11events.c 2012-01-19 08:30:06.000000000 +0200
+++ SDL-1.2.15.mod/src/video/x11/SDL_x11events.c 2018-10-26 23:20:45.228724684 +0300
2018-09-10 00:42:26 +02:00
@@ -57,12 +57,6 @@
static SDLKey MISC_keymap[256];
SDLKey X11_TranslateKeycode(Display *display, KeyCode kc);
-/*
- Pending resize target for ConfigureNotify (so outdated events don't
- cause inappropriate resize events)
-*/
-int X11_PendingConfigureNotifyWidth = -1;
-int X11_PendingConfigureNotifyHeight = -1;
#ifdef X_HAVE_UTF8_STRING
Uint32 Utf8ToUcs4(const Uint8 *utf8)
@@ -395,6 +389,8 @@
{
int posted;
XEvent xevent;
+ int orig_event_type;
+ KeyCode orig_keycode;
SDL_memset(&xevent, '\0', sizeof (XEvent)); /* valgrind fix. --ryan. */
XNextEvent(SDL_Display, &xevent);
@@ -410,9 +406,29 @@
#ifdef X_HAVE_UTF8_STRING
/* If we are translating with IM, we need to pass all events
to XFilterEvent, and discard those filtered events immediately. */
+ orig_event_type = xevent.type;
+ if (orig_event_type == KeyPress || orig_event_type == KeyRelease) {
+ orig_keycode = xevent.xkey.keycode;
+ } else {
+ orig_keycode = 0;
+ }
if ( SDL_TranslateUNICODE
&& SDL_IM != NULL
&& XFilterEvent(&xevent, None) ) {
+ if (orig_keycode) {
+ SDL_keysym keysym;
+ static XComposeStatus state;
+ char keybuf[32];
+
+ keysym.scancode = xevent.xkey.keycode;
+ keysym.sym = X11_TranslateKeycode(SDL_Display, xevent.xkey.keycode);
+ keysym.mod = KMOD_NONE;
+ keysym.unicode = 0;
+ if (orig_event_type == KeyPress && XLookupString(&xevent.xkey, keybuf, sizeof(keybuf), NULL, &state))
+ keysym.unicode = (Uint8)keybuf[0];
+
+ SDL_PrivateKeyboard(orig_event_type == KeyPress ? SDL_PRESSED : SDL_RELEASED, &keysym);
+ }
return 0;
}
#endif
@@ -429,12 +445,15 @@
if ( xevent.xcrossing.mode == NotifyUngrab )
printf("Mode: NotifyUngrab\n");
#endif
- if ( this->input_grab == SDL_GRAB_OFF ) {
- posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+ if ( (xevent.xcrossing.mode != NotifyGrab) &&
+ (xevent.xcrossing.mode != NotifyUngrab) ) {
+ if ( this->input_grab == SDL_GRAB_OFF ) {
+ posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+ }
+ posted = SDL_PrivateMouseMotion(0, 0,
+ xevent.xcrossing.x,
+ xevent.xcrossing.y);
}
- posted = SDL_PrivateMouseMotion(0, 0,
- xevent.xcrossing.x,
- xevent.xcrossing.y);
}
break;
@@ -825,16 +844,6 @@
#ifdef DEBUG_XEVENTS
printf("ConfigureNotify! (resize: %dx%d)\n", xevent.xconfigure.width, xevent.xconfigure.height);
#endif
- if ((X11_PendingConfigureNotifyWidth != -1) &&
- (X11_PendingConfigureNotifyHeight != -1)) {
- if ((xevent.xconfigure.width != X11_PendingConfigureNotifyWidth) &&
- (xevent.xconfigure.height != X11_PendingConfigureNotifyHeight)) {
- /* Event is from before the resize, so ignore. */
- break;
- }
- X11_PendingConfigureNotifyWidth = -1;
- X11_PendingConfigureNotifyHeight = -1;
- }
if ( SDL_VideoSurface ) {
if ((xevent.xconfigure.width != SDL_VideoSurface->w) ||
(xevent.xconfigure.height != SDL_VideoSurface->h)) {
@@ -1246,8 +1255,11 @@
* sequences (dead accents, compose key sequences) will not work since the
* state has been irrevocably lost.
*/
+extern DECLSPEC Uint16 SDLCALL X11_KeyToUnicode(SDLKey, SDLMod);
+
Uint16 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers)
{
+ static int warning = 0;
struct SDL_VideoDevice *this = current_video;
char keybuf[32];
int i;
@@ -1255,6 +1267,12 @@
XKeyEvent xkey;
Uint16 unicode;
+ if ( warning ) {
+ warning = 0;
+ fprintf(stderr, "WARNING: Application is using X11_KeyToUnicode().\n");
+ fprintf(stderr, "This is not an official SDL function, please report this as a bug.\n");
+ }
+
if ( !this || !SDL_Display ) {
return 0;
}