summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2018-07-01 12:11:19 +0100
committerJon Turney <jon.turney@dronecode.org.uk>2019-06-15 19:55:52 +0100
commita5ef6cc5464c5af191a89934a2caf58f31987636 (patch)
tree9338ee8554a2b3f49cf26d051096c2694fef95f9
parent3c3c25b95348232fe7ac3380188ba2056cc14483 (diff)
hw/xwin: Remove nounicodeclipboard option
Always use CF_UNICODETEXT clipboard format. Windows will automatically down-convert to CF_TEXT for clients which request that. This is subtly different in one way: if CF_TEXT is requested, we now post CF_UNICODETEXT and it is converted to CF_TEXT *in the locale of the requesting process*. Previously, we would convert to CF_TEXT *in our locale* and post that. Note that the !X_HAVE_UTF8_STRING case was utterly botched, but fortunately that has never been true...
-rw-r--r--hw/xwin/InitOutput.c3
-rw-r--r--hw/xwin/man/XWin.man3
-rw-r--r--hw/xwin/winclipboard/internal.h1
-rw-r--r--hw/xwin/winclipboard/thread.c3
-rw-r--r--hw/xwin/winclipboard/winclipboard.h2
-rw-r--r--hw/xwin/winclipboard/wndproc.c5
-rw-r--r--hw/xwin/winclipboard/xevents.c142
-rw-r--r--hw/xwin/winclipboard/xwinclip.c20
-rw-r--r--hw/xwin/winclipboard/xwinclip.man3
-rw-r--r--hw/xwin/winclipboardinit.c2
-rw-r--r--hw/xwin/winglobals.c1
-rw-r--r--hw/xwin/winglobals.h1
-rw-r--r--hw/xwin/winprocarg.c9
13 files changed, 49 insertions, 146 deletions
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index bf34466ad..ec3144993 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -820,9 +820,6 @@ winUseMsg(void)
"\tDo not draw a window border, title bar, etc. Windowed\n"
"\tmode only.\n");
- ErrorF("-nounicodeclipboard\n"
- "\tDo not use Unicode clipboard even if on a NT-based platform.\n");
-
ErrorF("-[no]primary\n"
"\tWhen clipboard integration is enabled, map the X11 PRIMARY selection\n"
"\tto the Windows clipboard. Default is enabled.\n");
diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man
index ac45108a3..3e10db3e5 100644
--- a/hw/xwin/man/XWin.man
+++ b/hw/xwin/man/XWin.man
@@ -233,9 +233,6 @@ icon per screen. You can globally disable tray icons with
\fB\-notrayicon\fP, then enable it for specific screens with
\fB\-trayicon\fP for those screens.
.TP 8
-.B \-nounicodeclipboard
-Do not use Unicode clipboard even if on a NT-based platform.
-.TP 8
.B \-[no]unixkill
Enable or disable the \fICtrl-Alt-Backspace\fP key combination as a
signal to exit the X Server. The \fICtrl-Alt-Backspace\fP key combination
diff --git a/hw/xwin/winclipboard/internal.h b/hw/xwin/winclipboard/internal.h
index 6dc2fb660..2c4a20426 100644
--- a/hw/xwin/winclipboard/internal.h
+++ b/hw/xwin/winclipboard/internal.h
@@ -100,7 +100,6 @@ typedef struct
typedef struct
{
- Bool fUseUnicode;
Atom *targetList;
unsigned char *incr;
unsigned long int incrsize;
diff --git a/hw/xwin/winclipboard/thread.c b/hw/xwin/winclipboard/thread.c
index c92d41c95..4dd819e75 100644
--- a/hw/xwin/winclipboard/thread.c
+++ b/hw/xwin/winclipboard/thread.c
@@ -106,7 +106,7 @@ static int
*/
Bool
-winClipboardProc(Bool fUseUnicode, char *szDisplay)
+winClipboardProc(char *szDisplay)
{
ClipboardAtoms atoms;
int iReturn;
@@ -271,7 +271,6 @@ winClipboardProc(Bool fUseUnicode, char *szDisplay)
}
}
- data.fUseUnicode = fUseUnicode;
data.incr = NULL;
data.incrsize = 0;
diff --git a/hw/xwin/winclipboard/winclipboard.h b/hw/xwin/winclipboard/winclipboard.h
index 9c5c568a7..2ae27fd2b 100644
--- a/hw/xwin/winclipboard/winclipboard.h
+++ b/hw/xwin/winclipboard/winclipboard.h
@@ -27,7 +27,7 @@
#ifndef WINCLIPBOARD_H
#define WINCLIPBOARD_H
-Bool winClipboardProc(Bool fUseUnicode, char *szDisplay);
+Bool winClipboardProc(char *szDisplay);
void winFixClipboardChain(void);
diff --git a/hw/xwin/winclipboard/wndproc.c b/hw/xwin/winclipboard/wndproc.c
index 59857b703..d1f7d4cfb 100644
--- a/hw/xwin/winclipboard/wndproc.c
+++ b/hw/xwin/winclipboard/wndproc.c
@@ -322,7 +322,6 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_RENDERFORMAT:
{
int iReturn;
- Bool fConvertToUnicode;
Bool pasted = FALSE;
Atom selection;
ClipboardConversionData data;
@@ -331,9 +330,6 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
winDebug("winClipboardWindowProc - WM_RENDERFORMAT %d - Hello.\n",
(int)wParam);
- /* Flag whether to convert to Unicode or not */
- fConvertToUnicode = (CF_UNICODETEXT == wParam);
-
selection = winClipboardGetLastOwnedSelectionAtom(atoms);
if (selection == None) {
ErrorF("winClipboardWindowProc - no monitored selection is owned\n");
@@ -350,7 +346,6 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
iWindow, CurrentTime);
/* Process X events */
- data.fUseUnicode = fConvertToUnicode;
data.incr = NULL;
data.incrsize = 0;
diff --git a/hw/xwin/winclipboard/xevents.c b/hw/xwin/winclipboard/xevents.c
index 7d55f3d92..36e136148 100644
--- a/hw/xwin/winclipboard/xevents.c
+++ b/hw/xwin/winclipboard/xevents.c
@@ -200,7 +200,6 @@ winClipboardSelectionNotifyData(HWND hwnd, Window iWindow, Display *pDisplay, Cl
char *pszReturnData = NULL;
wchar_t *pwszUnicodeStr = NULL;
HGLOBAL hGlobal = NULL;
- char *pszConvertData = NULL;
char *pszGlobalData = NULL;
/* Retrieve the selection data and delete the property */
@@ -268,19 +267,13 @@ winClipboardSelectionNotifyData(HWND hwnd, Window iWindow, Display *pDisplay, Cl
xtpText.nitems = nitems;
}
- if (data->fUseUnicode) {
#ifdef X_HAVE_UTF8_STRING
- /* Convert the text property to a text list */
- iReturn = Xutf8TextPropertyToTextList(pDisplay,
- &xtpText,
- &ppszTextList, &iCount);
+ /* Convert the text property to a text list */
+ iReturn = Xutf8TextPropertyToTextList(pDisplay,
+ &xtpText,
+ &ppszTextList, &iCount);
#endif
- }
- else {
- iReturn = XmbTextPropertyToTextList(pDisplay,
- &xtpText,
- &ppszTextList, &iCount);
- }
+
if (iReturn == Success || iReturn > 0) {
/* Conversion succeeded or some unconvertible characters */
if (ppszTextList != NULL) {
@@ -343,40 +336,30 @@ winClipboardSelectionNotifyData(HWND hwnd, Window iWindow, Display *pDisplay, Cl
/* Convert the X clipboard string to DOS format */
winClipboardUNIXtoDOS(&pszReturnData, strlen(pszReturnData));
- if (data->fUseUnicode) {
- /* Find out how much space needed to convert MBCS to Unicode */
- int iUnicodeLen = MultiByteToWideChar(CP_UTF8,
- 0,
- pszReturnData, -1, NULL, 0);
+ /* Find out how much space needed to convert MBCS to Unicode */
+ int iUnicodeLen = MultiByteToWideChar(CP_UTF8,
+ 0,
+ pszReturnData, -1, NULL, 0);
- /* NOTE: iUnicodeLen includes space for null terminator */
- pwszUnicodeStr = malloc(sizeof(wchar_t) * iUnicodeLen);
- if (!pwszUnicodeStr) {
- ErrorF("winClipboardFlushXEvents - SelectionNotify "
- "malloc failed for pwszUnicodeStr, aborting.\n");
+ /* NOTE: iUnicodeLen includes space for null terminator */
+ pwszUnicodeStr = malloc(sizeof(wchar_t) * iUnicodeLen);
+ if (!pwszUnicodeStr) {
+ ErrorF("winClipboardFlushXEvents - SelectionNotify "
+ "malloc failed for pwszUnicodeStr, aborting.\n");
- /* Abort */
- goto winClipboardFlushXEvents_SelectionNotify_Done;
- }
+ /* Abort */
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
- /* Do the actual conversion */
- MultiByteToWideChar(CP_UTF8,
- 0,
- pszReturnData,
- -1, pwszUnicodeStr, iUnicodeLen);
+ /* Do the actual conversion */
+ MultiByteToWideChar(CP_UTF8,
+ 0,
+ pszReturnData,
+ -1, pwszUnicodeStr, iUnicodeLen);
- /* Allocate global memory for the X clipboard data */
- hGlobal = GlobalAlloc(GMEM_MOVEABLE,
- sizeof(wchar_t) * iUnicodeLen);
- }
- else {
- int iConvertDataLen = 0;
- pszConvertData = strdup(pszReturnData);
- iConvertDataLen = strlen(pszConvertData) + 1;
+ /* Allocate global memory for the X clipboard data */
+ hGlobal = GlobalAlloc(GMEM_MOVEABLE, sizeof(wchar_t) * iUnicodeLen);
- /* Allocate global memory for the X clipboard data */
- hGlobal = GlobalAlloc(GMEM_MOVEABLE, iConvertDataLen);
- }
free(pszReturnData);
@@ -400,26 +383,16 @@ winClipboardSelectionNotifyData(HWND hwnd, Window iWindow, Display *pDisplay, Cl
}
/* Copy the returned string into the global memory */
- if (data->fUseUnicode) {
- wcscpy((wchar_t *)pszGlobalData, pwszUnicodeStr);
- free(pwszUnicodeStr);
- pwszUnicodeStr = NULL;
- }
- else {
- strcpy(pszGlobalData, pszConvertData);
- free(pszConvertData);
- pszConvertData = NULL;
- }
+ wcscpy((wchar_t *)pszGlobalData, pwszUnicodeStr);
+ free(pwszUnicodeStr);
+ pwszUnicodeStr = NULL;
/* Release the pointer to the global memory */
GlobalUnlock(hGlobal);
pszGlobalData = NULL;
/* Push the selection data to the Windows clipboard */
- if (data->fUseUnicode)
- SetClipboardData(CF_UNICODETEXT, hGlobal);
- else
- SetClipboardData(CF_TEXT, hGlobal);
+ SetClipboardData(CF_UNICODETEXT, hGlobal);
/* Flag that SetClipboardData has been called */
fSetClipboardData = FALSE;
@@ -438,7 +411,6 @@ winClipboardSelectionNotifyData(HWND hwnd, Window iWindow, Display *pDisplay, Cl
value = NULL;
nitems = 0;
}
- free(pszConvertData);
free(pwszUnicodeStr);
if (hGlobal && pszGlobalData)
GlobalUnlock(hGlobal);
@@ -577,7 +549,7 @@ winClipboardFlushXEvents(HWND hwnd,
fCloseClipboard = TRUE;
/* Check that clipboard format is available */
- if (data->fUseUnicode && !IsClipboardFormatAvailable(CF_UNICODETEXT)) {
+ if (!IsClipboardFormatAvailable(CF_UNICODETEXT)) {
static int count; /* Hack to stop acroread spamming the log */
static HWND lasthwnd; /* I've not seen any other client get here repeatedly? */
@@ -594,14 +566,6 @@ winClipboardFlushXEvents(HWND hwnd,
fAbort = TRUE;
goto winClipboardFlushXEvents_SelectionRequest_Done;
}
- else if (!data->fUseUnicode && !IsClipboardFormatAvailable(CF_TEXT)) {
- ErrorF("winClipboardFlushXEvents - CF_TEXT is not "
- "available from Win32 clipboard. Aborting.\n");
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
/* Setup the string style */
if (event.xselectionrequest.target == XA_STRING)
@@ -616,14 +580,9 @@ winClipboardFlushXEvents(HWND hwnd,
xiccesStyle = XStringStyle;
/* Get a pointer to the clipboard text, in desired format */
- if (data->fUseUnicode) {
- /* Retrieve clipboard data */
- hGlobal = GetClipboardData(CF_UNICODETEXT);
- }
- else {
- /* Retrieve clipboard data */
- hGlobal = GetClipboardData(CF_TEXT);
- }
+ /* Retrieve clipboard data */
+ hGlobal = GetClipboardData(CF_UNICODETEXT);
+
if (!hGlobal) {
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
"GetClipboardData () failed: %08x\n", (unsigned int)GetLastError());
@@ -635,23 +594,18 @@ winClipboardFlushXEvents(HWND hwnd,
pszGlobalData = (char *) GlobalLock(hGlobal);
/* Convert the Unicode string to UTF8 (MBCS) */
- if (data->fUseUnicode) {
- int iConvertDataLen = WideCharToMultiByte(CP_UTF8,
+ int iConvertDataLen = WideCharToMultiByte(CP_UTF8,
0,
(LPCWSTR) pszGlobalData,
-1, NULL, 0, NULL, NULL);
- /* NOTE: iConvertDataLen includes space for null terminator */
- pszConvertData = malloc(iConvertDataLen);
- WideCharToMultiByte(CP_UTF8,
- 0,
- (LPCWSTR) pszGlobalData,
- -1,
- pszConvertData,
- iConvertDataLen, NULL, NULL);
- }
- else {
- pszConvertData = strdup(pszGlobalData);
- }
+ /* NOTE: iConvertDataLen includes space for null terminator */
+ pszConvertData = malloc(iConvertDataLen);
+ WideCharToMultiByte(CP_UTF8,
+ 0,
+ (LPCWSTR) pszGlobalData,
+ -1,
+ pszConvertData,
+ iConvertDataLen, NULL, NULL);
/* Convert DOS string to UNIX string */
winClipboardDOStoUNIX(pszConvertData, strlen(pszConvertData));
@@ -665,18 +619,12 @@ winClipboardFlushXEvents(HWND hwnd,
xtpText.nitems = 0;
/* Create the text property from the text list */
- if (data->fUseUnicode) {
#ifdef X_HAVE_UTF8_STRING
- iReturn = Xutf8TextListToTextProperty(pDisplay,
- pszTextList,
- 1, xiccesStyle, &xtpText);
+ iReturn = Xutf8TextListToTextProperty(pDisplay,
+ pszTextList,
+ 1, xiccesStyle, &xtpText);
#endif
- }
- else {
- iReturn = XmbTextListToTextProperty(pDisplay,
- pszTextList,
- 1, xiccesStyle, &xtpText);
- }
+
if (iReturn == XNoMemory || iReturn == XLocaleNotSupported) {
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
"X*TextListToTextProperty failed: %d\n", iReturn);
diff --git a/hw/xwin/winclipboard/xwinclip.c b/hw/xwin/winclipboard/xwinclip.c
index 856c4dd54..6fd1c7598 100644
--- a/hw/xwin/winclipboard/xwinclip.c
+++ b/hw/xwin/winclipboard/xwinclip.c
@@ -67,7 +67,6 @@ main (int argc, char *argv[])
{
int i;
char *pszDisplay = NULL;
- int fUnicodeClipboard = 1;
/* Parse command-line parameters */
for (i = 1; i < argc; ++i)
@@ -85,13 +84,6 @@ main (int argc, char *argv[])
continue;
}
- /* Look for -nounicodeclipboard */
- if (!strcmp (argv[i], "-nounicodeclipboard"))
- {
- fUnicodeClipboard = 0;
- continue;
- }
-
/* Look for -noprimary */
if (!strcmp (argv[i], "-noprimary"))
{
@@ -104,16 +96,6 @@ main (int argc, char *argv[])
exit (1);
}
- /* Do we have Unicode support? */
- if (fUnicodeClipboard)
- {
- printf ("Unicode clipboard I/O\n");
- }
- else
- {
- printf ("Non Unicode clipboard I/O\n");
- }
-
/* Apply locale specified in the LANG environment variable */
if (!setlocale (LC_ALL, ""))
{
@@ -128,7 +110,7 @@ main (int argc, char *argv[])
setlocale(LC_ALL, "C");
}
- winClipboardProc(fUnicodeClipboard, pszDisplay);
+ winClipboardProc(pszDisplay);
return 0;
}
diff --git a/hw/xwin/winclipboard/xwinclip.man b/hw/xwin/winclipboard/xwinclip.man
index f9e0d3bfb..e3db50177 100644
--- a/hw/xwin/winclipboard/xwinclip.man
+++ b/hw/xwin/winclipboard/xwinclip.man
@@ -27,9 +27,6 @@ Do \fINOT\fP run \fIxwinclip\fP unless \fIXWin(1)\fP has been started with the -
.B \-display [display]
Specifies the X server display to connect to.
.TP 8
-.B \-nounicodeclipboard
-Do not use unicode text on the clipboard.
-.TP 8
.B \-noprimary
Do not monitor the PRIMARY selection.
diff --git a/hw/xwin/winclipboardinit.c b/hw/xwin/winclipboardinit.c
index 8aef8fe02..3324661df 100644
--- a/hw/xwin/winclipboardinit.c
+++ b/hw/xwin/winclipboardinit.c
@@ -82,7 +82,7 @@ winClipboardThreadProc(void *arg)
/* Flag that clipboard client has been launched */
g_fClipboardStarted = TRUE;
- fShutdown = winClipboardProc(g_fUnicodeClipboard, szDisplay);
+ fShutdown = winClipboardProc(szDisplay);
/* Flag that clipboard client has stopped */
g_fClipboardStarted = FALSE;
diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c
index b0086f871..9bd6c0f5a 100644
--- a/hw/xwin/winglobals.c
+++ b/hw/xwin/winglobals.c
@@ -90,7 +90,6 @@ winDispatchProcPtr winProcEstablishConnectionOrig = NULL;
* Clipboard variables
*/
-Bool g_fUnicodeClipboard = TRUE;
Bool g_fClipboard = TRUE;
Bool g_fClipboardStarted = FALSE;
diff --git a/hw/xwin/winglobals.h b/hw/xwin/winglobals.h
index fee507683..a0469e1c5 100644
--- a/hw/xwin/winglobals.h
+++ b/hw/xwin/winglobals.h
@@ -68,7 +68,6 @@ typedef int (*winDispatchProcPtr) (ClientPtr);
* Wrapped DIX functions
*/
extern winDispatchProcPtr winProcEstablishConnectionOrig;
-extern Bool g_fUnicodeClipboard;
extern Bool g_fClipboard;
extern Bool g_fClipboardStarted;
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index a69b41853..d930f2aa7 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -1012,15 +1012,6 @@ ddxProcessArgument(int argc, char *argv[], int i)
return 2;
}
- /*
- * Look for the '-nounicodeclipboard' argument
- */
- if (IS_OPTION("-nounicodeclipboard")) {
- g_fUnicodeClipboard = FALSE;
- /* Indicate that we have processed the argument */
- return 1;
- }
-
if (IS_OPTION("-xkbrules")) {
CHECK_ARGS(1);
g_cmdline.xkbRules = argv[++i];