applied refactoring to win32 code.

This commit is contained in:
crs 2002-07-11 13:13:37 +00:00
parent 3468f3d503
commit feeb15a08d
18 changed files with 201 additions and 164 deletions

View File

@ -191,8 +191,7 @@ CClient::close()
} }
void void
CClient::enter(SInt32 xAbs, SInt32 yAbs, CClient::enter(SInt32 xAbs, SInt32 yAbs, UInt32, KeyModifierMask mask, bool)
UInt32 seqNum, KeyModifierMask mask, bool)
{ {
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
@ -216,6 +215,8 @@ CClient::leave()
sendClipboard(id); sendClipboard(id);
} }
} }
return true;
} }
void void

View File

@ -1,5 +1,5 @@
#include "CMSWindowsSecondaryScreen.h" #include "CMSWindowsSecondaryScreen.h"
#include "CClient.h" #include "IScreenReceiver.h"
#include "CClipboard.h" #include "CClipboard.h"
#include "CMSWindowsClipboard.h" #include "CMSWindowsClipboard.h"
#include "CMSWindowsScreenSaver.h" #include "CMSWindowsScreenSaver.h"
@ -22,8 +22,9 @@
// CMSWindowsSecondaryScreen // CMSWindowsSecondaryScreen
// //
CMSWindowsSecondaryScreen::CMSWindowsSecondaryScreen() : CMSWindowsSecondaryScreen::CMSWindowsSecondaryScreen(
m_client(NULL), IScreenReceiver* receiver) :
m_receiver(receiver),
m_threadID(0), m_threadID(0),
m_lastThreadID(0), m_lastThreadID(0),
m_desk(NULL), m_desk(NULL),
@ -32,6 +33,8 @@ CMSWindowsSecondaryScreen::CMSWindowsSecondaryScreen() :
m_active(false), m_active(false),
m_nextClipboardWindow(NULL) m_nextClipboardWindow(NULL)
{ {
assert(m_receiver != NULL);
m_is95Family = CPlatform::isWindows95Family(); m_is95Family = CPlatform::isWindows95Family();
// make sure this thread has a message queue // make sure this thread has a message queue
@ -78,14 +81,8 @@ CMSWindowsSecondaryScreen::stop()
} }
void void
CMSWindowsSecondaryScreen::open(CClient* client) CMSWindowsSecondaryScreen::open()
{ {
assert(m_client == NULL);
assert(client != NULL);
// set the client
m_client = client;
// open the display // open the display
openDisplay(); openDisplay();
@ -109,8 +106,6 @@ CMSWindowsSecondaryScreen::open(CClient* client)
void void
CMSWindowsSecondaryScreen::close() CMSWindowsSecondaryScreen::close()
{ {
assert(m_client != NULL);
// release keys that are logically pressed // release keys that are logically pressed
releaseKeys(); releaseKeys();
@ -119,9 +114,6 @@ CMSWindowsSecondaryScreen::close()
// close the display // close the display
closeDisplay(); closeDisplay();
// done with client
m_client = NULL;
} }
void void
@ -189,8 +181,8 @@ CMSWindowsSecondaryScreen::leave()
if (m_clipboardOwner != clipboardOwner) { if (m_clipboardOwner != clipboardOwner) {
m_clipboardOwner = clipboardOwner; m_clipboardOwner = clipboardOwner;
if (m_clipboardOwner != m_window) { if (m_clipboardOwner != m_window) {
m_client->onClipboardChanged(kClipboardClipboard); m_receiver->onGrabClipboard(kClipboardClipboard);
m_client->onClipboardChanged(kClipboardSelection); m_receiver->onGrabClipboard(kClipboardSelection);
} }
} }
} }
@ -555,8 +547,8 @@ CMSWindowsSecondaryScreen::onEvent(HWND hwnd, UINT msg,
// window to do that). // window to do that).
m_clipboardOwner = GetClipboardOwner(); m_clipboardOwner = GetClipboardOwner();
if (m_clipboardOwner != m_window && m_clipboardOwner != NULL) { if (m_clipboardOwner != m_window && m_clipboardOwner != NULL) {
m_client->onClipboardChanged(kClipboardClipboard); m_receiver->onGrabClipboard(kClipboardClipboard);
m_client->onClipboardChanged(kClipboardSelection); m_receiver->onGrabClipboard(kClipboardSelection);
} }
return 0; return 0;
@ -573,7 +565,13 @@ CMSWindowsSecondaryScreen::onEvent(HWND hwnd, UINT msg,
// screen resolution has changed // screen resolution has changed
updateScreenShape(); updateScreenShape();
m_multimon = isMultimon(); m_multimon = isMultimon();
m_client->onResolutionChanged();
// send new info
CClientInfo info;
getShape(info.m_x, info.m_y, info.m_w, info.m_h);
getMousePos(info.m_mx, info.m_my);
info.m_zoneSize = getJumpZoneSize();
m_receiver->onInfoChanged(info);
return 0; return 0;
} }

View File

@ -13,16 +13,18 @@
#include "CString.h" #include "CString.h"
#include "stdvector.h" #include "stdvector.h"
class IScreenReceiver;
class CMSWindowsSecondaryScreen : public CMSWindowsScreen, class CMSWindowsSecondaryScreen : public CMSWindowsScreen,
public ISecondaryScreen { public ISecondaryScreen {
public: public:
CMSWindowsSecondaryScreen(); CMSWindowsSecondaryScreen(IScreenReceiver*);
virtual ~CMSWindowsSecondaryScreen(); virtual ~CMSWindowsSecondaryScreen();
// ISecondaryScreen overrides // ISecondaryScreen overrides
virtual void run(); virtual void run();
virtual void stop(); virtual void stop();
virtual void open(CClient*); virtual void open();
virtual void close(); virtual void close();
virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute, virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute,
KeyModifierMask mask); KeyModifierMask mask);
@ -95,7 +97,7 @@ private:
private: private:
CMutex m_mutex; CMutex m_mutex;
CClient* m_client; IScreenReceiver* m_receiver;
// true if windows 95/98/me // true if windows 95/98/me
bool m_is95Family; bool m_is95Family;

View File

@ -239,6 +239,7 @@ CServerProxy::onGrabClipboard(ClipboardID id)
log((CLOG_DEBUG1 "sending clipboard %d changed", id)); log((CLOG_DEBUG1 "sending clipboard %d changed", id));
CLock lock(&m_mutex); CLock lock(&m_mutex);
CProtocolUtil::writef(getOutputStream(), kMsgCClipboard, id, m_seqNum); CProtocolUtil::writef(getOutputStream(), kMsgCClipboard, id, m_seqNum);
return true;
} }
void void
@ -253,7 +254,7 @@ void
CServerProxy::flushCompressedMouse() CServerProxy::flushCompressedMouse()
{ {
bool send = false; bool send = false;
SInt32 x, y; SInt32 x = 0, y = 0;
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
if (m_compressMouse) { if (m_compressMouse) {

View File

@ -108,6 +108,10 @@ SOURCE=.\client.rc
SOURCE=.\CMSWindowsSecondaryScreen.cpp SOURCE=.\CMSWindowsSecondaryScreen.cpp
# End Source File # End Source File
# Begin Source File
SOURCE=.\CServerProxy.cpp
# End Source File
# End Group # End Group
# Begin Group "Header Files" # Begin Group "Header Files"
@ -120,6 +124,18 @@ SOURCE=.\CClient.h
SOURCE=.\CMSWindowsSecondaryScreen.h SOURCE=.\CMSWindowsSecondaryScreen.h
# End Source File # End Source File
# Begin Source File
SOURCE=.\CServerProxy.h
# End Source File
# Begin Source File
SOURCE=.\ISecondaryScreen.h
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# End Group # End Group
# Begin Group "Resource Files" # Begin Group "Resource Files"

View File

@ -1,8 +1,11 @@
#include "CMSWindowsPrimaryScreen.h" #include "CMSWindowsPrimaryScreen.h"
#include "CServer.h" #include "IScreenReceiver.h"
#include "IPrimaryScreenReceiver.h"
#include "CMSWindowsClipboard.h" #include "CMSWindowsClipboard.h"
#include "CMSWindowsScreenSaver.h" #include "CMSWindowsScreenSaver.h"
#include "CPlatform.h" #include "CPlatform.h"
#include "CClipboard.h"
#include "ProtocolTypes.h"
#include "XScreen.h" #include "XScreen.h"
#include "XSynergy.h" #include "XSynergy.h"
#include "CThread.h" #include "CThread.h"
@ -13,8 +16,11 @@
// CMSWindowsPrimaryScreen // CMSWindowsPrimaryScreen
// //
CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen() : CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen(
m_server(NULL), IScreenReceiver* receiver,
IPrimaryScreenReceiver* primaryReceiver) :
m_receiver(receiver),
m_primaryReceiver(primaryReceiver),
m_threadID(0), m_threadID(0),
m_desk(NULL), m_desk(NULL),
m_deskName(), m_deskName(),
@ -25,19 +31,24 @@ CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen() :
m_nextClipboardWindow(NULL), m_nextClipboardWindow(NULL),
m_clipboardOwner(NULL) m_clipboardOwner(NULL)
{ {
assert(m_receiver != NULL);
assert(m_primaryReceiver != NULL);
// load the hook library // load the hook library
m_hookLibrary = LoadLibrary("synrgyhk"); m_hookLibrary = LoadLibrary("synrgyhk");
if (m_hookLibrary == NULL) { if (m_hookLibrary == NULL) {
log((CLOG_ERR "failed to load hook library")); log((CLOG_ERR "failed to load hook library"));
throw XScreenOpenFailure(); throw XScreenOpenFailure();
} }
m_setSides = (SetSidesFunc)GetProcAddress(m_hookLibrary, "setSides");
m_setZone = (SetZoneFunc)GetProcAddress(m_hookLibrary, "setZone"); m_setZone = (SetZoneFunc)GetProcAddress(m_hookLibrary, "setZone");
m_setRelay = (SetRelayFunc)GetProcAddress(m_hookLibrary, "setRelay"); m_setRelay = (SetRelayFunc)GetProcAddress(m_hookLibrary, "setRelay");
m_install = (InstallFunc)GetProcAddress(m_hookLibrary, "install"); m_install = (InstallFunc)GetProcAddress(m_hookLibrary, "install");
m_uninstall = (UninstallFunc)GetProcAddress(m_hookLibrary, "uninstall"); m_uninstall = (UninstallFunc)GetProcAddress(m_hookLibrary, "uninstall");
m_init = (InitFunc)GetProcAddress(m_hookLibrary, "init"); m_init = (InitFunc)GetProcAddress(m_hookLibrary, "init");
m_cleanup = (CleanupFunc)GetProcAddress(m_hookLibrary, "cleanup"); m_cleanup = (CleanupFunc)GetProcAddress(m_hookLibrary, "cleanup");
if (m_setZone == NULL || if (m_setSides == NULL ||
m_setZone == NULL ||
m_setRelay == NULL || m_setRelay == NULL ||
m_install == NULL || m_install == NULL ||
m_uninstall == NULL || m_uninstall == NULL ||
@ -114,14 +125,8 @@ CMSWindowsPrimaryScreen::stop()
} }
void void
CMSWindowsPrimaryScreen::open(CServer* server) CMSWindowsPrimaryScreen::open()
{ {
assert(m_server == NULL);
assert(server != NULL);
// set the server
m_server = server;
// open the display // open the display
openDisplay(); openDisplay();
@ -137,9 +142,12 @@ CMSWindowsPrimaryScreen::open(CServer* server)
m_y = pos.y; m_y = pos.y;
// send screen info // send screen info
SInt32 x, y, w, h; CClientInfo info;
getScreenShape(x, y, w, h); getScreenShape(info.m_x, info.m_y, info.m_w, info.m_h);
m_server->setInfo(x, y, w, h, getJumpZoneSize(), m_x, m_y); info.m_zoneSize = getJumpZoneSize();
info.m_mx = m_x;
info.m_my = m_y;
m_receiver->onInfoChanged(info);
// compute center pixel of primary screen // compute center pixel of primary screen
m_xCenter = GetSystemMetrics(SM_CXSCREEN) >> 1; m_xCenter = GetSystemMetrics(SM_CXSCREEN) >> 1;
@ -148,6 +156,9 @@ CMSWindowsPrimaryScreen::open(CServer* server)
// get keyboard state // get keyboard state
updateKeys(); updateKeys();
// set jump zones
m_setZone(info.m_x, info.m_y, info.m_w, info.m_h, info.m_zoneSize);
// enter the screen // enter the screen
enterNoWarp(); enterNoWarp();
} }
@ -155,13 +166,8 @@ CMSWindowsPrimaryScreen::open(CServer* server)
void void
CMSWindowsPrimaryScreen::close() CMSWindowsPrimaryScreen::close()
{ {
assert(m_server != NULL);
// close the display // close the display
closeDisplay(); closeDisplay();
// done with server
m_server = NULL;
} }
void void
@ -194,7 +200,7 @@ CMSWindowsPrimaryScreen::leave()
} }
// relay all mouse and keyboard events // relay all mouse and keyboard events
m_setRelay(); m_setRelay(true);
// get state of keys as we leave // get state of keys as we leave
updateKeys(); updateKeys();
@ -239,8 +245,8 @@ CMSWindowsPrimaryScreen::leave()
try { try {
m_clipboardOwner = clipboardOwner; m_clipboardOwner = clipboardOwner;
if (m_clipboardOwner != m_window) { if (m_clipboardOwner != m_window) {
m_server->grabClipboard(kClipboardClipboard); m_receiver->onGrabClipboard(kClipboardClipboard);
m_server->grabClipboard(kClipboardSelection); m_receiver->onGrabClipboard(kClipboardSelection);
} }
} }
catch (XBadClient&) { catch (XBadClient&) {
@ -252,14 +258,9 @@ CMSWindowsPrimaryScreen::leave()
} }
void void
CMSWindowsPrimaryScreen::onConfigure() CMSWindowsPrimaryScreen::reconfigure(UInt32 activeSides)
{ {
if ((m_is95Family || m_desk != NULL) && !m_active) { m_setSides(activeSides);
SInt32 x, y, w, h;
getScreenShape(x, y, w, h);
m_setZone(m_server->getActivePrimarySides(),
x, y, w, h, getJumpZoneSize());
}
} }
void void
@ -308,19 +309,6 @@ CMSWindowsPrimaryScreen::grabClipboard(ClipboardID /*id*/)
} }
} }
void
CMSWindowsPrimaryScreen::getShape(
SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
{
getScreenShape(x, y, w, h);
}
SInt32
CMSWindowsPrimaryScreen::getJumpZoneSize() const
{
return 1;
}
void void
CMSWindowsPrimaryScreen::getClipboard(ClipboardID /*id*/, CMSWindowsPrimaryScreen::getClipboard(ClipboardID /*id*/,
IClipboard* dst) const IClipboard* dst) const
@ -390,17 +378,10 @@ CMSWindowsPrimaryScreen::isLockedToScreen() const
return false; return false;
} }
bool
CMSWindowsPrimaryScreen::isScreenSaverActive() const
{
return getScreenSaver()->isActive();
}
void void
CMSWindowsPrimaryScreen::onOpenDisplay() CMSWindowsPrimaryScreen::onOpenDisplay()
{ {
assert(m_window == NULL); assert(m_window == NULL);
assert(m_server != NULL);
// save thread id. we'll need to pass this to the hook library. // save thread id. we'll need to pass this to the hook library.
m_threadID = GetCurrentThreadId(); m_threadID = GetCurrentThreadId();
@ -478,11 +459,11 @@ CMSWindowsPrimaryScreen::onPreTranslate(MSG* msg)
const SInt32 repeat = (SInt32)(msg->lParam & 0xffff); const SInt32 repeat = (SInt32)(msg->lParam & 0xffff);
if (repeat >= 2) { if (repeat >= 2) {
log((CLOG_DEBUG1 "event: key repeat key=%d mask=0x%04x count=%d", key, mask, repeat)); log((CLOG_DEBUG1 "event: key repeat key=%d mask=0x%04x count=%d", key, mask, repeat));
m_server->onKeyRepeat(key, mask, repeat); m_primaryReceiver->onKeyRepeat(key, mask, repeat);
} }
else { else {
log((CLOG_DEBUG1 "event: key press key=%d mask=0x%04x", key, mask)); log((CLOG_DEBUG1 "event: key press key=%d mask=0x%04x", key, mask));
m_server->onKeyDown(key, mask); m_primaryReceiver->onKeyDown(key, mask);
} }
// update key state // update key state
@ -491,7 +472,7 @@ CMSWindowsPrimaryScreen::onPreTranslate(MSG* msg)
else { else {
// key release // key release
log((CLOG_DEBUG1 "event: key release key=%d mask=0x%04x", key, mask)); log((CLOG_DEBUG1 "event: key release key=%d mask=0x%04x", key, mask));
m_server->onKeyUp(key, mask); m_primaryReceiver->onKeyUp(key, mask);
// update key state // update key state
updateKey(msg->wParam, false); updateKey(msg->wParam, false);
@ -520,7 +501,7 @@ CMSWindowsPrimaryScreen::onPreTranslate(MSG* msg)
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
log((CLOG_DEBUG1 "event: button press button=%d", button)); log((CLOG_DEBUG1 "event: button press button=%d", button));
if (button != kButtonNone) { if (button != kButtonNone) {
m_server->onMouseDown(button); m_primaryReceiver->onMouseDown(button);
m_keys[s_vkButton[button]] |= 0x80; m_keys[s_vkButton[button]] |= 0x80;
} }
break; break;
@ -530,7 +511,7 @@ CMSWindowsPrimaryScreen::onPreTranslate(MSG* msg)
case WM_RBUTTONUP: case WM_RBUTTONUP:
log((CLOG_DEBUG1 "event: button release button=%d", button)); log((CLOG_DEBUG1 "event: button release button=%d", button));
if (button != kButtonNone) { if (button != kButtonNone) {
m_server->onMouseUp(button); m_primaryReceiver->onMouseUp(button);
m_keys[s_vkButton[button]] &= ~0x80; m_keys[s_vkButton[button]] &= ~0x80;
} }
break; break;
@ -542,7 +523,7 @@ CMSWindowsPrimaryScreen::onPreTranslate(MSG* msg)
// ignore message if posted prior to last mark change // ignore message if posted prior to last mark change
if (m_markReceived == m_mark) { if (m_markReceived == m_mark) {
log((CLOG_ERR "event: button wheel delta=%d %d", msg->wParam, msg->lParam)); log((CLOG_ERR "event: button wheel delta=%d %d", msg->wParam, msg->lParam));
m_server->onMouseWheel(msg->wParam); m_primaryReceiver->onMouseWheel(msg->wParam);
} }
return true; return true;
@ -552,7 +533,7 @@ CMSWindowsPrimaryScreen::onPreTranslate(MSG* msg)
SInt32 x = static_cast<SInt32>(msg->wParam); SInt32 x = static_cast<SInt32>(msg->wParam);
SInt32 y = static_cast<SInt32>(msg->lParam); SInt32 y = static_cast<SInt32>(msg->lParam);
if (!m_active) { if (!m_active) {
m_server->onMouseMovePrimary(x, y); m_primaryReceiver->onMouseMovePrimary(x, y);
} }
else { else {
// compute motion delta. this is relative to the // compute motion delta. this is relative to the
@ -572,7 +553,7 @@ CMSWindowsPrimaryScreen::onPreTranslate(MSG* msg)
warpCursorToCenter(); warpCursorToCenter();
// send motion // send motion
m_server->onMouseMoveSecondary(x, y); m_primaryReceiver->onMouseMoveSecondary(x, y);
} }
} }
else { else {
@ -591,11 +572,11 @@ CMSWindowsPrimaryScreen::onPreTranslate(MSG* msg)
case SYNERGY_MSG_SCREEN_SAVER: case SYNERGY_MSG_SCREEN_SAVER:
if (msg->wParam != 0) { if (msg->wParam != 0) {
if (getScreenSaver()->checkStarted(msg->message, FALSE, 0)) { if (getScreenSaver()->checkStarted(msg->message, FALSE, 0)) {
m_server->onScreenSaver(true); m_primaryReceiver->onScreenSaver(true);
} }
} }
else { else {
m_server->onScreenSaver(false); m_primaryReceiver->onScreenSaver(false);
} }
return true; return true;
@ -655,8 +636,8 @@ CMSWindowsPrimaryScreen::onEvent(HWND hwnd, UINT msg,
try { try {
m_clipboardOwner = GetClipboardOwner(); m_clipboardOwner = GetClipboardOwner();
if (m_clipboardOwner != m_window) { if (m_clipboardOwner != m_window) {
m_server->grabClipboard(kClipboardClipboard); m_receiver->onGrabClipboard(kClipboardClipboard);
m_server->grabClipboard(kClipboardSelection); m_receiver->onGrabClipboard(kClipboardSelection);
} }
} }
catch (XBadClient&) { catch (XBadClient&) {
@ -696,13 +677,21 @@ CMSWindowsPrimaryScreen::onEvent(HWND hwnd, UINT msg,
// tell hook about resize if not active // tell hook about resize if not active
else { else {
onConfigure(); m_setZone(x, y, w, h, getJumpZoneSize());
} }
// send new screen info // send new screen info
POINT pos; POINT pos;
GetCursorPos(&pos); GetCursorPos(&pos);
m_server->setInfo(x, y, w, h, getJumpZoneSize(), pos.x, pos.y); CClientInfo info;
info.m_x = x;
info.m_y = y;
info.m_w = w;
info.m_h = h;
info.m_zoneSize = getJumpZoneSize();
info.m_mx = pos.x;
info.m_my = pos.y;
m_receiver->onInfoChanged(info);
} }
return 0; return 0;
@ -727,8 +716,8 @@ CMSWindowsPrimaryScreen::enterNoWarp()
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &dummy, 0); SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &dummy, 0);
} }
// install jump zones // watch jump zones
onConfigure(); m_setRelay(false);
// restore active window and hide our window // restore active window and hide our window
onEnter(); onEnter();
@ -787,6 +776,12 @@ CMSWindowsPrimaryScreen::onLeave()
return true; return true;
} }
SInt32
CMSWindowsPrimaryScreen::getJumpZoneSize() const
{
return 1;
}
void void
CMSWindowsPrimaryScreen::nextMark() CMSWindowsPrimaryScreen::nextMark()
{ {
@ -956,8 +951,8 @@ CMSWindowsPrimaryScreen::switchDesktop(HDESK desk)
onLeave(); onLeave();
} }
else { else {
// set jump zones // watch jump zones
onConfigure(); m_setRelay(false);
// all messages prior to now are invalid // all messages prior to now are invalid
nextMark(); nextMark();

View File

@ -2,35 +2,35 @@
#define CMSWINDOWSPRIMARYSCREEN_H #define CMSWINDOWSPRIMARYSCREEN_H
#include "CMSWindowsScreen.h" #include "CMSWindowsScreen.h"
#include "IPrimaryScreen.h"
#include "CSynergyHook.h" #include "CSynergyHook.h"
#include "MouseTypes.h" #include "MouseTypes.h"
#include "IPrimaryScreen.h"
#include "CString.h" #include "CString.h"
class IScreenReceiver;
class IPrimaryScreenReceiver;
class CMSWindowsPrimaryScreen : public CMSWindowsScreen, public IPrimaryScreen { class CMSWindowsPrimaryScreen : public CMSWindowsScreen, public IPrimaryScreen {
public: public:
typedef bool (CMSWindowsPrimaryScreen::*HookMethod)(int, WPARAM, LPARAM); typedef bool (CMSWindowsPrimaryScreen::*HookMethod)(int, WPARAM, LPARAM);
CMSWindowsPrimaryScreen(); CMSWindowsPrimaryScreen(IScreenReceiver*, IPrimaryScreenReceiver*);
virtual ~CMSWindowsPrimaryScreen(); virtual ~CMSWindowsPrimaryScreen();
// IPrimaryScreen overrides // IPrimaryScreen overrides
virtual void run(); virtual void run();
virtual void stop(); virtual void stop();
virtual void open(CServer*); virtual void open();
virtual void close(); virtual void close();
virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute, bool); virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute, bool);
virtual bool leave(); virtual bool leave();
virtual void onConfigure(); virtual void reconfigure(UInt32 activeSides);
virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute); virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute);
virtual void setClipboard(ClipboardID, const IClipboard*); virtual void setClipboard(ClipboardID, const IClipboard*);
virtual void grabClipboard(ClipboardID); virtual void grabClipboard(ClipboardID);
virtual void getShape(SInt32&, SInt32&, SInt32&, SInt32&) const;
virtual SInt32 getJumpZoneSize() const;
virtual void getClipboard(ClipboardID, IClipboard*) const; virtual void getClipboard(ClipboardID, IClipboard*) const;
virtual KeyModifierMask getToggleMask() const; virtual KeyModifierMask getToggleMask() const;
virtual bool isLockedToScreen() const; virtual bool isLockedToScreen() const;
virtual bool isScreenSaverActive() const;
protected: protected:
// CMSWindowsScreen overrides // CMSWindowsScreen overrides
@ -45,6 +45,8 @@ private:
void onEnter(); void onEnter();
bool onLeave(); bool onLeave();
SInt32 getJumpZoneSize() const;
// warp mouse to center of primary display (used when computing // warp mouse to center of primary display (used when computing
// motion deltas while mouse is on secondary screen). // motion deltas while mouse is on secondary screen).
void warpCursorToCenter(); void warpCursorToCenter();
@ -67,7 +69,8 @@ private:
void updateKey(UINT vkCode, bool press); void updateKey(UINT vkCode, bool press);
private: private:
CServer* m_server; IScreenReceiver* m_receiver;
IPrimaryScreenReceiver* m_primaryReceiver;
// true if windows 95/98/me // true if windows 95/98/me
bool m_is95Family; bool m_is95Family;
@ -111,6 +114,7 @@ private:
CleanupFunc m_cleanup; CleanupFunc m_cleanup;
InstallFunc m_install; InstallFunc m_install;
UninstallFunc m_uninstall; UninstallFunc m_uninstall;
SetSidesFunc m_setSides;
SetZoneFunc m_setZone; SetZoneFunc m_setZone;
SetRelayFunc m_setRelay; SetRelayFunc m_setRelay;
InstallScreenSaverFunc m_installScreenSaver; InstallScreenSaverFunc m_installScreenSaver;

View File

@ -43,9 +43,9 @@ CPrimaryClient::stop()
} }
void void
CPrimaryClient::reconfigure() CPrimaryClient::reconfigure(UInt32 activeSides)
{ {
m_screen->reconfigure(); m_screen->reconfigure(activeSides);
} }
void void

View File

@ -20,7 +20,7 @@ public:
void stop(); void stop();
// called by server when the configuration changes // called by server when the configuration changes
void reconfigure(); void reconfigure(UInt32 activeSides);
// accessors // accessors

View File

@ -8,7 +8,6 @@
#include "ProtocolTypes.h" #include "ProtocolTypes.h"
#include "XScreen.h" #include "XScreen.h"
#include "XSynergy.h" #include "XSynergy.h"
// XXX #include "CNetworkAddress.h"
#include "IDataSocket.h" #include "IDataSocket.h"
#include "IListenSocket.h" #include "IListenSocket.h"
#include "ISocketFactory.h" #include "ISocketFactory.h"
@ -167,7 +166,7 @@ CServer::setConfig(const CConfig& config)
// tell primary screen about reconfiguration // tell primary screen about reconfiguration
if (m_primaryClient != NULL) { if (m_primaryClient != NULL) {
m_primaryClient->reconfigure(); m_primaryClient->reconfigure(getActivePrimarySides());
} }
return true; return true;
@ -191,8 +190,8 @@ CServer::getConfig(CConfig* config) const
UInt32 UInt32
CServer::getActivePrimarySides() const CServer::getActivePrimarySides() const
{ {
// note -- m_mutex must be locked on entry
UInt32 sides = 0; UInt32 sides = 0;
CLock lock(&m_mutex);
if (!m_config.getNeighbor(getPrimaryScreenName(), if (!m_config.getNeighbor(getPrimaryScreenName(),
CConfig::kLeft).empty()) { CConfig::kLeft).empty()) {
sides |= CConfig::kLeftMask; sides |= CConfig::kLeftMask;
@ -723,7 +722,7 @@ CServer::switchScreen(IClient* dst, SInt32 x, SInt32 y, bool screenSaver)
// update the primary client's clipboards if we're leaving the // update the primary client's clipboards if we're leaving the
// primary screen. // primary screen.
if (m_active == m_primaryClient) { if (m_active == m_primaryClient) {
for (UInt32 id = 0; id < kClipboardEnd; ++id) { for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
CClipboardInfo& clipboard = m_clipboards[id]; CClipboardInfo& clipboard = m_clipboards[id];
if (clipboard.m_clipboardOwner == m_primaryClient->getName()) { if (clipboard.m_clipboardOwner == m_primaryClient->getName()) {
CString clipboardData; CString clipboardData;
@ -973,14 +972,14 @@ CServer::closeClients(const CConfig& config)
index != m_clientThreads.end(); ) { index != m_clientThreads.end(); ) {
const CString& name = index->first; const CString& name = index->first;
if (!config.isCanonicalName(name)) { if (!config.isCanonicalName(name)) {
// save the thread and remove it from m_clientThreads
threads.push_back(index->second);
m_clientThreads.erase(index++);
// lookup IClient with name // lookup IClient with name
CClientList::const_iterator index2 = m_clients.find(name); CClientList::const_iterator index2 = m_clients.find(name);
assert(index2 != m_clients.end()); assert(index2 != m_clients.end());
// save the thread and remove it from m_clientThreads
threads.push_back(index->second);
m_clientThreads.erase(index++);
// close that client // close that client
assert(index2->second != m_primaryClient); assert(index2->second != m_primaryClient);
index2->second->close(); index2->second->close();
@ -1520,6 +1519,9 @@ CServer::openPrimaryScreen()
// open the screen // open the screen
log((CLOG_DEBUG1 "opening primary screen")); log((CLOG_DEBUG1 "opening primary screen"));
m_primaryClient->open(); m_primaryClient->open();
// tell it about the active sides
m_primaryClient->reconfigure(getActivePrimarySides());
} }
catch (...) { catch (...) {
if (m_active != NULL) { if (m_active != NULL) {

View File

@ -50,9 +50,6 @@ public:
// get the primary screen's name // get the primary screen's name
CString getPrimaryScreenName() const; CString getPrimaryScreenName() const;
// get the sides of the primary screen that have neighbors
UInt32 getActivePrimarySides() const;
// IPrimaryScreenReceiver overrides // IPrimaryScreenReceiver overrides
virtual void onError(); virtual void onError();
virtual void onKeyDown(KeyID, KeyModifierMask); virtual void onKeyDown(KeyID, KeyModifierMask);
@ -76,6 +73,9 @@ protected:
private: private:
typedef std::list<CThread> CThreadList; typedef std::list<CThread> CThreadList;
// get the sides of the primary screen that have neighbors
UInt32 getActivePrimarySides() const;
// handle mouse motion // handle mouse motion
bool onMouseMovePrimaryNoLock(SInt32 x, SInt32 y); bool onMouseMovePrimaryNoLock(SInt32 x, SInt32 y);
void onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy); void onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy);

View File

@ -47,8 +47,8 @@ static HANDLE g_keyHookEvent = NULL;
static HHOOK g_keyboardLL = NULL; static HHOOK g_keyboardLL = NULL;
static bool g_screenSaver = false; static bool g_screenSaver = false;
static bool g_relay = false; static bool g_relay = false;
static SInt32 g_zoneSize = 0;
static UInt32 g_zoneSides = 0; static UInt32 g_zoneSides = 0;
static SInt32 g_zoneSize = 0;
static SInt32 g_xScreen = 0; static SInt32 g_xScreen = 0;
static SInt32 g_yScreen = 0; static SInt32 g_yScreen = 0;
static SInt32 g_wScreen = 0; static SInt32 g_wScreen = 0;
@ -510,8 +510,8 @@ install()
// set defaults // set defaults
g_relay = false; g_relay = false;
g_zoneSize = 0;
g_zoneSides = 0; g_zoneSides = 0;
g_zoneSize = 0;
g_xScreen = 0; g_xScreen = 0;
g_yScreen = 0; g_yScreen = 0;
g_wScreen = 0; g_wScreen = 0;
@ -681,30 +681,28 @@ uninstallScreenSaver(void)
} }
void void
setZone(UInt32 sides, setSides(UInt32 sides)
SInt32 x, SInt32 y, SInt32 w, SInt32 h, {
SInt32 jumpZoneSize) g_zoneSides = sides;
}
void
setZone(SInt32 x, SInt32 y, SInt32 w, SInt32 h, SInt32 jumpZoneSize)
{ {
g_zoneSize = jumpZoneSize; g_zoneSize = jumpZoneSize;
g_zoneSides = sides;
g_xScreen = x; g_xScreen = x;
g_yScreen = y; g_yScreen = y;
g_wScreen = w; g_wScreen = w;
g_hScreen = h; g_hScreen = h;
g_relay = false;
restoreCursor();
} }
void void
setRelay(void) setRelay(int enable)
{ {
g_relay = true; g_relay = (enable != 0);
g_zoneSize = 0; if (!g_relay) {
g_zoneSides = 0; restoreCursor();
g_xScreen = 0; }
g_yScreen = 0;
g_wScreen = 0;
g_hScreen = 0;
} }
} }

View File

@ -32,9 +32,9 @@ typedef int (*InstallFunc)(void);
typedef int (*UninstallFunc)(void); typedef int (*UninstallFunc)(void);
typedef int (*InstallScreenSaverFunc)(void); typedef int (*InstallScreenSaverFunc)(void);
typedef int (*UninstallScreenSaverFunc)(void); typedef int (*UninstallScreenSaverFunc)(void);
typedef void (*SetZoneFunc)(UInt32, typedef void (*SetSidesFunc)(UInt32);
SInt32, SInt32, SInt32, SInt32, SInt32); typedef void (*SetZoneFunc)(SInt32, SInt32, SInt32, SInt32, SInt32);
typedef void (*SetRelayFunc)(void); typedef void (*SetRelayFunc)(int);
CSYNERGYHOOK_API int init(DWORD); CSYNERGYHOOK_API int init(DWORD);
CSYNERGYHOOK_API int cleanup(void); CSYNERGYHOOK_API int cleanup(void);
@ -42,10 +42,10 @@ CSYNERGYHOOK_API int install(void);
CSYNERGYHOOK_API int uninstall(void); CSYNERGYHOOK_API int uninstall(void);
CSYNERGYHOOK_API int installScreenSaver(void); CSYNERGYHOOK_API int installScreenSaver(void);
CSYNERGYHOOK_API int uninstallScreenSaver(void); CSYNERGYHOOK_API int uninstallScreenSaver(void);
CSYNERGYHOOK_API void setZone(UInt32 sides, CSYNERGYHOOK_API void setSides(UInt32 sides);
SInt32 x, SInt32 y, SInt32 w, SInt32 h, CSYNERGYHOOK_API void setZone(SInt32 x, SInt32 y, SInt32 w, SInt32 h,
SInt32 jumpZoneSize); SInt32 jumpZoneSize);
CSYNERGYHOOK_API void setRelay(void); CSYNERGYHOOK_API void setRelay(int enable); // relay iff enable != 0
} }

View File

@ -397,7 +397,7 @@ CXWindowsPrimaryScreen::leave()
} }
void void
CXWindowsPrimaryScreen::reconfigure() CXWindowsPrimaryScreen::reconfigure(UInt32)
{ {
// do nothing // do nothing
} }

View File

@ -20,7 +20,7 @@ public:
virtual void close(); virtual void close();
virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute, bool); virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute, bool);
virtual bool leave(); virtual bool leave();
virtual void reconfigure(); virtual void reconfigure(UInt32 activeSides);
virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute); virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute);
virtual void setClipboard(ClipboardID, const IClipboard*); virtual void setClipboard(ClipboardID, const IClipboard*);
virtual void grabClipboard(ClipboardID); virtual void grabClipboard(ClipboardID);

View File

@ -57,10 +57,10 @@ public:
// leave() must not call any receiver methods except onError(). // leave() must not call any receiver methods except onError().
virtual bool leave() = 0; virtual bool leave() = 0;
// called when the configuration has changed. subclasses may need // called when the configuration has changed. activeSides is a
// to adjust things (like the jump zones) after the configuration // bitmask of CConfig::EDirectionMask indicating which sides of
// changes. // the primary screen are linked to clients.
virtual void reconfigure() = 0; virtual void reconfigure(UInt32 activeSides) = 0;
// warp the cursor to the given position // warp the cursor to the given position
virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute) = 0; virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute) = 0;

View File

@ -94,6 +94,14 @@ LINK32=link.exe
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File # Begin Source File
SOURCE=.\CClientProxy.cpp
# End Source File
# Begin Source File
SOURCE=.\CClientProxy1_0.cpp
# End Source File
# Begin Source File
SOURCE=.\CConfig.cpp SOURCE=.\CConfig.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -106,18 +114,14 @@ SOURCE=.\CMSWindowsPrimaryScreen.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\CPrimaryClient.cpp
# End Source File
# Begin Source File
SOURCE=.\CServer.cpp SOURCE=.\CServer.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\CServerProtocol.cpp
# End Source File
# Begin Source File
SOURCE=.\CServerProtocol1_0.cpp
# End Source File
# Begin Source File
SOURCE=.\server.cpp SOURCE=.\server.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -130,6 +134,14 @@ SOURCE=.\server.rc
# PROP Default_Filter "h;hpp;hxx;hm;inl" # PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File # Begin Source File
SOURCE=.\CClientProxy.h
# End Source File
# Begin Source File
SOURCE=.\CClientProxy1_0.h
# End Source File
# Begin Source File
SOURCE=.\CConfig.h SOURCE=.\CConfig.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -142,15 +154,15 @@ SOURCE=.\CMSWindowsPrimaryScreen.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\CPrimaryClient.h
# End Source File
# Begin Source File
SOURCE=.\CServer.h SOURCE=.\CServer.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\CServerProtocol.h SOURCE=.\IPrimaryScreen.h
# End Source File
# Begin Source File
SOURCE=.\CServerProtocol1_0.h
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -143,19 +143,27 @@ SOURCE=.\CTCPSocketFactory.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\IClient.h
# End Source File
# Begin Source File
SOURCE=.\IClipboard.h SOURCE=.\IClipboard.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\IPrimaryScreen.h SOURCE=.\IPrimaryScreenReceiver.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\ISecondaryScreen.h SOURCE=.\IScreenReceiver.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\IServerProtocol.h SOURCE=.\IScreenSaver.h
# End Source File
# Begin Source File
SOURCE=.\IServer.h
# End Source File # End Source File
# Begin Source File # Begin Source File