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.
This commit is contained in:
crs 2002-04-27 18:06:40 +00:00
parent f9170eb139
commit 9ac0473d5a
8 changed files with 43 additions and 32 deletions

View File

@ -303,7 +303,7 @@ void CClient::closeSecondaryScreen()
void CClient::onEnter() void CClient::onEnter()
{ {
SInt32 x, y; SInt16 x, y;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
CProtocolUtil::readf(m_input, kMsgCEnter + 4, &x, &y); CProtocolUtil::readf(m_input, kMsgCEnter + 4, &x, &y);
@ -328,7 +328,7 @@ void CClient::onGrabClipboard()
void CClient::onScreenSaver() void CClient::onScreenSaver()
{ {
SInt32 on; SInt8 on;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
CProtocolUtil::readf(m_input, kMsgCScreenSaver + 4, &on); CProtocolUtil::readf(m_input, kMsgCScreenSaver + 4, &on);
@ -395,7 +395,7 @@ void CClient::onSetClipboard()
void CClient::onKeyDown() void CClient::onKeyDown()
{ {
SInt32 id, mask; SInt16 id, mask;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
CProtocolUtil::readf(m_input, kMsgDKeyDown + 4, &id, &mask); CProtocolUtil::readf(m_input, kMsgDKeyDown + 4, &id, &mask);
@ -406,7 +406,7 @@ void CClient::onKeyDown()
void CClient::onKeyRepeat() void CClient::onKeyRepeat()
{ {
SInt32 id, mask, count; SInt16 id, mask, count;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
CProtocolUtil::readf(m_input, kMsgDKeyRepeat + 4, &id, &mask, &count); CProtocolUtil::readf(m_input, kMsgDKeyRepeat + 4, &id, &mask, &count);
@ -418,7 +418,7 @@ void CClient::onKeyRepeat()
void CClient::onKeyUp() void CClient::onKeyUp()
{ {
SInt32 id, mask; SInt16 id, mask;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
CProtocolUtil::readf(m_input, kMsgDKeyUp + 4, &id, &mask); CProtocolUtil::readf(m_input, kMsgDKeyUp + 4, &id, &mask);
@ -429,7 +429,7 @@ void CClient::onKeyUp()
void CClient::onMouseDown() void CClient::onMouseDown()
{ {
SInt32 id; SInt8 id;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
CProtocolUtil::readf(m_input, kMsgDMouseDown + 4, &id); CProtocolUtil::readf(m_input, kMsgDMouseDown + 4, &id);
@ -439,7 +439,7 @@ void CClient::onMouseDown()
void CClient::onMouseUp() void CClient::onMouseUp()
{ {
SInt32 id; SInt8 id;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
CProtocolUtil::readf(m_input, kMsgDMouseUp + 4, &id); CProtocolUtil::readf(m_input, kMsgDMouseUp + 4, &id);
@ -449,7 +449,7 @@ void CClient::onMouseUp()
void CClient::onMouseMove() void CClient::onMouseMove()
{ {
SInt32 x, y; SInt16 x, y;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
CProtocolUtil::readf(m_input, kMsgDMouseMove + 4, &x, &y); CProtocolUtil::readf(m_input, kMsgDMouseMove + 4, &x, &y);
@ -459,7 +459,7 @@ void CClient::onMouseMove()
void CClient::onMouseWheel() void CClient::onMouseWheel()
{ {
SInt32 delta; SInt16 delta;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
CProtocolUtil::readf(m_input, kMsgDMouseWheel + 4, &delta); CProtocolUtil::readf(m_input, kMsgDMouseWheel + 4, &delta);

View File

@ -127,18 +127,24 @@ void CXWindowsSecondaryScreen::open(CClient* client)
// open the display // open the display
openDisplay(); openDisplay();
// verify the availability of the XTest extension {
CDisplayLock display(this); // verify the availability of the XTest extension
int majorOpcode, firstEvent, firstError; CDisplayLock display(this);
if (!XQueryExtension(display, XTestExtensionName, int majorOpcode, firstEvent, firstError;
if (!XQueryExtension(display, XTestExtensionName,
&majorOpcode, &firstEvent, &firstError)) &majorOpcode, &firstEvent, &firstError))
throw int(6); // FIXME -- make exception for this throw int(6); // FIXME -- make exception for this
// update key state // update key state
updateKeys(display); updateKeys(display);
updateKeycodeMap(display); updateKeycodeMap(display);
updateModifierMap(display); updateModifierMap(display);
updateModifiers(display); updateModifiers(display);
}
// assume primary has all clipboards
for (ClipboardID id = 0; id < kClipboardEnd; ++id)
grabClipboard(id);
} }
void CXWindowsSecondaryScreen::close() void CXWindowsSecondaryScreen::close()

View File

@ -320,7 +320,7 @@ void CServer::onMouseUp(ButtonID id)
bool CServer::onMouseMovePrimary(SInt32 x, SInt32 y) 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 // mouse move on primary (server's) screen
assert(m_active != NULL); assert(m_active != NULL);

View File

@ -181,7 +181,7 @@ void CServerProtocol1_0::sendMouseWheel(
void CServerProtocol1_0::recvInfo() void CServerProtocol1_0::recvInfo()
{ {
// parse the message // parse the message
SInt32 w, h, zoneInfo; SInt16 w, h, zoneInfo;
CProtocolUtil::readf(getInputStream(), kMsgDInfo + 4, &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)); log((CLOG_INFO "received client \"%s\" info size=%dx%d, zone=%d", getClient().c_str(), w, h, zoneInfo));

View File

@ -95,7 +95,7 @@ void CXWindowsPrimaryScreen::run()
} }
case MotionNotify: { 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; SInt32 x, y;
if (!m_active) { if (!m_active) {
x = xevent.xmotion.x_root; x = xevent.xmotion.x_root;

View File

@ -73,28 +73,32 @@ void CProtocolUtil::readf(IInputStream* stream,
read(stream, buffer, len); read(stream, buffer, len);
// convert it // convert it
UInt32* v = va_arg(args, UInt32*); void* v = va_arg(args, void*);
switch (len) { switch (len) {
case 1: case 1:
// 1 byte integer // 1 byte integer
*v = static_cast<UInt32>(buffer[0]); *reinterpret_cast<UInt8*>(v) = buffer[0];
log((CLOG_DEBUG "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt8*>(v), *reinterpret_cast<UInt8*>(v)));
break; break;
case 2: case 2:
// 2 byte integer // 2 byte integer
*v = (static_cast<UInt32>(buffer[0]) << 8) | *reinterpret_cast<UInt16*>(v) =
static_cast<UInt32>(buffer[1]); (static_cast<UInt16>(buffer[0]) << 8) |
static_cast<UInt16>(buffer[1]);
log((CLOG_DEBUG "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt16*>(v), *reinterpret_cast<UInt16*>(v)));
break; break;
case 4: case 4:
// 4 byte integer // 4 byte integer
*v = (static_cast<UInt32>(buffer[0]) << 24) | *reinterpret_cast<UInt32*>(v) =
(static_cast<UInt32>(buffer[1]) << 16) | (static_cast<UInt32>(buffer[0]) << 24) |
(static_cast<UInt32>(buffer[2]) << 8) | (static_cast<UInt32>(buffer[1]) << 16) |
static_cast<UInt32>(buffer[3]); (static_cast<UInt32>(buffer[2]) << 8) |
static_cast<UInt32>(buffer[3]);
log((CLOG_DEBUG "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt32*>(v), *reinterpret_cast<UInt32*>(v)));
break; break;
} }
log((CLOG_DEBUG "readf: read %d byte integer: %d (0x%x)", len, *v, *v));
break; break;
} }

View File

@ -352,6 +352,7 @@ bool CXWindowsScreen::getDisplayClipboard(
// events because X stupidly doesn't provide a mask for selection // events because X stupidly doesn't provide a mask for selection
// events, so we use a predicate to find our event. // events, so we use a predicate to find our event.
XEvent xevent; XEvent xevent;
// FIXME -- must limit the time we wait for bad clients
while (XCheckIfEvent(m_display, &xevent, while (XCheckIfEvent(m_display, &xevent,
&CXWindowsScreen::findSelectionNotify, &CXWindowsScreen::findSelectionNotify,
(XPointer)&requestor) != True) { (XPointer)&requestor) != True) {

View File

@ -78,7 +78,7 @@ static const char kMsgDMouseWheel[] = "DMWM%2i";
// that message. $1 = clipboard identifier. // that message. $1 = clipboard identifier.
static const char kMsgDClipboard[] = "DCLP%1i%4i%s"; 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 = // $1 = seconary screen width in pixels, $2 = screen height, $3 =
// size of warp zone. // size of warp zone.
static const char kMsgDInfo[] = "DINF%2i%2i%2i"; static const char kMsgDInfo[] = "DINF%2i%2i%2i";