client now compresses mouse motion events. this fixes slow

dragging on grace, possibly on win32 too.
This commit is contained in:
crs 2002-06-26 13:48:08 +00:00
parent 78d28fd6e5
commit d9b2c59d02
2 changed files with 60 additions and 1 deletions

View File

@ -297,8 +297,16 @@ CClient::runSession(void*)
bool fail = false; bool fail = false;
try { try {
// no compressed mouse motion yet
m_compressMouse = false;
// handle messages from server // handle messages from server
for (;;) { for (;;) {
// if no input is pending then flush compressed mouse motion
if (input->getSize() == 0) {
flushCompressedMouse();
}
// wait for reply // wait for reply
log((CLOG_DEBUG2 "waiting for message")); log((CLOG_DEBUG2 "waiting for message"));
UInt8 code[4]; UInt8 code[4];
@ -462,6 +470,15 @@ CClient::closeSecondaryScreen()
m_screen = NULL; m_screen = NULL;
} }
void
CClient::flushCompressedMouse()
{
if (m_compressMouse) {
m_compressMouse = false;
m_screen->mouseMove(m_xMouse, m_yMouse);
}
}
void void
CClient::onEnter() CClient::onEnter()
{ {
@ -473,6 +490,11 @@ CClient::onEnter()
m_active = true; m_active = true;
} }
log((CLOG_DEBUG1 "recv enter, %d,%d %d %04x", x, y, m_seqNum, mask)); log((CLOG_DEBUG1 "recv enter, %d,%d %d %04x", x, y, m_seqNum, mask));
// discard old compressed mouse motion, if any
m_compressMouse = false;
// tell screen we're entering
m_screen->enter(x, y, static_cast<KeyModifierMask>(mask)); m_screen->enter(x, y, static_cast<KeyModifierMask>(mask));
} }
@ -481,6 +503,9 @@ CClient::onLeave()
{ {
log((CLOG_DEBUG1 "recv leave")); log((CLOG_DEBUG1 "recv leave"));
// send last mouse motion
flushCompressedMouse();
// tell screen we're leaving // tell screen we're leaving
m_screen->leave(); m_screen->leave();
@ -610,6 +635,9 @@ CClient::onSetClipboard()
void void
CClient::onKeyDown() CClient::onKeyDown()
{ {
// get mouse up to date
flushCompressedMouse();
UInt16 id, mask; UInt16 id, mask;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
@ -623,6 +651,9 @@ CClient::onKeyDown()
void void
CClient::onKeyRepeat() CClient::onKeyRepeat()
{ {
// get mouse up to date
flushCompressedMouse();
UInt16 id, mask, count; UInt16 id, mask, count;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
@ -637,6 +668,9 @@ CClient::onKeyRepeat()
void void
CClient::onKeyUp() CClient::onKeyUp()
{ {
// get mouse up to date
flushCompressedMouse();
UInt16 id, mask; UInt16 id, mask;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
@ -650,6 +684,9 @@ CClient::onKeyUp()
void void
CClient::onMouseDown() CClient::onMouseDown()
{ {
// get mouse up to date
flushCompressedMouse();
SInt8 id; SInt8 id;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
@ -662,6 +699,9 @@ CClient::onMouseDown()
void void
CClient::onMouseUp() CClient::onMouseUp()
{ {
// get mouse up to date
flushCompressedMouse();
SInt8 id; SInt8 id;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
@ -680,6 +720,16 @@ CClient::onMouseMove()
CLock lock(&m_mutex); CLock lock(&m_mutex);
CProtocolUtil::readf(m_input, kMsgDMouseMove + 4, &x, &y); CProtocolUtil::readf(m_input, kMsgDMouseMove + 4, &x, &y);
ignore = m_ignoreMove; ignore = m_ignoreMove;
// compress mouse motion events if more input follows
if (!ignore && !m_compressMouse && m_input->getSize() > 0) {
m_compressMouse = true;
}
if (m_compressMouse) {
ignore = true;
m_xMouse = x;
m_yMouse = y;
}
} }
log((CLOG_DEBUG2 "recv mouse move %d,%d", x, y)); log((CLOG_DEBUG2 "recv mouse move %d,%d", x, y));
if (!ignore) { if (!ignore) {
@ -690,6 +740,9 @@ CClient::onMouseMove()
void void
CClient::onMouseWheel() CClient::onMouseWheel()
{ {
// get mouse up to date
flushCompressedMouse();
SInt16 delta; SInt16 delta;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);

View File

@ -47,10 +47,13 @@ public:
private: private:
void runSession(void*); void runSession(void*);
// open/close the primary screen // open/close the secondary screen
void openSecondaryScreen(); void openSecondaryScreen();
void closeSecondaryScreen(); void closeSecondaryScreen();
// if compressing mouse motion then send the last motion now
void flushCompressedMouse();
// message handlers // message handlers
void onEnter(); void onEnter();
void onLeave(); void onLeave();
@ -86,6 +89,9 @@ private:
bool m_ownClipboard[kClipboardEnd]; bool m_ownClipboard[kClipboardEnd];
IClipboard::Time m_timeClipboard[kClipboardEnd]; IClipboard::Time m_timeClipboard[kClipboardEnd];
CString m_dataClipboard[kClipboardEnd]; CString m_dataClipboard[kClipboardEnd];
bool m_compressMouse;
SInt32 m_xMouse, m_yMouse;
}; };
#endif #endif