Add patches suggested by @slouken in round 1 review
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h
index ba08ea9..673b7f1 100644
--- a/src/video/x11/SDL_x11sym.h
+++ b/src/video/x11/SDL_x11sym.h
@@ -157,7 +157,6 @@ SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,S
SDL_X11_SYM(void,XRefreshKeyboardMapping,(XMappingEvent *a),(a),)
SDL_X11_SYM(int,XQueryTree,(Display* a,Window b,Window* c,Window* d,Window** e,unsigned int* f),(a,b,c,d,e,f),return)
SDL_X11_SYM(Bool,XSupportsLocale,(void),(),return)
-SDL_X11_SYM(void,XSetWMName,(Display* a,Window b,XTextProperty* c),(a,b,c),return)
SDL_X11_SYM(Status,XmbTextListToTextProperty,(Display* a,char** b,int c,XICCEncodingStyle d,XTextProperty* e),(a,b,c,d,e),return)
#if SDL_VIDEO_DRIVER_X11_XFIXES
diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c
index 6d2cd07..1bf4032 100644
--- a/src/video/x11/SDL_x11video.c
+++ b/src/video/x11/SDL_x11video.c
@@ -461,13 +461,9 @@ X11_VideoInit(_THIS)
#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */
#ifndef X_HAVE_UTF8_STRING
- SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "X server doesn't support UTF8_STRING, a feature introduced in 2000! This is likely to become a hard error in a future libSDL2.");
+#warning X server does not support UTF8_STRING, a feature introduced in 2000! This is likely to become a hard error in a future libSDL2.
#endif
- if (X11_XSupportsLocale() != True) {
- return SDL_SetError("Current locale not supported by X server, cannot continue.");
- }
-
if (X11_InitKeyboard(_this) != 0) {
return -1;
}
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 48f0cc6..51869a6 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -262,6 +262,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
}
data->window = window;
data->xwindow = w;
+
#ifdef X_HAVE_UTF8_STRING
if (SDL_X11_HAVE_UTF8 && videodata->im) {
data->ic =
@@ -716,11 +717,11 @@ X11_GetWindowTitle(_THIS, Window xwindow)
0L, 8192L, False, XA_STRING, &real_type, &real_format,
&items_read, &items_left, &propdata);
if (status == Success && propdata) {
- SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Failed to convert _WM_NAME title expecting UTF8! Title: %s", title);
+ SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Failed to convert WM_NAME title expecting UTF8! Title: %s", title);
title = SDL_iconv_string("UTF-8", "", SDL_static_cast(char*, propdata), items_read+1);
X11_XFree(propdata);
} else {
- SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get any window title response from Xorg, returning empty string!");
+ SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Could not get any window title response from Xorg, returning empty string!");
title = SDL_strdup("");
}
}
@@ -1871,22 +1872,25 @@ X11_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation)
return 0;
}
-bool SDL_X11_SetWindowTitle(Display* display, Window xwindow, char* title) {
+int SDL_X11_SetWindowTitle(Display* display, Window xwindow, char* title) {
Atom _NET_WM_NAME = X11_XInternAtom(display, "_NET_WM_NAME", False);
XTextProperty titleprop;
- int conv = X11_XmbTextListToTextProperty(display, (char**) &title, 1, XStdICCTextStyle, &titleprop);
+ int conv = X11_XmbTextListToTextProperty(display, (char**) &title, 1, XTextStyle, &titleprop);
Status status;
+ if (X11_XSupportsLocale() != True) {
+ return SDL_SetError("Current locale not supported by X server, cannot continue.");
+ }
+
if (conv == 0) {
X11_XSetTextProperty(display, xwindow, &titleprop, XA_WM_NAME);
X11_XFree(titleprop.value);
- // we know this can't be a locale error as we checked X locale validity in X11_VideoInit
- } else if (conv <= 0) {
- SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "X11 reporting it's out of memory");
- return EXIT_FAILURE;
- } else { // conv >= 0
- SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "%d characters were not convertable to the current locale!", conv);
- return EXIT_FAILURE;
+ // we know this can't be a locale error as we checked X locale validity
+ } else if (conv < 0) {
+ return SDL_OutOfMemory();
+ } else { // conv > 0
+ SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "%d characters were not convertable to the current locale!", conv);
+ return 0;
}
#ifdef X_HAVE_UTF8_STRING
@@ -1895,13 +1899,12 @@ bool SDL_X11_SetWindowTitle(Display* display, Window xwindow, char* title) {
X11_XSetTextProperty(display, xwindow, &titleprop, _NET_WM_NAME);
X11_XFree(titleprop.value);
} else {
- SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Failed to convert title to UTF8! Bad encoding, or bad Xorg encoding? Window title: «%s»", title);
- return EXIT_FAILURE;
+ return SDL_SetError("Failed to convert title to UTF8! Bad encoding, or bad Xorg encoding? Window title: «%s»", title);
}
#endif
X11_XFlush(display);
- return EXIT_SUCCESS;
+ return 0;
}
#endif /* SDL_VIDEO_DRIVER_X11 */
diff --git a/src/video/x11/SDL_x11window.h b/src/video/x11/SDL_x11window.h
index dd66af7..11bd9fe 100644
--- a/src/video/x11/SDL_x11window.h
+++ b/src/video/x11/SDL_x11window.h
@@ -117,7 +117,7 @@ extern int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
extern void X11_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept);
extern int X11_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation);
-bool SDL_X11_SetWindowTitle(Display* display, Window xwindow, char* string);
+int SDL_X11_SetWindowTitle(Display* display, Window xwindow, char* string);
#endif /* SDL_x11window_h_ */