removed unnecessary call in screen class, added logging calls

in clipboard class, and added another cast in protocol util
to avoid warning on win32.
This commit is contained in:
crs 2002-05-22 17:08:37 +00:00
parent 9e161163b0
commit 8df02380e5
4 changed files with 8 additions and 102 deletions

View File

@ -20,7 +20,7 @@ CMSWindowsClipboard::~CMSWindowsClipboard()
bool CMSWindowsClipboard::open(Time time)
{
log((CLOG_INFO "open clipboard"));
log((CLOG_DEBUG "open clipboard"));
if (!OpenClipboard(m_window)) {
log((CLOG_WARN "failed to open clipboard"));
@ -42,14 +42,14 @@ bool CMSWindowsClipboard::open(Time time)
void CMSWindowsClipboard::close()
{
log((CLOG_INFO "close clipboard"));
log((CLOG_DEBUG "close clipboard"));
CloseClipboard();
}
void CMSWindowsClipboard::add(
EFormat format, const CString& data)
{
log((CLOG_INFO "add %d bytes to clipboard format: %d", data.size(), format));
log((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format));
if (!OpenClipboard(m_window)) {
log((CLOG_WARN "failed to open clipboard"));

View File

@ -37,7 +37,10 @@ void CMSWindowsScreen::init(HINSTANCE instance)
void CMSWindowsScreen::doRun()
{
// save thread id for posting quit message
m_thread = GetCurrentThreadId();
// event loop
for (;;) {
// wait for and get the next event
MSG msg;
@ -151,101 +154,6 @@ void CMSWindowsScreen::getEvent(MSG* msg) const
GetMessage(msg, NULL, 0, 0);
}
void CMSWindowsScreen::getDisplayClipboard(
IClipboard* clipboard,
HWND requestor) const
{
/* FIXME
assert(clipboard != NULL);
assert(requestor != None);
// clear the clipboard object
clipboard->open();
// block others from using the display while we get the clipboard.
// in particular, this prevents the event thread from stealing the
// selection notify event we're expecting.
CLock lock(&m_mutex);
// use PRIMARY selection as the "clipboard"
Atom selection = XA_PRIMARY;
// ask the selection for all the formats it has. some owners return
// the TARGETS atom and some the ATOM atom when TARGETS is requested.
Atom format;
CString targets;
if (getDisplayClipboard(selection, m_atomTargets,
requestor, timestamp, &format, &targets) &&
(format == m_atomTargets || format == XA_ATOM)) {
// get each target (that we can interpret). some owners return
// some targets multiple times in the list so don't try to get
// those multiple times.
const Atom* targetAtoms = reinterpret_cast<const Atom*>(targets.data());
const SInt32 numTargets = targets.size() / sizeof(Atom);
std::set<IClipboard::EFormat> clipboardFormats;
std::set<Atom> targets;
log((CLOG_DEBUG "selection has %d targets", numTargets));
for (SInt32 i = 0; i < numTargets; ++i) {
Atom format = targetAtoms[i];
log((CLOG_DEBUG " source target %d", format));
// skip already handled targets
if (targets.count(format) > 0) {
log((CLOG_DEBUG " skipping handled target %d", format));
continue;
}
// mark this target as done
targets.insert(format);
// determine the expected clipboard format
IClipboard::EFormat expectedFormat = getFormat(format);
// if we can use the format and we haven't already retrieved
// it then get it
if (expectedFormat == IClipboard::kNumFormats) {
log((CLOG_DEBUG " no format for target", format));
continue;
}
if (clipboardFormats.count(expectedFormat) > 0) {
log((CLOG_DEBUG " skipping handled format %d", expectedFormat));
continue;
}
CString data;
if (!getDisplayClipboard(selection, format,
requestor, timestamp, &format, &data)) {
log((CLOG_DEBUG " no data for target", format));
continue;
}
// use the actual format, not the expected
IClipboard::EFormat actualFormat = getFormat(format);
if (actualFormat == IClipboard::kNumFormats) {
log((CLOG_DEBUG " no format for target", format));
continue;
}
if (clipboardFormats.count(actualFormat) > 0) {
log((CLOG_DEBUG " skipping handled format %d", actualFormat));
continue;
}
// add to clipboard and note we've done it
clipboard->add(actualFormat, data);
clipboardFormats.insert(actualFormat);
}
}
else {
// non-ICCCM conforming selection owner. try TEXT format.
// FIXME
log((CLOG_DEBUG "selection doesn't support TARGETS, format is %d", format));
}
// done with clipboard
clipboard->close();
*/
}
LRESULT CALLBACK CMSWindowsScreen::wndProc(
HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)

View File

@ -46,9 +46,6 @@ protected:
// wait for and get the next message. cancellable.
void getEvent(MSG*) const;
// copy the clipboard contents to clipboard
void getDisplayClipboard(IClipboard* clipboard, HWND) const;
// called by doRun() to handle an event. return true to skip
// event translation and dispatch.
virtual bool onPreTranslate(MSG*) = 0;

View File

@ -84,8 +84,9 @@ void CProtocolUtil::readf(IInputStream* stream,
case 2:
// 2 byte integer
*reinterpret_cast<UInt16*>(v) =
static_cast<UInt16>(
(static_cast<UInt16>(buffer[0]) << 8) |
static_cast<UInt16>(buffer[1]);
static_cast<UInt16>(buffer[1]));
log((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt16*>(v), *reinterpret_cast<UInt16*>(v)));
break;