From dec7875a6e23212021e4d9080330a42832dfe02a Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Tue, 15 Jun 2021 01:40:19 +0000
Subject: [PATCH] update SDL soruce to 2.0.14
---
source/src/video/x11/SDL_x11events.c | 80 +++++++++++++++++++++++++++++----------
1 files changed, 59 insertions(+), 21 deletions(-)
diff --git a/source/src/video/x11/SDL_x11events.c b/source/src/video/x11/SDL_x11events.c
index 24e9b0c..ea72927 100644
--- a/source/src/video/x11/SDL_x11events.c
+++ b/source/src/video/x11/SDL_x11events.c
@@ -39,7 +39,6 @@
#include "SDL_hints.h"
#include "SDL_timer.h"
#include "SDL_syswm.h"
-#include "SDL_assert.h"
#include <stdio.h>
@@ -433,8 +432,12 @@
static void
X11_DispatchMapNotify(SDL_WindowData *data)
{
- SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0);
- SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
+ SDL_Window *window = data->window;
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0);
+ if (!(window->flags & SDL_WINDOW_HIDDEN) && (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
+ SDL_UpdateWindowGrab(window);
+ }
}
static void
@@ -642,6 +645,29 @@
}
}
+static Bool
+isMapNotify(Display *display, XEvent *ev, XPointer arg)
+{
+ XUnmapEvent *unmap;
+
+ unmap = (XUnmapEvent*) arg;
+
+ return ev->type == MapNotify &&
+ ev->xmap.window == unmap->window &&
+ ev->xmap.serial == unmap->serial;
+}
+
+static Bool
+isReparentNotify(Display *display, XEvent *ev, XPointer arg)
+{
+ XUnmapEvent *unmap;
+
+ unmap = (XUnmapEvent*) arg;
+
+ return ev->type == ReparentNotify &&
+ ev->xreparent.window == unmap->window &&
+ ev->xreparent.serial == unmap->serial;
+}
static void
X11_DispatchEvent(_THIS)
@@ -683,7 +709,7 @@
/* But only if we're using one of the DBus IMEs, otherwise
some XIM IMEs will generate duplicate events */
if (orig_keycode) {
-#if defined(HAVE_IBUS_IBUS_H) || defined(HAVE_FCITX_FRONTEND_H)
+#if defined(HAVE_IBUS_IBUS_H) || defined(HAVE_FCITX)
SDL_Scancode scancode = videodata->key_layout[orig_keycode];
videodata->filter_code = orig_keycode;
videodata->filter_time = xevent.xkey.time;
@@ -818,9 +844,9 @@
break;
}
- if (xevent.xfocus.detail == NotifyInferior) {
+ if (xevent.xfocus.detail == NotifyInferior || xevent.xfocus.detail == NotifyPointer) {
#ifdef DEBUG_XEVENTS
- printf("window %p: FocusIn (NotifierInferior, ignoring)\n", data);
+ printf("window %p: FocusIn (NotifyInferior/NotifyPointer, ignoring)\n", data);
#endif
break;
}
@@ -851,10 +877,12 @@
#endif
break;
}
- if (xevent.xfocus.detail == NotifyInferior) {
- /* We still have focus if a child gets focus */
+ if (xevent.xfocus.detail == NotifyInferior || xevent.xfocus.detail == NotifyPointer) {
+ /* We still have focus if a child gets focus. We also don't
+ care about the position of the pointer when the keyboard
+ focus changed. */
#ifdef DEBUG_XEVENTS
- printf("window %p: FocusOut (NotifierInferior, ignoring)\n", data);
+ printf("window %p: FocusOut (NotifyInferior/NotifyPointer, ignoring)\n", data);
#endif
break;
}
@@ -946,10 +974,17 @@
/* Have we been iconified? */
case UnmapNotify:{
+ XEvent ev;
+
#ifdef DEBUG_XEVENTS
printf("window %p: UnmapNotify!\n", data);
#endif
- X11_DispatchUnmapNotify(data);
+
+ if (X11_XCheckIfEvent(display, &ev, &isReparentNotify, (XPointer)&xevent.xunmap)) {
+ X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&xevent.xunmap);
+ } else {
+ X11_DispatchUnmapNotify(data);
+ }
}
break;
@@ -1346,19 +1381,22 @@
X11_ReadProperty(&p, display, data->xwindow, videodata->PRIMARY);
if (p.format == 8) {
- char* saveptr = NULL;
- char* name = X11_XGetAtomName(display, target);
- char *token = SDL_strtokr((char *) p.data, "\r\n", &saveptr);
- while (token != NULL) {
- if (SDL_strcmp("text/plain", name)==0) {
- SDL_SendDropText(data->window, token);
- } else if (SDL_strcmp("text/uri-list", name)==0) {
- char *fn = X11_URIToLocal(token);
- if (fn) {
- SDL_SendDropFile(data->window, fn);
+ char *saveptr = NULL;
+ char *name = X11_XGetAtomName(display, target);
+ if (name) {
+ char *token = SDL_strtokr((char *) p.data, "\r\n", &saveptr);
+ while (token != NULL) {
+ if (SDL_strcmp("text/plain", name) == 0) {
+ SDL_SendDropText(data->window, token);
+ } else if (SDL_strcmp("text/uri-list", name) == 0) {
+ char *fn = X11_URIToLocal(token);
+ if (fn) {
+ SDL_SendDropFile(data->window, fn);
+ }
}
+ token = SDL_strtokr(NULL, "\r\n", &saveptr);
}
- token = SDL_strtokr(NULL, "\r\n", &saveptr);
+ X11_XFree(name);
}
SDL_SendDropComplete(data->window);
}
--
Gitblit v1.9.3