X11 clipboard logging now also prints atom names, not just numbers.
This commit is contained in:
parent
3758d9d282
commit
fddf7d04a3
|
@ -110,7 +110,7 @@ CXWindowsClipboard::addRequest(Window owner, Window requestor,
|
||||||
// at the given time.
|
// at the given time.
|
||||||
bool success = false;
|
bool success = false;
|
||||||
if (owner == m_window) {
|
if (owner == m_window) {
|
||||||
LOG((CLOG_DEBUG1 "request for clipboard %d, target %d by 0x%08x (property=%d)", m_selection, target, requestor, property));
|
LOG((CLOG_DEBUG1 "request for clipboard %d, target %s by 0x%08x (property=%s)", m_selection, CXWindowsUtil::atomToString(m_display, target).c_str(), requestor, CXWindowsUtil::atomToString(m_display, property).c_str()));
|
||||||
if (wasOwnedAtTime(time)) {
|
if (wasOwnedAtTime(time)) {
|
||||||
if (target == m_atomMultiple) {
|
if (target == m_atomMultiple) {
|
||||||
// add a multiple request. property may not be None
|
// add a multiple request. property may not be None
|
||||||
|
@ -203,7 +203,7 @@ CXWindowsClipboard::processRequest(Window requestor,
|
||||||
// unknown requestor window
|
// unknown requestor window
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOG((CLOG_DEBUG1 "received property %d delete from 0x08%x", property, requestor));
|
LOG((CLOG_DEBUG1 "received property %s delete from 0x08%x", CXWindowsUtil::atomToString(m_display, property).c_str(), requestor));
|
||||||
|
|
||||||
// find the property in the known requests. it should be the
|
// find the property in the known requests. it should be the
|
||||||
// first property but we'll check 'em all if we have to.
|
// first property but we'll check 'em all if we have to.
|
||||||
|
@ -398,7 +398,7 @@ CXWindowsClipboard::getConverter(Atom target, bool onlyIfNotAdded) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (converter == NULL) {
|
if (converter == NULL) {
|
||||||
LOG((CLOG_DEBUG1 " no converter for target %d", target));
|
LOG((CLOG_DEBUG1 " no converter for target %s", CXWindowsUtil::atomToString(m_display, target).c_str()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,10 +503,12 @@ CXWindowsClipboard::icccmFillCache()
|
||||||
data.append(reinterpret_cast<char*>(&target), sizeof(target));
|
data.append(reinterpret_cast<char*>(&target), sizeof(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
// try each converter in order (because they're in order of
|
|
||||||
// preference).
|
|
||||||
const Atom* targets = reinterpret_cast<const Atom*>(data.data());
|
const Atom* targets = reinterpret_cast<const Atom*>(data.data());
|
||||||
const UInt32 numTargets = data.size() / sizeof(Atom);
|
const UInt32 numTargets = data.size() / sizeof(Atom);
|
||||||
|
LOG((CLOG_DEBUG " available targets: %s", CXWindowsUtil::atomsToString(m_display, targets, numTargets).c_str()));
|
||||||
|
|
||||||
|
// try each converter in order (because they're in order of
|
||||||
|
// preference).
|
||||||
for (ConverterList::const_iterator index = m_converters.begin();
|
for (ConverterList::const_iterator index = m_converters.begin();
|
||||||
index != m_converters.end(); ++index) {
|
index != m_converters.end(); ++index) {
|
||||||
IXWindowsClipboardConverter* converter = *index;
|
IXWindowsClipboardConverter* converter = *index;
|
||||||
|
@ -532,7 +534,7 @@ CXWindowsClipboard::icccmFillCache()
|
||||||
Atom actualTarget;
|
Atom actualTarget;
|
||||||
CString targetData;
|
CString targetData;
|
||||||
if (!icccmGetSelection(target, &actualTarget, &targetData)) {
|
if (!icccmGetSelection(target, &actualTarget, &targetData)) {
|
||||||
LOG((CLOG_DEBUG1 " no data for target %d", target));
|
LOG((CLOG_DEBUG1 " no data for target %s", CXWindowsUtil::atomToString(m_display, target).c_str()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,7 +542,7 @@ CXWindowsClipboard::icccmFillCache()
|
||||||
IClipboard::EFormat format = converter->getFormat();
|
IClipboard::EFormat format = converter->getFormat();
|
||||||
m_data[format] = converter->toIClipboard(targetData);
|
m_data[format] = converter->toIClipboard(targetData);
|
||||||
m_added[format] = true;
|
m_added[format] = true;
|
||||||
LOG((CLOG_DEBUG " added format %d for target %d", format, target));
|
LOG((CLOG_DEBUG " added format %d for target %s (%u %s)", format, CXWindowsUtil::atomToString(m_display, target).c_str(), targetData.size(), targetData.size() == 1 ? "byte" : "bytes"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,12 +557,12 @@ CXWindowsClipboard::icccmGetSelection(Atom target,
|
||||||
CICCCMGetClipboard getter(m_window, m_time, m_atomData);
|
CICCCMGetClipboard getter(m_window, m_time, m_atomData);
|
||||||
if (!getter.readClipboard(m_display, m_selection,
|
if (!getter.readClipboard(m_display, m_selection,
|
||||||
target, actualTarget, data)) {
|
target, actualTarget, data)) {
|
||||||
LOG((CLOG_DEBUG1 "can't get data for selection target %d", target));
|
LOG((CLOG_DEBUG1 "can't get data for selection target %s", CXWindowsUtil::atomToString(m_display, target).c_str()));
|
||||||
LOGC(getter.m_error, (CLOG_WARN "ICCCM violation by clipboard owner"));
|
LOGC(getter.m_error, (CLOG_WARN "ICCCM violation by clipboard owner"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (*actualTarget == None) {
|
else if (*actualTarget == None) {
|
||||||
LOG((CLOG_DEBUG1 "selection conversion failed for target %d", target));
|
LOG((CLOG_DEBUG1 "selection conversion failed for target %s", CXWindowsUtil::atomToString(m_display, target).c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -770,7 +772,7 @@ CXWindowsClipboard::motifFillCache()
|
||||||
Atom actualTarget;
|
Atom actualTarget;
|
||||||
CString targetData;
|
CString targetData;
|
||||||
if (!motifGetSelection(motifFormat, &actualTarget, &targetData)) {
|
if (!motifGetSelection(motifFormat, &actualTarget, &targetData)) {
|
||||||
LOG((CLOG_DEBUG1 " no data for target %d", target));
|
LOG((CLOG_DEBUG1 " no data for target %s", CXWindowsUtil::atomToString(m_display, target).c_str()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -778,7 +780,7 @@ CXWindowsClipboard::motifFillCache()
|
||||||
IClipboard::EFormat format = converter->getFormat();
|
IClipboard::EFormat format = converter->getFormat();
|
||||||
m_data[format] = converter->toIClipboard(targetData);
|
m_data[format] = converter->toIClipboard(targetData);
|
||||||
m_added[format] = true;
|
m_added[format] = true;
|
||||||
LOG((CLOG_DEBUG " added format %d for target %d", format, target));
|
LOG((CLOG_DEBUG " added format %d for target %s", format, CXWindowsUtil::atomToString(m_display, target).c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1255,7 +1257,7 @@ CXWindowsClipboard::CICCCMGetClipboard::readClipboard(Display* display,
|
||||||
assert(actualTarget != NULL);
|
assert(actualTarget != NULL);
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
|
|
||||||
LOG((CLOG_DEBUG1 "request selection=%d, target=%d, window=%x", selection, target, m_requestor));
|
LOG((CLOG_DEBUG1 "request selection=%s, target=%s, window=%x", CXWindowsUtil::atomToString(display, selection).c_str(), CXWindowsUtil::atomToString(display, target).c_str(), m_requestor));
|
||||||
|
|
||||||
// save output pointers
|
// save output pointers
|
||||||
m_actualTarget = actualTarget;
|
m_actualTarget = actualTarget;
|
||||||
|
@ -1423,7 +1425,7 @@ CXWindowsClipboard::CICCCMGetClipboard::processEvent(
|
||||||
else if (m_incr) {
|
else if (m_incr) {
|
||||||
// if first incremental chunk then save target
|
// if first incremental chunk then save target
|
||||||
if (oldSize == 0) {
|
if (oldSize == 0) {
|
||||||
LOG((CLOG_DEBUG1 " INCR first chunk, target %d", target));
|
LOG((CLOG_DEBUG1 " INCR first chunk, target %s", CXWindowsUtil::atomToString(display, target).c_str()));
|
||||||
*m_actualTarget = target;
|
*m_actualTarget = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1445,7 +1447,7 @@ CXWindowsClipboard::CICCCMGetClipboard::processEvent(
|
||||||
|
|
||||||
// not incremental; save the target.
|
// not incremental; save the target.
|
||||||
else {
|
else {
|
||||||
LOG((CLOG_DEBUG1 " target %d", target));
|
LOG((CLOG_DEBUG1 " target %s", CXWindowsUtil::atomToString(display, target).c_str()));
|
||||||
*m_actualTarget = target;
|
*m_actualTarget = target;
|
||||||
m_done = true;
|
m_done = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "CXWindowsUtil.h"
|
#include "CXWindowsUtil.h"
|
||||||
#include "CThread.h"
|
#include "CThread.h"
|
||||||
#include "CLog.h"
|
#include "CLog.h"
|
||||||
|
#include "CStringUtil.h"
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#define XK_XKB_KEYS
|
#define XK_XKB_KEYS
|
||||||
#define XK_LATIN1
|
#define XK_LATIN1
|
||||||
|
@ -1244,6 +1245,32 @@ CXWindowsUtil::decomposeKeySym(KeySym keysym, KeySyms& decomposed)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CString
|
||||||
|
CXWindowsUtil::atomToString(Display* display, Atom atom)
|
||||||
|
{
|
||||||
|
char* name = XGetAtomName(display, atom);
|
||||||
|
CString msg = CStringUtil::print("%s (%d)", name, (int)atom);
|
||||||
|
XFree(name);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
CString
|
||||||
|
CXWindowsUtil::atomsToString(Display* display, const Atom* atom, UInt32 num)
|
||||||
|
{
|
||||||
|
char** names = new char*[num];
|
||||||
|
XGetAtomNames(display, const_cast<Atom*>(atom), (int)num, names);
|
||||||
|
CString msg;
|
||||||
|
for (UInt32 i = 0; i < num; ++i) {
|
||||||
|
msg += CStringUtil::print("%s (%d), ", names[i], (int)atom[i]);
|
||||||
|
XFree(names[i]);
|
||||||
|
}
|
||||||
|
delete[] names;
|
||||||
|
if (msg.size() > 2) {
|
||||||
|
msg.erase(msg.size() - 2);
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
CXWindowsUtil::propertyNotifyPredicate(Display*, XEvent* xevent, XPointer arg)
|
CXWindowsUtil::propertyNotifyPredicate(Display*, XEvent* xevent, XPointer arg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,6 +81,20 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool decomposeKeySym(KeySym keysym, KeySyms& decomposed);
|
static bool decomposeKeySym(KeySym keysym, KeySyms& decomposed);
|
||||||
|
|
||||||
|
//! Convert Atom to its string
|
||||||
|
/*!
|
||||||
|
Converts \p atom to its string representation.
|
||||||
|
*/
|
||||||
|
static CString atomToString(Display*, Atom atom);
|
||||||
|
|
||||||
|
//! Convert several Atoms to a string
|
||||||
|
/*!
|
||||||
|
Converts each atom in \p atoms to its string representation and
|
||||||
|
concatenates the results.
|
||||||
|
*/
|
||||||
|
static CString atomsToString(Display* display,
|
||||||
|
const Atom* atom, UInt32 num);
|
||||||
|
|
||||||
//! X11 error handler
|
//! X11 error handler
|
||||||
/*!
|
/*!
|
||||||
This class sets an X error handler in the c'tor and restores the
|
This class sets an X error handler in the c'tor and restores the
|
||||||
|
|
Loading…
Reference in New Issue