fixes, mainly for windows. first, had to add a notification from

CServer to the primary screen when the configuration changes so it
can make necessary adjustments (the win32 primary screen must tell
the hook dll about the new jump zones).

changed includes of some std c++ library files to go through
our own include files.  these wrap the include with stuff to
keep vc++ quiet when compiling at warning level 4, which is
what it does now.  it also works around missing <istream> and
<ostream> on g++2.96.

added missing std:: where necessary.  g++ doesn't really support
namespaces so it lets references without the namespace slip
through.

added workaround or fix.  not sure if istringstream::str(string)
should reset eofbit.  it does on g++ but does not on vc++.
added clear() after str() so it works either way.

added low-level keyboard hook to win32.  if available (it's only
available on NT SP3 and up) it allows us to catch and handle
alt+tab, alt+esc, ctrl+esc, and windows key hot keys.  i think
that leaves only ctrl+alt+del and accessibility functions
uncaught on those systems.
This commit is contained in:
crs 2002-06-01 19:26:11 +00:00
parent 1ac62a9533
commit d2135af0d9
46 changed files with 576 additions and 203 deletions

View File

@ -21,6 +21,11 @@ static const char* g_priority[] = {
}; };
static const int g_numPriority = (int)(sizeof(g_priority) / static const int g_numPriority = (int)(sizeof(g_priority) /
sizeof(g_priority[0])); sizeof(g_priority[0]));
#if defined(NDEBUG)
static const int g_defaultMaxPriority = 4;
#else
static const int g_defaultMaxPriority = 5;
#endif
static const int g_maxPriorityLength = 7; // length of longest string static const int g_maxPriorityLength = 7; // length of longest string
static const int g_prioritySuffixLength = 2; static const int g_prioritySuffixLength = 2;
static const int g_priorityPad = g_maxPriorityLength + static const int g_priorityPad = g_maxPriorityLength +
@ -145,11 +150,7 @@ int CLog::getMaxPriority()
CHoldLock lock(s_lock); CHoldLock lock(s_lock);
if (s_maxPriority == -1) { if (s_maxPriority == -1) {
#if defined(NDEBUG) s_maxPriority = g_defaultMaxPriority;
s_maxPriority = 4;
#else
s_maxPriority = 5;
#endif
const char* priEnv = getenv("SYN_LOG_PRI"); const char* priEnv = getenv("SYN_LOG_PRI");
if (priEnv != NULL) { if (priEnv != NULL) {
for (int i = 0; i < g_numPriority; ++i) { for (int i = 0; i < g_numPriority; ++i) {

View File

@ -37,11 +37,11 @@ public:
private: private:
class CHoldLock { class CHoldLock {
public: public:
CHoldLock(CLog::Lock lock) : m_lock(lock) { m_lock(true); } CHoldLock(Lock lock) : m_lock(lock) { m_lock(true); }
~CHoldLock() { m_lock(false); } ~CHoldLock() { m_lock(false); }
private: private:
CLog::Lock m_lock; Lock m_lock;
}; };
static void dummyLock(bool); static void dummyLock(bool);

View File

@ -2,7 +2,14 @@
#define CSTRING_H #define CSTRING_H
#include "common.h" #include "common.h"
#include "stdpre.h"
#include <string> #include <string>
#include "stdpost.h"
#if defined(_MSC_VER)
#pragma warning(push, 4)
#pragma warning(disable: 4097) // typedef-name used as synonym
#endif
#ifndef CSTRING_DEF_CTOR #ifndef CSTRING_DEF_CTOR
#define CSTRING_ALLOC1 #define CSTRING_ALLOC1
@ -37,5 +44,9 @@ public:
_Myt(_f, _l CSTRING_ALLOC2) { } _Myt(_f, _l CSTRING_ALLOC2) { }
}; };
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif #endif

View File

@ -2,7 +2,9 @@
#define XBASE_H #define XBASE_H
#include "CString.h" #include "CString.h"
#include "stdpre.h"
#include <exception> #include <exception>
#include "stdpost.h"
class XBase : public std::exception { class XBase : public std::exception {
public: public:

View File

@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release" # PROP Intermediate_Dir "Release"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # ADD CPP /nologo /MT /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
@ -65,7 +65,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Debug" # PROP Intermediate_Dir "Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"
@ -139,6 +139,46 @@ SOURCE=.\IJob.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\stdfstream.h
# End Source File
# Begin Source File
SOURCE=.\stdistream.h
# End Source File
# Begin Source File
SOURCE=.\stdlist.h
# End Source File
# Begin Source File
SOURCE=.\stdmap.h
# End Source File
# Begin Source File
SOURCE=.\stdostream.h
# End Source File
# Begin Source File
SOURCE=.\stdpost.h
# End Source File
# Begin Source File
SOURCE=.\stdpre.h
# End Source File
# Begin Source File
SOURCE=.\stdset.h
# End Source File
# Begin Source File
SOURCE=.\stdsstream.h
# End Source File
# Begin Source File
SOURCE=.\stdvector.h
# End Source File
# Begin Source File
SOURCE=.\TMethodJob.h SOURCE=.\TMethodJob.h
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -25,17 +25,8 @@
// turn off bonehead warnings // turn off bonehead warnings
#pragma warning(disable: 4786) // identifier truncated in debug info #pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4514) // unreferenced inline function removed
//
// ignore warnings inside microsoft's standard C++ library
//
// bonehead bugs/warnings
#pragma warning(disable: 4097) // typedef-name used as synonym
#pragma warning(disable: 4511) // copy constructor can't be generated
#pragma warning(disable: 4512) // assignment operator can't be generated
// we'd really rather have these enabled to check our code
#pragma warning(disable: 4100) // unreferenced formal parameter
#endif // (_MSC_VER >= 1200) #endif // (_MSC_VER >= 1200)
#else #else

4
base/stdfstream.h Normal file
View File

@ -0,0 +1,4 @@
#include "stdpre.h"
#include <fstream>
#include "stdpost.h"
#include "stdistream.h"

28
base/stdistream.h Normal file
View File

@ -0,0 +1,28 @@
#include "stdpre.h"
#if !defined(CONFIG_PLATFORM_LINUX)
#include <istream>
#else
#include <iostream>
#endif
#include "stdpost.h"
#if defined(CONFIG_PLATFORM_WIN32) && defined(_MSC_VER)
inline
std::istream& operator>>(std::istream& s, SInt8& i)
{ return s >> (signed char&)i; }
inline
std::istream& operator>>(std::istream& s, SInt16& i)
{ return s >> (short&)i; }
inline
std::istream& operator>>(std::istream& s, SInt32& i)
{ return s >> (int&)i; }
inline
std::istream& operator>>(std::istream& s, UInt8& i)
{ return s >> (unsigned char&)i; }
inline
std::istream& operator>>(std::istream& s, UInt16& i)
{ return s >> (unsigned short&)i; }
inline
std::istream& operator>>(std::istream& s, UInt32& i)
{ return s >> (unsigned int&)i; }
#endif

3
base/stdlist.h Normal file
View File

@ -0,0 +1,3 @@
#include "stdpre.h"
#include <list>
#include "stdpost.h"

3
base/stdmap.h Normal file
View File

@ -0,0 +1,3 @@
#include "stdpre.h"
#include <map>
#include "stdpost.h"

7
base/stdostream.h Normal file
View File

@ -0,0 +1,7 @@
#include "stdpre.h"
#if !defined(CONFIG_PLATFORM_LINUX)
#include <ostream>
#else
#include <iostream>
#endif
#include "stdpost.h"

3
base/stdpost.h Normal file
View File

@ -0,0 +1,3 @@
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

11
base/stdpre.h Normal file
View File

@ -0,0 +1,11 @@
#if defined(_MSC_VER)
#pragma warning(disable: 4786) // identifier truncated
#pragma warning(disable: 4514) // unreferenced inline
#pragma warning(disable: 4710) // not inlined
#pragma warning(disable: 4663) // C++ change, template specialization
#pragma warning(push, 3)
#pragma warning(disable: 4018) // signed/unsigned mismatch
#pragma warning(disable: 4284)
#pragma warning(disable: 4146) // unary minus on unsigned value
#pragma warning(disable: 4127) // conditional expression is constant
#endif

3
base/stdset.h Normal file
View File

@ -0,0 +1,3 @@
#include "stdpre.h"
#include <set>
#include "stdpost.h"

4
base/stdsstream.h Normal file
View File

@ -0,0 +1,4 @@
#include "stdpre.h"
#include <sstream>
#include "stdpost.h"
#include "stdistream.h"

3
base/stdvector.h Normal file
View File

@ -0,0 +1,3 @@
#include "stdpre.h"
#include <vector>
#include "stdpost.h"

View File

@ -3,8 +3,8 @@
#include "CMSWindowsScreen.h" #include "CMSWindowsScreen.h"
#include "ISecondaryScreen.h" #include "ISecondaryScreen.h"
#include <map> #include "stdmap.h"
#include <vector> #include "stdvector.h"
class CMSWindowsSecondaryScreen : public CMSWindowsScreen, public ISecondaryScreen { class CMSWindowsSecondaryScreen : public CMSWindowsScreen, public ISecondaryScreen {
public: public:

View File

@ -3,8 +3,8 @@
#include "CXWindowsScreen.h" #include "CXWindowsScreen.h"
#include "ISecondaryScreen.h" #include "ISecondaryScreen.h"
#include <map> #include "stdmap.h"
#include <vector> #include "stdvector.h"
class CXWindowsSecondaryScreen : public CXWindowsScreen, public ISecondaryScreen { class CXWindowsSecondaryScreen : public CXWindowsScreen, public ISecondaryScreen {
public: public:

View File

@ -5,6 +5,7 @@
#include "CNetwork.h" #include "CNetwork.h"
#include "CNetworkAddress.h" #include "CNetworkAddress.h"
#include "CThread.h" #include "CThread.h"
#include <assert.h>
// //
// logging thread safety // logging thread safety

View File

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release" # PROP Intermediate_Dir "Release"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c # ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -68,7 +68,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug" # PROP Intermediate_Dir "Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32

View File

@ -3,11 +3,12 @@
#include "XHTTP.h" #include "XHTTP.h"
#include "IInputStream.h" #include "IInputStream.h"
#include "IOutputStream.h" #include "IOutputStream.h"
#include "stdsstream.h"
#include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <locale.h> #include <locale.h>
#include <time.h> #include <time.h>
#include <algorithm> #include <algorithm>
#include <sstream>
// //
// CHTTPUtil::CaselessCmp // CHTTPUtil::CaselessCmp
@ -88,6 +89,7 @@ CHTTPRequest* CHTTPProtocol::readRequest(IInputStream* stream)
// parse version // parse version
char dot; char dot;
s.str(version); s.str(version);
s.clear();
s.ignore(5); s.ignore(5);
s >> request->m_majorVersion; s >> request->m_majorVersion;
s.get(dot); s.get(dot);
@ -229,7 +231,7 @@ void CHTTPProtocol::reply(
} }
// write reply header // write reply header
ostringstream s; std::ostringstream s;
s << "HTTP/" << reply.m_majorVersion << "." << s << "HTTP/" << reply.m_majorVersion << "." <<
reply.m_minorVersion << " " << reply.m_minorVersion << " " <<
reply.m_status << " " << reply.m_status << " " <<

View File

@ -3,8 +3,8 @@
#include "BasicTypes.h" #include "BasicTypes.h"
#include "CString.h" #include "CString.h"
#include <map> #include "stdmap.h"
#include <vector> #include "stdvector.h"
class IInputStream; class IInputStream;
class IOutputStream; class IOutputStream;

View File

@ -1,6 +1,6 @@
#include "XHTTP.h" #include "XHTTP.h"
#include "CHTTPProtocol.h" #include "CHTTPProtocol.h"
#include <stdio.h> #include "stdsstream.h"
// //
// XHTTP // XHTTP
@ -45,16 +45,15 @@ void XHTTP::addHeaders(CHTTPReply&) const
CString XHTTP::getWhat() const throw() CString XHTTP::getWhat() const throw()
{ {
try { try {
char code[20]; std::ostringstream s;
sprintf(code, "%d ", m_status); s << m_status << " ";
CString msg(code);
if (!m_reason.empty()) { if (!m_reason.empty()) {
msg += m_reason; s << m_reason.c_str();
} }
else { else {
msg += getReason(m_status); s << getReason(m_status);
} }
return msg; return s.str();
} }
catch (...) { catch (...) {
return CString(); return CString();

110
http/http.dsp Executable file
View File

@ -0,0 +1,110 @@
# Microsoft Developer Studio Project File - Name="http" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=http - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "http.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "http.mak" CFG="http - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "http - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "http - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "millpond"
# PROP Scc_LocalPath "."
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "http - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\io" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "http - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "http - Win32 Release"
# Name "http - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\CHTTPProtocol.cpp
# End Source File
# Begin Source File
SOURCE=.\XHTTP.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\CHTTPProtocol.h
# End Source File
# Begin Source File
SOURCE=.\XHTTP.h
# End Source File
# End Group
# End Target
# End Project

View File

@ -2,8 +2,8 @@
#define CSTREAMBUFFER_H #define CSTREAMBUFFER_H
#include "BasicTypes.h" #include "BasicTypes.h"
#include <list> #include "stdlist.h"
#include <vector> #include "stdvector.h"
class CStreamBuffer { class CStreamBuffer {
public: public:

View File

@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release" # PROP Intermediate_Dir "Release"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /I "..\mt" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\mt" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
@ -65,7 +65,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Debug" # PROP Intermediate_Dir "Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /I "..\mt" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\mt" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"

View File

@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release" # PROP Intermediate_Dir "Release"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
@ -65,7 +65,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Debug" # PROP Intermediate_Dir "Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"

View File

@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release" # PROP Intermediate_Dir "Release"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
@ -65,7 +65,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Debug" # PROP Intermediate_Dir "Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"

View File

@ -1,12 +1,7 @@
#include "CConfig.h" #include "CConfig.h"
#include "stdistream.h"
#include "stdostream.h"
#include <assert.h> #include <assert.h>
// FIXME -- fix this with automake and config.h
#if !defined(CONFIG_PLATFORM_LINUX)
#include <istream>
#include <ostream>
#else
#include <iostream>
#endif
// //
// CConfig // CConfig
@ -160,10 +155,10 @@ const char* CConfig::dirName(EDirection dir)
return s_name[dir - kFirstDirection]; return s_name[dir - kFirstDirection];
} }
bool CConfig::readLine(istream& s, CString& line) bool CConfig::readLine(std::istream& s, CString& line)
{ {
s >> std::ws; s >> std::ws;
while (getline(s, line)) { while (std::getline(s, line)) {
// strip comments and then trailing whitespace // strip comments and then trailing whitespace
CString::size_type i = line.rfind('#'); CString::size_type i = line.rfind('#');
if (i != CString::npos) { if (i != CString::npos) {
@ -183,7 +178,7 @@ bool CConfig::readLine(istream& s, CString& line)
return false; return false;
} }
void CConfig::readSection(istream& s) void CConfig::readSection(std::istream& s)
{ {
static const char s_section[] = "section:"; static const char s_section[] = "section:";
static const char s_screens[] = "screens"; static const char s_screens[] = "screens";
@ -223,7 +218,7 @@ void CConfig::readSection(istream& s)
} }
} }
void CConfig::readSectionScreens(istream& s) void CConfig::readSectionScreens(std::istream& s)
{ {
CString line; CString line;
CString name; CString name;
@ -256,7 +251,7 @@ void CConfig::readSectionScreens(istream& s)
throw XConfigRead("unexpected end of screens section"); throw XConfigRead("unexpected end of screens section");
} }
void CConfig::readSectionLinks(istream& s) void CConfig::readSectionLinks(std::istream& s)
{ {
CString line; CString line;
CString screen; CString screen;
@ -338,7 +333,7 @@ void CConfig::readSectionLinks(istream& s)
// CConfig I/O // CConfig I/O
// //
istream& operator>>(istream& s, CConfig& config) std::istream& operator>>(std::istream& s, CConfig& config)
{ {
// FIXME -- should track line and column to improve error reporting // FIXME -- should track line and column to improve error reporting
@ -350,44 +345,44 @@ istream& operator>>(istream& s, CConfig& config)
return s; return s;
} }
ostream& operator<<(ostream& s, const CConfig& config) std::ostream& operator<<(std::ostream& s, const CConfig& config)
{ {
// screens section // screens section
s << "section: screens" << endl; s << "section: screens" << std::endl;
for (CConfig::const_iterator screen = config.begin(); for (CConfig::const_iterator screen = config.begin();
screen != config.end(); ++screen) { screen != config.end(); ++screen) {
s << "\t" << screen->c_str() << ":" << endl; s << "\t" << screen->c_str() << ":" << std::endl;
} }
s << "end" << endl; s << "end" << std::endl;
// links section // links section
CString neighbor; CString neighbor;
s << "section: links" << endl; s << "section: links" << std::endl;
for (CConfig::const_iterator screen = config.begin(); for (CConfig::const_iterator screen = config.begin();
screen != config.end(); ++screen) { screen != config.end(); ++screen) {
s << "\t" << screen->c_str() << ":" << endl; s << "\t" << screen->c_str() << ":" << std::endl;
neighbor = config.getNeighbor(*screen, CConfig::kLeft); neighbor = config.getNeighbor(*screen, CConfig::kLeft);
if (!neighbor.empty()) { if (!neighbor.empty()) {
s << "\t\tleft=" << neighbor.c_str() << endl; s << "\t\tleft=" << neighbor.c_str() << std::endl;
} }
neighbor = config.getNeighbor(*screen, CConfig::kRight); neighbor = config.getNeighbor(*screen, CConfig::kRight);
if (!neighbor.empty()) { if (!neighbor.empty()) {
s << "\t\tright=" << neighbor.c_str() << endl; s << "\t\tright=" << neighbor.c_str() << std::endl;
} }
neighbor = config.getNeighbor(*screen, CConfig::kTop); neighbor = config.getNeighbor(*screen, CConfig::kTop);
if (!neighbor.empty()) { if (!neighbor.empty()) {
s << "\t\tup=" << neighbor.c_str() << endl; s << "\t\tup=" << neighbor.c_str() << std::endl;
} }
neighbor = config.getNeighbor(*screen, CConfig::kBottom); neighbor = config.getNeighbor(*screen, CConfig::kBottom);
if (!neighbor.empty()) { if (!neighbor.empty()) {
s << "\t\tdown=" << neighbor.c_str() << endl; s << "\t\tdown=" << neighbor.c_str() << std::endl;
} }
} }
s << "end" << endl; s << "end" << std::endl;
return s; return s;
} }

View File

@ -5,7 +5,7 @@
#include "CString.h" #include "CString.h"
#include "XBase.h" #include "XBase.h"
#include <iosfwd> #include <iosfwd>
#include <map> #include "stdmap.h"
class CConfig; class CConfig;
@ -57,7 +57,7 @@ public:
} }
private: private:
CConfig::internal_const_iterator m_i; internal_const_iterator m_i;
}; };
CConfig(); CConfig();
@ -98,17 +98,17 @@ public:
// read/write a configuration. operator>> will throw XConfigRead // read/write a configuration. operator>> will throw XConfigRead
// on error. // on error.
friend istream& operator>>(istream&, CConfig&); friend std::istream& operator>>(std::istream&, CConfig&);
friend ostream& operator<<(ostream&, const CConfig&); friend std::ostream& operator<<(std::ostream&, const CConfig&);
// get the name of a direction (for debugging) // get the name of a direction (for debugging)
static const char* dirName(EDirection); static const char* dirName(EDirection);
private: private:
static bool readLine(istream&, CString&); static bool readLine(std::istream&, CString&);
void readSection(istream&); void readSection(std::istream&);
void readSectionScreens(istream&); void readSectionScreens(std::istream&);
void readSectionLinks(istream&); void readSectionLinks(std::istream&);
private: private:
CCellMap m_map; CCellMap m_map;

View File

@ -6,8 +6,9 @@
#include "CLog.h" #include "CLog.h"
#include "XThread.h" #include "XThread.h"
#include "ISocket.h" #include "ISocket.h"
#include <set> #include "stdset.h"
#include <sstream> #include "stdsstream.h"
#include <assert.h>
// //
// CHTTPServer // CHTTPServer
@ -158,7 +159,7 @@ void CHTTPServer::doProcessGetEditMap(
static const char* s_editMapScreenEnd = static const char* s_editMapScreenEnd =
"</td>\r\n"; "</td>\r\n";
ostringstream s; std::ostringstream s;
// convert screen map into a temporary screen map // convert screen map into a temporary screen map
CScreenArray screens; CScreenArray screens;
@ -236,7 +237,7 @@ void CHTTPServer::doProcessPostEditMap(
} }
try { try {
ostringstream s; std::ostringstream s;
// convert post data into a temporary screen map. also check // convert post data into a temporary screen map. also check
// that no screen name is invalid or used more than once. // that no screen name is invalid or used more than once.
@ -309,7 +310,7 @@ void CHTTPServer::doProcessPostEditMap(
// now reply with current map // now reply with current map
doProcessGetEditMap(request, reply); doProcessGetEditMap(request, reply);
} }
catch (XHTTP& e) { catch (XHTTP&) {
// FIXME -- construct a more meaningful error? // FIXME -- construct a more meaningful error?
throw; throw;
} }
@ -318,7 +319,7 @@ void CHTTPServer::doProcessPostEditMap(
bool CHTTPServer::parseXY( bool CHTTPServer::parseXY(
const CString& xy, SInt32& x, SInt32& y) const CString& xy, SInt32& x, SInt32& y)
{ {
istringstream s(xy); std::istringstream s(xy);
char delimiter; char delimiter;
s >> x; s >> x;
s.get(delimiter); s.get(delimiter);
@ -326,65 +327,10 @@ bool CHTTPServer::parseXY(
return (!!s && delimiter == 'x'); return (!!s && delimiter == 'x');
} }
/*
#include <iostream> // FIXME
// FIXME
cout << "method: " << request.m_method << endl;
cout << "uri: " << request.m_uri << endl;
cout << "version: " << request.m_majorVersion << "." <<
request.m_majorVersion << endl;
cout << "headers:" << endl; //
for (CHTTPRequest::CHeaderMap::const_iterator // CHTTPServer::CScreenArray
index = request.m_headerIndexByName.begin(); //
index != request.m_headerIndexByName.end();
++index) {
assert(index->second < request.m_headers.size());
cout << " " << index->first << ": " <<
request.m_headers[index->second] << endl;
}
cout << endl;
cout << request.m_body << endl;
// FIXME
reply.m_majorVersion = request.m_majorVersion;
reply.m_minorVersion = request.m_minorVersion;
reply.m_status = 200;
reply.m_reason = "OK";
reply.m_method = request.m_method;
reply.m_headers.push_back(std::make_pair(CString("Content-Type"),
CString("text/html")));
if (request.m_uri != "/bar") {
reply.m_body =
"<html>\r\n"
" <head>\r\n"
" <title>test</title>\r\n"
" </head>\r\n"
" <body>\r\n"
" <h2>test</h2>\r\n"
" <form method=POST action=\"bar\" enctype=\"multipart/form-data\">\r\n"
" <input type=text name=a size=8 maxlength=40 value=\"aValue\">\r\n"
" <input type=submit name=b value=\"blah\">\r\n"
" </form>\r\n"
" </body>\r\n"
"</html>\r\n"
;
}
else {
reply.m_body =
"<html>\r\n"
" <head>\r\n"
" <title>test reply</title>\r\n"
" </head>\r\n"
" <body>\r\n"
" <h2>test reply</h2>\r\n"
" </body>\r\n"
"</html>\r\n"
;
}
// FIXME
*/
CHTTPServer::CScreenArray::CScreenArray() : m_w(0), m_h(0) CHTTPServer::CScreenArray::CScreenArray() : m_w(0), m_h(0)
{ {

View File

@ -3,7 +3,7 @@
#include "BasicTypes.h" #include "BasicTypes.h"
#include "CString.h" #include "CString.h"
#include <vector> #include "stdvector.h"
class CServer; class CServer;
class CConfig; class CConfig;

View File

@ -22,7 +22,13 @@ CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen() :
m_mark(0), m_mark(0),
m_markReceived(0) m_markReceived(0)
{ {
// do nothing // detect operating system
OSVERSIONINFO version;
version.dwOSVersionInfoSize = sizeof(version);
if (GetVersionEx(&version) == 0) {
log((CLOG_WARN "cannot determine OS: %d", GetLastError()));
}
m_is95Family = (version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
} }
CMSWindowsPrimaryScreen::~CMSWindowsPrimaryScreen() CMSWindowsPrimaryScreen::~CMSWindowsPrimaryScreen()
@ -97,7 +103,19 @@ void CMSWindowsPrimaryScreen::doEnter()
// not active anymore // not active anymore
m_active = false; m_active = false;
// set the zones that should cause a jump // release keyboard/mouse and set the zones that should cause a jump
/* FIXME
if (UnregisterHotKey(m_window, 0x0001) != 0) {
log((CLOG_INFO "released hot key"));
}
else {
log((CLOG_INFO "failed to release hot key: %d", GetLastError()));
}
*/
if (m_is95Family) {
DWORD dummy = 0;
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &dummy, 0);
}
SInt32 w, h; SInt32 w, h;
getScreenSize(&w, &h); getScreenSize(&w, &h);
SetZoneFunc setZone = (SetZoneFunc)GetProcAddress( SetZoneFunc setZone = (SetZoneFunc)GetProcAddress(
@ -159,6 +177,19 @@ void CMSWindowsPrimaryScreen::leave()
SetRelayFunc setRelay = (SetRelayFunc)GetProcAddress( SetRelayFunc setRelay = (SetRelayFunc)GetProcAddress(
m_hookLibrary, "setRelay"); m_hookLibrary, "setRelay");
setRelay(); setRelay();
if (m_is95Family) {
// disable ctrl+alt+del, alt+tab, ctrl+esc
DWORD dummy = 0;
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &dummy, 0);
}
/* FIXME
if (RegisterHotKey(m_window, 0x0001, MOD_ALT, VK_TAB) != 0) {
log((CLOG_INFO "got hot key"));
}
else {
log((CLOG_INFO "failed to get hot key: %d", GetLastError()));
}
*/
// get keyboard input and capture mouse // get keyboard input and capture mouse
SetActiveWindow(m_window); SetActiveWindow(m_window);
@ -203,6 +234,17 @@ void CMSWindowsPrimaryScreen::leave()
} }
} }
void CMSWindowsPrimaryScreen::onConfigure()
{
if (!m_active) {
SInt32 w, h;
getScreenSize(&w, &h);
SetZoneFunc setZone = (SetZoneFunc)GetProcAddress(
m_hookLibrary, "setZone");
setZone(m_server->getActivePrimarySides(), w, h, getJumpZoneSize());
}
}
void CMSWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y) void CMSWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y)
{ {
// set the cursor position without generating an event // set the cursor position without generating an event
@ -479,7 +521,12 @@ LRESULT CMSWindowsPrimaryScreen::onEvent(
WPARAM wParam, LPARAM lParam) WPARAM wParam, LPARAM lParam)
{ {
switch (msg) { switch (msg) {
// FIXME -- handle display changes (and resize full-screen window) /*
case WM_HOTKEY:
log((CLOG_INFO "hot key: %d, %d, %s %s %s", wParam, HIWORD(lParam), (LOWORD(lParam) & MOD_ALT) ? "ALT" : "", (LOWORD(lParam) & MOD_CONTROL) ? "CTRL" : "", (LOWORD(lParam) & MOD_SHIFT) ? "SHIFT" : "", (LOWORD(lParam) & MOD_WIN) ? "WIN" : ""));
return 0;
*/
case WM_PAINT: case WM_PAINT:
ValidateRect(hwnd, NULL); ValidateRect(hwnd, NULL);
return 0; return 0;

View File

@ -20,6 +20,7 @@ public:
virtual void close(); virtual void close();
virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute); virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute);
virtual void leave(); virtual void leave();
virtual void onConfigure();
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);
@ -49,6 +50,7 @@ private:
private: private:
CServer* m_server; CServer* m_server;
bool m_is95Family;
bool m_active; bool m_active;
HWND m_window; HWND m_window;
HWND m_nextClipboardWindow; HWND m_nextClipboardWindow;

View File

@ -151,6 +151,11 @@ bool CServer::setConfig(const CConfig& config)
// cut over // cut over
m_config = config; m_config = config;
// tell primary screen about reconfiguration
if (m_primary != NULL) {
m_primary->onConfigure();
}
} }
// wait for old secondary screen threads to disconnect. must // wait for old secondary screen threads to disconnect. must

View File

@ -10,8 +10,8 @@
#include "CString.h" #include "CString.h"
#include "CThread.h" #include "CThread.h"
#include "XBase.h" #include "XBase.h"
#include <list> #include "stdlist.h"
#include <map> #include "stdmap.h"
class CThread; class CThread;
class IServerProtocol; class IServerProtocol;

View File

@ -42,6 +42,10 @@ static HHOOK g_keyboard = NULL;
static HHOOK g_mouse = NULL; static HHOOK g_mouse = NULL;
static HHOOK g_cbt = NULL; static HHOOK g_cbt = NULL;
static HHOOK g_getMessage = NULL; static HHOOK g_getMessage = NULL;
static HANDLE g_keyHookThread = NULL;
static DWORD g_keyHookThreadID = 0;
static HANDLE g_keyHookEvent = NULL;
static HHOOK g_keyboardLL = NULL;
static bool g_relay = false; static bool g_relay = false;
static SInt32 g_zoneSize = 0; static SInt32 g_zoneSize = 0;
static UInt32 g_zoneSides = 0; static UInt32 g_zoneSides = 0;
@ -103,7 +107,9 @@ static LRESULT CALLBACK keyboardHook(int code, WPARAM wParam, LPARAM lParam)
case VK_CAPITAL: case VK_CAPITAL:
case VK_NUMLOCK: case VK_NUMLOCK:
case VK_SCROLL: case VK_SCROLL:
// pass event // pass event on. we want to let these through to
// the window proc because otherwise the keyboard
// lights may not stay synchronized.
break; break;
default: default:
@ -250,6 +256,119 @@ static LRESULT CALLBACK getMessageHook(int code, WPARAM wParam, LPARAM lParam)
return CallNextHookEx(g_getMessage, code, wParam, lParam); return CallNextHookEx(g_getMessage, code, wParam, lParam);
} }
#if (_WIN32_WINNT >= 0x0400)
//
// low-level keyboard hook -- this allows us to capture and handle
// alt+tab, alt+esc, ctrl+esc, and windows key hot keys. on the down
// side, key repeats are not compressed for us.
//
static LRESULT CALLBACK keyboardLLHook(int code, WPARAM wParam, LPARAM lParam)
{
if (code >= 0) {
if (g_relay) {
KBDLLHOOKSTRUCT* info = reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam);
// let certain keys pass through
switch (info->vkCode) {
case VK_CAPITAL:
case VK_NUMLOCK:
case VK_SCROLL:
// pass event on. we want to let these through to
// the window proc because otherwise the keyboard
// lights may not stay synchronized.
break;
default:
// construct lParam for WM_KEYDOWN, etc.
DWORD lParam = 1; // repeat code
lParam |= (info->scanCode << 16); // scan code
if (info->flags & LLKHF_EXTENDED) {
lParam |= (1lu << 24); // extended key
}
if (info->flags & LLKHF_ALTDOWN) {
lParam |= (1lu << 29); // context code
}
if (info->flags & LLKHF_UP) {
lParam |= (1lu << 31); // transition
}
// FIXME -- bit 30 should be set if key was already down
// forward message to our window
PostMessage(g_hwnd, SYNERGY_MSG_KEY, info->vkCode, lParam);
// discard event
return 1;
}
}
}
return CallNextHookEx(g_keyboardLL, code, wParam, lParam);
}
static DWORD WINAPI getKeyboardLLProc(void*)
{
// thread proc for low-level keyboard hook. this does nothing but
// install the hook, process events, and uninstall the hook.
// force this thread to have a message queue
MSG msg;
PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
// install low-level keyboard hook
g_keyboardLL = SetWindowsHookEx(WH_KEYBOARD_LL,
&keyboardLLHook,
g_hinstance,
0);
if (g_keyboardLL == NULL) {
// indicate failure and exit
g_keyHookThreadID = 0;
SetEvent(g_keyHookEvent);
return 1;
}
// ready
SetEvent(g_keyHookEvent);
// message loop
bool done = false;
while (!done) {
switch (GetMessage(&msg, NULL, 0, 0)) {
case -1:
break;
case 0:
done = true;
break;
default:
TranslateMessage(&msg);
DispatchMessage(&msg);
break;
}
}
// uninstall hook
UnhookWindowsHookEx(g_keyboardLL);
g_keyboardLL = NULL;
return 0;
}
#else // (_WIN32_WINNT < 0x0400)
#error foo
static DWORD WINAPI getKeyboardLLProc(void*)
{
g_keyHookThreadID = 0;
SetEvent(g_keyHookEvent);
return 1;
}
#endif
static EWheelSupport GetWheelSupport() static EWheelSupport GetWheelSupport()
{ {
// get operating system // get operating system
@ -286,8 +405,8 @@ static EWheelSupport GetWheelSupport()
// assume modern. we don't do anything special in this case // assume modern. we don't do anything special in this case
// except respond to WM_MOUSEWHEEL messages. GetSystemMetrics() // except respond to WM_MOUSEWHEEL messages. GetSystemMetrics()
// can apparently return FALSE even if a mouse wheel is present // can apparently return FALSE even if a mouse wheel is present
// though i'm not sure exactly when it does that (but WinME does // though i'm not sure exactly when it does that (WinME returns
// for my logitech usb trackball). // FALSE for my logitech USB trackball).
return kWheelModern; return kWheelModern;
} }
@ -387,6 +506,34 @@ int install(HWND hwnd)
// ignore failure; we just won't get mouse wheel messages // ignore failure; we just won't get mouse wheel messages
} }
// install low-level keyboard hook, if possible. since this hook
// is called in the context of the installing thread and that
// thread must have a message loop but we don't want the caller's
// message loop to do the work, we'll fire up a separate thread
// just for the hook. note that low-level keyboard hooks are only
// available on windows NT SP3 and above.
g_keyHookEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (g_keyHookEvent != NULL) {
g_keyHookThread = CreateThread(NULL, 0, &getKeyboardLLProc, 0,
CREATE_SUSPENDED, &g_keyHookThreadID);
if (g_keyHookThread != NULL) {
// start the thread and wait for it to initialize
ResumeThread(g_keyHookThread);
WaitForSingleObject(g_keyHookEvent, INFINITE);
ResetEvent(g_keyHookEvent);
// the thread clears g_keyHookThreadID if it failed
if (g_keyHookThreadID == 0) {
CloseHandle(g_keyHookThread);
g_keyHookThread = NULL;
}
}
if (g_keyHookThread == NULL) {
CloseHandle(g_keyHookEvent);
g_keyHookEvent = NULL;
}
}
return 1; return 1;
} }
@ -397,6 +544,15 @@ int uninstall(void)
assert(g_cbt != NULL); assert(g_cbt != NULL);
// uninstall hooks // uninstall hooks
if (g_keyHookThread != NULL) {
PostThreadMessage(g_keyHookThreadID, WM_QUIT, 0, 0);
WaitForSingleObject(g_keyHookThread, INFINITE);
CloseHandle(g_keyHookEvent);
CloseHandle(g_keyHookThread);
g_keyHookEvent = NULL;
g_keyHookThread = NULL;
g_keyHookThreadID = 0;
}
UnhookWindowsHookEx(g_keyboard); UnhookWindowsHookEx(g_keyboard);
UnhookWindowsHookEx(g_mouse); UnhookWindowsHookEx(g_mouse);
UnhookWindowsHookEx(g_cbt); UnhookWindowsHookEx(g_cbt);

View File

@ -303,6 +303,11 @@ void CXWindowsPrimaryScreen::leave()
m_active = true; m_active = true;
} }
void CXWindowsPrimaryScreen::onConfigure()
{
// do nothing
}
void CXWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y) void CXWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y)
{ {
CDisplayLock display(this); CDisplayLock display(this);

View File

@ -18,6 +18,7 @@ public:
virtual void close(); virtual void close();
virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute); virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute);
virtual void leave(); virtual void leave();
virtual void onConfigure();
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

@ -4,7 +4,8 @@
#include "CMutex.h" #include "CMutex.h"
#include "CNetwork.h" #include "CNetwork.h"
#include "CThread.h" #include "CThread.h"
#include <fstream> #include "stdfstream.h"
#include <assert.h>
// //
// config file stuff // config file stuff
@ -54,7 +55,7 @@ void realMain()
CConfig config; CConfig config;
{ {
log((CLOG_DEBUG "opening configuration")); log((CLOG_DEBUG "opening configuration"));
ifstream configStream(s_configFileName); std::ifstream configStream(s_configFileName);
if (!configStream) { if (!configStream) {
throw XConfigRead("cannot open configuration"); throw XConfigRead("cannot open configuration");
} }

View File

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release" # PROP Intermediate_Dir "Release"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c # ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /I "..\http" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -68,7 +68,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug" # PROP Intermediate_Dir "Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /I "..\http" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@ -92,11 +92,15 @@ 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=.\CMSWindowsPrimaryScreen.cpp SOURCE=.\CConfig.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\CConfig.cpp SOURCE=.\CHTTPServer.cpp
# End Source File
# Begin Source File
SOURCE=.\CMSWindowsPrimaryScreen.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -124,11 +128,15 @@ 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=.\CMSWindowsPrimaryScreen.h SOURCE=.\CConfig.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\CConfig.h SOURCE=.\CHTTPServer.h
# End Source File
# Begin Source File
SOURCE=.\CMSWindowsPrimaryScreen.h
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "ReleaseHook" # PROP Intermediate_Dir "ReleaseHook"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /YX /FD /c # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /FD /c # ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /FD /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -68,7 +68,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "DebugHook" # PROP Intermediate_Dir "DebugHook"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /YX /FD /GZ /c # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /FD /GZ /c # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /FD /GZ /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@ -93,6 +93,7 @@ LINK32=link.exe
# Begin Source File # Begin Source File
SOURCE=.\CSynergyHook.cpp SOURCE=.\CSynergyHook.cpp
# ADD CPP /D _WIN32_WINNT=0x0400
# End Source File # End Source File
# End Group # End Group
# Begin Group "Header Files" # Begin Group "Header Files"

View File

@ -7,10 +7,6 @@ Project: "all"=.\all.dsp - Package Owner=<4>
Package=<5> Package=<5>
{{{ {{{
begin source code control
millpond
.
end source code control
}}} }}}
Package=<4> Package=<4>
@ -29,10 +25,6 @@ Project: "base"=.\base\base.dsp - Package Owner=<4>
Package=<5> Package=<5>
{{{ {{{
begin source code control
millpond
.\base
end source code control
}}} }}}
Package=<4> Package=<4>
@ -45,10 +37,6 @@ Project: "client"=.\client\client.dsp - Package Owner=<4>
Package=<5> Package=<5>
{{{ {{{
begin source code control
millpond
.\client
end source code control
}}} }}}
Package=<4> Package=<4>
@ -72,14 +60,22 @@ Package=<4>
############################################################################### ###############################################################################
Project: "http"=.\HTTP\http.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "io"=.\io\io.dsp - Package Owner=<4> Project: "io"=.\io\io.dsp - Package Owner=<4>
Package=<5> Package=<5>
{{{ {{{
begin source code control
millpond
.\io
end source code control
}}} }}}
Package=<4> Package=<4>
@ -92,10 +88,6 @@ Project: "makehook"=.\server\makehook.dsp - Package Owner=<4>
Package=<5> Package=<5>
{{{ {{{
begin source code control
millpond
.\server
end source code control
}}} }}}
Package=<4> Package=<4>
@ -111,10 +103,6 @@ Project: "mt"=.\mt\mt.dsp - Package Owner=<4>
Package=<5> Package=<5>
{{{ {{{
begin source code control
millpond
.\mt
end source code control
}}} }}}
Package=<4> Package=<4>
@ -127,10 +115,6 @@ Project: "net"=.\net\net.dsp - Package Owner=<4>
Package=<5> Package=<5>
{{{ {{{
begin source code control
millpond
.\net
end source code control
}}} }}}
Package=<4> Package=<4>
@ -143,10 +127,6 @@ Project: "server"=.\server\server.dsp - Package Owner=<4>
Package=<5> Package=<5>
{{{ {{{
begin source code control
millpond
.\server
end source code control
}}} }}}
Package=<4> Package=<4>
@ -169,6 +149,9 @@ Package=<4>
Begin Project Dependency Begin Project Dependency
Project_Dep_Name makehook Project_Dep_Name makehook
End Project Dependency End Project Dependency
Begin Project Dependency
Project_Dep_Name http
End Project Dependency
}}} }}}
############################################################################### ###############################################################################
@ -177,10 +160,6 @@ Project: "synergy"=.\synergy\synergy.dsp - Package Owner=<4>
Package=<5> Package=<5>
{{{ {{{
begin source code control
millpond
.\synergy
end source code control
}}} }}}
Package=<4> Package=<4>
@ -193,10 +172,6 @@ Project: "synrgyhk"=.\server\synrgyhk.dsp - Package Owner=<4>
Package=<5> Package=<5>
{{{ {{{
begin source code control
millpond
.\server
end source code control
}}} }}}
Package=<4> Package=<4>

View File

@ -4,9 +4,9 @@
#include "IClipboard.h" #include "IClipboard.h"
#include "ClipboardTypes.h" #include "ClipboardTypes.h"
#include "CString.h" #include "CString.h"
#include "stdmap.h"
#include "stdlist.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <map>
#include <list>
class CXWindowsClipboard : public IClipboard { class CXWindowsClipboard : public IClipboard {
public: public:

View File

@ -49,6 +49,11 @@ public:
// the cursor and grab exclusive access to the input devices. // the cursor and grab exclusive access to the input devices.
virtual void leave() = 0; virtual void leave() = 0;
// called when the configuration has changed. subclasses may need
// to adjust things (like the jump zones) after the configuration
// changes.
virtual void onConfigure() = 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

@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release" # PROP Intermediate_Dir "Release"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
@ -65,7 +65,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Debug" # PROP Intermediate_Dir "Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"