From 47fa03e091beaaaf092cd402e38fd204f85097de Mon Sep 17 00:00:00 2001 From: Harold L Hunt II Date: Fri, 16 Jan 2004 21:26:36 +0000 Subject: [PATCH] Sync with XWin Server 4.3.0-42 release. Minor fixes to clipboard code to hopefully fix some crashes. Cleanup of multi-window mode exit messages. --- hw/xwin/InitOutput.c | 5 ++++- hw/xwin/winclipboardwrappers.c | 24 ++++++++++++++++++++++++ hw/xwin/winclipboardxevents.c | 8 ++++++++ hw/xwin/winglobals.c | 8 ++++++-- hw/xwin/winmsg.h | 4 ++-- hw/xwin/winmultiwindowwm.c | 33 +++++++++++++++++---------------- 6 files changed, 61 insertions(+), 21 deletions(-) diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index af61b40b2..fdeac5afc 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -57,6 +57,9 @@ int g_iLogVerbose = 4; char * g_pszLogFile = WIN_LOG_FNAME; Bool g_fLogInited = FALSE; +extern Bool g_fClipboardLaunched; +extern Bool g_fClipboardStarted; + extern HMODULE g_hmodDirectDraw; extern FARPROC g_fpDirectDrawCreate; extern FARPROC g_fpDirectDrawCreateClipper; @@ -123,7 +126,7 @@ OsVendorReset (void) ErrorF ("OsVendorReset - Hello\n"); /* Close down clipboard resources */ - if (g_fClipboard) + if (g_fClipboard && g_fClipboardLaunched && g_fClipboardStarted) { /* Synchronously destroy the clipboard window */ if (g_hwndClipboard != NULL) diff --git a/hw/xwin/winclipboardwrappers.c b/hw/xwin/winclipboardwrappers.c index a6060925f..01f1179a3 100755 --- a/hw/xwin/winclipboardwrappers.c +++ b/hw/xwin/winclipboardwrappers.c @@ -102,6 +102,17 @@ winProcQueryTree (ClientPtr client) return iReturn; } + /* Make errors more obvious */ + winProcQueryTreeOrig = NULL; + + /* Do nothing if clipboard is not enabled */ + if (!g_fClipboard) + { + ErrorF ("winProcQueryTree - Clipboard is not enabled, " + "returning.\n"); + return iReturn; + } + /* If the clipboard client has already been started, abort */ if (g_fClipboardLaunched) { @@ -172,6 +183,19 @@ winProcEstablishConnection (ClientPtr client) ErrorF ("winProcEstablishConnection - Hello\n"); + /* Do nothing if clipboard is not enabled */ + if (!g_fClipboard) + { + ErrorF ("winProcEstablishConnection - Clipboard is not enabled, " + "returning.\n"); + + /* Unwrap the original function, call it, and return */ + InitialVector[2] = winProcEstablishConnectionOrig; + iReturn = (*winProcEstablishConnectionOrig) (client); + winProcEstablishConnectionOrig = NULL; + return iReturn; + } + /* Watch for server reset */ if (s_ulServerGeneration != serverGeneration) { diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c index eb495cb41..0f3bdda9f 100644 --- a/hw/xwin/winclipboardxevents.c +++ b/hw/xwin/winclipboardxevents.c @@ -78,6 +78,7 @@ winClipboardFlushXEvents (HWND hwnd, int i; Bool fAbort = FALSE; Bool fCloseClipboard = FALSE; + Bool fSetClipboardData = TRUE; /* Get the next event - will not block because one is ready */ XNextEvent (pDisplay, &event); @@ -734,6 +735,9 @@ winClipboardFlushXEvents (HWND hwnd, else SetClipboardData (CF_TEXT, hGlobal); + /* Flag that SetClipboardData has been called */ + fSetClipboardData = FALSE; + /* * NOTE: Do not try to free pszGlobalData, it is owned by * Windows after the call to SetClipboardData (). @@ -751,6 +755,10 @@ winClipboardFlushXEvents (HWND hwnd, free (pwszUnicodeStr); if (hGlobal && pszGlobalData) GlobalUnlock (hGlobal); + if (fSetClipboardData && fUnicodeSupport) + SetClipboardData (CF_UNICODETEXT, NULL); + if (fSetClipboardData && !fUnicodeSupport) + SetClipboardData (CF_TEXT, NULL); break; default: diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c index c8cac1658..9cd9c1e04 100644 --- a/hw/xwin/winglobals.c +++ b/hw/xwin/winglobals.c @@ -85,7 +85,6 @@ winDispatchProcPtr winProcSetSelectionOwnerOrig = NULL; Bool g_fClipboardLaunched = FALSE; Bool g_fClipboardStarted = FALSE; pthread_t g_ptClipboardProc; -Bool g_fClipboardStarted; HWND g_hwndClipboard; void *g_pClipboardDisplay; Window g_iClipboardWindow; @@ -98,7 +97,12 @@ Atom g_atomLastOwnedSelection; */ void -winInitializeGlobals () +winInitializeGlobals (void) { g_fClipboardLaunched = FALSE; + g_fClipboardStarted = FALSE; + g_iClipboardWindow = None; + g_pClipboardDisplay = NULL; + g_atomLastOwnedSelection = None; + g_hwndClipboard = NULL; } diff --git a/hw/xwin/winmsg.h b/hw/xwin/winmsg.h index 16ec536b0..169698d09 100644 --- a/hw/xwin/winmsg.h +++ b/hw/xwin/winmsg.h @@ -1,3 +1,5 @@ +#ifndef __WIN_MSG_H__ +#define __WIN_MSG_H__ /* *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. * @@ -29,8 +31,6 @@ */ /* $XFree86: xc/programs/Xserver/hw/xwin/winmsg.h,v 1.2 2003/10/02 13:30:10 eich Exp $ */ -#ifndef __WIN_MSG_H__ -#define __WIN_MSG_H__ /* * Function prototypes diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 7ef8c4b2c..09a97b578 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -661,7 +661,7 @@ winMultiWindowWMProc (void *pArg) break; default: - ErrorF ("winMultiWindowWMProc - Unknown Message.\n"); + ErrorF ("winMultiWindowWMProc - Unknown Message. Exiting.\n"); pthread_exit (NULL); break; } @@ -688,7 +688,6 @@ winMultiWindowWMProc (void *pArg) } - /* * X message procedure */ @@ -712,7 +711,7 @@ winMultiWindowXMsgProc (void *pArg) /* Check that argument pointer is not invalid */ if (pProcArg == NULL) { - ErrorF ("winMultiWindowXMsgProc - pProcArg is NULL, bailing.\n"); + ErrorF ("winMultiWindowXMsgProc - pProcArg is NULL. Exiting.\n"); pthread_exit (NULL); } @@ -722,7 +721,8 @@ winMultiWindowXMsgProc (void *pArg) iReturn = pthread_mutex_lock (pProcArg->ppmServerStarted); if (iReturn != 0) { - ErrorF ("winMultiWindowXMsgProc - pthread_mutex_lock () failed: %d\n", + ErrorF ("winMultiWindowXMsgProc - pthread_mutex_lock () failed: %d. " + "Exiting.\n", iReturn); pthread_exit (NULL); } @@ -732,7 +732,7 @@ winMultiWindowXMsgProc (void *pArg) /* Allow multiple threads to access Xlib */ if (XInitThreads () == 0) { - ErrorF ("winMultiWindowXMsgProc - XInitThreads () failed.\n"); + ErrorF ("winMultiWindowXMsgProc - XInitThreads () failed. Exiting.\n"); pthread_exit (NULL); } @@ -757,13 +757,13 @@ winMultiWindowXMsgProc (void *pArg) && iReturn != WIN_JMP_OKAY) { /* setjmp returned an unknown value, exit */ - ErrorF ("winInitMultiWindowXMsgProc - setjmp returned: %d exiting\n", + ErrorF ("winInitMultiWindowXMsgProc - setjmp returned: %d. Exiting.\n", iReturn); pthread_exit (NULL); } else if (iReturn == WIN_JMP_ERROR_IO) { - ErrorF ("winInitMultiWindowXMsgProc - Caught IO Error, shutting down\n"); + ErrorF ("winInitMultiWindowXMsgProc - Caught IO Error. Exiting.\n"); pthread_exit (NULL); } @@ -803,8 +803,8 @@ winMultiWindowXMsgProc (void *pArg) /* Make sure that the display opened */ if (pProcArg->pDisplay == NULL) { - ErrorF ("winMultiWindowXMsgProc - " - "Failed opening the display, giving up.\n\f"); + ErrorF ("winMultiWindowXMsgProc - Failed opening the display. " + "Exiting.\n"); pthread_exit (NULL); } @@ -978,7 +978,7 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) /* Check that argument pointer is not invalid */ if (pProcArg == NULL) { - ErrorF ("winInitMultiWindowWM - pProcArg is NULL, bailing.\n"); + ErrorF ("winInitMultiWindowWM - pProcArg is NULL. Exiting.\n"); pthread_exit (NULL); } @@ -988,7 +988,8 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) iReturn = pthread_mutex_lock (pProcArg->ppmServerStarted); if (iReturn != 0) { - ErrorF ("winInitMultiWindowWM - pthread_mutex_lock () failed: %d\n", + ErrorF ("winInitMultiWindowWM - pthread_mutex_lock () failed: %d. " + "Exiting.\n", iReturn); pthread_exit (NULL); } @@ -998,7 +999,7 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) /* Allow multiple threads to access Xlib */ if (XInitThreads () == 0) { - ErrorF ("winInitMultiWindowWM - XInitThreads () failed.\n"); + ErrorF ("winInitMultiWindowWM - XInitThreads () failed. Exiting.\n"); pthread_exit (NULL); } @@ -1022,13 +1023,13 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) && iReturn != WIN_JMP_OKAY) { /* setjmp returned an unknown value, exit */ - ErrorF ("winInitMultiWindowWM - setjmp returned: %d exiting\n", + ErrorF ("winInitMultiWindowWM - setjmp returned: %d. Exiting.\n", iReturn); pthread_exit (NULL); } else if (iReturn == WIN_JMP_ERROR_IO) { - ErrorF ("winInitMultiWindowWM - Caught IO Error, shutting down\n"); + ErrorF ("winInitMultiWindowWM - Caught IO Erro. Exiting.\n"); pthread_exit (NULL); } @@ -1068,8 +1069,8 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) /* Make sure that the display opened */ if (pWMInfo->pDisplay == NULL) { - ErrorF ("winInitMultiWindowWM - Failed opening the display, " - "giving up.\n\f"); + ErrorF ("winInitMultiWindowWM - Failed opening the display. " + "Exiting.\n"); pthread_exit (NULL); }