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:
parent
9e161163b0
commit
8df02380e5
|
@ -20,7 +20,7 @@ CMSWindowsClipboard::~CMSWindowsClipboard()
|
||||||
|
|
||||||
bool CMSWindowsClipboard::open(Time time)
|
bool CMSWindowsClipboard::open(Time time)
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "open clipboard"));
|
log((CLOG_DEBUG "open clipboard"));
|
||||||
|
|
||||||
if (!OpenClipboard(m_window)) {
|
if (!OpenClipboard(m_window)) {
|
||||||
log((CLOG_WARN "failed to open clipboard"));
|
log((CLOG_WARN "failed to open clipboard"));
|
||||||
|
@ -42,14 +42,14 @@ bool CMSWindowsClipboard::open(Time time)
|
||||||
|
|
||||||
void CMSWindowsClipboard::close()
|
void CMSWindowsClipboard::close()
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "close clipboard"));
|
log((CLOG_DEBUG "close clipboard"));
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMSWindowsClipboard::add(
|
void CMSWindowsClipboard::add(
|
||||||
EFormat format, const CString& data)
|
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)) {
|
if (!OpenClipboard(m_window)) {
|
||||||
log((CLOG_WARN "failed to open clipboard"));
|
log((CLOG_WARN "failed to open clipboard"));
|
||||||
|
|
|
@ -37,7 +37,10 @@ void CMSWindowsScreen::init(HINSTANCE instance)
|
||||||
|
|
||||||
void CMSWindowsScreen::doRun()
|
void CMSWindowsScreen::doRun()
|
||||||
{
|
{
|
||||||
|
// save thread id for posting quit message
|
||||||
m_thread = GetCurrentThreadId();
|
m_thread = GetCurrentThreadId();
|
||||||
|
|
||||||
|
// event loop
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// wait for and get the next event
|
// wait for and get the next event
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
@ -151,101 +154,6 @@ void CMSWindowsScreen::getEvent(MSG* msg) const
|
||||||
GetMessage(msg, NULL, 0, 0);
|
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(
|
LRESULT CALLBACK CMSWindowsScreen::wndProc(
|
||||||
HWND hwnd, UINT msg,
|
HWND hwnd, UINT msg,
|
||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
|
|
|
@ -46,9 +46,6 @@ protected:
|
||||||
// wait for and get the next message. cancellable.
|
// wait for and get the next message. cancellable.
|
||||||
void getEvent(MSG*) const;
|
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
|
// called by doRun() to handle an event. return true to skip
|
||||||
// event translation and dispatch.
|
// event translation and dispatch.
|
||||||
virtual bool onPreTranslate(MSG*) = 0;
|
virtual bool onPreTranslate(MSG*) = 0;
|
||||||
|
|
|
@ -84,8 +84,9 @@ void CProtocolUtil::readf(IInputStream* stream,
|
||||||
case 2:
|
case 2:
|
||||||
// 2 byte integer
|
// 2 byte integer
|
||||||
*reinterpret_cast<UInt16*>(v) =
|
*reinterpret_cast<UInt16*>(v) =
|
||||||
|
static_cast<UInt16>(
|
||||||
(static_cast<UInt16>(buffer[0]) << 8) |
|
(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)));
|
log((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt16*>(v), *reinterpret_cast<UInt16*>(v)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue