diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2011-02-11 16:10:36 +0000 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-03-10 13:25:37 +0000 |
commit | 05bf2547f0ab9145cfffe8c47a5f2abb87b9f5a6 (patch) | |
tree | a11e7ae4dd730439d3c282888a68cebf64214a32 | |
parent | 4d83edb381320ce0adbf32be9d782116b6c13b24 (diff) |
Consolidate XInitThreads/XSupportsLocale() in a single place.
If XSupportsLocale() fails, set a known good locale.
-rw-r--r-- | hw/xwin/InitOutput.c | 22 | ||||
-rw-r--r-- | hw/xwin/winclipboard.h | 1 | ||||
-rw-r--r-- | hw/xwin/winclipboardthread.c | 13 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwm.c | 27 |
4 files changed, 18 insertions, 45 deletions
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index ab6557b7b..9e3843845 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -35,12 +35,10 @@ from The Open Group. #include "winmsg.h" #include "winconfig.h" #include "winprefs.h" -#ifdef XWIN_CLIPBOARD -#include "X11/Xlocale.h" -#endif #ifdef DPMSExtension #include "dpmsproc.h" #endif +#include <locale.h> #ifdef __CYGWIN__ #include <mntent.h> #endif @@ -986,11 +984,27 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[]) /* Perform some one time initialization */ if (1 == serverGeneration) { + /* Allow multiple threads to access Xlib */ + if (XInitThreads () == 0) + { + ErrorF ("XInitThreads failed.\n"); + } + /* * setlocale applies to all threads in the current process. * Apply locale specified in LANG environment variable. */ - setlocale (LC_ALL, ""); + if (!setlocale (LC_ALL, "")) + { + ErrorF ("setlocale failed.\n"); + } + + /* See if X supports the current locale */ + if (XSupportsLocale () == FALSE) + { + ErrorF ("Warning: Locale not supported by X, falling back to 'C' locale.\n"); + setlocale(LC_ALL, "C"); + } } #endif diff --git a/hw/xwin/winclipboard.h b/hw/xwin/winclipboard.h index b655f1623..bdec33f53 100644 --- a/hw/xwin/winclipboard.h +++ b/hw/xwin/winclipboard.h @@ -49,7 +49,6 @@ #include <X11/Xatom.h> #include <X11/Xproto.h> #include <X11/Xutil.h> -#include <X11/Xlocale.h> /* Windows headers */ #include <X11/Xwindows.h> diff --git a/hw/xwin/winclipboardthread.c b/hw/xwin/winclipboardthread.c index 896a2a0e9..d37fa5288 100644 --- a/hw/xwin/winclipboardthread.c +++ b/hw/xwin/winclipboardthread.c @@ -122,19 +122,6 @@ winClipboardProc (void *pvNotUsed) /* Save the Unicode support flag in a global */ g_fUseUnicode = fUseUnicode; - /* Allow multiple threads to access Xlib */ - if (XInitThreads () == 0) - { - ErrorF ("winClipboardProc - XInitThreads failed.\n"); - goto winClipboardProc_Exit; - } - - /* See if X supports the current locale */ - if (XSupportsLocale () == False) - { - ErrorF ("winClipboardProc - Warning: Locale not supported by X.\n"); - } - /* Set error handler */ XSetErrorHandler (winClipboardErrorHandler); g_winClipboardProcThread = pthread_self(); diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 27dd1a014..3cd1a293d 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -48,7 +48,6 @@ #include <X11/X.h> #include <X11/Xatom.h> #include <X11/Xlib.h> -#include <X11/Xlocale.h> #include <X11/Xproto.h> #include <X11/Xutil.h> #include <X11/cursorfont.h> @@ -896,19 +895,6 @@ winMultiWindowXMsgProc (void *pArg) ErrorF ("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n"); - /* Allow multiple threads to access Xlib */ - if (XInitThreads () == 0) - { - ErrorF ("winMultiWindowXMsgProc - XInitThreads () failed. Exiting.\n"); - pthread_exit (NULL); - } - - /* See if X supports the current locale */ - if (XSupportsLocale () == False) - { - ErrorF ("winMultiWindowXMsgProc - Warning: locale not supported by X\n"); - } - /* Release the server started mutex */ pthread_mutex_unlock (pProcArg->ppmServerStarted); @@ -1305,19 +1291,6 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) ErrorF ("winInitMultiWindowWM - pthread_mutex_lock () returned.\n"); - /* Allow multiple threads to access Xlib */ - if (XInitThreads () == 0) - { - ErrorF ("winInitMultiWindowWM - XInitThreads () failed. Exiting.\n"); - pthread_exit (NULL); - } - - /* See if X supports the current locale */ - if (XSupportsLocale () == False) - { - ErrorF ("winInitMultiWindowWM - Warning: Locale not supported by X.\n"); - } - /* Release the server started mutex */ pthread_mutex_unlock (pProcArg->ppmServerStarted); |