From 9ac0473d5a485aa52e73c52c88d842a8c823fa08 Mon Sep 17 00:00:00 2001 From: crs Date: Sat, 27 Apr 2002 18:06:40 +0000 Subject: [PATCH] checkpoint. changed CProtocolUtil::readf() to store 1 and 2 byte integers into pointers to 1 and 2 byte integers. was always assuming pointers to 4 byte integers. --- client/CClient.cpp | 18 +++++++++--------- client/CXWindowsSecondaryScreen.cpp | 26 ++++++++++++++++---------- server/CServer.cpp | 2 +- server/CServerProtocol1_0.cpp | 2 +- server/CXWindowsPrimaryScreen.cpp | 2 +- synergy/CProtocolUtil.cpp | 22 +++++++++++++--------- synergy/CXWindowsScreen.cpp | 1 + synergy/ProtocolTypes.h | 2 +- 8 files changed, 43 insertions(+), 32 deletions(-) diff --git a/client/CClient.cpp b/client/CClient.cpp index 811ac7ee..5af2031a 100644 --- a/client/CClient.cpp +++ b/client/CClient.cpp @@ -303,7 +303,7 @@ void CClient::closeSecondaryScreen() void CClient::onEnter() { - SInt32 x, y; + SInt16 x, y; { CLock lock(&m_mutex); CProtocolUtil::readf(m_input, kMsgCEnter + 4, &x, &y); @@ -328,7 +328,7 @@ void CClient::onGrabClipboard() void CClient::onScreenSaver() { - SInt32 on; + SInt8 on; { CLock lock(&m_mutex); CProtocolUtil::readf(m_input, kMsgCScreenSaver + 4, &on); @@ -395,7 +395,7 @@ void CClient::onSetClipboard() void CClient::onKeyDown() { - SInt32 id, mask; + SInt16 id, mask; { CLock lock(&m_mutex); CProtocolUtil::readf(m_input, kMsgDKeyDown + 4, &id, &mask); @@ -406,7 +406,7 @@ void CClient::onKeyDown() void CClient::onKeyRepeat() { - SInt32 id, mask, count; + SInt16 id, mask, count; { CLock lock(&m_mutex); CProtocolUtil::readf(m_input, kMsgDKeyRepeat + 4, &id, &mask, &count); @@ -418,7 +418,7 @@ void CClient::onKeyRepeat() void CClient::onKeyUp() { - SInt32 id, mask; + SInt16 id, mask; { CLock lock(&m_mutex); CProtocolUtil::readf(m_input, kMsgDKeyUp + 4, &id, &mask); @@ -429,7 +429,7 @@ void CClient::onKeyUp() void CClient::onMouseDown() { - SInt32 id; + SInt8 id; { CLock lock(&m_mutex); CProtocolUtil::readf(m_input, kMsgDMouseDown + 4, &id); @@ -439,7 +439,7 @@ void CClient::onMouseDown() void CClient::onMouseUp() { - SInt32 id; + SInt8 id; { CLock lock(&m_mutex); CProtocolUtil::readf(m_input, kMsgDMouseUp + 4, &id); @@ -449,7 +449,7 @@ void CClient::onMouseUp() void CClient::onMouseMove() { - SInt32 x, y; + SInt16 x, y; { CLock lock(&m_mutex); CProtocolUtil::readf(m_input, kMsgDMouseMove + 4, &x, &y); @@ -459,7 +459,7 @@ void CClient::onMouseMove() void CClient::onMouseWheel() { - SInt32 delta; + SInt16 delta; { CLock lock(&m_mutex); CProtocolUtil::readf(m_input, kMsgDMouseWheel + 4, &delta); diff --git a/client/CXWindowsSecondaryScreen.cpp b/client/CXWindowsSecondaryScreen.cpp index f5fe3461..8e088c8e 100644 --- a/client/CXWindowsSecondaryScreen.cpp +++ b/client/CXWindowsSecondaryScreen.cpp @@ -127,18 +127,24 @@ void CXWindowsSecondaryScreen::open(CClient* client) // open the display openDisplay(); - // verify the availability of the XTest extension - CDisplayLock display(this); - int majorOpcode, firstEvent, firstError; - if (!XQueryExtension(display, XTestExtensionName, + { + // verify the availability of the XTest extension + CDisplayLock display(this); + int majorOpcode, firstEvent, firstError; + if (!XQueryExtension(display, XTestExtensionName, &majorOpcode, &firstEvent, &firstError)) - throw int(6); // FIXME -- make exception for this + throw int(6); // FIXME -- make exception for this - // update key state - updateKeys(display); - updateKeycodeMap(display); - updateModifierMap(display); - updateModifiers(display); + // update key state + updateKeys(display); + updateKeycodeMap(display); + updateModifierMap(display); + updateModifiers(display); + } + + // assume primary has all clipboards + for (ClipboardID id = 0; id < kClipboardEnd; ++id) + grabClipboard(id); } void CXWindowsSecondaryScreen::close() diff --git a/server/CServer.cpp b/server/CServer.cpp index 84617aa4..f5080edc 100644 --- a/server/CServer.cpp +++ b/server/CServer.cpp @@ -320,7 +320,7 @@ void CServer::onMouseUp(ButtonID id) bool CServer::onMouseMovePrimary(SInt32 x, SInt32 y) { - log((CLOG_DEBUG "onMouseMovePrimary %d,%d", x, y)); +// log((CLOG_DEBUG "onMouseMovePrimary %d,%d", x, y)); // mouse move on primary (server's) screen assert(m_active != NULL); diff --git a/server/CServerProtocol1_0.cpp b/server/CServerProtocol1_0.cpp index 5a97c3e5..c405063b 100644 --- a/server/CServerProtocol1_0.cpp +++ b/server/CServerProtocol1_0.cpp @@ -181,7 +181,7 @@ void CServerProtocol1_0::sendMouseWheel( void CServerProtocol1_0::recvInfo() { // parse the message - SInt32 w, h, zoneInfo; + SInt16 w, h, zoneInfo; CProtocolUtil::readf(getInputStream(), kMsgDInfo + 4, &w, &h, &zoneInfo); log((CLOG_INFO "received client \"%s\" info size=%dx%d, zone=%d", getClient().c_str(), w, h, zoneInfo)); diff --git a/server/CXWindowsPrimaryScreen.cpp b/server/CXWindowsPrimaryScreen.cpp index f1315116..3ee1d65f 100644 --- a/server/CXWindowsPrimaryScreen.cpp +++ b/server/CXWindowsPrimaryScreen.cpp @@ -95,7 +95,7 @@ void CXWindowsPrimaryScreen::run() } case MotionNotify: { - log((CLOG_DEBUG "event: MotionNotify %d,%d", xevent.xmotion.x_root, xevent.xmotion.y_root)); +// log((CLOG_DEBUG "event: MotionNotify %d,%d", xevent.xmotion.x_root, xevent.xmotion.y_root)); SInt32 x, y; if (!m_active) { x = xevent.xmotion.x_root; diff --git a/synergy/CProtocolUtil.cpp b/synergy/CProtocolUtil.cpp index c15cfb2a..5aca0e09 100644 --- a/synergy/CProtocolUtil.cpp +++ b/synergy/CProtocolUtil.cpp @@ -73,28 +73,32 @@ void CProtocolUtil::readf(IInputStream* stream, read(stream, buffer, len); // convert it - UInt32* v = va_arg(args, UInt32*); + void* v = va_arg(args, void*); switch (len) { case 1: // 1 byte integer - *v = static_cast(buffer[0]); + *reinterpret_cast(v) = buffer[0]; + log((CLOG_DEBUG "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast(v), *reinterpret_cast(v))); break; case 2: // 2 byte integer - *v = (static_cast(buffer[0]) << 8) | - static_cast(buffer[1]); + *reinterpret_cast(v) = + (static_cast(buffer[0]) << 8) | + static_cast(buffer[1]); + log((CLOG_DEBUG "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast(v), *reinterpret_cast(v))); break; case 4: // 4 byte integer - *v = (static_cast(buffer[0]) << 24) | - (static_cast(buffer[1]) << 16) | - (static_cast(buffer[2]) << 8) | - static_cast(buffer[3]); + *reinterpret_cast(v) = + (static_cast(buffer[0]) << 24) | + (static_cast(buffer[1]) << 16) | + (static_cast(buffer[2]) << 8) | + static_cast(buffer[3]); + log((CLOG_DEBUG "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast(v), *reinterpret_cast(v))); break; } - log((CLOG_DEBUG "readf: read %d byte integer: %d (0x%x)", len, *v, *v)); break; } diff --git a/synergy/CXWindowsScreen.cpp b/synergy/CXWindowsScreen.cpp index 4aa74a41..ee9f1492 100644 --- a/synergy/CXWindowsScreen.cpp +++ b/synergy/CXWindowsScreen.cpp @@ -352,6 +352,7 @@ bool CXWindowsScreen::getDisplayClipboard( // events because X stupidly doesn't provide a mask for selection // events, so we use a predicate to find our event. XEvent xevent; +// FIXME -- must limit the time we wait for bad clients while (XCheckIfEvent(m_display, &xevent, &CXWindowsScreen::findSelectionNotify, (XPointer)&requestor) != True) { diff --git a/synergy/ProtocolTypes.h b/synergy/ProtocolTypes.h index 0e70502c..ca54ff04 100644 --- a/synergy/ProtocolTypes.h +++ b/synergy/ProtocolTypes.h @@ -78,7 +78,7 @@ static const char kMsgDMouseWheel[] = "DMWM%2i"; // that message. $1 = clipboard identifier. static const char kMsgDClipboard[] = "DCLP%1i%4i%s"; -// client data: seconary -> primary +// client data: secondary -> primary // $1 = seconary screen width in pixels, $2 = screen height, $3 = // size of warp zone. static const char kMsgDInfo[] = "DINF%2i%2i%2i";