Cleanup code for copy/paste of text
Remove support for COMPOUND_TEXT. All apps should these days support UTF8_STRING. If not they'll have to live with STRING or TEXT. ICCCM states that TEXT is in the encoding of choice. Make this latin1 instead of local8bit. XA_STRING is defined to be latin1, so don't use local8bit here neither.
This commit is contained in:
parent
ab74e89f5f
commit
f190d39197
@ -577,27 +577,6 @@ bool QXcbClipboard::clipboardReadProperty(xcb_window_t win, xcb_atom_t property,
|
|||||||
|
|
||||||
free(reply);
|
free(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ###### FIXME
|
|
||||||
if (*format == 8 && type == m_connection->atom(QXcbAtom::COMPOUND_TEXT)) {
|
|
||||||
// convert COMPOUND_TEXT to a multibyte string
|
|
||||||
XTextProperty textprop;
|
|
||||||
textprop.encoding = type;
|
|
||||||
textprop.format = *format;
|
|
||||||
textprop.nitems = buffer_offset;
|
|
||||||
textprop.value = (unsigned char *) buffer->data();
|
|
||||||
|
|
||||||
char **list_ret = 0;
|
|
||||||
int count;
|
|
||||||
if (XmbTextPropertyToTextList(DISPLAY_FROM_XCB(m_connection), &textprop, &list_ret,
|
|
||||||
&count) == Success && count && list_ret) {
|
|
||||||
offset = buffer_offset = strlen(list_ret[0]);
|
|
||||||
buffer->resize(offset);
|
|
||||||
memcpy(buffer->data(), list_ret[0], offset);
|
|
||||||
}
|
|
||||||
if (list_ret) XFreeStringList(list_ret);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -628,7 +628,6 @@ static const char * xcb_atomnames = {
|
|||||||
"_NET_ACTIVE_WINDOW\0"
|
"_NET_ACTIVE_WINDOW\0"
|
||||||
|
|
||||||
// Property formats
|
// Property formats
|
||||||
"COMPOUND_TEXT\0"
|
|
||||||
"TEXT\0"
|
"TEXT\0"
|
||||||
"UTF8_STRING\0"
|
"UTF8_STRING\0"
|
||||||
|
|
||||||
|
@ -171,7 +171,6 @@ namespace QXcbAtom {
|
|||||||
_NET_ACTIVE_WINDOW,
|
_NET_ACTIVE_WINDOW,
|
||||||
|
|
||||||
// Property formats
|
// Property formats
|
||||||
COMPOUND_TEXT,
|
|
||||||
TEXT,
|
TEXT,
|
||||||
UTF8_STRING,
|
UTF8_STRING,
|
||||||
|
|
||||||
|
@ -69,8 +69,7 @@ QString QXcbMime::mimeAtomToString(QXcbConnection *connection, xcb_atom_t a)
|
|||||||
// special cases for string type
|
// special cases for string type
|
||||||
if (a == QXcbAtom::XA_STRING
|
if (a == QXcbAtom::XA_STRING
|
||||||
|| a == connection->atom(QXcbAtom::UTF8_STRING)
|
|| a == connection->atom(QXcbAtom::UTF8_STRING)
|
||||||
|| a == connection->atom(QXcbAtom::TEXT)
|
|| a == connection->atom(QXcbAtom::TEXT))
|
||||||
|| a == connection->atom(QXcbAtom::COMPOUND_TEXT))
|
|
||||||
return QLatin1String("text/plain");
|
return QLatin1String("text/plain");
|
||||||
|
|
||||||
// special case for images
|
// special case for images
|
||||||
@ -98,36 +97,17 @@ bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeDa
|
|||||||
|
|
||||||
if ((a == connection->atom(QXcbAtom::UTF8_STRING)
|
if ((a == connection->atom(QXcbAtom::UTF8_STRING)
|
||||||
|| a == QXcbAtom::XA_STRING
|
|| a == QXcbAtom::XA_STRING
|
||||||
|| a == connection->atom(QXcbAtom::TEXT)
|
|| a == connection->atom(QXcbAtom::TEXT))
|
||||||
|| a == connection->atom(QXcbAtom::COMPOUND_TEXT))
|
|
||||||
&& QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)) {
|
&& QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)) {
|
||||||
if (a == connection->atom(QXcbAtom::UTF8_STRING)){
|
if (a == connection->atom(QXcbAtom::UTF8_STRING)) {
|
||||||
*data = QInternalMimeData::renderDataHelper(QLatin1String("text/plain"), mimeData);
|
*data = QInternalMimeData::renderDataHelper(QLatin1String("text/plain"), mimeData);
|
||||||
ret = true;
|
ret = true;
|
||||||
} else if (a == QXcbAtom::XA_STRING) {
|
} else if (a == QXcbAtom::XA_STRING ||
|
||||||
|
a == connection->atom(QXcbAtom::TEXT)) {
|
||||||
|
// ICCCM says STRING is latin1
|
||||||
*data = QString::fromUtf8(QInternalMimeData::renderDataHelper(
|
*data = QString::fromUtf8(QInternalMimeData::renderDataHelper(
|
||||||
QLatin1String("text/plain"), mimeData)).toLocal8Bit();
|
QLatin1String("text/plain"), mimeData)).toLatin1();
|
||||||
ret = true;
|
ret = true;
|
||||||
} else if (a == connection->atom(QXcbAtom::TEXT)
|
|
||||||
|| a == connection->atom(QXcbAtom::COMPOUND_TEXT)) {
|
|
||||||
// the ICCCM states that TEXT and COMPOUND_TEXT are in the
|
|
||||||
// encoding of choice, so we choose the encoding of the locale
|
|
||||||
QByteArray strData = QString::fromUtf8(QInternalMimeData::renderDataHelper(
|
|
||||||
QLatin1String("text/plain"), mimeData)).toLocal8Bit();
|
|
||||||
char *list[] = { strData.data(), NULL };
|
|
||||||
|
|
||||||
XICCEncodingStyle style = (a == connection->atom(QXcbAtom::COMPOUND_TEXT))
|
|
||||||
? XCompoundTextStyle : XStdICCTextStyle;
|
|
||||||
XTextProperty textprop;
|
|
||||||
if (list[0] != NULL
|
|
||||||
&& XmbTextListToTextProperty(DISPLAY_FROM_XCB(connection), list, 1, style, &textprop) == Success) {
|
|
||||||
*atomFormat = textprop.encoding;
|
|
||||||
*dataFormat = textprop.format;
|
|
||||||
*data = QByteArray((const char *) textprop.value, textprop.nitems * textprop.format / 8);
|
|
||||||
ret = true;
|
|
||||||
|
|
||||||
XFree(textprop.value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -162,7 +142,6 @@ QList<xcb_atom_t> QXcbMime::mimeAtomsForFormat(QXcbConnection *connection, const
|
|||||||
atoms.append(connection->atom(QXcbAtom::UTF8_STRING));
|
atoms.append(connection->atom(QXcbAtom::UTF8_STRING));
|
||||||
atoms.append(QXcbAtom::XA_STRING);
|
atoms.append(QXcbAtom::XA_STRING);
|
||||||
atoms.append(connection->atom(QXcbAtom::TEXT));
|
atoms.append(connection->atom(QXcbAtom::TEXT));
|
||||||
atoms.append(connection->atom(QXcbAtom::COMPOUND_TEXT));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// special cases for uris
|
// special cases for uris
|
||||||
@ -198,16 +177,11 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
|
|||||||
|
|
||||||
// special cases for string types
|
// special cases for string types
|
||||||
if (format == QLatin1String("text/plain")) {
|
if (format == QLatin1String("text/plain")) {
|
||||||
if (a == connection->atom(QXcbAtom::UTF8_STRING)) {
|
if (a == connection->atom(QXcbAtom::UTF8_STRING))
|
||||||
qDebug() << data;
|
|
||||||
return QString::fromUtf8(data);
|
return QString::fromUtf8(data);
|
||||||
}
|
if (a == QXcbAtom::XA_STRING ||
|
||||||
if (a == QXcbAtom::XA_STRING)
|
a == connection->atom(QXcbAtom::TEXT))
|
||||||
return QString::fromLatin1(data);
|
return QString::fromLatin1(data);
|
||||||
if (a == connection->atom(QXcbAtom::TEXT)
|
|
||||||
|| a == connection->atom(QXcbAtom::COMPOUND_TEXT))
|
|
||||||
// #### might be wrong for COMPOUND_TEXT
|
|
||||||
return QString::fromLocal8Bit(data, data.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// special case for uri types
|
// special case for uri types
|
||||||
@ -268,12 +242,10 @@ xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString
|
|||||||
if (format == QLatin1String("text/plain")) {
|
if (format == QLatin1String("text/plain")) {
|
||||||
if (atoms.contains(connection->atom(QXcbAtom::UTF8_STRING)))
|
if (atoms.contains(connection->atom(QXcbAtom::UTF8_STRING)))
|
||||||
return connection->atom(QXcbAtom::UTF8_STRING);
|
return connection->atom(QXcbAtom::UTF8_STRING);
|
||||||
if (atoms.contains(connection->atom(QXcbAtom::COMPOUND_TEXT)))
|
|
||||||
return connection->atom(QXcbAtom::COMPOUND_TEXT);
|
|
||||||
if (atoms.contains(connection->atom(QXcbAtom::TEXT)))
|
|
||||||
return connection->atom(QXcbAtom::TEXT);
|
|
||||||
if (atoms.contains(QXcbAtom::XA_STRING))
|
if (atoms.contains(QXcbAtom::XA_STRING))
|
||||||
return QXcbAtom::XA_STRING;
|
return QXcbAtom::XA_STRING;
|
||||||
|
if (atoms.contains(connection->atom(QXcbAtom::TEXT)))
|
||||||
|
return connection->atom(QXcbAtom::TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// find matches for uri types
|
// find matches for uri types
|
||||||
|
Loading…
Reference in New Issue
Block a user