From 0ed0d3979050c4ee7bef64441d50c494d58d93b0 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Thu, 5 Jul 2012 22:08:38 +0100 Subject: [PATCH] hw/xwin: Remove winClipboardDetectUnicodeSupport() This code for detecting if the Windows clipboard can support unicode is long obsolete. All NT versions of Windows support unicode clipboard, so any version of Windows we can run on must support unicode clipboard. The -nounicodeclipboard flag to disable use of unicode on the clipboard is retained. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/Makefile.am | 1 - hw/xwin/winclipboard.h | 7 ---- hw/xwin/winclipboardthread.c | 6 +--- hw/xwin/winclipboardunicode.c | 65 ---------------------------------- hw/xwin/winclipboardwndproc.c | 7 ++-- hw/xwin/winclipboardwrappers.c | 8 ++--- hw/xwin/winclipboardxevents.c | 14 ++------ 7 files changed, 8 insertions(+), 100 deletions(-) delete mode 100644 hw/xwin/winclipboardunicode.c diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am index c49016398..4c2f04ef0 100644 --- a/hw/xwin/Makefile.am +++ b/hw/xwin/Makefile.am @@ -5,7 +5,6 @@ SRCS_CLIPBOARD = \ winclipboardinit.c \ winclipboardtextconv.c \ winclipboardthread.c \ - winclipboardunicode.c \ winclipboardwndproc.c \ winclipboardwrappers.c \ winclipboardxevents.c diff --git a/hw/xwin/winclipboard.h b/hw/xwin/winclipboard.h index 203a9639a..27eb2f96f 100644 --- a/hw/xwin/winclipboard.h +++ b/hw/xwin/winclipboard.h @@ -111,13 +111,6 @@ void *winClipboardProc(void *); void winDeinitClipboard(void); -/* - * winclipboardunicode.c - */ - -Bool - winClipboardDetectUnicodeSupport(void); - /* * winclipboardwndproc.c */ diff --git a/hw/xwin/winclipboardthread.c b/hw/xwin/winclipboardthread.c index 47bd50fd8..f2e8e6d6f 100644 --- a/hw/xwin/winclipboardthread.c +++ b/hw/xwin/winclipboardthread.c @@ -64,7 +64,6 @@ static int clipboardRestarts = 0; static XIOErrorHandler g_winClipboardOldIOErrorHandler; static pthread_t g_winClipboardProcThread; -Bool g_fUnicodeSupport = FALSE; Bool g_fUseUnicode = FALSE; /* @@ -106,11 +105,8 @@ winClipboardProc(void *pvNotUsed) winDebug("winClipboardProc - Hello\n"); ++clipboardRestarts; - /* Do we have Unicode support? */ - g_fUnicodeSupport = winClipboardDetectUnicodeSupport(); - /* Do we use Unicode clipboard? */ - fUseUnicode = g_fUnicodeClipboard && g_fUnicodeSupport; + fUseUnicode = g_fUnicodeClipboard; /* Save the Unicode support flag in a global */ g_fUseUnicode = fUseUnicode; diff --git a/hw/xwin/winclipboardunicode.c b/hw/xwin/winclipboardunicode.c deleted file mode 100644 index 9c06f7b4d..000000000 --- a/hw/xwin/winclipboardunicode.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved. - * - *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 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 HAROLD L HUNT II 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. - * - *Except as contained in this notice, the name of Harold L Hunt II - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from Harold L Hunt II. - * - * Authors: Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include -#endif -#include "winclipboard.h" - -/* - * Determine whether we suport Unicode or not. - * NOTE: Currently, just check if we are on an NT-based platform or not. - */ - -Bool -winClipboardDetectUnicodeSupport(void) -{ - Bool fReturn = FALSE; - OSVERSIONINFO osvi = { 0 }; - - /* Get operating system version information */ - osvi.dwOSVersionInfoSize = sizeof(osvi); - GetVersionEx(&osvi); - - /* Branch on platform ID */ - switch (osvi.dwPlatformId) { - case VER_PLATFORM_WIN32_NT: - /* Unicode supported on NT only */ - fReturn = TRUE; - break; - - case VER_PLATFORM_WIN32_WINDOWS: - /* Unicode is not supported on non-NT */ - fReturn = FALSE; - break; - } - - return fReturn; -} diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c index 78b061517..cbe6599f4 100644 --- a/hw/xwin/winclipboardwndproc.c +++ b/hw/xwin/winclipboardwndproc.c @@ -49,7 +49,6 @@ */ extern Bool g_fUseUnicode; -extern Bool g_fUnicodeSupport; extern void *g_pClipboardDisplay; extern Window g_iClipboardWindow; extern Atom g_atomLastOwnedSelection; @@ -60,6 +59,7 @@ extern Atom g_atomLastOwnedSelection; static int + winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay, Bool fUseUnicode, int iTimeoutSec); @@ -415,7 +415,7 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (message == WM_RENDERALLFORMATS) fConvertToUnicode = FALSE; else - fConvertToUnicode = g_fUnicodeSupport && (CF_UNICODETEXT == wParam); + fConvertToUnicode = (CF_UNICODETEXT == wParam); /* Request the selection contents */ iReturn = XConvertSelection(pDisplay, @@ -470,8 +470,7 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) */ if (WIN_XEVENTS_NOTIFY != iReturn) { /* Paste no data, to satisfy required call to SetClipboardData */ - if (g_fUnicodeSupport) - SetClipboardData(CF_UNICODETEXT, NULL); + SetClipboardData(CF_UNICODETEXT, NULL); SetClipboardData(CF_TEXT, NULL); ErrorF diff --git a/hw/xwin/winclipboardwrappers.c b/hw/xwin/winclipboardwrappers.c index 882edc18e..1118f4ff8 100644 --- a/hw/xwin/winclipboardwrappers.c +++ b/hw/xwin/winclipboardwrappers.c @@ -60,7 +60,6 @@ DISPATCH_PROC(winProcSetSelectionOwner); * References to external symbols */ -extern Bool g_fUnicodeSupport; extern int g_iNumScreens; extern unsigned int g_uiAuthDataLen; extern char *g_pAuthData; @@ -362,11 +361,8 @@ winProcSetSelectionOwner(ClientPtr client) goto winProcSetSelectionOwner_Done; } - /* Advertise Unicode if we support it */ - if (g_fUnicodeSupport) - SetClipboardData(CF_UNICODETEXT, NULL); - - /* Always advertise regular text */ + /* Advertise regular text and unicode */ + SetClipboardData(CF_UNICODETEXT, NULL); SetClipboardData(CF_TEXT, NULL); /* Save handle to last owned selection */ diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c index 59b1f0715..ce533c59f 100644 --- a/hw/xwin/winclipboardxevents.c +++ b/hw/xwin/winclipboardxevents.c @@ -36,12 +36,6 @@ #include "winclipboard.h" #include "misc.h" -/* - * References to external symbols - */ - -extern Bool g_fUnicodeSupport; - /* * Process any pending X events */ @@ -228,10 +222,6 @@ winClipboardFlushXEvents(HWND hwnd, else xiccesStyle = XStringStyle; - /* - * FIXME: Can't pass CF_UNICODETEXT on Windows 95/98/Me - */ - /* Get a pointer to the clipboard text, in desired format */ if (fUseUnicode) { /* Retrieve clipboard data */ @@ -687,10 +677,10 @@ winClipboardFlushXEvents(HWND hwnd, free(pwszUnicodeStr); if (hGlobal && pszGlobalData) GlobalUnlock(hGlobal); - if (fSetClipboardData && g_fUnicodeSupport) + if (fSetClipboardData) { SetClipboardData(CF_UNICODETEXT, NULL); - if (fSetClipboardData) SetClipboardData(CF_TEXT, NULL); + } return WIN_XEVENTS_NOTIFY; case SelectionClear: