diff options
-rw-r--r-- | hw/xfree86/os-support/shared/posix_tty.c | 1 | ||||
-rw-r--r-- | hw/xfree86/os-support/shared/sigio.c | 1 | ||||
-rw-r--r-- | hw/xwin/InitOutput.c | 5 | ||||
-rw-r--r-- | hw/xwin/layout_mapping_check.c | 51 | ||||
-rw-r--r-- | hw/xwin/winclipboard/thread.c | 1 | ||||
-rw-r--r-- | hw/xwin/winclipboard/wndproc.c | 1 | ||||
-rw-r--r-- | hw/xwin/winconfig.c | 74 | ||||
-rw-r--r-- | hw/xwin/winlayouts.h | 4 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwm.c | 35 | ||||
-rw-r--r-- | hw/xwin/winprefs.c | 1 | ||||
-rw-r--r-- | include/os.h | 6 | ||||
-rw-r--r-- | os/auth.c | 4 | ||||
-rw-r--r-- | os/backtrace.c | 76 | ||||
-rw-r--r-- | os/osinit.c | 4 | ||||
-rw-r--r-- | xkb/ddxLoad.c | 30 |
15 files changed, 239 insertions, 55 deletions
diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c index 6e2af001a..8e561430b 100644 --- a/hw/xfree86/os-support/shared/posix_tty.c +++ b/hw/xfree86/os-support/shared/posix_tty.c @@ -56,6 +56,7 @@ #include <xorg-config.h> #endif +#include <sys/select.h> #include <X11/X.h> #include "xf86.h" #include "xf86Priv.h" diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c index 45949f7a3..de4244bdf 100644 --- a/hw/xfree86/os-support/shared/sigio.c +++ b/hw/xfree86/os-support/shared/sigio.c @@ -56,6 +56,7 @@ #include <xorg-config.h> #endif +#include <sys/select.h> #include <X11/X.h> #include "xf86.h" #include "xf86Priv.h" diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 47a32eae5..30b4e86c8 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -166,6 +166,8 @@ main(int argc, char *argv[], char *envp[]) { int iReturn; + xorg_crashreport_init(NULL); + /* Create & acquire the termination mutex */ iReturn = pthread_mutex_init(&g_pmTerminating, NULL); if (iReturn != 0) { @@ -663,6 +665,9 @@ OsVendorInit(void) */ g_fLogInited = TRUE; g_pszLogFile = LogInit(g_pszLogFile, ".old"); + + /* Tell crashreporter logfile name */ + xorg_crashreport_init(g_pszLogFile); } LogSetParameter(XLOG_FLUSH, 1); LogSetParameter(XLOG_VERBOSITY, g_iLogVerbose); diff --git a/hw/xwin/layout_mapping_check.c b/hw/xwin/layout_mapping_check.c new file mode 100644 index 000000000..429be9821 --- /dev/null +++ b/hw/xwin/layout_mapping_check.c @@ -0,0 +1,51 @@ +/* + * Copyright © 2015 Jon TURNEY + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include "winlayouts.h" + +int main() +{ + WinKBLayoutPtr pLayout; + for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++) { + char cmd[1024]; + strcpy(cmd, "setxkbmap "); + strcat(cmd, "-layout "); + strcat(cmd, pLayout->xkblayout); + strcat(cmd, " -model "); + strcat(cmd, pLayout->xkbmodel); + if (pLayout->xkbvariant) { + strcat(cmd, " -variant "); + strcat(cmd, pLayout->xkbvariant); + } + if (pLayout->xkboptions) { + strcat(cmd, " -options "); + strcat(cmd, pLayout->xkboptions); + } + if (system(cmd)) { + printf("'%s' failed\n", cmd); + } + } +} diff --git a/hw/xwin/winclipboard/thread.c b/hw/xwin/winclipboard/thread.c index 27d929c10..aa0a98b91 100644 --- a/hw/xwin/winclipboard/thread.c +++ b/hw/xwin/winclipboard/thread.c @@ -55,6 +55,7 @@ #ifdef HAS_WINSOCK #include <X11/Xwinsock.h> #else +#include <sys/select.h> #include <errno.h> #endif diff --git a/hw/xwin/winclipboard/wndproc.c b/hw/xwin/winclipboard/wndproc.c index 5f1886f65..a3a512ff7 100644 --- a/hw/xwin/winclipboard/wndproc.c +++ b/hw/xwin/winclipboard/wndproc.c @@ -45,6 +45,7 @@ #include <sys/types.h> #include <sys/time.h> +#include <sys/select.h> #include <limits.h> #include <X11/Xatom.h> diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c index 28629a849..d401a1f70 100644 --- a/hw/xwin/winconfig.c +++ b/hw/xwin/winconfig.c @@ -225,7 +225,8 @@ winConfigKeyboard(DeviceIntPtr pDevice) { char layoutName[KL_NAMELENGTH]; unsigned char layoutFriendlyName[256]; - static unsigned int layoutNum = 0; + unsigned int layoutNum = 0; + unsigned int deviceIdentifier = 0; int keyboardType; #ifdef XWIN_XF86CONFIG @@ -273,15 +274,10 @@ winConfigKeyboard(DeviceIntPtr pDevice) if (keyboardType > 0 && GetKeyboardLayoutName(layoutName)) { WinKBLayoutPtr pLayout; Bool bfound = FALSE; + int pass; - if (!layoutNum) - layoutNum = strtoul(layoutName, (char **) NULL, 16); + layoutNum = strtoul(layoutName, (char **) NULL, 16); if ((layoutNum & 0xffff) == 0x411) { - /* The japanese layouts know a lot of different IMEs which all have - different layout numbers set. Map them to a single entry. - Same might apply for chinese, korean and other symbol languages - too */ - layoutNum = (layoutNum & 0xffff); if (keyboardType == 7) { /* Japanese layouts have problems with key event messages such as the lack of WM_KEYUP for Caps Lock key. @@ -319,31 +315,47 @@ winConfigKeyboard(DeviceIntPtr pDevice) "Windows keyboard layout: \"%s\" (%08x) \"%s\", type %d\n", layoutName, layoutNum, layoutFriendlyName, keyboardType); - for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++) { - if (pLayout->winlayout != layoutNum) - continue; - if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType) - continue; - - bfound = TRUE; - winMsg(X_PROBED, - "Found matching XKB configuration \"%s\"\n", - pLayout->layoutname); - - winMsg(X_PROBED, - "Model = \"%s\" Layout = \"%s\"" - " Variant = \"%s\" Options = \"%s\"\n", - pLayout->xkbmodel ? pLayout->xkbmodel : "none", - pLayout->xkblayout ? pLayout->xkblayout : "none", - pLayout->xkbvariant ? pLayout->xkbvariant : "none", - pLayout->xkboptions ? pLayout->xkboptions : "none"); + deviceIdentifier = layoutNum >> 16; + for (pass = 0; pass < 2; pass++) { + /* If we didn't find an exact match for the input locale identifer, + try to find an match on the language identifier part only */ + if (pass == 1) + layoutNum = (layoutNum & 0xffff); + + for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++) { + if (pLayout->winlayout != layoutNum) + continue; + if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType) + continue; + + bfound = TRUE; + winMsg(X_PROBED, + "Found matching XKB configuration \"%s\"\n", + pLayout->layoutname); + + winMsg(X_PROBED, + "Model = \"%s\" Layout = \"%s\"" + " Variant = \"%s\" Options = \"%s\"\n", + pLayout->xkbmodel ? pLayout->xkbmodel : "none", + pLayout->xkblayout ? pLayout->xkblayout : "none", + pLayout->xkbvariant ? pLayout->xkbvariant : "none", + pLayout->xkboptions ? pLayout->xkboptions : "none"); + + g_winInfo.xkb.model = pLayout->xkbmodel; + g_winInfo.xkb.layout = pLayout->xkblayout; + g_winInfo.xkb.variant = pLayout->xkbvariant; + g_winInfo.xkb.options = pLayout->xkboptions; + + if (deviceIdentifier == 0xa0000) { + winMsg(X_PROBED, "Windows keyboard layout device identifier indicates Macintosh, setting Model = \"macintosh\""); + g_winInfo.xkb.model = "macintosh"; + } - g_winInfo.xkb.model = pLayout->xkbmodel; - g_winInfo.xkb.layout = pLayout->xkblayout; - g_winInfo.xkb.variant = pLayout->xkbvariant; - g_winInfo.xkb.options = pLayout->xkboptions; + break; + } - break; + if (bfound) + break; } if (!bfound) { diff --git a/hw/xwin/winlayouts.h b/hw/xwin/winlayouts.h index d3d5c6df3..c7905e3c2 100644 --- a/hw/xwin/winlayouts.h +++ b/hw/xwin/winlayouts.h @@ -42,7 +42,8 @@ typedef struct { */ WinKBLayoutRec winKBLayouts[] = { - {0x00000404, -1, "pc105", "zh_TW", NULL, NULL, "Chinese (Taiwan)"}, + {0x00000404, -1, "pc105", "cn", NULL, NULL, "Chinese (Traditional)"}, + {0x00000804, -1, "pc105", "cn", NULL, NULL, "Chinese (Simplified)"}, {0x00000405, -1, "pc105", "cz", NULL, NULL, "Czech"}, {0x00010405, -1, "pc105", "cz_qwerty", NULL, NULL, "Czech (QWERTY)"}, {0x00000406, -1, "pc105", "dk", NULL, NULL, "Danish"}, @@ -72,7 +73,6 @@ WinKBLayoutRec winKBLayouts[] = { {0x0000040f, -1, "pc105", "is", NULL, NULL, "Icelandic"}, {0x00000410, -1, "pc105", "it", NULL, NULL, "Italian"}, {0x00010410, -1, "pc105", "it", NULL, NULL, "Italian (142)"}, - {0xa0000410, -1, "macbook79", "it", "mac", NULL, "Italiano (Apple)"}, {0x00000411, 7, "jp106", "jp", NULL, NULL, "Japanese"}, {0x00000412, -1, "kr106", "kr", NULL, NULL, "Korean"}, {0x00000413, -1, "pc105", "nl", NULL, NULL, "Dutch"}, diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 589b6e06d..e2bd7e127 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -503,27 +503,39 @@ GetWindowName(Display * pDisplay, Window iWin, char **ppWindowName, Atom atmNetW XFree(xtpWindowName.value); } + /* return the window name, unless... */ + *ppWindowName = pszWindowName; + if (g_fHostInTitle) { XTextProperty xtpClientMachine; - char *pszClientMachine; - char hostname[HOST_NAME_MAX + 1]; /* Try to get client machine name */ nResult = XGetWMClientMachine(pDisplay, iWin, &xtpClientMachine); if (nResult && xtpClientMachine.value && xtpClientMachine.nitems) { + char *pszClientMachine; + char *pszClientHostname; + char *dot; + char hostname[HOST_NAME_MAX + 1]; + pszClientMachine = Xutf8TextPropertyToString(pDisplay, &xtpClientMachine); XFree(xtpClientMachine.value); + /* If client machine name looks like a FQDN, find the hostname */ + pszClientHostname = strdup(pszClientMachine); + dot = strchr(pszClientHostname, '.'); + if (dot) + *dot = '\0'; + /* - If we have a client machine name - and it's not the local host name + If we have a client machine hostname + and it's not the local hostname and it's not already in the window title... */ - if (strlen(pszClientMachine) && + if (strlen(pszClientHostname) && !gethostname(hostname, HOST_NAME_MAX + 1) && - strcmp(hostname, pszClientMachine) && - (strstr(pszWindowName, pszClientMachine) == 0)) { + strcmp(hostname, pszClientHostname) && + (strstr(pszWindowName, pszClientHostname) == 0)) { /* ... add '@<clientmachine>' to end of window name */ *ppWindowName = malloc(strlen(pszWindowName) + @@ -533,15 +545,12 @@ GetWindowName(Display * pDisplay, Window iWin, char **ppWindowName, Atom atmNetW strcat(*ppWindowName, pszClientMachine); free(pszWindowName); - free(pszClientMachine); - - return; } + + free(pszClientMachine); + free(pszClientHostname); } } - - /* otherwise just return the window name */ - *ppWindowName = pszWindowName; } /* diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c index 4d53f8a79..9f1e9b1b7 100644 --- a/hw/xwin/winprefs.c +++ b/hw/xwin/winprefs.c @@ -37,6 +37,7 @@ #include <stdlib.h> #ifdef __CYGWIN__ #include <sys/resource.h> +#include <sys/select.h> #include <sys/wait.h> #include <pthread.h> #endif diff --git a/include/os.h b/include/os.h index 3bd412a70..8c09955b2 100644 --- a/include/os.h +++ b/include/os.h @@ -51,6 +51,7 @@ SOFTWARE. #include <stdarg.h> #include <stdint.h> #include <string.h> +#include <signal.h> #define SCREEN_SAVER_ON 0 #define SCREEN_SAVER_OFF 1 @@ -653,7 +654,10 @@ extern _X_EXPORT void xorg_backtrace(void); extern _X_EXPORT void -xorg_crashreport(void); +xorg_crashreport(int signo, siginfo_t *sip, void *sigcontext); + +extern _X_EXPORT void +xorg_crashreport_init(const char *logfile); extern _X_EXPORT int os_move_fd(int fd); @@ -207,11 +207,11 @@ CheckAuthorization(unsigned int name_length, return (*protocols[i].Check) (data_length, data, client, reason); } - *reason = "Protocol not supported by server\n"; + *reason = "Authorization protocol not supported by server\n"; } } else - *reason = "No protocol specified\n"; + *reason = "Authorization required, but no authorization protocol specified\n"; return (XID) ~0L; } diff --git a/os/backtrace.c b/os/backtrace.c index c11552125..9f32b5687 100644 --- a/os/backtrace.c +++ b/os/backtrace.c @@ -369,11 +369,81 @@ xorg_backtrace(void) return; } -/* Cygwin-specific reporter script which uses exec_wrapper */ +/* Cygwin-specific crash-reporter glue */ + +#include <X11/Xwindows.h> +#include <sys/cygwin.h> + +typedef int (*PFNCYGWINCRASHREPORTERINIT)(const char *, const char *); +typedef void (*PFNCYGWINCRASHREPORTERREPORT)(EXCEPTION_POINTERS *ep); + +PFNCYGWINCRASHREPORTERREPORT crashreporter_report = NULL; + +#define CRASHREPORT_URL "http://www.dronecode.org.uk/cgi-bin/addreport.php" + +void +xorg_crashreport_init(const char *logfile) +{ + /* Initialize crashreporter, if available */ + HMODULE h = LoadLibrary("cygwin-crashreporter-hooks.dll"); + if (h) + { + int result = 0; + PFNCYGWINCRASHREPORTERINIT crashreporter_init = (PFNCYGWINCRASHREPORTERINIT) GetProcAddress (h, "CygwinCrashReporterInit"); + crashreporter_report = (PFNCYGWINCRASHREPORTERREPORT) GetProcAddress (h, "CygwinCrashReporterReport"); + + if (crashreporter_init && crashreporter_report) + { + char *windows_logfile = cygwin_create_path(CCP_POSIX_TO_WIN_A, logfile); + + result = (*crashreporter_init) (CRASHREPORT_URL, windows_logfile); + + if (!result) + ErrorF("Failed to initialize crashreporting\n"); + else + DebugF("crashreporting initialized, status %d\n", result); + + free(windows_logfile); + } + else + { + ErrorF("Could not locate crashreporting functions\n"); + } + + if (!result) + FreeLibrary (h); + } + else + { + ErrorF("Could not load crashreporter dll\n"); + } +} + +#ifdef CW_EXCEPTION_RECORD_FROM_SIGINFO_T +#include <ucontext.h> +#endif + void -xorg_crashreport(void) +xorg_crashreport(int signo, siginfo_t *sip, void *sigcontext) { - return xorg_backtrace_exec_wrapper(BINDIR "/xorg-crashreport"); + if (crashreporter_report) + { +#ifdef CW_EXCEPTION_RECORD_FROM_SIGINFO_T + ucontext_t *ucontext = (ucontext_t *)sigcontext; + EXCEPTION_RECORD er; + int res = !cygwin_internal(CW_EXCEPTION_RECORD_FROM_SIGINFO_T, sip, &er); + + if (ucontext && res) + { + EXCEPTION_POINTERS ep; + ep.ExceptionRecord = &er; + ep.ContextRecord = (CONTEXT *)(&ucontext->uc_mcontext); + crashreporter_report(&ep); + } + else +#endif + crashreporter_report(NULL); + } } #endif diff --git a/os/osinit.c b/os/osinit.c index f4750cf8c..8eb6ab409 100644 --- a/os/osinit.c +++ b/os/osinit.c @@ -108,7 +108,7 @@ OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper) #if !defined(WIN32) || defined(__CYGWIN__) static void #ifdef SA_SIGINFO -OsSigHandler(int signo, siginfo_t * sip, void *unused) +OsSigHandler(int signo, siginfo_t * sip, void *sigcontext) #else OsSigHandler(int signo) #endif @@ -149,7 +149,7 @@ OsSigHandler(int signo) /* log, cleanup, and abort */ xorg_backtrace(); - xorg_crashreport(); + xorg_crashreport(signo, sip, sigcontext); FatalError("Caught signal %d (%s). Server aborting\n", signo, strsignal(signo)); diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index 0fb3f4499..6f692ab34 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -115,10 +115,14 @@ RunXkbComp(xkbcomp_buffer_callback callback, void *userdata) const char *xkbbindirsep = emptystring; #if defined(WIN32) || defined(__CYGWIN__) + int status; /* WIN32 has no popen. The input must be stored in a file which is used as input for xkbcomp. xkbcomp does not read from stdin. */ char tmpname[PATH_MAX]; const char *xkmfile = tmpname; + /* Temporary file used to hold stdout and stderr from xkbcomp */ + char tmpname2[PATH_MAX]; + const char *stderrfile = tmpname2; #else const char *xkmfile = "-"; #endif @@ -131,6 +135,9 @@ RunXkbComp(xkbcomp_buffer_callback callback, void *userdata) strcpy(tmpname, Win32TempDir()); strcat(tmpname, PATHSEPARATOR "xkb_XXXXXX"); (void) mktemp(tmpname); + strcpy(tmpname2, Win32TempDir()); + strcat(tmpname2, PATHSEPARATOR "xkb_XXXXXX"); + (void) mktemp(tmpname2); #endif if (XkbBaseDirectory != NULL) { @@ -172,6 +179,10 @@ RunXkbComp(xkbcomp_buffer_callback callback, void *userdata) out = Popen(buf, "w"); #else out = fopen(tmpname, "w"); + + strcat(buf, " >"); + strcat(buf, stderrfile); + strcat(buf, " 2>&1"); #endif if (out != NULL) { @@ -181,7 +192,7 @@ RunXkbComp(xkbcomp_buffer_callback callback, void *userdata) #if !defined(WIN32) && !defined(__CYGWIN__) if (Pclose(out) == 0) #else - if (fclose(out) == 0 && System(buf) >= 0) + if (fclose(out) == 0 && (status = System(buf)) == 0) #endif { if (xkbDebugFlags) @@ -189,14 +200,31 @@ RunXkbComp(xkbcomp_buffer_callback callback, void *userdata) free(buf); #if defined(WIN32) || defined(__CYGWIN__) unlink(tmpname); + unlink(tmpname2); #endif return xnfstrdup(keymap); } else LogMessage(X_ERROR, "Error compiling keymap (%s)\n", keymap); #if defined(WIN32) || defined(__CYGWIN__) + LogMessage(X_ERROR, "xkbcomp exit status %d\n", status); + + { + char *lineptr = NULL; + size_t n = 0; + FILE *in = fopen(tmpname2, "r"); + if (in) + { + while (getline(&lineptr, &n, in) > 0) + LogMessage(X_ERROR, "%s", lineptr); + + fclose(in); + } + } + /* remove the temporary file */ unlink(tmpname); + unlink(tmpname2); #endif } else { |