Changeset 2752
- Timestamp:
- Jul 29, 2006, 6:43:07 AM (19 years ago)
- Location:
- trunk/synergy
- Files:
-
- 18 added
- 5 edited
- 26 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/synergy/cmd/synergyc/CPMClientTaskBarReceiver.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "C OSXClientTaskBarReceiver.h"16 #include "CPMClientTaskBarReceiver.h" 16 17 #include "CArch.h" 17 18 18 19 // 19 // C OSXClientTaskBarReceiver20 // CPMClientTaskBarReceiver 20 21 // 21 22 22 C OSXClientTaskBarReceiver::COSXClientTaskBarReceiver(23 CPMClientTaskBarReceiver::CPMClientTaskBarReceiver( 23 24 const CBufferedLogOutputter*) 24 25 { … … 27 28 } 28 29 29 C OSXClientTaskBarReceiver::~COSXClientTaskBarReceiver()30 CPMClientTaskBarReceiver::~CPMClientTaskBarReceiver() 30 31 { 31 32 ARCH->removeReceiver(this); … … 33 34 34 35 void 35 C OSXClientTaskBarReceiver::showStatus()36 CPMClientTaskBarReceiver::showStatus() 36 37 { 37 38 // do nothing … … 39 40 40 41 void 41 C OSXClientTaskBarReceiver::runMenu(int, int)42 CPMClientTaskBarReceiver::runMenu(int, int) 42 43 { 43 44 // do nothing … … 45 46 46 47 void 47 C OSXClientTaskBarReceiver::primaryAction()48 CPMClientTaskBarReceiver::primaryAction() 48 49 { 49 50 // do nothing … … 51 52 52 53 const IArchTaskBarReceiver::Icon 53 C OSXClientTaskBarReceiver::getIcon() const54 CPMClientTaskBarReceiver::getIcon() const 54 55 { 55 56 return NULL; 56 57 } 58 -
trunk/synergy/cmd/synergyc/CPMClientTaskBarReceiver.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C OSXCLIENTTASKBARRECEIVER_H16 #define C OSXCLIENTTASKBARRECEIVER_H16 #ifndef CPMCLIENTTASKBARRECEIVER_H 17 #define CPMCLIENTTASKBARRECEIVER_H 17 18 18 19 #include "CClientTaskBarReceiver.h" … … 20 21 class CBufferedLogOutputter; 21 22 22 //! Implementation of CClientTaskBarReceiver for OS X23 class C OSXClientTaskBarReceiver : public CClientTaskBarReceiver {23 //! Implementation of CClientTaskBarReceiver for PM 24 class CPMClientTaskBarReceiver : public CClientTaskBarReceiver { 24 25 public: 25 C OSXClientTaskBarReceiver(const CBufferedLogOutputter*);26 virtual ~C OSXClientTaskBarReceiver();26 CPMClientTaskBarReceiver(const CBufferedLogOutputter*); 27 virtual ~CPMClientTaskBarReceiver(); 27 28 28 29 // IArchTaskBarReceiver overrides … … 34 35 35 36 #endif 37 -
trunk/synergy/cmd/synergyc/synergyc.cpp
r2749 r2752 49 49 #include "COSXScreen.h" 50 50 #include "COSXClientTaskBarReceiver.h" 51 #elif WINAPI_PM 52 #include "CPMScreen.h" 53 #include "CPMClientTaskBarReceiver.h" 51 54 #endif 52 55 … … 110 113 #elif WINAPI_CARBON 111 114 return new CScreen(new COSXScreen(false)); 115 #elif WINAPI_PM 116 return new CScreen(new CPMScreen(false)); 112 117 #endif 113 118 } … … 124 129 #elif WINAPI_CARBON 125 130 return new COSXClientTaskBarReceiver(logBuffer); 131 #elif WINAPI_PM 132 return new CPMClientTaskBarReceiver(logBuffer); 126 133 #endif 127 134 } -
trunk/synergy/cmd/synergys/CPMServerTaskBarReceiver.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "C OSXServerTaskBarReceiver.h"16 #include "CPMServerTaskBarReceiver.h" 16 17 #include "CArch.h" 17 18 18 19 // 19 // C OSXServerTaskBarReceiver20 // CPMServerTaskBarReceiver 20 21 // 21 22 22 C OSXServerTaskBarReceiver::COSXServerTaskBarReceiver(23 CPMServerTaskBarReceiver::CPMServerTaskBarReceiver( 23 24 const CBufferedLogOutputter*) 24 25 { … … 27 28 } 28 29 29 C OSXServerTaskBarReceiver::~COSXServerTaskBarReceiver()30 CPMServerTaskBarReceiver::~CPMServerTaskBarReceiver() 30 31 { 31 32 ARCH->removeReceiver(this); … … 33 34 34 35 void 35 C OSXServerTaskBarReceiver::showStatus()36 CPMServerTaskBarReceiver::showStatus() 36 37 { 37 38 // do nothing … … 39 40 40 41 void 41 C OSXServerTaskBarReceiver::runMenu(int, int)42 CPMServerTaskBarReceiver::runMenu(int, int) 42 43 { 43 44 // do nothing … … 45 46 46 47 void 47 C OSXServerTaskBarReceiver::primaryAction()48 CPMServerTaskBarReceiver::primaryAction() 48 49 { 49 50 // do nothing … … 51 52 52 53 const IArchTaskBarReceiver::Icon 53 C OSXServerTaskBarReceiver::getIcon() const54 CPMServerTaskBarReceiver::getIcon() const 54 55 { 55 56 return NULL; -
trunk/synergy/cmd/synergys/CPMServerTaskBarReceiver.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C OSXSERVERTASKBARRECEIVER_H16 #define C OSXSERVERTASKBARRECEIVER_H16 #ifndef CPMSERVERTASKBARRECEIVER_H 17 #define CPMSERVERTASKBARRECEIVER_H 17 18 18 19 #include "CServerTaskBarReceiver.h" … … 20 21 class CBufferedLogOutputter; 21 22 22 //! Implementation of CServerTaskBarReceiver for OS X23 class C OSXServerTaskBarReceiver : public CServerTaskBarReceiver {23 //! Implementation of CServerTaskBarReceiver for PM 24 class CPMServerTaskBarReceiver : public CServerTaskBarReceiver { 24 25 public: 25 C OSXServerTaskBarReceiver(const CBufferedLogOutputter*);26 virtual ~C OSXServerTaskBarReceiver();26 CPMServerTaskBarReceiver(const CBufferedLogOutputter*); 27 virtual ~CPMServerTaskBarReceiver(); 27 28 28 29 // IArchTaskBarReceiver overrides -
trunk/synergy/cmd/synergys/synergys.cpp
r2749 r2752 52 52 #include "COSXScreen.h" 53 53 #include "COSXServerTaskBarReceiver.h" 54 #elif WINAPI_PM 55 #include "CPMScreen.h" 56 #include "CPMServerTaskBarReceiver.h" 54 57 #endif 55 58 … … 127 130 #elif WINAPI_CARBON 128 131 return new CScreen(new COSXScreen(true)); 132 #elif WINAPI_PM 133 return new CScreen(new CPMScreen(true)); 129 134 #endif 130 135 } … … 141 146 #elif WINAPI_CARBON 142 147 return new COSXServerTaskBarReceiver(logBuffer); 148 #elif WINAPI_PM 149 return new CPMServerTaskBarReceiver(logBuffer); 143 150 #endif 144 151 } -
trunk/synergy/lib/arch/CArch.cpp
r2749 r2752 44 44 #elif SYSAPI_UNIX 45 45 # include "CArchConsoleUnix.h" 46 # include "CArchDaemonUnix.h" 46 # ifdef __OS2__ 47 # include "CArchDaemonNone.h" 48 # else 49 # include "CArchDaemonUnix.h" 50 # endif 47 51 # include "CArchFileUnix.h" 48 52 # include "CArchLogUnix.h" … … 54 58 # include "CArchStringUnix.h" 55 59 # include "CArchSystemUnix.h" 56 # include "CArchTaskBarXWindows.h" 60 # ifdef __OS2__ /// @todo isn't this really WINAPI? 61 # include "CArchTaskBarOS2.h" 62 # else 63 # include "CArchTaskBarXWindows.h" 64 # endif 57 65 # include "CArchTimeUnix.h" 58 66 #endif -
trunk/synergy/lib/arch/CArchMultithreadPosix.h
r2749 r2752 15 15 #ifndef CARCHMULTITHREADPOSIX_H 16 16 #define CARCHMULTITHREADPOSIX_H 17 18 #ifdef __OS2__ 19 20 #include "CArchMultithreadOS2.h" 21 22 #else /* !__OS2__ */ 17 23 18 24 #include "IArchMultithread.h" … … 111 117 }; 112 118 119 #endif /* !__OS2__ */ 113 120 #endif -
trunk/synergy/lib/common/common.h
r2749 r2752 85 85 # define X_DISPLAY_MISSING 1 86 86 # endif 87 88 # if defined(__OS2__) 89 # define SYSAPI_UNIX 1 90 # define WINAPI_PM 1 91 92 # define HAVE_CXX_BOOL 1 93 # define HAVE_CXX_CASTS 1 94 # define HAVE_CXX_EXCEPTIONS 1 95 # define HAVE_CXX_MUTABLE 1 96 # define HAVE_CXX_STDLIB 1 97 //# define HAVE_GETPWUID_R 1 98 # define HAVE_GMTIME_R 1 99 # define HAVE_INET_ATON 1 100 # define HAVE_INTTYPES_H 1 101 # define HAVE_ISTREAM 1 102 # define HAVE_MEMORY_H 1 103 # define HAVE_NANOSLEEP 1 104 # define HAVE_OSTREAM 1 105 # define HAVE_POSIX_SIGWAIT 1 106 // we don't have pthreads, but we use the same header to reduce changes. 107 # define HAVE_PTHREAD 1 108 //# define HAVE_PTHREAD_SIGNAL 1 109 # include <sys/types.h> 110 # include <sys/socket.h> 111 //# if defined(_SOCKLEN_T) 112 //# define HAVE_SOCKLEN_T 1 113 //# endif 114 # define HAVE_SSTREAM 1 115 # define HAVE_STDINT_H 1 116 # define HAVE_STDLIB_H 1 117 # define HAVE_STRINGS_H 1 118 # define HAVE_STRING_H 1 119 # define HAVE_SYS_SELECT_H 1 120 # define HAVE_SYS_SOCKET_H 1 121 # define HAVE_SYS_STAT_H 1 122 # define HAVE_SYS_TIME_H 1 123 # define HAVE_SYS_TYPES_H 1 124 # define HAVE_SYS_UTSNAME_H 1 125 # define HAVE_UNISTD_H 1 126 # define HAVE_VSNPRINTF 1 127 # define HAVE_WCHAR_H 1 128 # define HAVE_LOCALE_H 1 129 130 # define SELECT_TYPE_ARG1 int 131 # define SELECT_TYPE_ARG234 (fd_set *) 132 # define SELECT_TYPE_ARG5 (struct timeval *) 133 # define SIZEOF_CHAR 1 134 # define SIZEOF_INT 4 135 # define SIZEOF_LONG 4 136 # define SIZEOF_SHORT 2 137 # define STDC_HEADERS 1 138 # define TIME_WITH_SYS_TIME 1 139 # define X_DISPLAY_MISSING 1 140 # endif /* __OS2__ */ 87 141 #endif 88 142 -
trunk/synergy/lib/platform/CPMClipboard.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2002 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "C MSWindowsClipboard.h"16 #include "C MSWindowsClipboardTextConverter.h"17 #include "C MSWindowsClipboardUTF16Converter.h"18 #include "C MSWindowsClipboardBitmapConverter.h"19 #include "C MSWindowsClipboardHTMLConverter.h"16 #include "CPMClipboard.h" 17 #include "CPMClipboardTextConverter.h" 18 #include "CPMClipboardBitmapConverter.h" 19 #include "CPMClipboardHTMLConverter.h" 20 #include "CPMUtil.h" 20 21 #include "CLog.h" 21 #include "CArchMiscWindows.h"22 22 23 23 // 24 // C MSWindowsClipboard24 // CPMClipboard 25 25 // 26 26 27 UINT CMSWindowsClipboard::s_ownershipFormat = 0;28 29 C MSWindowsClipboard::CMSWindowsClipboard(HWND window) :27 ATOM CPMClipboard::s_ownershipFormat = 0; 28 29 CPMClipboard::CPMClipboard(HWND window) : 30 30 m_window(window), 31 31 m_time(0) 32 32 { 33 33 // add converters, most desired first 34 m_converters.push_back(new CMSWindowsClipboardUTF16Converter); 35 if (CArchMiscWindows::isWindows95Family()) { 36 // windows nt family converts to/from unicode automatically. 37 // let it do so to avoid text encoding issues. 38 m_converters.push_back(new CMSWindowsClipboardTextConverter); 39 } 40 m_converters.push_back(new CMSWindowsClipboardBitmapConverter); 41 m_converters.push_back(new CMSWindowsClipboardHTMLConverter); 42 } 43 44 CMSWindowsClipboard::~CMSWindowsClipboard() 34 m_converters.push_back(new CPMClipboardTextConverter); 35 m_converters.push_back(new CPMClipboardBitmapConverter); 36 m_converters.push_back(new CPMClipboardHTMLConverter); 37 } 38 39 CPMClipboard::~CPMClipboard() 45 40 { 46 41 clearConverters(); … … 48 43 49 44 bool 50 C MSWindowsClipboard::emptyUnowned()45 CPMClipboard::emptyUnowned() 51 46 { 52 47 LOG((CLOG_DEBUG "empty clipboard")); 53 48 54 49 // empty the clipboard (and take ownership) 55 if (! EmptyClipboard()) {50 if (!WinEmptyClipbrd(CPMUtil::getHAB())) { 56 51 LOG((CLOG_DEBUG "failed to grab clipboard")); 57 52 return false; … … 62 57 63 58 bool 64 C MSWindowsClipboard::empty()59 CPMClipboard::empty() 65 60 { 66 61 if (!emptyUnowned()) { … … 69 64 70 65 // mark clipboard as being owned by synergy 71 HGLOBAL data = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, 1); 72 SetClipboardData(getOwnershipFormat(), data); 73 74 return true; 66 PVOID pv = NULL; 67 APIRET rc = DosAllocSharedMem(&pv, NULL, 1, PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_GETTABLE | OBJ_GIVEABLE); 68 if (rc) { 69 assert(rc); 70 return false; 71 } 72 return !!WinSetClipbrdData(CPMUtil::getHAB(), (ULONG)pv, getOwnershipFormat(), CFI_POINTER); 75 73 } 76 74 77 75 void 78 C MSWindowsClipboard::add(EFormat format, const CString& data)76 CPMClipboard::add(EFormat format, const CString& data) 79 77 { 80 78 LOG((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format)); … … 82 80 // convert data to win32 form 83 81 for (ConverterList::const_iterator index = m_converters.begin(); 84 index != m_converters.end(); ++index) { 85 IMSWindowsClipboardConverter* converter = *index; 82 index != m_converters.end(); 83 ++index) { 84 IPMClipboardConverter* converter = *index; 86 85 87 86 // skip converters for other formats 88 87 if (converter->getFormat() == format) { 89 HANDLE win32Data = converter->fromIClipboard(data);90 if ( win32Data != NULL) {91 U INT win32Format = converter->getWin32Format();92 if (SetClipboardData(win32Format, win32Data) == NULL) { 93 // free converted data if we couldn't put it on94 // the clipboard95 GlobalFree(win32Data);88 ULONG ulPMData = converter->fromIClipboard(data); 89 if (ulPMData != NULL) { 90 ULONG ulPMFormat = converter->getPMFormat(); 91 ULONG ulPMFormatInfo = converter->getPMFormatInfo(); 92 if (!WinSetClipbrdData(CPMUtil::getHAB(), ulPMData, ulPMFormat, ulPMFormatInfo)) { 93 // free converted data if we couldn't put it on the clipboard 94 converter->freePMData(ulPMData); 96 95 } 97 96 } … … 101 100 102 101 bool 103 C MSWindowsClipboard::open(Time time) const102 CPMClipboard::open(Time time) const 104 103 { 105 104 LOG((CLOG_DEBUG "open clipboard")); 106 105 107 if (! OpenClipboard(m_window)) {106 if (!WinOpenClipbrd(m_window)) { 108 107 LOG((CLOG_WARN "failed to open clipboard")); 109 108 return false; … … 116 115 117 116 void 118 C MSWindowsClipboard::close() const117 CPMClipboard::close() const 119 118 { 120 119 LOG((CLOG_DEBUG "close clipboard")); 121 CloseClipboard();120 WinCloseClipbrd(CPMUtil::getHAB()); 122 121 } 123 122 124 123 IClipboard::Time 125 C MSWindowsClipboard::getTime() const124 CPMClipboard::getTime() const 126 125 { 127 126 return m_time; … … 129 128 130 129 bool 131 C MSWindowsClipboard::has(EFormat format) const130 CPMClipboard::has(EFormat format) const 132 131 { 133 132 for (ConverterList::const_iterator index = m_converters.begin(); 134 index != m_converters.end(); ++index) { 135 IMSWindowsClipboardConverter* converter = *index; 133 index != m_converters.end(); 134 ++index) { 135 IPMClipboardConverter* converter = *index; 136 136 if (converter->getFormat() == format) { 137 if (IsClipboardFormatAvailable(converter->getWin32Format())) { 137 ULONG fFmtInfo; 138 if (WinQueryClipbrdFmtInfo(CPMUtil::getHAB(), getOwnershipFormat(), &fFmtInfo)) { 138 139 return true; 139 140 } … … 144 145 145 146 CString 146 C MSWindowsClipboard::get(EFormat format) const147 CPMClipboard::get(EFormat format) const 147 148 { 148 149 // find the converter for the first clipboard format we can handle 149 I MSWindowsClipboardConverter* converter = NULL;150 U INT win32Format = EnumClipboardFormats(0);151 while (converter == NULL && win32Format != 0) {150 IPMClipboardConverter* converter = NULL; 151 ULONG pmFormat = WinEnumClipbrdFmts(CPMUtil::getHAB(), 0); 152 while (converter == NULL && pmFormat != 0) { 152 153 for (ConverterList::const_iterator index = m_converters.begin(); 153 index != m_converters.end(); ++index) { 154 index != m_converters.end(); 155 ++index) { 154 156 converter = *index; 155 if (converter->get Win32Format() == win32Format &&156 converter->getFormat() 157 if (converter->getPMFormat() == pmFormat && 158 converter->getFormat() == format) { 157 159 break; 158 160 } 159 161 converter = NULL; 160 162 } 161 win32Format = EnumClipboardFormats(win32Format);163 pmFormat = WinEnumClipbrdFmts(CPMUtil::getHAB(), pmFormat); 162 164 } 163 165 … … 168 170 169 171 // get a handle to the clipboard data 170 HANDLE win32Data = GetClipboardData(converter->getWin32Format());171 if ( win32Data == NULL) {172 ULONG ulData = WinQueryClipbrdData(CPMUtil::getHAB(), converter->getPMFormat()); 173 if (ulData == 0) { 172 174 return CString(); 173 175 } 174 176 175 177 // convert 176 return converter->toIClipboard( win32Data);178 return converter->toIClipboard(ulData); 177 179 } 178 180 179 181 void 180 C MSWindowsClipboard::clearConverters()182 CPMClipboard::clearConverters() 181 183 { 182 184 for (ConverterList::iterator index = m_converters.begin(); 183 index != m_converters.end(); ++index) { 185 index != m_converters.end(); 186 ++index) { 184 187 delete *index; 185 188 } … … 188 191 189 192 bool 190 CMSWindowsClipboard::isOwnedBySynergy() 193 CPMClipboard::isOwnedBySynergy() 194 { 195 ULONG fFmtInfo; 196 return (!!WinQueryClipbrdFmtInfo(CPMUtil::getHAB(), getOwnershipFormat(), &fFmtInfo)); 197 } 198 199 ATOM 200 CPMClipboard::getOwnershipFormat() 191 201 { 192 202 // create ownership format if we haven't yet 193 203 if (s_ownershipFormat == 0) { 194 s_ownershipFormat = RegisterClipboardFormat(TEXT("SynergyOwnership")); 195 } 196 return (IsClipboardFormatAvailable(getOwnershipFormat()) != 0); 197 } 198 199 UINT 200 CMSWindowsClipboard::getOwnershipFormat() 201 { 202 // create ownership format if we haven't yet 203 if (s_ownershipFormat == 0) { 204 s_ownershipFormat = RegisterClipboardFormat(TEXT("SynergyOwnership")); 204 ATOM hAtom = WinAddAtom(WinQuerySystemAtomTable(), (PCSZ)"SynergyOwnership"); 205 if (hAtom == 0) 206 hAtom = WinFindAtom(WinQuerySystemAtomTable(), (PCSZ)"SynergyOwnership"); 207 assert(hAtom != 0); 208 s_ownershipFormat = hAtom; 205 209 } 206 210 -
trunk/synergy/lib/platform/CPMClipboard.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2002 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C MSWINDOWSCLIPBOARD_H16 #define C MSWINDOWSCLIPBOARD_H16 #ifndef CPMCLIPBOARD_H 17 #define CPMCLIPBOARD_H 17 18 18 19 #include "IClipboard.h" 19 20 #include "stdvector.h" 20 #define WIN32_LEAN_AND_MEAN 21 #include <windows.h> 21 #define INCL_ERRORS 22 #define INCL_BASE 23 #define INCL_PM 24 #include <os2.h> 22 25 23 class I MSWindowsClipboardConverter;26 class IPMClipboardConverter; 24 27 25 28 //! Microsoft windows clipboard implementation 26 class C MSWindowsClipboard : public IClipboard {29 class CPMClipboard : public IClipboard { 27 30 public: 28 C MSWindowsClipboard(HWND window);29 virtual ~C MSWindowsClipboard();31 CPMClipboard(HWND window); 32 virtual ~CPMClipboard(); 30 33 31 34 //! Empty clipboard without ownership … … 59 62 void clearConverters(); 60 63 61 U INT convertFormatToWin32(EFormat) const;62 HANDLE convertTextToWin32(const CString& data) const;63 CString convertTextFrom Win32(HANDLE) const;64 ULONG convertFormatToPM(EFormat) const; 65 ULONG convertTextToPM(const CString& data) const; 66 CString convertTextFromPM(ULONG) const; 64 67 65 static UINTgetOwnershipFormat();68 static ATOM getOwnershipFormat(); 66 69 67 70 private: 68 typedef std::vector<I MSWindowsClipboardConverter*> ConverterList;71 typedef std::vector<IPMClipboardConverter*> ConverterList; 69 72 70 73 HWND m_window; 71 74 mutable Time m_time; 72 75 ConverterList m_converters; 73 static UINTs_ownershipFormat;76 static ATOM s_ownershipFormat; 74 77 }; 75 78 … … 79 82 converters. 80 83 */ 81 class I MSWindowsClipboardConverter : public IInterface {84 class IPMClipboardConverter : public IInterface { 82 85 public: 83 86 // accessors … … 87 90 getFormat() const = 0; 88 91 89 // return the atom representing the win32clipboard format that92 // return the atom representing the PM clipboard format that 90 93 // this object converts from/to 91 virtual U INT getWin32Format() const = 0;94 virtual ULONG getPMFormat() const = 0; 92 95 93 // convert from the IClipboard format to the win32 clipboard format. 96 // return the format info flags for the PM clipboard format 97 // this object converts from/to 98 virtual ULONG getPMFormatInfo() const = 0; 99 100 // convert from the IClipboard format to the PM clipboard format. 94 101 // the input data must be in the IClipboard format returned by 95 // getFormat(). the return data will be in the win32 clipboard 96 // format returned by getWin32Format(), allocated by GlobalAlloc(). 97 virtual HANDLE fromIClipboard(const CString&) const = 0; 102 // getFormat(). the return data will be in the PM clipboard 103 // format returned by getPMFormat(). 104 virtual ULONG fromIClipboard(const CString&) const = 0; 105 106 // free PM clipboard data (failure case). 107 virtual void freePMData(ULONG) const = 0; 98 108 99 109 // convert from the win32 clipboard format to the IClipboard format 100 110 // (i.e., the reverse of fromIClipboard()). 101 virtual CString toIClipboard( HANDLEdata) const = 0;111 virtual CString toIClipboard(ULONG data) const = 0; 102 112 }; 103 113 -
trunk/synergy/lib/platform/CPMClipboardAnyTextConverter.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2002 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "C MSWindowsClipboardAnyTextConverter.h"16 #include "CPMClipboardAnyTextConverter.h" 16 17 17 18 // 18 // C MSWindowsClipboardAnyTextConverter19 // CPMClipboardAnyTextConverter 19 20 // 20 21 21 C MSWindowsClipboardAnyTextConverter::CMSWindowsClipboardAnyTextConverter()22 CPMClipboardAnyTextConverter::CPMClipboardAnyTextConverter() 22 23 { 23 24 // do nothing 24 25 } 25 26 26 C MSWindowsClipboardAnyTextConverter::~CMSWindowsClipboardAnyTextConverter()27 CPMClipboardAnyTextConverter::~CPMClipboardAnyTextConverter() 27 28 { 28 29 // do nothing … … 30 31 31 32 IClipboard::EFormat 32 C MSWindowsClipboardAnyTextConverter::getFormat() const33 CPMClipboardAnyTextConverter::getFormat() const 33 34 { 34 35 return IClipboard::kText; 35 36 } 37 ULONG 38 CPMClipboardAnyTextConverter::getPMFormatInfo() const 39 { 40 return CFI_POINTER; 41 } 36 42 37 HANDLE 38 C MSWindowsClipboardAnyTextConverter::fromIClipboard(const CString& data) const43 ULONG 44 CPMClipboardAnyTextConverter::fromIClipboard(const CString& data) const 39 45 { 40 46 // convert linefeeds and then convert to desired encoding 41 CString text = doFromIClipboard(convertLinefeedTo Win32(data));42 UInt32 size= text.size();47 CString text = doFromIClipboard(convertLinefeedToPM(data)); 48 UInt32 cb = text.size(); 43 49 44 50 // copy to memory handle 45 HGLOBAL gData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, size); 46 if (gData != NULL) { 47 // get a pointer to the allocated memory 48 char* dst = (char*)GlobalLock(gData); 49 if (dst != NULL) { 50 memcpy(dst, text.data(), size); 51 GlobalUnlock(gData); 52 } 53 else { 54 GlobalFree(gData); 55 gData = NULL; 56 } 57 } 51 PVOID pv = NULL; 52 APIRET rc = DosAllocSharedMem(&pv, NULL, cb, PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_GETTABLE | OBJ_GIVEABLE); 53 if (rc == NO_ERROR) { 54 return (ULONG)memcpy(pv, text.data(), cb); 55 } 56 return 0; 57 } 58 58 59 return gData; 59 void 60 CPMClipboardAnyTextConverter::freePMData(ULONG ulPMData) const 61 { 62 DosFreeMem((PVOID)ulPMData); 60 63 } 61 64 62 65 CString 63 C MSWindowsClipboardAnyTextConverter::toIClipboard(HANDLEdata) const66 CPMClipboardAnyTextConverter::toIClipboard(ULONG data) const 64 67 { 65 // get datator66 const char* src = (const char*)GlobalLock(data);67 UInt32 srcSize = (UInt32)GlobalSize(data);68 if (src == NULL || srcSize <= 1) {69 return CString();70 }71 72 68 // convert text 73 CString text = doToIClipboard(CString(src, srcSize)); 74 75 // release handle 76 GlobalUnlock(data); 69 const char *psz = (const char *)data; 70 CString text = doToIClipboard(CString(psz)); 77 71 78 72 // convert newlines … … 81 75 82 76 CString 83 CMSWindowsClipboardAnyTextConverter::convertLinefeedToWin32( 84 const CString& src) const 77 CPMClipboardAnyTextConverter::convertLinefeedToPM(const CString& src) const 85 78 { 86 79 // note -- we assume src is a valid UTF-8 string … … 115 108 116 109 CString 117 CMSWindowsClipboardAnyTextConverter::convertLinefeedToUnix( 118 const CString& src) const 110 CPMClipboardAnyTextConverter::convertLinefeedToUnix(const CString& src) const 119 111 { 120 112 // count newlines in string -
trunk/synergy/lib/platform/CPMClipboardAnyTextConverter.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2002 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C MSWINDOWSCLIPBOARDANYTEXTCONVERTER_H16 #define C MSWINDOWSCLIPBOARDANYTEXTCONVERTER_H16 #ifndef CPMCLIPBOARDANYTEXTCONVERTER_H 17 #define CPMCLIPBOARDANYTEXTCONVERTER_H 17 18 18 #include "C MSWindowsClipboard.h"19 #include "CPMClipboard.h" 19 20 20 21 //! Convert to/from some text encoding 21 class C MSWindowsClipboardAnyTextConverter :22 public I MSWindowsClipboardConverter {22 class CPMClipboardAnyTextConverter : 23 public IPMClipboardConverter { 23 24 public: 24 C MSWindowsClipboardAnyTextConverter();25 virtual ~C MSWindowsClipboardAnyTextConverter();25 CPMClipboardAnyTextConverter(); 26 virtual ~CPMClipboardAnyTextConverter(); 26 27 27 // I MSWindowsClipboardConverter overrides28 // IPMClipboardConverter overrides 28 29 virtual IClipboard::EFormat 29 30 getFormat() const; 30 virtual UINT getWin32Format() const = 0; 31 virtual HANDLE fromIClipboard(const CString&) const; 32 virtual CString toIClipboard(HANDLE) const; 31 virtual ULONG getPMFormat() const = 0; 32 virtual ULONG getPMFormatInfo() const; 33 virtual ULONG fromIClipboard(const CString&) const; 34 virtual void freePMData(ULONG) const; 35 virtual CString toIClipboard(ULONG) const; 33 36 34 37 protected: … … 50 53 51 54 private: 52 CString convertLinefeedTo Win32(const CString&) const;55 CString convertLinefeedToPM(const CString&) const; 53 56 CString convertLinefeedToUnix(const CString&) const; 54 57 }; -
trunk/synergy/lib/platform/CPMClipboardBitmapConverter.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "C MSWindowsClipboardBitmapConverter.h"16 #include "CPMClipboardBitmapConverter.h" 16 17 #include "CLog.h" 17 18 18 19 // 19 // C MSWindowsClipboardBitmapConverter20 // CPMClipboardBitmapConverter 20 21 // 21 22 22 C MSWindowsClipboardBitmapConverter::CMSWindowsClipboardBitmapConverter()23 CPMClipboardBitmapConverter::CPMClipboardBitmapConverter() 23 24 { 24 25 // do nothing 25 26 } 26 27 27 C MSWindowsClipboardBitmapConverter::~CMSWindowsClipboardBitmapConverter()28 CPMClipboardBitmapConverter::~CPMClipboardBitmapConverter() 28 29 { 29 30 // do nothing … … 31 32 32 33 IClipboard::EFormat 33 C MSWindowsClipboardBitmapConverter::getFormat() const34 CPMClipboardBitmapConverter::getFormat() const 34 35 { 35 36 return IClipboard::kBitmap; 36 37 } 37 38 38 U INT39 C MSWindowsClipboardBitmapConverter::getWin32Format() const39 ULONG 40 CPMClipboardBitmapConverter::getPMFormat() const 40 41 { 41 return CF_ DIB;42 return CF_BITMAP; 42 43 } 43 44 44 HANDLE 45 C MSWindowsClipboardBitmapConverter::fromIClipboard(const CString& data) const45 ULONG 46 CPMClipboardBitmapConverter::getPMFormatInfo() const 46 47 { 47 // copy to memory handle 48 HGLOBAL gData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, data.size()); 49 if (gData != NULL) { 50 // get a pointer to the allocated memory 51 char* dst = (char*)GlobalLock(gData); 52 if (dst != NULL) { 53 memcpy(dst, data.data(), data.size()); 54 GlobalUnlock(gData); 55 } 56 else { 57 GlobalFree(gData); 58 gData = NULL; 59 } 60 } 48 return CFI_HANDLE; 49 } 61 50 62 return gData; 51 ULONG 52 CPMClipboardBitmapConverter::fromIClipboard(const CString& data) const 53 { 54 /* 55 * We're getting a windows DIB, create a PM bitmap from that. 56 */ 57 /** @todo implement me */ 58 return 0; 63 59 } 64 60 65 61 CString 66 C MSWindowsClipboardBitmapConverter::toIClipboard(HANDLEdata) const62 CPMClipboardBitmapConverter::toIClipboard(ULONG data) const 67 63 { 64 #if 1 65 /** @todo implement me */ 66 return CString(); 67 #else 68 HBITMAP hbmp = (HBITMAP)data; 69 70 BITMAPINFOHEADER2 BmpHdr; 71 72 ULONG cbFix; 73 ULONG cx; 74 ULONG cy; 75 USHORT cPlanes; 76 USHORT cBitCount; 77 ULONG ulCompression; 78 ULONG cbImage; 79 ULONG cxResolution; 80 ULONG cyResolution; 81 ULONG cclrUsed; 82 ULONG cclrImportant; 83 USHORT usUnits; 84 USHORT usReserved; 85 USHORT usRecording; 86 USHORT usRendering; 87 ULONG cSize1; 88 ULONG cSize2; 89 ULONG ulColorEncoding; 90 ULONG ulIdentifier; 91 92 if (GpiQueryBitmapInfoHeader(hbmp, &BmpHdr)) { 93 LOG((CLOG_INFO "bitmap: %dx%d %d", bmpData.biWidth, bitmap->bmiHeader.biHeight, (int)bitmap->bmiHeader.biBitCount)); 94 if ( BmpHdr.cPlanes == 1 95 && (BmpHdr.cBitsCount == 32 || BmpHdr.cBitsCount == 24 /*???*/) 96 && BmpHdr.ulCompression == ) { 97 // already in canonical form 98 char *abImage = new char[BmpHdr.cbImage]; 99 /* fun stuff starts here. */ 100 //if (GipQueryBitmapBits() { 101 } 102 CString image(abImage, srcSize); 103 delete abImage; 104 return image; 105 } 106 107 } 108 return CString(); 109 68 110 // get datator 69 111 const char* src = (const char*)GlobalLock(data); … … 113 155 (bitmap->bmiHeader.biBitCount == 16 || 114 156 bitmap->bmiHeader.biBitCount == 32)) { 115 srcBits += 3 * sizeof( DWORD);157 srcBits += 3 * sizeof(ULONG); 116 158 } 117 159 } … … 144 186 145 187 return image; 188 #endif 146 189 } 190 -
trunk/synergy/lib/platform/CPMClipboardBitmapConverter.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C MSWINDOWSCLIPBOARDBITMAPCONVERTER_H16 #define C MSWINDOWSCLIPBOARDBITMAPCONVERTER_H16 #ifndef CPMCLIPBOARDBITMAPCONVERTER_H 17 #define CPMCLIPBOARDBITMAPCONVERTER_H 17 18 18 #include "C MSWindowsClipboard.h"19 #include "CPMClipboard.h" 19 20 20 21 //! Convert to/from some text encoding 21 class C MSWindowsClipboardBitmapConverter :22 public I MSWindowsClipboardConverter {22 class CPMClipboardBitmapConverter : 23 public IPMClipboardConverter { 23 24 public: 24 C MSWindowsClipboardBitmapConverter();25 virtual ~C MSWindowsClipboardBitmapConverter();25 CPMClipboardBitmapConverter(); 26 virtual ~CPMClipboardBitmapConverter(); 26 27 27 // I MSWindowsClipboardConverter overrides28 // IPMClipboardConverter overrides 28 29 virtual IClipboard::EFormat 29 30 getFormat() const; 30 virtual UINT getWin32Format() const; 31 virtual HANDLE fromIClipboard(const CString&) const; 32 virtual CString toIClipboard(HANDLE) const; 31 virtual ULONG getPMFormat() const; 32 virtual ULONG getPMFormatInfo() const; 33 virtual ULONG fromIClipboard(const CString&) const; 34 virtual void freePMData(ULONG) const; 35 virtual CString toIClipboard(ULONG) const; 33 36 }; 34 37 -
trunk/synergy/lib/platform/CPMClipboardHTMLConverter.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "C MSWindowsClipboardHTMLConverter.h"16 #include "CPMClipboardHTMLConverter.h" 16 17 #include "CStringUtil.h" 17 18 18 19 // 19 // C MSWindowsClipboardHTMLConverter20 // CPMClipboardHTMLConverter 20 21 // 21 22 22 C MSWindowsClipboardHTMLConverter::CMSWindowsClipboardHTMLConverter()23 CPMClipboardHTMLConverter::CPMClipboardHTMLConverter() 23 24 { 24 m_format = RegisterClipboardFormat("HTML Format"); 25 m_format = WinAddAtom(WinQuerySystemAtomTable(), (PCSZ)"HTML Format"); 26 if (!m_format) { 27 m_format = WinFindAtom(WinQuerySystemAtomTable(), (PCSZ)"HTML Format"); 28 assert(m_format); 29 } 25 30 } 26 31 27 C MSWindowsClipboardHTMLConverter::~CMSWindowsClipboardHTMLConverter()32 CPMClipboardHTMLConverter::~CPMClipboardHTMLConverter() 28 33 { 29 34 // do nothing … … 31 36 32 37 IClipboard::EFormat 33 C MSWindowsClipboardHTMLConverter::getFormat() const38 CPMClipboardHTMLConverter::getFormat() const 34 39 { 35 40 return IClipboard::kHTML; 36 41 } 37 42 38 U INT39 C MSWindowsClipboardHTMLConverter::getWin32Format() const43 ULONG 44 CPMClipboardHTMLConverter::getPMFormat() const 40 45 { 41 46 return m_format; … … 43 48 44 49 CString 45 C MSWindowsClipboardHTMLConverter::doFromIClipboard(const CString& data) const50 CPMClipboardHTMLConverter::doFromIClipboard(const CString& data) const 46 51 { 47 52 // prepare to CF_HTML format prefix and suffix … … 64 69 65 70 CString 66 C MSWindowsClipboardHTMLConverter::doToIClipboard(const CString& data) const71 CPMClipboardHTMLConverter::doToIClipboard(const CString& data) const 67 72 { 68 73 // get fragment start/end args … … 85 90 86 91 CString 87 C MSWindowsClipboardHTMLConverter::findArg(92 CPMClipboardHTMLConverter::findArg( 88 93 const CString& data, const CString& name) const 89 94 { -
trunk/synergy/lib/platform/CPMClipboardHTMLConverter.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C MSWINDOWSCLIPBOARDHTMLCONVERTER_H16 #define C MSWINDOWSCLIPBOARDHTMLCONVERTER_H16 #ifndef CPMCLIPBOARDHTMLCONVERTER_H 17 #define CPMCLIPBOARDHTMLCONVERTER_H 17 18 18 #include "C MSWindowsClipboardAnyTextConverter.h"19 #include "CPMClipboardAnyTextConverter.h" 19 20 20 21 //! Convert to/from HTML encoding 21 class C MSWindowsClipboardHTMLConverter :22 public C MSWindowsClipboardAnyTextConverter {22 class CPMClipboardHTMLConverter : 23 public CPMClipboardAnyTextConverter { 23 24 public: 24 C MSWindowsClipboardHTMLConverter();25 virtual ~C MSWindowsClipboardHTMLConverter();25 CPMClipboardHTMLConverter(); 26 virtual ~CPMClipboardHTMLConverter(); 26 27 27 // IMSWindowsClipboardConverter overrides 28 virtual IClipboard::EFormat 29 getFormat() const; 30 virtual UINT getWin32Format() const; 28 // IPMClipboardConverter overrides 29 virtual IClipboard::EFormat getFormat() const; 30 virtual ULONG getPMFormat() const; 31 31 32 32 protected: 33 // C MSWindowsClipboardAnyTextConverter overrides33 // CPMClipboardAnyTextConverter overrides 34 34 virtual CString doFromIClipboard(const CString&) const; 35 35 virtual CString doToIClipboard(const CString&) const; … … 39 39 40 40 private: 41 UINTm_format;41 ATOM m_format; 42 42 }; 43 43 -
trunk/synergy/lib/platform/CPMClipboardTextConverter.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2002 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "C MSWindowsClipboardTextConverter.h"16 #include "CPMClipboardTextConverter.h" 16 17 #include "CUnicode.h" 17 18 18 19 // 19 // C MSWindowsClipboardTextConverter20 // CPMClipboardTextConverter 20 21 // 21 22 22 C MSWindowsClipboardTextConverter::CMSWindowsClipboardTextConverter()23 CPMClipboardTextConverter::CPMClipboardTextConverter() 23 24 { 24 25 // do nothing 25 26 } 26 27 27 C MSWindowsClipboardTextConverter::~CMSWindowsClipboardTextConverter()28 CPMClipboardTextConverter::~CPMClipboardTextConverter() 28 29 { 29 30 // do nothing 30 31 } 31 32 32 U INT33 C MSWindowsClipboardTextConverter::getWin32Format() const33 ULONG 34 CPMClipboardTextConverter::getPMFormat() const 34 35 { 35 36 return CF_TEXT; … … 37 38 38 39 CString 39 C MSWindowsClipboardTextConverter::doFromIClipboard(const CString& data) const40 CPMClipboardTextConverter::doFromIClipboard(const CString& data) const 40 41 { 41 42 // convert and add nul terminator … … 44 45 45 46 CString 46 C MSWindowsClipboardTextConverter::doToIClipboard(const CString& data) const47 CPMClipboardTextConverter::doToIClipboard(const CString& data) const 47 48 { 48 49 // convert and truncate at first nul terminator -
trunk/synergy/lib/platform/CPMClipboardTextConverter.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2002 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C MSWINDOWSCLIPBOARDTEXTCONVERTER_H16 #define C MSWINDOWSCLIPBOARDTEXTCONVERTER_H16 #ifndef CPMCLIPBOARDTEXTCONVERTER_H 17 #define CPMCLIPBOARDTEXTCONVERTER_H 17 18 18 #include "C MSWindowsClipboardAnyTextConverter.h"19 #include "CPMClipboardAnyTextConverter.h" 19 20 20 21 //! Convert to/from locale text encoding 21 class C MSWindowsClipboardTextConverter :22 public C MSWindowsClipboardAnyTextConverter {22 class CPMClipboardTextConverter : 23 public CPMClipboardAnyTextConverter { 23 24 public: 24 C MSWindowsClipboardTextConverter();25 virtual ~C MSWindowsClipboardTextConverter();25 CPMClipboardTextConverter(); 26 virtual ~CPMClipboardTextConverter(); 26 27 27 // I MSWindowsClipboardConverter overrides28 virtual U INT getWin32Format() const;28 // IPMClipboardConverter overrides 29 virtual ULONG getPMFormat() const; 29 30 30 31 protected: 31 // C MSWindowsClipboardAnyTextConverter overrides32 // CPMClipboardAnyTextConverter overrides 32 33 virtual CString doFromIClipboard(const CString&) const; 33 34 virtual CString doToIClipboard(const CString&) const; -
trunk/synergy/lib/platform/CPMEventQueueBuffer.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "C MSWindowsEventQueueBuffer.h"16 #include "CPMEventQueueBuffer.h" 16 17 #include "CThread.h" 17 18 #include "IEventQueue.h" 18 #include "CArchMiscWindows.h"19 19 20 20 // … … 26 26 27 27 // 28 // C MSWindowsEventQueueBuffer28 // CPMEventQueueBuffer 29 29 // 30 30 31 C MSWindowsEventQueueBuffer::CMSWindowsEventQueueBuffer()31 CPMEventQueueBuffer::CPMEventQueueBuffer() 32 32 { 33 // remember thread. we'll be posting messages to it. 34 m_thread = GetCurrentThreadId(); 33 // remember the queue (/ thread / hab). we'll be posting messages to it. 34 m_hab = WinInitialize(0); 35 m_hmq = WinCreateMsgQueue(m_hab, 0); 36 assert(m_hmq != NULLHANDLE); 35 37 36 38 // create a message type for custom events 37 m_userEvent = RegisterWindowMessage("SYNERGY_USER_EVENT");39 m_userEvent = WM_USER + 42 + 42 + 42; 38 40 39 41 // get message type for daemon quit 40 m_daemonQuit = CArchMiscWindows::getDaemonQuitMessage();42 m_daemonQuit = WM_USER + 666; 41 43 42 // make sure this thread has a message queue 43 MSG dummy; 44 PeekMessage(&dummy, NULL, WM_USER, WM_USER, PM_NOREMOVE); 44 // create the event semaphore we'll be waiting on when waiting for messages. 45 m_hev = NULLHANDLE; 46 APIRET rc = DosCreateEventSem(NULL, &m_hev, 0, FALSE); 47 assert(rc == NO_ERROR); 45 48 } 46 49 47 C MSWindowsEventQueueBuffer::~CMSWindowsEventQueueBuffer()50 CPMEventQueueBuffer::~CPMEventQueueBuffer() 48 51 { 49 52 // do nothing 53 DosCloseEventSem(m_hev); 54 WinDestroyMsgQueue(m_hmq); 55 WinTerminate(m_hab); 50 56 } 51 57 52 58 void 53 C MSWindowsEventQueueBuffer::waitForEvent(double timeout)59 CPMEventQueueBuffer::waitForEvent(double timeout) 54 60 { 55 // check if messages are available first. if we don't do this then 56 // MsgWaitForMultipleObjects() will block even if the queue isn't 57 // empty if the messages in the queue were there before the last 58 // call to GetMessage()/PeekMessage(). 59 if (HIWORD(GetQueueStatus(QS_ALLINPUT)) != 0) { 60 return; 61 } 62 63 // convert timeout 64 DWORD t; 65 if (timeout < 0.0) { 66 t = INFINITE; 67 } 68 else { 69 t = (DWORD)(1000.0 * timeout); 70 } 71 72 // wait for a message. we cannot be interrupted by thread 73 // cancellation but that's okay because we're run in the main 74 // thread and we never cancel that thread. 75 HANDLE dummy[1]; 76 MsgWaitForMultipleObjects(0, dummy, FALSE, t, QS_ALLINPUT); 61 // check if messages are available first. 62 ULONG fStatus = WinQueryQueueStatus(HWND_DESKTOP); 63 if (!fStatus) { 64 // convert timeout and wait. 65 ULONG ulPMTimeout = timeout < 0.0 66 ? SEM_INDEFINITE_WAIT 67 : (ULONG)(1000.0 * timeout); 68 WinWaitEventSem(m_hev, ulPMTimeout); 69 } 77 70 } 78 71 79 72 IEventQueueBuffer::Type 80 C MSWindowsEventQueueBuffer::getEvent(CEvent& event, UInt32& dataID)73 CPMEventQueueBuffer::getEvent(CEvent& event, UInt32& dataID) 81 74 { 82 // peek at messages first. waiting for QS_ALLINPUT will return 83 // if a message has been sent to our window but GetMessage will 84 // dispatch that message behind our backs and block. PeekMessage 85 // will also dispatch behind our backs but won't block. 86 if (!PeekMessage(&m_event, NULL, 0, 0, PM_NOREMOVE) && 87 !PeekMessage(&m_event, (HWND)-1, 0, 0, PM_NOREMOVE)) { 75 // peek at messages first. 76 QMSG qmsg; 77 if (!WinPeekMsg(m_hab, &qmsg, NULLHANDLE, 0, 0, PM_NOREMOVE)) { 88 78 return kNone; 89 79 } 90 80 91 // BOOL. yeah, right. 92 BOOL result = GetMessage(&m_event, NULL, 0, 0); 93 if (result == -1) { 94 return kNone; 95 } 96 else if (result == 0) { 81 // get the message 82 if ( !WinGetMsg(m_hab, &m_event, NULLHANDLE, 0, 0) 83 || (m_event.msg == m_daemonQuit && m_daemonQuit != 0)) { 97 84 event = CEvent(CEvent::kQuit); 98 85 return kSystem; 99 86 } 100 else if (m_daemonQuit != 0 && m_event.message == m_daemonQuit) { 101 event = CEvent(CEvent::kQuit); 102 return kSystem; 103 } 104 else if (m_event.message == m_userEvent) { 105 dataID = static_cast<UInt32>(m_event.wParam); 87 88 if (m_event.msg == m_userEvent) { 89 dataID = (UInt32)(uintptr_t)m_event.mp1; 106 90 return kUser; 107 91 } 108 else { 109 event = CEvent(CEvent::kSystem, 110 IEventQueue::getSystemTarget(), &m_event); 111 return kSystem; 112 } 92 93 event = CEvent(CEvent::kSystem, IEventQueue::getSystemTarget(), &m_event); 94 return kSystem; 113 95 } 114 96 115 97 bool 116 C MSWindowsEventQueueBuffer::addEvent(UInt32 dataID)98 CPMEventQueueBuffer::addEvent(UInt32 dataID) 117 99 { 118 return (PostThreadMessage(m_thread, m_userEvent, 119 static_cast<WPARAM>(dataID), 0) != 0); 100 return WinPostQueueMsg(m_hmq, m_userEvent, (MPARAM)dataID, 0) != FALSE; 120 101 } 121 102 122 103 bool 123 C MSWindowsEventQueueBuffer::isEmpty() const104 CPMEventQueueBuffer::isEmpty() const 124 105 { 125 return (HIWORD(GetQueueStatus(QS_ALLINPUT)) == 0); 106 ULONG fStatus = WinQueryQueueStatus(HWND_DESKTOP); 107 return fStatus != 0; 126 108 } 127 109 128 110 CEventQueueTimer* 129 C MSWindowsEventQueueBuffer::newTimer(double, bool) const111 CPMEventQueueBuffer::newTimer(double, bool) const 130 112 { 131 113 return new CEventQueueTimer; … … 133 115 134 116 void 135 C MSWindowsEventQueueBuffer::deleteTimer(CEventQueueTimer* timer) const117 CPMEventQueueBuffer::deleteTimer(CEventQueueTimer* timer) const 136 118 { 137 119 delete timer; 138 120 } 121 -
trunk/synergy/lib/platform/CPMEventQueueBuffer.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C MSWINDOWSEVENTQUEUEBUFFER_H16 #define C MSWINDOWSEVENTQUEUEBUFFER_H16 #ifndef CPMEVENTQUEUEBUFFER_H 17 #define CPMEVENTQUEUEBUFFER_H 17 18 18 19 #include "IEventQueueBuffer.h" 19 #define WIN32_LEAN_AND_MEAN 20 #include <windows.h> 20 #define INCL_ERRORS 21 #define INCL_BASE 22 #define INCL_PM 23 #include <os2.h> 21 24 22 //! Event queue buffer for Win3223 class C MSWindowsEventQueueBuffer : public IEventQueueBuffer {25 //! Event queue buffer for PM 26 class CPMEventQueueBuffer : public IEventQueueBuffer { 24 27 public: 25 C MSWindowsEventQueueBuffer();26 virtual ~C MSWindowsEventQueueBuffer();28 CPMEventQueueBuffer(); 29 virtual ~CPMEventQueueBuffer(); 27 30 28 31 // IEventQueueBuffer overrides … … 36 39 37 40 private: 38 DWORD m_thread; 39 UINT m_userEvent; 40 MSG m_event; 41 UINT m_daemonQuit; 41 HAB m_hab; 42 HMQ m_hmq; 43 HEV m_hev; 44 ULONG m_userEvent; 45 QMSG m_event; 46 ULONG m_daemonQuit; 42 47 }; 43 48 -
trunk/synergy/lib/platform/CPMKeyState.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2003 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "CMSWindowsKeyState.h" 16 #include "CMSWindowsDesks.h" 16 #include "CPMKeyState.h" 17 17 #include "CThread.h" 18 18 #include "CFunctionJob.h" … … 21 21 #include "IEventQueue.h" 22 22 #include "TMethodEventJob.h" 23 #include "CArchMiscWindows.h"24 25 // extended mouse buttons26 #if !defined(VK_XBUTTON1)27 #define VK_XBUTTON1 0x0528 #define VK_XBUTTON2 0x0629 #endif30 23 31 24 // 32 // C MSWindowsKeyState25 // CPMKeyState 33 26 // 34 27 35 28 // map virtual keys to synergy key enumeration 36 const KeyID CMSWindowsKeyState::s_virtualKey[] = 37 { 38 /* 0x000 */ { kKeyNone }, // reserved 39 /* 0x001 */ { kKeyNone }, // VK_LBUTTON 40 /* 0x002 */ { kKeyNone }, // VK_RBUTTON 41 /* 0x003 */ { kKeyNone }, // VK_CANCEL 42 /* 0x004 */ { kKeyNone }, // VK_MBUTTON 43 /* 0x005 */ { kKeyNone }, // VK_XBUTTON1 44 /* 0x006 */ { kKeyNone }, // VK_XBUTTON2 45 /* 0x007 */ { kKeyNone }, // undefined 46 /* 0x008 */ { kKeyBackSpace }, // VK_BACK 47 /* 0x009 */ { kKeyTab }, // VK_TAB 48 /* 0x00a */ { kKeyNone }, // undefined 49 /* 0x00b */ { kKeyNone }, // undefined 50 /* 0x00c */ { kKeyClear }, // VK_CLEAR 51 /* 0x00d */ { kKeyReturn }, // VK_RETURN 52 /* 0x00e */ { kKeyNone }, // undefined 53 /* 0x00f */ { kKeyNone }, // undefined 54 /* 0x010 */ { kKeyShift_L }, // VK_SHIFT 55 /* 0x011 */ { kKeyControl_L }, // VK_CONTROL 56 /* 0x012 */ { kKeyAlt_L }, // VK_MENU 57 /* 0x013 */ { kKeyPause }, // VK_PAUSE 58 /* 0x014 */ { kKeyCapsLock }, // VK_CAPITAL 59 /* 0x015 */ { kKeyNone }, // VK_KANA 60 /* 0x016 */ { kKeyNone }, // VK_HANGUL 61 /* 0x017 */ { kKeyNone }, // VK_JUNJA 62 /* 0x018 */ { kKeyNone }, // VK_FINAL 63 /* 0x019 */ { kKeyZenkaku }, // VK_KANJI 64 /* 0x01a */ { kKeyNone }, // undefined 65 /* 0x01b */ { kKeyEscape }, // VK_ESCAPE 66 /* 0x01c */ { kKeyHenkan }, // VK_CONVERT 67 /* 0x01d */ { kKeyNone }, // VK_NONCONVERT 68 /* 0x01e */ { kKeyNone }, // VK_ACCEPT 69 /* 0x01f */ { kKeyNone }, // VK_MODECHANGE 70 /* 0x020 */ { kKeyNone }, // VK_SPACE 71 /* 0x021 */ { kKeyKP_PageUp }, // VK_PRIOR 72 /* 0x022 */ { kKeyKP_PageDown },// VK_NEXT 73 /* 0x023 */ { kKeyKP_End }, // VK_END 74 /* 0x024 */ { kKeyKP_Home }, // VK_HOME 75 /* 0x025 */ { kKeyKP_Left }, // VK_LEFT 76 /* 0x026 */ { kKeyKP_Up }, // VK_UP 77 /* 0x027 */ { kKeyKP_Right }, // VK_RIGHT 78 /* 0x028 */ { kKeyKP_Down }, // VK_DOWN 79 /* 0x029 */ { kKeySelect }, // VK_SELECT 80 /* 0x02a */ { kKeyNone }, // VK_PRINT 81 /* 0x02b */ { kKeyExecute }, // VK_EXECUTE 82 /* 0x02c */ { kKeyPrint }, // VK_SNAPSHOT 83 /* 0x02d */ { kKeyKP_Insert }, // VK_INSERT 84 /* 0x02e */ { kKeyKP_Delete }, // VK_DELETE 85 /* 0x02f */ { kKeyHelp }, // VK_HELP 86 /* 0x030 */ { kKeyNone }, // VK_0 87 /* 0x031 */ { kKeyNone }, // VK_1 88 /* 0x032 */ { kKeyNone }, // VK_2 89 /* 0x033 */ { kKeyNone }, // VK_3 90 /* 0x034 */ { kKeyNone }, // VK_4 91 /* 0x035 */ { kKeyNone }, // VK_5 92 /* 0x036 */ { kKeyNone }, // VK_6 93 /* 0x037 */ { kKeyNone }, // VK_7 94 /* 0x038 */ { kKeyNone }, // VK_8 95 /* 0x039 */ { kKeyNone }, // VK_9 96 /* 0x03a */ { kKeyNone }, // undefined 97 /* 0x03b */ { kKeyNone }, // undefined 98 /* 0x03c */ { kKeyNone }, // undefined 99 /* 0x03d */ { kKeyNone }, // undefined 100 /* 0x03e */ { kKeyNone }, // undefined 101 /* 0x03f */ { kKeyNone }, // undefined 102 /* 0x040 */ { kKeyNone }, // undefined 103 /* 0x041 */ { kKeyNone }, // VK_A 104 /* 0x042 */ { kKeyNone }, // VK_B 105 /* 0x043 */ { kKeyNone }, // VK_C 106 /* 0x044 */ { kKeyNone }, // VK_D 107 /* 0x045 */ { kKeyNone }, // VK_E 108 /* 0x046 */ { kKeyNone }, // VK_F 109 /* 0x047 */ { kKeyNone }, // VK_G 110 /* 0x048 */ { kKeyNone }, // VK_H 111 /* 0x049 */ { kKeyNone }, // VK_I 112 /* 0x04a */ { kKeyNone }, // VK_J 113 /* 0x04b */ { kKeyNone }, // VK_K 114 /* 0x04c */ { kKeyNone }, // VK_L 115 /* 0x04d */ { kKeyNone }, // VK_M 116 /* 0x04e */ { kKeyNone }, // VK_N 117 /* 0x04f */ { kKeyNone }, // VK_O 118 /* 0x050 */ { kKeyNone }, // VK_P 119 /* 0x051 */ { kKeyNone }, // VK_Q 120 /* 0x052 */ { kKeyNone }, // VK_R 121 /* 0x053 */ { kKeyNone }, // VK_S 122 /* 0x054 */ { kKeyNone }, // VK_T 123 /* 0x055 */ { kKeyNone }, // VK_U 124 /* 0x056 */ { kKeyNone }, // VK_V 125 /* 0x057 */ { kKeyNone }, // VK_W 126 /* 0x058 */ { kKeyNone }, // VK_X 127 /* 0x059 */ { kKeyNone }, // VK_Y 128 /* 0x05a */ { kKeyNone }, // VK_Z 129 /* 0x05b */ { kKeySuper_L }, // VK_LWIN 130 /* 0x05c */ { kKeySuper_R }, // VK_RWIN 131 /* 0x05d */ { kKeyMenu }, // VK_APPS 132 /* 0x05e */ { kKeyNone }, // undefined 133 /* 0x05f */ { kKeySleep }, // VK_SLEEP 134 /* 0x060 */ { kKeyKP_0 }, // VK_NUMPAD0 135 /* 0x061 */ { kKeyKP_1 }, // VK_NUMPAD1 136 /* 0x062 */ { kKeyKP_2 }, // VK_NUMPAD2 137 /* 0x063 */ { kKeyKP_3 }, // VK_NUMPAD3 138 /* 0x064 */ { kKeyKP_4 }, // VK_NUMPAD4 139 /* 0x065 */ { kKeyKP_5 }, // VK_NUMPAD5 140 /* 0x066 */ { kKeyKP_6 }, // VK_NUMPAD6 141 /* 0x067 */ { kKeyKP_7 }, // VK_NUMPAD7 142 /* 0x068 */ { kKeyKP_8 }, // VK_NUMPAD8 143 /* 0x069 */ { kKeyKP_9 }, // VK_NUMPAD9 144 /* 0x06a */ { kKeyKP_Multiply },// VK_MULTIPLY 145 /* 0x06b */ { kKeyKP_Add }, // VK_ADD 146 /* 0x06c */ { kKeyKP_Separator },// VK_SEPARATOR 147 /* 0x06d */ { kKeyKP_Subtract },// VK_SUBTRACT 148 /* 0x06e */ { kKeyKP_Decimal }, // VK_DECIMAL 149 /* 0x06f */ { kKeyNone }, // VK_DIVIDE 150 /* 0x070 */ { kKeyF1 }, // VK_F1 151 /* 0x071 */ { kKeyF2 }, // VK_F2 152 /* 0x072 */ { kKeyF3 }, // VK_F3 153 /* 0x073 */ { kKeyF4 }, // VK_F4 154 /* 0x074 */ { kKeyF5 }, // VK_F5 155 /* 0x075 */ { kKeyF6 }, // VK_F6 156 /* 0x076 */ { kKeyF7 }, // VK_F7 157 /* 0x077 */ { kKeyF8 }, // VK_F8 158 /* 0x078 */ { kKeyF9 }, // VK_F9 159 /* 0x079 */ { kKeyF10 }, // VK_F10 160 /* 0x07a */ { kKeyF11 }, // VK_F11 161 /* 0x07b */ { kKeyF12 }, // VK_F12 162 /* 0x07c */ { kKeyF13 }, // VK_F13 163 /* 0x07d */ { kKeyF14 }, // VK_F14 164 /* 0x07e */ { kKeyF15 }, // VK_F15 165 /* 0x07f */ { kKeyF16 }, // VK_F16 166 /* 0x080 */ { kKeyF17 }, // VK_F17 167 /* 0x081 */ { kKeyF18 }, // VK_F18 168 /* 0x082 */ { kKeyF19 }, // VK_F19 169 /* 0x083 */ { kKeyF20 }, // VK_F20 170 /* 0x084 */ { kKeyF21 }, // VK_F21 171 /* 0x085 */ { kKeyF22 }, // VK_F22 172 /* 0x086 */ { kKeyF23 }, // VK_F23 173 /* 0x087 */ { kKeyF24 }, // VK_F24 174 /* 0x088 */ { kKeyNone }, // unassigned 175 /* 0x089 */ { kKeyNone }, // unassigned 176 /* 0x08a */ { kKeyNone }, // unassigned 177 /* 0x08b */ { kKeyNone }, // unassigned 178 /* 0x08c */ { kKeyNone }, // unassigned 179 /* 0x08d */ { kKeyNone }, // unassigned 180 /* 0x08e */ { kKeyNone }, // unassigned 181 /* 0x08f */ { kKeyNone }, // unassigned 182 /* 0x090 */ { kKeyNumLock }, // VK_NUMLOCK 183 /* 0x091 */ { kKeyScrollLock }, // VK_SCROLL 184 /* 0x092 */ { kKeyNone }, // unassigned 185 /* 0x093 */ { kKeyNone }, // unassigned 186 /* 0x094 */ { kKeyNone }, // unassigned 187 /* 0x095 */ { kKeyNone }, // unassigned 188 /* 0x096 */ { kKeyNone }, // unassigned 189 /* 0x097 */ { kKeyNone }, // unassigned 190 /* 0x098 */ { kKeyNone }, // unassigned 191 /* 0x099 */ { kKeyNone }, // unassigned 192 /* 0x09a */ { kKeyNone }, // unassigned 193 /* 0x09b */ { kKeyNone }, // unassigned 194 /* 0x09c */ { kKeyNone }, // unassigned 195 /* 0x09d */ { kKeyNone }, // unassigned 196 /* 0x09e */ { kKeyNone }, // unassigned 197 /* 0x09f */ { kKeyNone }, // unassigned 198 /* 0x0a0 */ { kKeyShift_L }, // VK_LSHIFT 199 /* 0x0a1 */ { kKeyShift_R }, // VK_RSHIFT 200 /* 0x0a2 */ { kKeyControl_L }, // VK_LCONTROL 201 /* 0x0a3 */ { kKeyControl_R }, // VK_RCONTROL 202 /* 0x0a4 */ { kKeyAlt_L }, // VK_LMENU 203 /* 0x0a5 */ { kKeyAlt_R }, // VK_RMENU 204 /* 0x0a6 */ { kKeyNone }, // VK_BROWSER_BACK 205 /* 0x0a7 */ { kKeyNone }, // VK_BROWSER_FORWARD 206 /* 0x0a8 */ { kKeyNone }, // VK_BROWSER_REFRESH 207 /* 0x0a9 */ { kKeyNone }, // VK_BROWSER_STOP 208 /* 0x0aa */ { kKeyNone }, // VK_BROWSER_SEARCH 209 /* 0x0ab */ { kKeyNone }, // VK_BROWSER_FAVORITES 210 /* 0x0ac */ { kKeyNone }, // VK_BROWSER_HOME 211 /* 0x0ad */ { kKeyNone }, // VK_VOLUME_MUTE 212 /* 0x0ae */ { kKeyNone }, // VK_VOLUME_DOWN 213 /* 0x0af */ { kKeyNone }, // VK_VOLUME_UP 214 /* 0x0b0 */ { kKeyNone }, // VK_MEDIA_NEXT_TRACK 215 /* 0x0b1 */ { kKeyNone }, // VK_MEDIA_PREV_TRACK 216 /* 0x0b2 */ { kKeyNone }, // VK_MEDIA_STOP 217 /* 0x0b3 */ { kKeyNone }, // VK_MEDIA_PLAY_PAUSE 218 /* 0x0b4 */ { kKeyNone }, // VK_LAUNCH_MAIL 219 /* 0x0b5 */ { kKeyNone }, // VK_LAUNCH_MEDIA_SELECT 220 /* 0x0b6 */ { kKeyNone }, // VK_LAUNCH_APP1 221 /* 0x0b7 */ { kKeyNone }, // VK_LAUNCH_APP2 222 /* 0x0b8 */ { kKeyNone }, // unassigned 223 /* 0x0b9 */ { kKeyNone }, // unassigned 224 /* 0x0ba */ { kKeyNone }, // OEM specific 225 /* 0x0bb */ { kKeyNone }, // OEM specific 226 /* 0x0bc */ { kKeyNone }, // OEM specific 227 /* 0x0bd */ { kKeyNone }, // OEM specific 228 /* 0x0be */ { kKeyNone }, // OEM specific 229 /* 0x0bf */ { kKeyNone }, // OEM specific 230 /* 0x0c0 */ { kKeyNone }, // OEM specific 231 /* 0x0c1 */ { kKeyNone }, // unassigned 232 /* 0x0c2 */ { kKeyNone }, // unassigned 233 /* 0x0c3 */ { kKeyNone }, // unassigned 234 /* 0x0c4 */ { kKeyNone }, // unassigned 235 /* 0x0c5 */ { kKeyNone }, // unassigned 236 /* 0x0c6 */ { kKeyNone }, // unassigned 237 /* 0x0c7 */ { kKeyNone }, // unassigned 238 /* 0x0c8 */ { kKeyNone }, // unassigned 239 /* 0x0c9 */ { kKeyNone }, // unassigned 240 /* 0x0ca */ { kKeyNone }, // unassigned 241 /* 0x0cb */ { kKeyNone }, // unassigned 242 /* 0x0cc */ { kKeyNone }, // unassigned 243 /* 0x0cd */ { kKeyNone }, // unassigned 244 /* 0x0ce */ { kKeyNone }, // unassigned 245 /* 0x0cf */ { kKeyNone }, // unassigned 246 /* 0x0d0 */ { kKeyNone }, // unassigned 247 /* 0x0d1 */ { kKeyNone }, // unassigned 248 /* 0x0d2 */ { kKeyNone }, // unassigned 249 /* 0x0d3 */ { kKeyNone }, // unassigned 250 /* 0x0d4 */ { kKeyNone }, // unassigned 251 /* 0x0d5 */ { kKeyNone }, // unassigned 252 /* 0x0d6 */ { kKeyNone }, // unassigned 253 /* 0x0d7 */ { kKeyNone }, // unassigned 254 /* 0x0d8 */ { kKeyNone }, // unassigned 255 /* 0x0d9 */ { kKeyNone }, // unassigned 256 /* 0x0da */ { kKeyNone }, // unassigned 257 /* 0x0db */ { kKeyNone }, // OEM specific 258 /* 0x0dc */ { kKeyNone }, // OEM specific 259 /* 0x0dd */ { kKeyNone }, // OEM specific 260 /* 0x0de */ { kKeyNone }, // OEM specific 261 /* 0x0df */ { kKeyNone }, // OEM specific 262 /* 0x0e0 */ { kKeyNone }, // OEM specific 263 /* 0x0e1 */ { kKeyNone }, // OEM specific 264 /* 0x0e2 */ { kKeyNone }, // OEM specific 265 /* 0x0e3 */ { kKeyNone }, // OEM specific 266 /* 0x0e4 */ { kKeyNone }, // OEM specific 267 /* 0x0e5 */ { kKeyNone }, // unassigned 268 /* 0x0e6 */ { kKeyNone }, // OEM specific 269 /* 0x0e7 */ { kKeyNone }, // unassigned 270 /* 0x0e8 */ { kKeyNone }, // unassigned 271 /* 0x0e9 */ { kKeyNone }, // OEM specific 272 /* 0x0ea */ { kKeyNone }, // OEM specific 273 /* 0x0eb */ { kKeyNone }, // OEM specific 274 /* 0x0ec */ { kKeyNone }, // OEM specific 275 /* 0x0ed */ { kKeyNone }, // OEM specific 276 /* 0x0ee */ { kKeyNone }, // OEM specific 277 /* 0x0ef */ { kKeyNone }, // OEM specific 278 /* 0x0f0 */ { kKeyNone }, // OEM specific 279 /* 0x0f1 */ { kKeyNone }, // OEM specific 280 /* 0x0f2 */ { kKeyNone }, // OEM specific 281 /* 0x0f3 */ { kKeyNone }, // OEM specific 282 /* 0x0f4 */ { kKeyNone }, // OEM specific 283 /* 0x0f5 */ { kKeyNone }, // OEM specific 284 /* 0x0f6 */ { kKeyNone }, // VK_ATTN 285 /* 0x0f7 */ { kKeyNone }, // VK_CRSEL 286 /* 0x0f8 */ { kKeyNone }, // VK_EXSEL 287 /* 0x0f9 */ { kKeyNone }, // VK_EREOF 288 /* 0x0fa */ { kKeyNone }, // VK_PLAY 289 /* 0x0fb */ { kKeyNone }, // VK_ZOOM 290 /* 0x0fc */ { kKeyNone }, // reserved 291 /* 0x0fd */ { kKeyNone }, // VK_PA1 292 /* 0x0fe */ { kKeyNone }, // VK_OEM_CLEAR 293 /* 0x0ff */ { kKeyNone }, // reserved 294 295 /* 0x100 */ { kKeyNone }, // reserved 296 /* 0x101 */ { kKeyNone }, // VK_LBUTTON 297 /* 0x102 */ { kKeyNone }, // VK_RBUTTON 298 /* 0x103 */ { kKeyBreak }, // VK_CANCEL 299 /* 0x104 */ { kKeyNone }, // VK_MBUTTON 300 /* 0x105 */ { kKeyNone }, // VK_XBUTTON1 301 /* 0x106 */ { kKeyNone }, // VK_XBUTTON2 302 /* 0x107 */ { kKeyNone }, // undefined 303 /* 0x108 */ { kKeyNone }, // VK_BACK 304 /* 0x109 */ { kKeyNone }, // VK_TAB 305 /* 0x10a */ { kKeyNone }, // undefined 306 /* 0x10b */ { kKeyNone }, // undefined 307 /* 0x10c */ { kKeyClear }, // VK_CLEAR 308 /* 0x10d */ { kKeyKP_Enter }, // VK_RETURN 309 /* 0x10e */ { kKeyNone }, // undefined 310 /* 0x10f */ { kKeyNone }, // undefined 311 /* 0x110 */ { kKeyShift_R }, // VK_SHIFT 312 /* 0x111 */ { kKeyControl_R }, // VK_CONTROL 313 /* 0x112 */ { kKeyAlt_R }, // VK_MENU 314 /* 0x113 */ { kKeyNone }, // VK_PAUSE 315 /* 0x114 */ { kKeyNone }, // VK_CAPITAL 316 /* 0x115 */ { kKeyNone }, // VK_KANA 317 /* 0x116 */ { kKeyNone }, // VK_HANGUL 318 /* 0x117 */ { kKeyNone }, // VK_JUNJA 319 /* 0x118 */ { kKeyNone }, // VK_FINAL 320 /* 0x119 */ { kKeyNone }, // VK_KANJI 321 /* 0x11a */ { kKeyNone }, // undefined 322 /* 0x11b */ { kKeyNone }, // VK_ESCAPE 323 /* 0x11c */ { kKeyNone }, // VK_CONVERT 324 /* 0x11d */ { kKeyNone }, // VK_NONCONVERT 325 /* 0x11e */ { kKeyNone }, // VK_ACCEPT 326 /* 0x11f */ { kKeyNone }, // VK_MODECHANGE 327 /* 0x120 */ { kKeyNone }, // VK_SPACE 328 /* 0x121 */ { kKeyPageUp }, // VK_PRIOR 329 /* 0x122 */ { kKeyPageDown }, // VK_NEXT 330 /* 0x123 */ { kKeyEnd }, // VK_END 331 /* 0x124 */ { kKeyHome }, // VK_HOME 332 /* 0x125 */ { kKeyLeft }, // VK_LEFT 333 /* 0x126 */ { kKeyUp }, // VK_UP 334 /* 0x127 */ { kKeyRight }, // VK_RIGHT 335 /* 0x128 */ { kKeyDown }, // VK_DOWN 336 /* 0x129 */ { kKeySelect }, // VK_SELECT 337 /* 0x12a */ { kKeyNone }, // VK_PRINT 338 /* 0x12b */ { kKeyExecute }, // VK_EXECUTE 339 /* 0x12c */ { kKeyPrint }, // VK_SNAPSHOT 340 /* 0x12d */ { kKeyInsert }, // VK_INSERT 341 /* 0x12e */ { kKeyDelete }, // VK_DELETE 342 /* 0x12f */ { kKeyHelp }, // VK_HELP 343 /* 0x130 */ { kKeyNone }, // VK_0 344 /* 0x131 */ { kKeyNone }, // VK_1 345 /* 0x132 */ { kKeyNone }, // VK_2 346 /* 0x133 */ { kKeyNone }, // VK_3 347 /* 0x134 */ { kKeyNone }, // VK_4 348 /* 0x135 */ { kKeyNone }, // VK_5 349 /* 0x136 */ { kKeyNone }, // VK_6 350 /* 0x137 */ { kKeyNone }, // VK_7 351 /* 0x138 */ { kKeyNone }, // VK_8 352 /* 0x139 */ { kKeyNone }, // VK_9 353 /* 0x13a */ { kKeyNone }, // undefined 354 /* 0x13b */ { kKeyNone }, // undefined 355 /* 0x13c */ { kKeyNone }, // undefined 356 /* 0x13d */ { kKeyNone }, // undefined 357 /* 0x13e */ { kKeyNone }, // undefined 358 /* 0x13f */ { kKeyNone }, // undefined 359 /* 0x140 */ { kKeyNone }, // undefined 360 /* 0x141 */ { kKeyNone }, // VK_A 361 /* 0x142 */ { kKeyNone }, // VK_B 362 /* 0x143 */ { kKeyNone }, // VK_C 363 /* 0x144 */ { kKeyNone }, // VK_D 364 /* 0x145 */ { kKeyNone }, // VK_E 365 /* 0x146 */ { kKeyNone }, // VK_F 366 /* 0x147 */ { kKeyNone }, // VK_G 367 /* 0x148 */ { kKeyNone }, // VK_H 368 /* 0x149 */ { kKeyNone }, // VK_I 369 /* 0x14a */ { kKeyNone }, // VK_J 370 /* 0x14b */ { kKeyNone }, // VK_K 371 /* 0x14c */ { kKeyNone }, // VK_L 372 /* 0x14d */ { kKeyNone }, // VK_M 373 /* 0x14e */ { kKeyNone }, // VK_N 374 /* 0x14f */ { kKeyNone }, // VK_O 375 /* 0x150 */ { kKeyNone }, // VK_P 376 /* 0x151 */ { kKeyNone }, // VK_Q 377 /* 0x152 */ { kKeyNone }, // VK_R 378 /* 0x153 */ { kKeyNone }, // VK_S 379 /* 0x154 */ { kKeyNone }, // VK_T 380 /* 0x155 */ { kKeyNone }, // VK_U 381 /* 0x156 */ { kKeyNone }, // VK_V 382 /* 0x157 */ { kKeyNone }, // VK_W 383 /* 0x158 */ { kKeyNone }, // VK_X 384 /* 0x159 */ { kKeyNone }, // VK_Y 385 /* 0x15a */ { kKeyNone }, // VK_Z 386 /* 0x15b */ { kKeySuper_L }, // VK_LWIN 387 /* 0x15c */ { kKeySuper_R }, // VK_RWIN 388 /* 0x15d */ { kKeyMenu }, // VK_APPS 389 /* 0x15e */ { kKeyNone }, // undefined 390 /* 0x15f */ { kKeyNone }, // VK_SLEEP 391 /* 0x160 */ { kKeyNone }, // VK_NUMPAD0 392 /* 0x161 */ { kKeyNone }, // VK_NUMPAD1 393 /* 0x162 */ { kKeyNone }, // VK_NUMPAD2 394 /* 0x163 */ { kKeyNone }, // VK_NUMPAD3 395 /* 0x164 */ { kKeyNone }, // VK_NUMPAD4 396 /* 0x165 */ { kKeyNone }, // VK_NUMPAD5 397 /* 0x166 */ { kKeyNone }, // VK_NUMPAD6 398 /* 0x167 */ { kKeyNone }, // VK_NUMPAD7 399 /* 0x168 */ { kKeyNone }, // VK_NUMPAD8 400 /* 0x169 */ { kKeyNone }, // VK_NUMPAD9 401 /* 0x16a */ { kKeyNone }, // VK_MULTIPLY 402 /* 0x16b */ { kKeyNone }, // VK_ADD 403 /* 0x16c */ { kKeyKP_Separator },// VK_SEPARATOR 404 /* 0x16d */ { kKeyNone }, // VK_SUBTRACT 405 /* 0x16e */ { kKeyNone }, // VK_DECIMAL 406 /* 0x16f */ { kKeyKP_Divide }, // VK_DIVIDE 407 /* 0x170 */ { kKeyNone }, // VK_F1 408 /* 0x171 */ { kKeyNone }, // VK_F2 409 /* 0x172 */ { kKeyNone }, // VK_F3 410 /* 0x173 */ { kKeyNone }, // VK_F4 411 /* 0x174 */ { kKeyNone }, // VK_F5 412 /* 0x175 */ { kKeyNone }, // VK_F6 413 /* 0x176 */ { kKeyNone }, // VK_F7 414 /* 0x177 */ { kKeyNone }, // VK_F8 415 /* 0x178 */ { kKeyNone }, // VK_F9 416 /* 0x179 */ { kKeyNone }, // VK_F10 417 /* 0x17a */ { kKeyNone }, // VK_F11 418 /* 0x17b */ { kKeyNone }, // VK_F12 419 /* 0x17c */ { kKeyF13 }, // VK_F13 420 /* 0x17d */ { kKeyF14 }, // VK_F14 421 /* 0x17e */ { kKeyF15 }, // VK_F15 422 /* 0x17f */ { kKeyF16 }, // VK_F16 423 /* 0x180 */ { kKeyF17 }, // VK_F17 424 /* 0x181 */ { kKeyF18 }, // VK_F18 425 /* 0x182 */ { kKeyF19 }, // VK_F19 426 /* 0x183 */ { kKeyF20 }, // VK_F20 427 /* 0x184 */ { kKeyF21 }, // VK_F21 428 /* 0x185 */ { kKeyF22 }, // VK_F22 429 /* 0x186 */ { kKeyF23 }, // VK_F23 430 /* 0x187 */ { kKeyF24 }, // VK_F24 431 /* 0x188 */ { kKeyNone }, // unassigned 432 /* 0x189 */ { kKeyNone }, // unassigned 433 /* 0x18a */ { kKeyNone }, // unassigned 434 /* 0x18b */ { kKeyNone }, // unassigned 435 /* 0x18c */ { kKeyNone }, // unassigned 436 /* 0x18d */ { kKeyNone }, // unassigned 437 /* 0x18e */ { kKeyNone }, // unassigned 438 /* 0x18f */ { kKeyNone }, // unassigned 439 /* 0x190 */ { kKeyNumLock }, // VK_NUMLOCK 440 /* 0x191 */ { kKeyNone }, // VK_SCROLL 441 /* 0x192 */ { kKeyNone }, // unassigned 442 /* 0x193 */ { kKeyNone }, // unassigned 443 /* 0x194 */ { kKeyNone }, // unassigned 444 /* 0x195 */ { kKeyNone }, // unassigned 445 /* 0x196 */ { kKeyNone }, // unassigned 446 /* 0x197 */ { kKeyNone }, // unassigned 447 /* 0x198 */ { kKeyNone }, // unassigned 448 /* 0x199 */ { kKeyNone }, // unassigned 449 /* 0x19a */ { kKeyNone }, // unassigned 450 /* 0x19b */ { kKeyNone }, // unassigned 451 /* 0x19c */ { kKeyNone }, // unassigned 452 /* 0x19d */ { kKeyNone }, // unassigned 453 /* 0x19e */ { kKeyNone }, // unassigned 454 /* 0x19f */ { kKeyNone }, // unassigned 455 /* 0x1a0 */ { kKeyShift_L }, // VK_LSHIFT 456 /* 0x1a1 */ { kKeyShift_R }, // VK_RSHIFT 457 /* 0x1a2 */ { kKeyControl_L }, // VK_LCONTROL 458 /* 0x1a3 */ { kKeyControl_R }, // VK_RCONTROL 459 /* 0x1a4 */ { kKeyAlt_L }, // VK_LMENU 460 /* 0x1a5 */ { kKeyAlt_R }, // VK_RMENU 461 /* 0x1a6 */ { kKeyWWWBack }, // VK_BROWSER_BACK 462 /* 0x1a7 */ { kKeyWWWForward }, // VK_BROWSER_FORWARD 463 /* 0x1a8 */ { kKeyWWWRefresh }, // VK_BROWSER_REFRESH 464 /* 0x1a9 */ { kKeyWWWStop }, // VK_BROWSER_STOP 465 /* 0x1aa */ { kKeyWWWSearch }, // VK_BROWSER_SEARCH 466 /* 0x1ab */ { kKeyWWWFavorites },// VK_BROWSER_FAVORITES 467 /* 0x1ac */ { kKeyWWWHome }, // VK_BROWSER_HOME 468 /* 0x1ad */ { kKeyAudioMute }, // VK_VOLUME_MUTE 469 /* 0x1ae */ { kKeyAudioDown }, // VK_VOLUME_DOWN 470 /* 0x1af */ { kKeyAudioUp }, // VK_VOLUME_UP 471 /* 0x1b0 */ { kKeyAudioNext }, // VK_MEDIA_NEXT_TRACK 472 /* 0x1b1 */ { kKeyAudioPrev }, // VK_MEDIA_PREV_TRACK 473 /* 0x1b2 */ { kKeyAudioStop }, // VK_MEDIA_STOP 474 /* 0x1b3 */ { kKeyAudioPlay }, // VK_MEDIA_PLAY_PAUSE 475 /* 0x1b4 */ { kKeyAppMail }, // VK_LAUNCH_MAIL 476 /* 0x1b5 */ { kKeyAppMedia }, // VK_LAUNCH_MEDIA_SELECT 477 /* 0x1b6 */ { kKeyAppUser1 }, // VK_LAUNCH_APP1 478 /* 0x1b7 */ { kKeyAppUser2 }, // VK_LAUNCH_APP2 479 /* 0x1b8 */ { kKeyNone }, // unassigned 480 /* 0x1b9 */ { kKeyNone }, // unassigned 481 /* 0x1ba */ { kKeyNone }, // OEM specific 482 /* 0x1bb */ { kKeyNone }, // OEM specific 483 /* 0x1bc */ { kKeyNone }, // OEM specific 484 /* 0x1bd */ { kKeyNone }, // OEM specific 485 /* 0x1be */ { kKeyNone }, // OEM specific 486 /* 0x1bf */ { kKeyNone }, // OEM specific 487 /* 0x1c0 */ { kKeyNone }, // OEM specific 488 /* 0x1c1 */ { kKeyNone }, // unassigned 489 /* 0x1c2 */ { kKeyNone }, // unassigned 490 /* 0x1c3 */ { kKeyNone }, // unassigned 491 /* 0x1c4 */ { kKeyNone }, // unassigned 492 /* 0x1c5 */ { kKeyNone }, // unassigned 493 /* 0x1c6 */ { kKeyNone }, // unassigned 494 /* 0x1c7 */ { kKeyNone }, // unassigned 495 /* 0x1c8 */ { kKeyNone }, // unassigned 496 /* 0x1c9 */ { kKeyNone }, // unassigned 497 /* 0x1ca */ { kKeyNone }, // unassigned 498 /* 0x1cb */ { kKeyNone }, // unassigned 499 /* 0x1cc */ { kKeyNone }, // unassigned 500 /* 0x1cd */ { kKeyNone }, // unassigned 501 /* 0x1ce */ { kKeyNone }, // unassigned 502 /* 0x1cf */ { kKeyNone }, // unassigned 503 /* 0x1d0 */ { kKeyNone }, // unassigned 504 /* 0x1d1 */ { kKeyNone }, // unassigned 505 /* 0x1d2 */ { kKeyNone }, // unassigned 506 /* 0x1d3 */ { kKeyNone }, // unassigned 507 /* 0x1d4 */ { kKeyNone }, // unassigned 508 /* 0x1d5 */ { kKeyNone }, // unassigned 509 /* 0x1d6 */ { kKeyNone }, // unassigned 510 /* 0x1d7 */ { kKeyNone }, // unassigned 511 /* 0x1d8 */ { kKeyNone }, // unassigned 512 /* 0x1d9 */ { kKeyNone }, // unassigned 513 /* 0x1da */ { kKeyNone }, // unassigned 514 /* 0x1db */ { kKeyNone }, // OEM specific 515 /* 0x1dc */ { kKeyNone }, // OEM specific 516 /* 0x1dd */ { kKeyNone }, // OEM specific 517 /* 0x1de */ { kKeyNone }, // OEM specific 518 /* 0x1df */ { kKeyNone }, // OEM specific 519 /* 0x1e0 */ { kKeyNone }, // OEM specific 520 /* 0x1e1 */ { kKeyNone }, // OEM specific 521 /* 0x1e2 */ { kKeyNone }, // OEM specific 522 /* 0x1e3 */ { kKeyNone }, // OEM specific 523 /* 0x1e4 */ { kKeyNone }, // OEM specific 524 /* 0x1e5 */ { kKeyNone }, // unassigned 525 /* 0x1e6 */ { kKeyNone }, // OEM specific 526 /* 0x1e7 */ { kKeyNone }, // unassigned 527 /* 0x1e8 */ { kKeyNone }, // unassigned 528 /* 0x1e9 */ { kKeyNone }, // OEM specific 529 /* 0x1ea */ { kKeyNone }, // OEM specific 530 /* 0x1eb */ { kKeyNone }, // OEM specific 531 /* 0x1ec */ { kKeyNone }, // OEM specific 532 /* 0x1ed */ { kKeyNone }, // OEM specific 533 /* 0x1ee */ { kKeyNone }, // OEM specific 534 /* 0x1ef */ { kKeyNone }, // OEM specific 535 /* 0x1f0 */ { kKeyNone }, // OEM specific 536 /* 0x1f1 */ { kKeyNone }, // OEM specific 537 /* 0x1f2 */ { kKeyNone }, // OEM specific 538 /* 0x1f3 */ { kKeyNone }, // OEM specific 539 /* 0x1f4 */ { kKeyNone }, // OEM specific 540 /* 0x1f5 */ { kKeyNone }, // OEM specific 541 /* 0x1f6 */ { kKeyNone }, // VK_ATTN 542 /* 0x1f7 */ { kKeyNone }, // VK_CRSEL 543 /* 0x1f8 */ { kKeyNone }, // VK_EXSEL 544 /* 0x1f9 */ { kKeyNone }, // VK_EREOF 545 /* 0x1fa */ { kKeyNone }, // VK_PLAY 546 /* 0x1fb */ { kKeyNone }, // VK_ZOOM 547 /* 0x1fc */ { kKeyNone }, // reserved 548 /* 0x1fd */ { kKeyNone }, // VK_PA1 549 /* 0x1fe */ { kKeyNone }, // VK_OEM_CLEAR 550 /* 0x1ff */ { kKeyNone } // reserved 29 const KeyID CPMKeyState::s_virtualKey[0x42] = 30 { 31 /* 0x000 */ kKeyNone, // reserved 32 /* 0x001 */ kKeyNone, // VK_BUTTON1 VK_BUTTON1 0x0001 33 /* 0x002 */ kKeyNone, // VK_BUTTON2 VK_BUTTON2 0x0002 34 /* 0x003 */ kKeyNone, // VK_BUTTON3 VK_BUTTON3 0x0003 35 /* 0x004 */ kKeyBreak, // VK_BREAK VK_BREAK 0x0004 36 /* 0x005 */ kKeyBackSpace, // VK_BACKSPACE 37 /* 0x006 */ kKeyTab, // VK_TAB 38 /* 0x007 */ kKeyLeftTab, // VK_BACKTAB -- ??? 39 /* 0x008 */ kKeyReturn, // VK_NEWLINE 40 /* 0x009 */ kKeyShift_L, // VK_SHIFT 41 /* 0x00a */ kKeyControl_L, // VK_CTRL 0x000a 42 /* 0x00b */ kKeyAlt_L, // VK_ALT 0x000b 43 /* 0x00c */ kKeyAltGr, // VK_ALTGRAF 0x000c 44 /* 0x00d */ kKeyPause, // VK_PAUSE 0x000d 45 /* 0x00e */ kKeyCapsLock, // VK_CAPSLOCK 0x000e 46 /* 0x00f */ kKeyEscape, // VK_ESC 0x000f 47 /* 0x010 */ kKeyNone, // VK_SPACE 0x0010 48 /* 0x011 */ kKeyPageUp, // VK_PAGEUP 0x0011 49 /* 0x012 */ kKeyPageDown, // VK_PAGEDOWN 0x0012 50 /* 0x013 */ kKeyEnd, // VK_END 0x0013 51 /* 0x014 */ kKeyHome, // VK_HOME 0x0014 52 /* 0x015 */ kKeyLeft, // VK_LEFT 0x0015 53 /* 0x016 */ kKeyUp, // VK_UP 0x0016 54 /* 0x017 */ kKeyRight, // VK_RIGHT 0x0017 55 /* 0x018 */ kKeyDown, // VK_DOWN 0x0018 56 /* 0x019 */ kKeyNone, // VK_PRINTSCRN 0x0019 57 /* 0x01a */ kKeyInsert, // VK_INSERT 0x001a 58 /* 0x01b */ kKeyDelete, // VK_DELETE 0x001b 59 /* 0x01c */ kKeyScrollLock, // VK_SCRLLOCK 0x001c 60 /* 0x01d */ kKeyNumLock, // VK_NUMLOCK 0x001d 61 /* 0x01e */ kKeyKP_Enter, // VK_ENTER 0x001e 62 /* 0x01f */ kKeySysReq, // VK_SYSRQ 0x001f 63 /* 0x020 */ kKeyF1, // VK_F1 0x0020 64 /* 0x021 */ kKeyF2, // VK_F2 0x0021 65 /* 0x022 */ kKeyF3, // VK_F3 0x0022 66 /* 0x023 */ kKeyF4, // VK_F4 0x0023 67 /* 0x024 */ kKeyF5, // VK_F5 0x0024 68 /* 0x025 */ kKeyF6, // VK_F6 0x0025 69 /* 0x026 */ kKeyF7, // VK_F7 0x0026 70 /* 0x027 */ kKeyF8, // VK_F8 0x0027 71 /* 0x028 */ kKeyF9, // VK_F9 0x0028 72 /* 0x029 */ kKeyF10, // VK_F10 0x0029 73 /* 0x02a */ kKeyF11, // VK_F11 0x002a 74 /* 0x02b */ kKeyF12, // VK_F12 0x002b 75 /* 0x02c */ kKeyF13, // VK_F13 0x002c 76 /* 0x02d */ kKeyF14, // VK_F14 0x002d 77 /* 0x02e */ kKeyF15, // VK_F15 0x002e 78 /* 0x02f */ kKeyF16, // VK_F16 0x002f 79 /* 0x030 */ kKeyF17, // VK_F17 0x0030 80 /* 0x031 */ kKeyF18, // VK_F18 0x0031 81 /* 0x032 */ kKeyF19, // VK_F19 0x0032 82 /* 0x033 */ kKeyF20, // VK_F20 0x0033 83 /* 0x034 */ kKeyF21, // VK_F21 0x0034 84 /* 0x035 */ kKeyF22, // VK_F22 0x0035 85 /* 0x036 */ kKeyF23, // VK_F23 0x0036 86 /* 0x037 */ kKeyF24, // VK_F24 0x0037 87 /* 0x038 */ kKeyNone, // VK_ENDDRAG 0x0038 88 /* 0x039 */ kKeyClear, // VK_CLEAR 0x0039 89 /* 0x03a */ kKeyNone, // VK_EREOF 0x003a 90 /* 0x03b */ kKeyNone, // VK_PA1 0x003b 91 /* 0x03c */ kKeyNone, // VK_ATTN 0x003c 92 /* 0x03d */ kKeyNone, // VK_CRSEL 0x003d 93 /* 0x03e */ kKeyNone, // VK_EXSEL 0x003e 94 /* 0x03f */ kKeyNone, // VK_COPY 0x003f 95 /* 0x040 */ kKeyNone, // VK_BLK1 0x0040 96 /* 0x041 */ kKeyNone // VK_BLK2 0x0041 551 97 }; 552 98 553 99 struct CWin32Modifiers { 554 100 public: 555 U INTm_vk;101 ULONG m_vk; 556 102 KeyModifierMask m_mask; 557 103 }; … … 560 106 { 561 107 { VK_SHIFT, KeyModifierShift }, 562 { VK_LSHIFT, KeyModifierShift }, 563 { VK_RSHIFT, KeyModifierShift }, 564 { VK_CONTROL, KeyModifierControl }, 565 { VK_LCONTROL, KeyModifierControl }, 566 { VK_RCONTROL, KeyModifierControl }, 567 { VK_MENU, KeyModifierAlt }, 568 { VK_LMENU, KeyModifierAlt }, 569 { VK_RMENU, KeyModifierAlt }, 570 { VK_LWIN, KeyModifierSuper }, 571 { VK_RWIN, KeyModifierSuper } 108 { VK_CTRL, KeyModifierControl }, 109 { VK_ALT, KeyModifierAlt }, 110 { VK_ALTGRAF, KeyModifierAltGr }, 572 111 }; 573 112 574 CMSWindowsKeyState::CMSWindowsKeyState(CMSWindowsDesks* desks, 575 void* eventTarget) : 576 m_is95Family(CArchMiscWindows::isWindows95Family()), 113 CPMKeyState::CPMKeyState(void* eventTarget) : 577 114 m_eventTarget(eventTarget), 578 m_desks(desks),579 m_keyLayout(GetKeyboardLayout(0)),580 115 m_fixTimer(NULL), 581 116 m_lastDown(0), … … 584 119 m_originalSavedModifiers(0) 585 120 { 586 // look up symbol that's available on winNT family but not win95 587 HMODULE userModule = GetModuleHandle("user32.dll"); 588 m_ToUnicodeEx = (ToUnicodeEx_t)GetProcAddress(userModule, "ToUnicodeEx"); 589 } 590 591 CMSWindowsKeyState::~CMSWindowsKeyState() 121 122 } 123 124 CPMKeyState::~CPMKeyState() 592 125 { 593 126 disable(); … … 595 128 596 129 void 597 C MSWindowsKeyState::disable()130 CPMKeyState::disable() 598 131 { 599 132 if (m_fixTimer != NULL) { … … 606 139 607 140 KeyButton 608 C MSWindowsKeyState::virtualKeyToButton(UINTvirtualKey) const141 CPMKeyState::virtualKeyToButton(ULONG virtualKey) const 609 142 { 610 143 return m_virtualKeyToButton[virtualKey & 0xffu]; 611 144 } 612 145 613 void614 CMSWindowsKeyState::setKeyLayout(HKL keyLayout)615 {616 m_keyLayout = keyLayout;617 }618 619 146 bool 620 C MSWindowsKeyState::testAutoRepeat(bool press, bool isRepeat, KeyButton button)147 CPMKeyState::testAutoRepeat(bool press, bool isRepeat, KeyButton button) 621 148 { 622 149 if (!isRepeat) { … … 633 160 634 161 void 635 C MSWindowsKeyState::saveModifiers()162 CPMKeyState::saveModifiers() 636 163 { 637 164 m_savedModifiers = getActiveModifiers(); … … 640 167 641 168 void 642 C MSWindowsKeyState::useSavedModifiers(bool enable)169 CPMKeyState::useSavedModifiers(bool enable) 643 170 { 644 171 if (enable != m_useSavedModifiers) { … … 654 181 655 182 KeyID 656 CMSWindowsKeyState::mapKeyFromEvent(WPARAM charAndVirtKey, 657 LPARAM info, KeyModifierMask* maskOut) const 658 { 659 static const KeyModifierMask s_controlAlt = 660 KeyModifierControl | KeyModifierAlt; 183 CPMKeyState::mapKeyFromEvent(MPARAM charAndVirtKey, MPARAM info, KeyModifierMask* maskOut) const 184 { 185 static const KeyModifierMask s_controlAlt = KeyModifierControl | KeyModifierAlt; 661 186 662 187 // extract character, virtual key, and if we didn't use AltGr … … 708 233 709 234 bool 710 C MSWindowsKeyState::didGroupsChange() const235 CPMKeyState::didGroupsChange() const 711 236 { 712 237 GroupList groups; … … 715 240 716 241 UINT 717 C MSWindowsKeyState::mapKeyToVirtualKey(KeyID key) const242 CPMKeyState::mapKeyToVirtualKey(KeyID key) const 718 243 { 719 244 if (key == kKeyNone) { … … 730 255 731 256 void 732 C MSWindowsKeyState::onKey(KeyButton button, bool down, KeyModifierMask newState)257 CPMKeyState::onKey(KeyButton button, bool down, KeyModifierMask newState) 733 258 { 734 259 // handle win32 brokenness and forward to superclass … … 739 264 740 265 void 741 C MSWindowsKeyState::sendKeyEvent(void* target,266 CPMKeyState::sendKeyEvent(void* target, 742 267 bool press, bool isAutoRepeat, 743 268 KeyID key, KeyModifierMask mask, … … 765 290 766 291 void 767 C MSWindowsKeyState::fakeKeyDown(KeyID id, KeyModifierMask mask,292 CPMKeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, 768 293 KeyButton button) 769 294 { … … 772 297 773 298 void 774 C MSWindowsKeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask,299 CPMKeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, 775 300 SInt32 count, KeyButton button) 776 301 { … … 779 304 780 305 bool 781 CMSWindowsKeyState::fakeCtrlAltDel() 782 { 783 if (!m_is95Family) { 784 // to fake ctrl+alt+del on the NT family we broadcast a suitable 785 // hotkey to all windows on the winlogon desktop. however, the 786 // current thread must be on that desktop to do the broadcast 787 // and we can't switch just any thread because some own windows 788 // or hooks. so start a new thread to do the real work. 789 CThread cad(new CFunctionJob(&CMSWindowsKeyState::ctrlAltDelThread)); 790 cad.wait(); 791 } 792 else { 793 // simulate ctrl+alt+del 794 fakeKeyDown(kKeyDelete, KeyModifierControl | KeyModifierAlt, 795 virtualKeyToButton(VK_DELETE)); 796 } 797 return true; 798 } 799 800 void 801 CMSWindowsKeyState::ctrlAltDelThread(void*) 802 { 803 // get the Winlogon desktop at whatever privilege we can 804 HDESK desk = OpenDesktop("Winlogon", 0, FALSE, MAXIMUM_ALLOWED); 805 if (desk != NULL) { 806 if (SetThreadDesktop(desk)) { 807 PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, 808 MAKELPARAM(MOD_CONTROL | MOD_ALT, VK_DELETE)); 809 } 810 else { 811 LOG((CLOG_DEBUG "can't switch to Winlogon desk: %d", GetLastError())); 812 } 813 CloseDesktop(desk); 814 } 815 else { 816 LOG((CLOG_DEBUG "can't open Winlogon desk: %d", GetLastError())); 817 } 306 CPMKeyState::fakeCtrlAltDel() 307 { 308 fakeKeyDown(kKeyDelete, KeyModifierControl | KeyModifierAlt, virtualKeyToButton(VK_DELETE)); 818 309 } 819 310 820 311 KeyModifierMask 821 C MSWindowsKeyState::pollActiveModifiers() const312 CPMKeyState::pollActiveModifiers() const 822 313 { 823 314 KeyModifierMask state = 0; … … 832 323 833 324 // we can get toggle modifiers from the system 834 if ( (GetKeyState(VK_CAPITAL) & 0x01) != 0) {325 if (WinGetKeyState(HWND_DESKTOP, VK_CAPITAL) & 1) { 835 326 state |= KeyModifierCapsLock; 836 327 } 837 if ( (GetKeyState(VK_NUMLOCK) & 0x01) != 0) {328 if (WinGetKeyState(HWND_DESKTOP, VK_NUMLOCK) & 1) { 838 329 state |= KeyModifierNumLock; 839 330 } 840 if ( (GetKeyState(VK_SCROLL) & 0x01) != 0) {331 if (WinGetKeyState(HWND_DESKTOP, VK_SCROLL) & 1) { 841 332 state |= KeyModifierScrollLock; 842 333 } … … 846 337 847 338 SInt32 848 C MSWindowsKeyState::pollActiveGroup() const339 CPMKeyState::pollActiveGroup() const 849 340 { 850 341 // determine the thread that'll receive this event 851 342 HWND targetWindow = GetForegroundWindow(); 852 DWORDtargetThread = GetWindowThreadProcessId(targetWindow, NULL);343 ULONG targetThread = GetWindowThreadProcessId(targetWindow, NULL); 853 344 854 345 // get keyboard layout for the thread … … 866 357 867 358 void 868 C MSWindowsKeyState::pollPressedKeys(KeyButtonSet& pressedKeys) const359 CPMKeyState::pollPressedKeys(KeyButtonSet& pressedKeys) const 869 360 { 870 361 BYTE keyState[256]; … … 878 369 879 370 void 880 C MSWindowsKeyState::getKeyMap(CKeyMap& keyMap)371 CPMKeyState::getKeyMap(CKeyMap& keyMap) 881 372 { 882 373 // update keyboard groups … … 1185 676 1186 677 void 1187 C MSWindowsKeyState::fakeKey(const Keystroke& keystroke)678 CPMKeyState::fakeKey(const Keystroke& keystroke) 1188 679 { 1189 680 switch (keystroke.m_type) { … … 1241 732 1242 733 KeyModifierMask& 1243 C MSWindowsKeyState::getActiveModifiersRValue()734 CPMKeyState::getActiveModifiersRValue() 1244 735 { 1245 736 if (m_useSavedModifiers) { … … 1252 743 1253 744 bool 1254 C MSWindowsKeyState::getGroups(GroupList& groups) const745 CPMKeyState::getGroups(GroupList& groups) const 1255 746 { 1256 747 // get keyboard layouts … … 1275 766 1276 767 void 1277 C MSWindowsKeyState::setWindowGroup(SInt32 group)768 CPMKeyState::setWindowGroup(SInt32 group) 1278 769 { 1279 770 HWND targetWindow = GetForegroundWindow(); … … 1294 785 1295 786 void 1296 C MSWindowsKeyState::fixKeys()787 CPMKeyState::fixKeys() 1297 788 { 1298 789 // fake key releases for the windows keys if we think they're … … 1347 838 m_fixTimer = EVENTQUEUE->newTimer(0.1, NULL); 1348 839 EVENTQUEUE->adoptHandler(CEvent::kTimer, m_fixTimer, 1349 new TMethodEventJob<C MSWindowsKeyState>(1350 this, &C MSWindowsKeyState::handleFixKeys));840 new TMethodEventJob<CPMKeyState>( 841 this, &CPMKeyState::handleFixKeys)); 1351 842 } 1352 843 else if (!fix && m_fixTimer != NULL) { … … 1359 850 1360 851 void 1361 C MSWindowsKeyState::handleFixKeys(const CEvent&, void*)852 CPMKeyState::handleFixKeys(const CEvent&, void*) 1362 853 { 1363 854 fixKeys(); … … 1365 856 1366 857 KeyID 1367 C MSWindowsKeyState::getKeyID(UINT virtualKey, KeyButton button)858 CPMKeyState::getKeyID(UINT virtualKey, KeyButton button) 1368 859 { 1369 860 if ((button & 0x100u) != 0) { … … 1374 865 1375 866 KeyID 1376 C MSWindowsKeyState::getIDForKey(CKeyMap::KeyItem& item,867 CPMKeyState::getIDForKey(CKeyMap::KeyItem& item, 1377 868 KeyButton button, UINT virtualKey, 1378 869 PBYTE keyState, HKL hkl) const … … 1412 903 1413 904 void 1414 C MSWindowsKeyState::addKeyEntry(CKeyMap& keyMap, CKeyMap::KeyItem& item)905 CPMKeyState::addKeyEntry(CKeyMap& keyMap, CKeyMap::KeyItem& item) 1415 906 { 1416 907 keyMap.addKeyEntry(item); -
trunk/synergy/lib/platform/CPMKeyState.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2003 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C MSWINDOWSKEYSTATE_H16 #define C MSWINDOWSKEYSTATE_H16 #ifndef CPMKEYSTATE_H 17 #define CPMKEYSTATE_H 17 18 18 19 #include "CKeyState.h" 19 20 #include "CString.h" 20 21 #include "stdvector.h" 21 #define WIN32_LEAN_AND_MEAN 22 #include <windows.h> 22 #define INCL_ERRORS 23 #define INCL_BASE 24 #define INCL_PM 25 #include <os2.h> 23 26 24 27 class CEvent; 25 28 class CEventQueueTimer; 26 class CMSWindowsDesks;27 29 28 30 //! Microsoft Windows key mapper … … 30 32 This class maps KeyIDs to keystrokes. 31 33 */ 32 class C MSWindowsKeyState : public CKeyState {34 class CPMKeyState : public CKeyState { 33 35 public: 34 C MSWindowsKeyState(CMSWindowsDesks* desks,void* eventTarget);35 virtual ~C MSWindowsKeyState();36 CPMKeyState(void* eventTarget); 37 virtual ~CPMKeyState(); 36 38 37 39 //! @name manipulators … … 44 46 */ 45 47 void disable(); 46 47 //! Set the active keyboard layout48 /*!49 Uses \p keyLayout when querying the keyboard.50 */51 void setKeyLayout(HKL keyLayout);52 48 53 49 //! Test and set autorepeat state … … 87 83 Returns the button for the \p virtualKey. 88 84 */ 89 KeyButton virtualKeyToButton(U INTvirtualKey) const;85 KeyButton virtualKeyToButton(ULONG virtualKey) const; 90 86 91 87 //! Map key event to a key … … 94 90 to a modifier mask. 95 91 */ 96 KeyID mapKeyFromEvent(WPARAM charAndVirtKey, 97 LPARAM info, KeyModifierMask* maskOut) const; 92 KeyID mapKeyFromEvent(MPARAM charAndVirtKey, MPARAM info, KeyModifierMask* maskOut) const; 98 93 99 94 //! Check if keyboard groups have changed … … 109 104 key. 110 105 */ 111 U INTmapKeyToVirtualKey(KeyID key) const;106 ULONG mapKeyToVirtualKey(KeyID key) const; 112 107 113 108 //! Map virtual key and button to KeyID … … 117 112 no such key. 118 113 */ 119 static KeyID getKeyID(U INTvirtualKey, KeyButton button);114 static KeyID getKeyID(ULONG virtualKey, KeyButton button); 120 115 121 116 //@} … … 148 143 149 144 private: 150 typedef std::vector<HKL> GroupList;151 152 // send ctrl+alt+del hotkey event on NT family153 static void ctrlAltDelThread(void*);154 155 bool getGroups(GroupList&) const;156 void setWindowGroup(SInt32 group);157 158 145 void fixKeys(); 159 146 void handleFixKeys(const CEvent&, void*); 160 147 161 148 KeyID getIDForKey(CKeyMap::KeyItem& item, 162 KeyButton button, U INTvirtualKey,163 PBYTE keyState , HKL hkl) const;149 KeyButton button, ULONG virtualKey, 150 PBYTE keyState) const; 164 151 165 152 void addKeyEntry(CKeyMap& keyMap, CKeyMap::KeyItem& item); … … 167 154 private: 168 155 // not implemented 169 C MSWindowsKeyState(const CMSWindowsKeyState&);170 C MSWindowsKeyState& operator=(const CMSWindowsKeyState&);156 CPMKeyState(const CPMKeyState&); 157 CPMKeyState& operator=(const CPMKeyState&); 171 158 172 159 private: 173 typedef std::map<HKL, SInt32> GroupMap; 174 typedef std::map<KeyID, UINT> KeyToVKMap; 160 typedef std::map<KeyID, ULONG> KeyToVKMap; 175 161 176 bool m_is95Family;177 162 void* m_eventTarget; 178 CMSWindowsDesks* m_desks; 179 HKL m_keyLayout; 180 UINT m_buttonToVK[512]; 181 UINT m_buttonToNumpadVK[512]; 163 ULONG m_buttonToVK[512]; 164 ULONG m_buttonToNumpadVK[512]; 182 165 KeyButton m_virtualKeyToButton[256]; 183 166 KeyToVKMap m_keyToVKMap; … … 185 168 // the timer used to check for fixing key state 186 169 CEventQueueTimer* m_fixTimer; 187 188 // the groups (keyboard layouts)189 GroupList m_groups;190 GroupMap m_groupMap;191 170 192 171 // the last button that we generated a key down event for. this … … 201 180 KeyModifierMask m_originalSavedModifiers; 202 181 203 // pointer to ToUnicodeEx. on win95 family this will be NULL. 204 typedef int (WINAPI *ToUnicodeEx_t)(UINT wVirtKey, 205 UINT wScanCode, 206 PBYTE lpKeyState, 207 LPWSTR pwszBuff, 208 int cchBuff, 209 UINT wFlags, 210 HKL dwhkl); 211 ToUnicodeEx_t m_ToUnicodeEx; 212 213 static const KeyID s_virtualKey[]; 182 static const KeyID s_virtualKey[0x42]; 214 183 }; 215 184 -
trunk/synergy/lib/platform/CPMScreen.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2002 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "CMSWindowsScreen.h" 16 #include "CMSWindowsClipboard.h" 17 #include "CMSWindowsDesks.h" 18 #include "CMSWindowsEventQueueBuffer.h" 19 #include "CMSWindowsKeyState.h" 20 #include "CMSWindowsScreenSaver.h" 16 #include "CPMScreen.h" 17 #include "CPMClipboard.h" 18 #include "CPMEventQueueBuffer.h" 19 #include "CPMKeyState.h" 20 #include "CPMScreenSaver.h" 21 21 #include "CClipboard.h" 22 22 #include "CKeyMap.h" … … 32 32 #include "TMethodJob.h" 33 33 #include "CArch.h" 34 #include "C ArchMiscWindows.h"34 #include "CPMUtil.h" 35 35 #include <string.h> 36 #include <pbt.h>37 36 38 37 // 39 // add backwards compatible multihead support (and suppress bogus warning). 40 // this isn't supported on MinGW yet AFAICT. 38 // CPMScreen 41 39 // 42 #if defined(_MSC_VER) 43 #pragma warning(push) 44 #pragma warning(disable: 4706) // assignment within conditional 45 #define COMPILE_MULTIMON_STUBS 46 #include <multimon.h> 47 #pragma warning(pop) 48 #endif 49 50 // X button stuff 51 #if !defined(WM_XBUTTONDOWN) 52 #define WM_XBUTTONDOWN 0x020B 53 #define WM_XBUTTONUP 0x020C 54 #define WM_XBUTTONDBLCLK 0x020D 55 #define WM_NCXBUTTONDOWN 0x00AB 56 #define WM_NCXBUTTONUP 0x00AC 57 #define WM_NCXBUTTONDBLCLK 0x00AD 58 #define MOUSEEVENTF_XDOWN 0x0080 59 #define MOUSEEVENTF_XUP 0x0100 60 #define XBUTTON1 0x0001 61 #define XBUTTON2 0x0002 62 #endif 63 #if !defined(VK_XBUTTON1) 64 #define VK_XBUTTON1 0x05 65 #define VK_XBUTTON2 0x06 66 #endif 67 68 // WM_POWERBROADCAST stuff 69 #if !defined(PBT_APMRESUMEAUTOMATIC) 70 #define PBT_APMRESUMEAUTOMATIC 0x0012 71 #endif 72 73 // 74 // CMSWindowsScreen 75 // 76 77 HINSTANCE CMSWindowsScreen::s_instance = NULL; 78 CMSWindowsScreen* CMSWindowsScreen::s_screen = NULL; 79 80 CMSWindowsScreen::CMSWindowsScreen(bool isPrimary) : 40 41 CPMScreen* CPMScreen::s_screen = NULL; 42 43 CPMScreen::CPMScreen(bool isPrimary) : 81 44 m_isPrimary(isPrimary), 82 m_is95Family(CArchMiscWindows::isWindows95Family()),83 45 m_isOnScreen(m_isPrimary), 84 46 m_class(0), 85 47 m_x(0), m_y(0), 86 m_ w(0), m_h(0),48 m_cx(0), m_cy(0), 87 49 m_xCenter(0), m_yCenter(0), 88 50 m_multimon(false), … … 92 54 m_markReceived(0), 93 55 m_fixTimer(NULL), 94 m_keyLayout(NULL),95 56 m_screensaver(NULL), 96 57 m_screensaverNotify(false), 97 58 m_screensaverActive(false), 98 m_window(NULL ),99 m_nextClipboardWindow(NULL ),59 m_window(NULLHANDLE), 60 m_nextClipboardWindow(NULLHANDLE), 100 61 m_ownClipboard(false), 101 m_desks(NULL), 102 m_hookLibrary(NULL), 62 m_hmodHook(NULLHANDLE), 103 63 m_init(NULL), 104 64 m_cleanup(NULL), … … 107 67 m_setMode(NULL), 108 68 m_keyState(NULL), 109 m_hasMouse( GetSystemMetrics(SM_MOUSEPRESENT) != 0),69 m_hasMouse(WinQuerySysValue(HWND_DESKTOP, SV_MOUSEPRESENT) != FALSE), 110 70 m_showingMouse(false) 111 71 { 112 assert(s_instance != NULL); 113 assert(s_screen == NULL); 72 assert(s_screen == NULL); 114 73 115 74 s_screen = this; 116 75 try { 117 76 if (m_isPrimary) { 118 m_hookLibrary = openHookLibrary("synrgyhk"); 119 } 120 m_screensaver = new CMSWindowsScreenSaver(); 121 m_desks = new CMSWindowsDesks(m_isPrimary, 122 m_hookLibrary, m_screensaver, 123 new TMethodJob<CMSWindowsScreen>(this, 124 &CMSWindowsScreen::updateKeysCB)); 125 m_keyState = new CMSWindowsKeyState(m_desks, getEventTarget()); 77 m_hmodHook = openHookLibrary("synrgyhk"); 78 } 79 m_screensaver = new CPMScreenSaver(); 80 m_keyState = new CPMKeyState(getEventTarget()); 126 81 updateScreenShape(); 127 82 m_class = createWindowClass(); 128 83 m_window = createWindow(m_class, "Synergy"); 129 84 forceShowCursor(); 130 LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_ w, m_h, m_multimon ? "(multi-monitor)" : ""));85 LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_cx, m_cy, m_multimon ? "(multi-monitor)" : "")); 131 86 LOG((CLOG_DEBUG "window is 0x%08x", m_window)); 132 87 } 133 88 catch (...) { 134 89 delete m_keyState; 135 delete m_desks;136 90 delete m_screensaver; 137 91 destroyWindow(m_window); 138 92 destroyClass(m_class); 139 closeHookLibrary(m_h ookLibrary);93 closeHookLibrary(m_hmodHook); 140 94 s_screen = NULL; 141 95 throw; … … 144 98 // install event handlers 145 99 EVENTQUEUE->adoptHandler(CEvent::kSystem, IEventQueue::getSystemTarget(), 146 new TMethodEventJob<C MSWindowsScreen>(this,147 &C MSWindowsScreen::handleSystemEvent));100 new TMethodEventJob<CPMScreen>(this, 101 &CPMScreen::handleSystemEvent)); 148 102 149 103 // install the platform event queue 150 EVENTQUEUE->adoptBuffer(new C MSWindowsEventQueueBuffer);151 } 152 153 C MSWindowsScreen::~CMSWindowsScreen()104 EVENTQUEUE->adoptBuffer(new CPMEventQueueBuffer); 105 } 106 107 CPMScreen::~CPMScreen() 154 108 { 155 109 assert(s_screen != NULL); … … 159 113 EVENTQUEUE->removeHandler(CEvent::kSystem, IEventQueue::getSystemTarget()); 160 114 delete m_keyState; 161 delete m_desks;162 115 delete m_screensaver; 163 116 destroyWindow(m_window); 164 117 destroyClass(m_class); 165 closeHookLibrary(m_h ookLibrary);118 closeHookLibrary(m_hmodHook); 166 119 s_screen = NULL; 167 120 } 168 121 169 122 void 170 CMSWindowsScreen::init(HINSTANCE instance) 171 { 172 assert(s_instance == NULL); 173 assert(instance != NULL); 174 175 s_instance = instance; 176 } 177 178 HINSTANCE 179 CMSWindowsScreen::getInstance() 180 { 181 return s_instance; 182 } 183 184 void 185 CMSWindowsScreen::enable() 123 CPMScreen::enable() 186 124 { 187 125 assert(m_isOnScreen == m_isPrimary); … … 190 128 m_fixTimer = EVENTQUEUE->newTimer(1.0, NULL); 191 129 EVENTQUEUE->adoptHandler(CEvent::kTimer, m_fixTimer, 192 new TMethodEventJob<CMSWindowsScreen>(this, 193 &CMSWindowsScreen::handleFixes)); 130 new TMethodEventJob<CPMScreen>(this, &CPMScreen::handleFixes)); 194 131 195 132 // install our clipboard snooper 196 m_nextClipboardWindow = SetClipboardViewer(m_window); 197 133 HAB hab = CPMUtil::getHAB(); 134 m_nextClipboardWindow = WinQueryClipbrdViewer(hab); 135 WinSetClipbrdViewer(hab, m_window); 136 137 /// @todo start here! 198 138 // track the active desk and (re)install the hooks 199 139 m_desks->enable(); … … 201 141 if (m_isPrimary) { 202 142 // set jump zones 203 m_setZone(m_x, m_y, m_ w, m_h, getJumpZoneSize());143 m_setZone(m_x, m_y, m_cx, m_cy, getJumpZoneSize()); 204 144 205 145 // watch jump zones 206 146 m_setMode(kHOOK_WATCH_JUMP_ZONE); 207 147 } 208 else { 209 // prevent the system from entering power saving modes. if 210 // it did we'd be forced to disconnect from the server and 211 // the server would not be able to wake us up. 212 CArchMiscWindows::addBusyState(CArchMiscWindows::kSYSTEM); 213 } 214 } 215 216 void 217 CMSWindowsScreen::disable() 148 } 149 150 void 151 CPMScreen::disable() 218 152 { 219 153 // stop tracking the active desk … … 223 157 // disable hooks 224 158 m_setMode(kHOOK_DISABLE); 225 226 // enable special key sequences on win95 family227 enableSpecialKeys(true);228 }229 else {230 // allow the system to enter power saving mode231 CArchMiscWindows::removeBusyState(CArchMiscWindows::kSYSTEM |232 CArchMiscWindows::kDISPLAY);233 159 } 234 160 … … 237 163 238 164 // stop snooping the clipboard 239 ChangeClipboardChain(m_window, m_nextClipboardWindow);165 WinSetClipbrdViewer(m_window, m_nextClipboardWindow); 240 166 m_nextClipboardWindow = NULL; 241 167 … … 252 178 253 179 void 254 C MSWindowsScreen::enter()180 CPMScreen::enter() 255 181 { 256 182 m_desks->enter(); 257 183 if (m_isPrimary) { 258 // enable special key sequences on win95 family259 enableSpecialKeys(true);260 261 184 // watch jump zones 262 185 m_setMode(kHOOK_WATCH_JUMP_ZONE); … … 272 195 273 196 bool 274 CMSWindowsScreen::leave() 275 { 276 // get keyboard layout of foreground window. we'll use this 277 // keyboard layout for translating keys sent to clients. 278 HWND window = GetForegroundWindow(); 279 DWORD thread = GetWindowThreadProcessId(window, NULL); 280 m_keyLayout = GetKeyboardLayout(thread); 281 282 // tell the key mapper about the keyboard layout 283 m_keyState->setKeyLayout(m_keyLayout); 284 285 // tell desk that we're leaving and tell it the keyboard layout 286 m_desks->leave(m_keyLayout); 287 197 CPMScreen::leave() 198 { 288 199 if (m_isPrimary) { 289 200 // warp to center 290 201 warpCursor(m_xCenter, m_yCenter); 291 202 292 // disable special key sequences on win95 family293 enableSpecialKeys(false);294 295 203 // all messages prior to now are invalid 296 204 nextMark(); … … 312 220 313 221 bool 314 C MSWindowsScreen::setClipboard(ClipboardID, const IClipboard* src)315 { 316 C MSWindowsClipboard dst(m_window);222 CPMScreen::setClipboard(ClipboardID, const IClipboard* src) 223 { 224 CPMClipboard dst(m_window); 317 225 if (src != NULL) { 318 226 // save clipboard data 319 227 return CClipboard::copy(&dst, src); 320 228 } 321 else { 322 // assert clipboard ownership 323 if (!dst.open(0)) { 324 return false; 325 } 326 dst.empty(); 327 dst.close(); 328 return true; 329 } 330 } 331 332 void 333 CMSWindowsScreen::checkClipboards() 334 { 335 // if we think we own the clipboard but we don't then somebody 336 // grabbed the clipboard on this screen without us knowing. 337 // tell the server that this screen grabbed the clipboard. 338 // 339 // this works around bugs in the clipboard viewer chain. 340 // sometimes NT will simply never send WM_DRAWCLIPBOARD 341 // messages for no apparent reason and rebooting fixes the 342 // problem. since we don't want a broken clipboard until the 343 // next reboot we do this double check. clipboard ownership 344 // won't be reflected on other screens until we leave but at 345 // least the clipboard itself will work. 346 if (m_ownClipboard && !CMSWindowsClipboard::isOwnedBySynergy()) { 229 // assert clipboard ownership 230 if (!dst.open(0)) { 231 return false; 232 } 233 dst.empty(); 234 dst.close(); 235 return true; 236 } 237 238 void 239 CPMScreen::checkClipboards() 240 { 241 // be careful, even if we don't have the NT bugs. 242 if (m_ownClipboard && !CPMClipboard::isOwnedBySynergy()) { 347 243 LOG((CLOG_DEBUG "clipboard changed: lost ownership and no notification received")); 348 244 m_ownClipboard = false; … … 353 249 354 250 void 355 CMSWindowsScreen::openScreensaver(bool notify) 356 { 357 assert(m_screensaver != NULL); 358 251 CPMScreen::openScreensaver(bool notify) 252 { 359 253 m_screensaverNotify = notify; 360 if (m_screensaverNotify) { 361 m_desks->installScreensaverHooks(true); 362 } 363 else { 254 if (!m_screensaverNotify) { 364 255 m_screensaver->disable(); 365 256 } … … 367 258 368 259 void 369 CMSWindowsScreen::closeScreensaver() 370 { 371 if (m_screensaver != NULL) { 372 if (m_screensaverNotify) { 373 m_desks->installScreensaverHooks(false); 374 } 375 else { 376 m_screensaver->enable(); 377 } 378 } 379 m_screensaverNotify = false; 380 } 381 382 void 383 CMSWindowsScreen::screensaver(bool activate) 384 { 385 assert(m_screensaver != NULL); 386 387 if (activate) { 388 m_screensaver->activate(); 389 } 390 else { 391 m_screensaver->deactivate(); 392 } 393 } 394 395 void 396 CMSWindowsScreen::resetOptions() 397 { 398 m_desks->resetOptions(); 399 } 400 401 void 402 CMSWindowsScreen::setOptions(const COptionsList& options) 403 { 404 m_desks->setOptions(options); 405 } 406 407 void 408 CMSWindowsScreen::setSequenceNumber(UInt32 seqNum) 260 CPMScreen::closeScreensaver() 261 { 262 if (!m_screensaverNotify) { 263 m_screensaver->enable(); 264 } 265 } 266 267 void 268 CPMScreen::screensaver(bool activate) 269 { 270 if (activate) { 271 m_screensaver->activate(); 272 } 273 else { 274 m_screensaver->deactivate(); 275 } 276 } 277 278 void 279 CPMScreen::resetOptions() 280 { 281 //example m_xtestIsXineramaUnaware = true; 282 } 283 284 void 285 CPMScreen::setOptions(const COptionsList& options) 286 { 287 for (UInt32 i = 0, n = options.size(); i < n; i += 2) { 288 //example if (options[i] == kOptionXTestXineramaUnaware) { 289 //example m_xtestIsXineramaUnaware = (options[i + 1] != 0); 290 //example LOG((CLOG_DEBUG1 "XTest is Xinerama unaware %s", m_xtestIsXineramaUnaware ? "true" : "false")); 291 //example } 292 } 293 } 294 295 void 296 CPMScreen::setSequenceNumber(UInt32 seqNum) 409 297 { 410 298 m_sequenceNumber = seqNum; … … 412 300 413 301 bool 414 C MSWindowsScreen::isPrimary() const302 CPMScreen::isPrimary() const 415 303 { 416 304 return m_isPrimary; … … 418 306 419 307 void* 420 CMSWindowsScreen::getEventTarget() const 421 { 422 return const_cast<CMSWindowsScreen*>(this); 423 } 424 425 bool 426 CMSWindowsScreen::getClipboard(ClipboardID, IClipboard* dst) const 427 { 428 CMSWindowsClipboard src(m_window); 429 CClipboard::copy(dst, &src); 430 return true; 431 } 432 433 void 434 CMSWindowsScreen::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const 308 CPMScreen::getEventTarget() const 309 { 310 return const_cast<CPMScreen*>(this); 311 } 312 313 bool 314 CPMScreen::getClipboard(ClipboardID, IClipboard* dst) const 315 { 316 CPMClipboard src(m_window); 317 return CClipboard::copy(dst, &src); 318 } 319 320 void 321 CPMScreen::getShape(SInt32& x, SInt32& y, SInt32& cx, SInt32& cy) const 435 322 { 436 323 assert(m_class != 0); … … 438 325 x = m_x; 439 326 y = m_y; 440 w = m_w; 441 h = m_h; 442 } 443 444 void 445 CMSWindowsScreen::getCursorPos(SInt32& x, SInt32& y) const 446 { 447 m_desks->getCursorPos(x, y); 448 } 449 450 void 451 CMSWindowsScreen::reconfigure(UInt32 activeSides) 452 { 453 assert(m_isPrimary); 454 455 LOG((CLOG_DEBUG "active sides: %x", activeSides)); 456 m_setSides(activeSides); 457 } 458 459 void 460 CMSWindowsScreen::warpCursor(SInt32 x, SInt32 y) 327 cx= m_cx; 328 cy = m_cy; 329 } 330 331 void 332 CPMScreen::getCursorPos(SInt32& x, SInt32& y) const 333 { 334 CURSORINFO Info; 335 if (WinQueryCursorInfo(HWND_DESKTOP, &Info)) { 336 x = Info.x; 337 y = m_cy - Info.y; 338 } else { 339 x = 0; 340 y = 0; 341 } 342 } 343 344 void 345 CPMScreen::reconfigure(UInt32 activeSides) 346 { 347 // do nothing. 348 } 349 350 void 351 CPMScreen::warpCursor(SInt32 x, SInt32 y) 461 352 { 462 353 // warp mouse … … 464 355 465 356 // remove all input events before and including warp 466 MSG msg; 467 while (PeekMessage(&msg, NULL, SYNERGY_MSG_INPUT_FIRST, 468 SYNERGY_MSG_INPUT_LAST, PM_REMOVE)) { 357 QMSG qmsg; 358 while (WinPeekMsg(m_hab, &qmsg, NULLHANDLE, SYNERGY_MSG_INPUT_FIRST, SYNERGY_MSG_INPUT_LAST, PM_REMOVE)) { 469 359 // do nothing 470 360 } … … 476 366 477 367 UInt32 478 C MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask)368 CPMScreen::registerHotKey(KeyID key, KeyModifierMask mask) 479 369 { 480 370 // only allow certain modifiers … … 490 380 } 491 381 382 #if 1 383 LOG((CLOG_WARN "not implemented id=%04x mask=%04x", key, mask)); 384 return 0; 385 #else 492 386 // convert to win32 493 387 UINT modifiers = 0; … … 545 439 LOG((CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", CKeyMap::formatKey(key, mask).c_str(), key, mask, id)); 546 440 return id; 547 } 548 549 void 550 CMSWindowsScreen::unregisterHotKey(UInt32 id) 441 #endif 442 } 443 444 void 445 CPMScreen::unregisterHotKey(UInt32 id) 551 446 { 552 447 // look up hotkey … … 558 453 // unregister with OS 559 454 bool err; 455 #if 1 456 err = true; 457 #else 560 458 if (i->second.getVirtualKey() != 0) { 561 459 err = !UnregisterHotKey(NULL, id); 562 } 563 else { 460 } else { 564 461 err = false; 565 462 } 463 #endif 566 464 if (err) { 567 465 LOG((CLOG_WARN "failed to unregister hotkey id=%d", id)); … … 578 476 579 477 void 580 C MSWindowsScreen::fakeInputBegin()478 CPMScreen::fakeInputBegin() 581 479 { 582 480 assert(m_isPrimary); … … 589 487 590 488 void 591 C MSWindowsScreen::fakeInputEnd()489 CPMScreen::fakeInputEnd() 592 490 { 593 491 assert(m_isPrimary); … … 600 498 601 499 SInt32 602 C MSWindowsScreen::getJumpZoneSize() const500 CPMScreen::getJumpZoneSize() const 603 501 { 604 502 return 1; … … 606 504 607 505 bool 608 C MSWindowsScreen::isAnyMouseButtonDown() const506 CPMScreen::isAnyMouseButtonDown() const 609 507 { 610 508 static const char* buttonToName[] = { … … 628 526 629 527 void 630 C MSWindowsScreen::getCursorCenter(SInt32& x, SInt32& y) const528 CPMScreen::getCursorCenter(SInt32& x, SInt32& y) const 631 529 { 632 530 x = m_xCenter; … … 635 533 636 534 void 637 C MSWindowsScreen::fakeMouseButton(ButtonID id, bool press) const535 CPMScreen::fakeMouseButton(ButtonID id, bool press) const 638 536 { 639 537 m_desks->fakeMouseButton(id, press); … … 641 539 642 540 void 643 C MSWindowsScreen::fakeMouseMove(SInt32 x, SInt32 y) const541 CPMScreen::fakeMouseMove(SInt32 x, SInt32 y) const 644 542 { 645 543 m_desks->fakeMouseMove(x, y); … … 647 545 648 546 void 649 C MSWindowsScreen::fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const547 CPMScreen::fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const 650 548 { 651 549 m_desks->fakeMouseRelativeMove(dx, dy); … … 653 551 654 552 void 655 C MSWindowsScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const553 CPMScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const 656 554 { 657 555 m_desks->fakeMouseWheel(xDelta, yDelta); … … 659 557 660 558 void 661 C MSWindowsScreen::updateKeys()559 CPMScreen::updateKeys() 662 560 { 663 561 m_desks->updateKeys(); … … 665 563 666 564 void 667 C MSWindowsScreen::fakeKeyDown(KeyID id, KeyModifierMask mask,565 CPMScreen::fakeKeyDown(KeyID id, KeyModifierMask mask, 668 566 KeyButton button) 669 567 { … … 673 571 674 572 void 675 C MSWindowsScreen::fakeKeyRepeat(KeyID id, KeyModifierMask mask,573 CPMScreen::fakeKeyRepeat(KeyID id, KeyModifierMask mask, 676 574 SInt32 count, KeyButton button) 677 575 { … … 681 579 682 580 void 683 C MSWindowsScreen::fakeKeyUp(KeyButton button)581 CPMScreen::fakeKeyUp(KeyButton button) 684 582 { 685 583 CPlatformScreen::fakeKeyUp(button); … … 688 586 689 587 void 690 C MSWindowsScreen::fakeAllKeysUp()588 CPMScreen::fakeAllKeysUp() 691 589 { 692 590 CPlatformScreen::fakeAllKeysUp(); … … 695 593 696 594 HINSTANCE 697 C MSWindowsScreen::openHookLibrary(const char* name)595 CPMScreen::openHookLibrary(const char* name) 698 596 { 699 597 // load the hook library … … 729 627 730 628 void 731 C MSWindowsScreen::closeHookLibrary(HINSTANCE hookLibrary) const629 CPMScreen::closeHookLibrary(HINSTANCE hookLibrary) const 732 630 { 733 631 if (hookLibrary != NULL) { … … 737 635 } 738 636 739 HCURSOR740 CMSWindowsScreen::createBlankCursor() const741 {742 // create a transparent cursor743 int cw = GetSystemMetrics(SM_CXCURSOR);744 int ch = GetSystemMetrics(SM_CYCURSOR);745 UInt8* cursorAND = new UInt8[ch * ((cw + 31) >> 2)];746 UInt8* cursorXOR = new UInt8[ch * ((cw + 31) >> 2)];747 memset(cursorAND, 0xff, ch * ((cw + 31) >> 2));748 memset(cursorXOR, 0x00, ch * ((cw + 31) >> 2));749 HCURSOR c = CreateCursor(s_instance, 0, 0, cw, ch, cursorAND, cursorXOR);750 delete[] cursorXOR;751 delete[] cursorAND;752 return c;753 }754 755 void756 CMSWindowsScreen::destroyCursor(HCURSOR cursor) const757 {758 if (cursor != NULL) {759 DestroyCursor(cursor);760 }761 }762 763 637 ATOM 764 C MSWindowsScreen::createWindowClass() const638 CPMScreen::createWindowClass() const 765 639 { 766 640 WNDCLASSEX classInfo; 767 641 classInfo.cbSize = sizeof(classInfo); 768 642 classInfo.style = CS_DBLCLKS | CS_NOCLOSE; 769 classInfo.lpfnWndProc = &C MSWindowsScreen::wndProc;643 classInfo.lpfnWndProc = &CPMScreen::wndProc; 770 644 classInfo.cbClsExtra = 0; 771 645 classInfo.cbWndExtra = 0; … … 781 655 782 656 void 783 C MSWindowsScreen::destroyClass(ATOM windowClass) const657 CPMScreen::destroyClass(ATOM windowClass) const 784 658 { 785 659 if (windowClass != 0) { … … 789 663 790 664 HWND 791 C MSWindowsScreen::createWindow(ATOM windowClass, const char* name) const665 CPMScreen::createWindow(ATOM windowClass, const char* name) const 792 666 { 793 667 HWND window = CreateWindowEx(WS_EX_TOPMOST | … … 809 683 810 684 void 811 C MSWindowsScreen::destroyWindow(HWND hwnd) const685 CPMScreen::destroyWindow(HWND hwnd) const 812 686 { 813 687 if (hwnd != NULL) { … … 817 691 818 692 void 819 C MSWindowsScreen::sendEvent(CEvent::Type type, void* data)693 CPMScreen::sendEvent(CEvent::Type type, void* data) 820 694 { 821 695 EVENTQUEUE->addEvent(CEvent(type, getEventTarget(), data)); … … 823 697 824 698 void 825 C MSWindowsScreen::sendClipboardEvent(CEvent::Type type, ClipboardID id)699 CPMScreen::sendClipboardEvent(CEvent::Type type, ClipboardID id) 826 700 { 827 701 CClipboardInfo* info = (CClipboardInfo*)malloc(sizeof(CClipboardInfo)); … … 832 706 833 707 void 834 C MSWindowsScreen::handleSystemEvent(const CEvent& event, void*)708 CPMScreen::handleSystemEvent(const CEvent& event, void*) 835 709 { 836 710 MSG* msg = reinterpret_cast<MSG*>(event.getData()); … … 848 722 849 723 void 850 C MSWindowsScreen::updateButtons()724 CPMScreen::updateButtons() 851 725 { 852 726 int numButtons = GetSystemMetrics(SM_CMOUSEBUTTONS); … … 862 736 863 737 IKeyState* 864 C MSWindowsScreen::getKeyState() const738 CPMScreen::getKeyState() const 865 739 { 866 740 return m_keyState; … … 868 742 869 743 bool 870 C MSWindowsScreen::onPreDispatch(HWND hwnd,744 CPMScreen::onPreDispatch(HWND hwnd, 871 745 UINT message, WPARAM wParam, LPARAM lParam) 872 746 { … … 889 763 890 764 bool 891 C MSWindowsScreen::onPreDispatchPrimary(HWND,765 CPMScreen::onPreDispatchPrimary(HWND, 892 766 UINT message, WPARAM wParam, LPARAM lParam) 893 767 { … … 946 820 947 821 bool 948 C MSWindowsScreen::onEvent(HWND, UINT msg,822 CPMScreen::onEvent(HWND, UINT msg, 949 823 WPARAM wParam, LPARAM lParam, LRESULT* result) 950 824 { … … 1006 880 *result = TRUE; 1007 881 return true; 1008 1009 case WM_DEVICECHANGE:1010 forceShowCursor();1011 break;1012 1013 case WM_SETTINGCHANGE:1014 if (wParam == SPI_SETMOUSEKEYS) {1015 forceShowCursor();1016 }1017 break;1018 882 } 1019 883 … … 1022 886 1023 887 bool 1024 C MSWindowsScreen::onMark(UInt32 mark)888 CPMScreen::onMark(UInt32 mark) 1025 889 { 1026 890 m_markReceived = mark; … … 1029 893 1030 894 bool 1031 C MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam)895 CPMScreen::onKey(WPARAM wParam, LPARAM lParam) 1032 896 { 1033 897 static const KeyModifierMask s_ctrlAlt = … … 1172 1036 1173 1037 bool 1174 C MSWindowsScreen::onHotKey(WPARAM wParam, LPARAM lParam)1038 CPMScreen::onHotKey(WPARAM wParam, LPARAM lParam) 1175 1039 { 1176 1040 // get the key info … … 1219 1083 1220 1084 bool 1221 C MSWindowsScreen::onMouseButton(WPARAM wParam, LPARAM lParam)1085 CPMScreen::onMouseButton(WPARAM wParam, LPARAM lParam) 1222 1086 { 1223 1087 // get which button 1224 bool pressed = mapPressFromEvent( wParam, lParam);1225 ButtonID button = mapButtonFromEvent( wParam, lParam);1088 bool pressed = mapPressFromEvent((ULONG)wParam, lParam); 1089 ButtonID button = mapButtonFromEvent((ULONG)wParam, lParam); 1226 1090 1227 1091 // keep our shadow key state up to date … … 1258 1122 1259 1123 bool 1260 C MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my)1124 CPMScreen::onMouseMove(SInt32 mx, SInt32 my) 1261 1125 { 1262 1126 // compute motion delta (relative to the last known … … 1292 1156 static SInt32 bogusZoneSize = 10; 1293 1157 if (-x + bogusZoneSize > m_xCenter - m_x || 1294 x + bogusZoneSize > m_x + m_ w- m_xCenter ||1158 x + bogusZoneSize > m_x + m_cx - m_xCenter || 1295 1159 -y + bogusZoneSize > m_yCenter - m_y || 1296 y + bogusZoneSize > m_y + m_ h- m_yCenter) {1160 y + bogusZoneSize > m_y + m_cy - m_yCenter) { 1297 1161 LOG((CLOG_DEBUG "dropped bogus motion %+d,%+d", x, y)); 1298 1162 } … … 1307 1171 1308 1172 bool 1309 C MSWindowsScreen::onMouseWheel(SInt32 xDelta, SInt32 yDelta)1173 CPMScreen::onMouseWheel(SInt32 xDelta, SInt32 yDelta) 1310 1174 { 1311 1175 // ignore message if posted prior to last mark change … … 1318 1182 1319 1183 bool 1320 C MSWindowsScreen::onScreensaver(bool activated)1184 CPMScreen::onScreensaver(bool activated) 1321 1185 { 1322 1186 // ignore this message if there are any other screen saver … … 1358 1222 1359 1223 bool 1360 C MSWindowsScreen::onDisplayChange()1224 CPMScreen::onDisplayChange() 1361 1225 { 1362 1226 // screen resolution may have changed. save old shape. 1363 SInt32 xOld = m_x, yOld = m_y, wOld = m_ w, hOld = m_h;1227 SInt32 xOld = m_x, yOld = m_y, wOld = m_cx, hOld = m_cy; 1364 1228 1365 1229 // update shape … … 1367 1231 1368 1232 // do nothing if resolution hasn't changed 1369 if (xOld != m_x || yOld != m_y || wOld != m_ w || hOld != m_h) {1233 if (xOld != m_x || yOld != m_y || wOld != m_cx || hOld != m_cy) { 1370 1234 if (m_isPrimary) { 1371 1235 // warp mouse to center if off screen … … 1376 1240 // tell hook about resize if on screen 1377 1241 else { 1378 m_setZone(m_x, m_y, m_ w, m_h, getJumpZoneSize());1242 m_setZone(m_x, m_y, m_cx, m_cy, getJumpZoneSize()); 1379 1243 } 1380 1244 } … … 1383 1247 sendEvent(getShapeChangedEvent()); 1384 1248 1385 LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_ w, m_h, m_multimon ? "(multi-monitor)" : ""));1249 LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_cx, m_cy, m_multimon ? "(multi-monitor)" : "")); 1386 1250 } 1387 1251 … … 1390 1254 1391 1255 bool 1392 C MSWindowsScreen::onClipboardChange()1256 CPMScreen::onClipboardChange() 1393 1257 { 1394 1258 // now notify client that somebody changed the clipboard (unless 1395 1259 // we're the owner). 1396 if (!C MSWindowsClipboard::isOwnedBySynergy()) {1260 if (!CPMClipboard::isOwnedBySynergy()) { 1397 1261 if (m_ownClipboard) { 1398 1262 LOG((CLOG_DEBUG "clipboard changed: lost ownership")); … … 1411 1275 1412 1276 void 1413 C MSWindowsScreen::warpCursorNoFlush(SInt32 x, SInt32 y)1277 CPMScreen::warpCursorNoFlush(SInt32 x, SInt32 y) 1414 1278 { 1415 1279 // send an event that we can recognize before the mouse warp 1416 PostThreadMessage(GetCurrentThreadId(), SYNERGY_MSG_PRE_WARP, x,y);1280 WinPostQueueMsg(m_hmq, SYNERGY_MSG_PRE_WARP, (MPARAM)x, (MPARAM)y); 1417 1281 1418 1282 // warp mouse. hopefully this inserts a mouse motion event 1419 1283 // between the previous message and the following message. 1420 SetCursorPos(x, y);1284 WinSetPointerPos(HWND_DESKTOP, x, y); 1421 1285 1422 1286 // yield the CPU. there's a race condition when warping: … … 1439 1303 1440 1304 // send an event that we can recognize after the mouse warp 1441 PostThreadMessage(GetCurrentThreadId(), SYNERGY_MSG_POST_WARP, 0, 0);1442 } 1443 1444 void 1445 C MSWindowsScreen::nextMark()1305 WinPostQueueMsg(m_hmq, SYNERGY_MSG_POST_WARP, 0, 0); 1306 } 1307 1308 void 1309 CPMScreen::nextMark() 1446 1310 { 1447 1311 // next mark … … 1449 1313 1450 1314 // mark point in message queue where the mark was changed 1451 PostThreadMessage(GetCurrentThreadId(), SYNERGY_MSG_MARK,m_mark, 0);1452 } 1453 1454 bool 1455 C MSWindowsScreen::ignore() const1315 WinPostQueueMsg(m_hmq, SYNERGY_MSG_MARK, (MPARAM)m_mark, 0); 1316 } 1317 1318 bool 1319 CPMScreen::ignore() const 1456 1320 { 1457 1321 return (m_mark != m_markReceived); … … 1459 1323 1460 1324 void 1461 C MSWindowsScreen::updateScreenShape()1325 CPMScreen::updateScreenShape() 1462 1326 { 1463 1327 // get shape 1464 m_x = GetSystemMetrics(SM_XVIRTUALSCREEN);1465 m_y = GetSystemMetrics(SM_YVIRTUALSCREEN);1466 m_ w = GetSystemMetrics(SM_CXVIRTUALSCREEN);1467 m_ h = GetSystemMetrics(SM_CYVIRTUALSCREEN);1328 m_x = 0; 1329 m_y = 0; 1330 m_cx = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN); 1331 m_cy = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN); 1468 1332 1469 1333 // get center for cursor 1470 m_xCenter = GetSystemMetrics(SM_CXSCREEN) >> 1;1471 m_yCenter = GetSystemMetrics(SM_CYSCREEN) >> 1;1334 m_xCenter = m_cx / 2; 1335 m_yCenter = m_cy / 2; 1472 1336 1473 1337 // check for multiple monitors 1474 m_multimon = (m_w != GetSystemMetrics(SM_CXSCREEN) || 1475 m_h != GetSystemMetrics(SM_CYSCREEN)); 1476 1477 // tell the desks 1478 m_desks->setShape(m_x, m_y, m_w, m_h, m_xCenter, m_yCenter, m_multimon); 1479 } 1480 1481 void 1482 CMSWindowsScreen::handleFixes(const CEvent&, void*) 1483 { 1484 // fix clipboard chain 1485 fixClipboardViewer(); 1486 1338 m_multimon = false; 1339 } 1340 1341 void 1342 CPMScreen::handleFixes(const CEvent&, void*) 1343 { 1487 1344 // update keys if keyboard layouts have changed 1488 1345 if (m_keyState->didGroupsChange()) { … … 1491 1348 } 1492 1349 1493 void1494 CMSWindowsScreen::fixClipboardViewer()1495 {1496 // XXX -- disable this code for now. somehow it can cause an infinite1497 // recursion in the WM_DRAWCLIPBOARD handler. either we're sending1498 // the message to our own window or some window farther down the chain1499 // forwards the message to our window or a window farther up the chain.1500 // i'm not sure how that could happen. the m_nextClipboardWindow = NULL1501 // was not in the code that infinite loops and may fix the bug but i1502 // doubt it.1503 return;1504 ChangeClipboardChain(m_window, m_nextClipboardWindow);1505 m_nextClipboardWindow = NULL;1506 m_nextClipboardWindow = SetClipboardViewer(m_window);1507 }1508 1509 void1510 CMSWindowsScreen::enableSpecialKeys(bool enable) const1511 {1512 // enable/disable ctrl+alt+del, alt+tab, etc on win95 family.1513 // since the win95 family doesn't support low-level hooks, we1514 // use this undocumented feature to suppress normal handling1515 // of certain key combinations.1516 if (m_is95Family) {1517 DWORD dummy = 0;1518 SystemParametersInfo(SPI_SETSCREENSAVERRUNNING,1519 enable ? FALSE : TRUE, &dummy, 0);1520 }1521 }1522 1523 1350 ButtonID 1524 CMSWindowsScreen::mapButtonFromEvent(WPARAM msg, LPARAM button) const 1525 { 1351 CPMScreen::mapButtonFromEvent(ULONG msg, MPARAM button) const 1352 { 1353 /** @todo query which is left and which is right. */ 1354 1526 1355 switch (msg) { 1527 case WM_LBUTTONDOWN: 1528 case WM_LBUTTONDBLCLK: 1529 case WM_LBUTTONUP: 1530 case WM_NCLBUTTONDOWN: 1531 case WM_NCLBUTTONDBLCLK: 1532 case WM_NCLBUTTONUP: 1533 return kButtonLeft; 1534 1535 case WM_MBUTTONDOWN: 1536 case WM_MBUTTONDBLCLK: 1537 case WM_MBUTTONUP: 1538 case WM_NCMBUTTONDOWN: 1539 case WM_NCMBUTTONDBLCLK: 1540 case WM_NCMBUTTONUP: 1541 return kButtonMiddle; 1542 1543 case WM_RBUTTONDOWN: 1544 case WM_RBUTTONDBLCLK: 1545 case WM_RBUTTONUP: 1546 case WM_NCRBUTTONDOWN: 1547 case WM_NCRBUTTONDBLCLK: 1548 case WM_NCRBUTTONUP: 1549 return kButtonRight; 1550 1551 case WM_XBUTTONDOWN: 1552 case WM_XBUTTONDBLCLK: 1553 case WM_XBUTTONUP: 1554 case WM_NCXBUTTONDOWN: 1555 case WM_NCXBUTTONDBLCLK: 1556 case WM_NCXBUTTONUP: 1557 switch (button) { 1558 case XBUTTON1: 1559 if (GetSystemMetrics(SM_CMOUSEBUTTONS) >= 4) { 1560 return kButtonExtra0 + 0; 1561 } 1562 break; 1563 1564 case XBUTTON2: 1565 if (GetSystemMetrics(SM_CMOUSEBUTTONS) >= 5) { 1566 return kButtonExtra0 + 1; 1567 } 1568 break; 1569 } 1570 return kButtonNone; 1571 1572 default: 1573 return kButtonNone; 1574 } 1575 } 1576 1577 bool 1578 CMSWindowsScreen::mapPressFromEvent(WPARAM msg, LPARAM) const 1356 case WM_BUTTON1DOWN: 1357 case WM_BUTTON1UP: 1358 case WM_BUTTON1DBLCLK: 1359 case WM_BUTTON1CLICK: //?? 1360 return kButtonLeft; 1361 1362 case WM_BUTTON2DOWN: 1363 case WM_BUTTON2UP: 1364 case WM_BUTTON2DBLCLK: 1365 case WM_BUTTON2CLICK: //?? 1366 return kButtonLeft; 1367 1368 case WM_BUTTON3DOWN: 1369 case WM_BUTTON3UP: 1370 case WM_BUTTON3DBLCLK: 1371 case WM_BUTTON3CLICK: //?? 1372 return kButtonMiddle; 1373 default: 1374 return kButtonNone; 1375 } 1376 } 1377 1378 bool 1379 CPMScreen::mapPressFromEvent(ULONG msg, LPARAM) const 1579 1380 { 1580 1381 switch (msg) { 1581 case WM_LBUTTONDOWN: 1582 case WM_MBUTTONDOWN: 1583 case WM_RBUTTONDOWN: 1584 case WM_XBUTTONDOWN: 1585 case WM_LBUTTONDBLCLK: 1586 case WM_MBUTTONDBLCLK: 1587 case WM_RBUTTONDBLCLK: 1588 case WM_XBUTTONDBLCLK: 1589 case WM_NCLBUTTONDOWN: 1590 case WM_NCMBUTTONDOWN: 1591 case WM_NCRBUTTONDOWN: 1592 case WM_NCXBUTTONDOWN: 1593 case WM_NCLBUTTONDBLCLK: 1594 case WM_NCMBUTTONDBLCLK: 1595 case WM_NCRBUTTONDBLCLK: 1596 case WM_NCXBUTTONDBLCLK: 1597 return true; 1598 1599 case WM_LBUTTONUP: 1600 case WM_MBUTTONUP: 1601 case WM_RBUTTONUP: 1602 case WM_XBUTTONUP: 1603 case WM_NCLBUTTONUP: 1604 case WM_NCMBUTTONUP: 1605 case WM_NCRBUTTONUP: 1606 case WM_NCXBUTTONUP: 1607 return false; 1608 1609 default: 1610 return false; 1611 } 1612 } 1613 1614 void 1615 CMSWindowsScreen::updateKeysCB(void*) 1382 case WM_BUTTON1DOWN: 1383 case WM_BUTTON1CLICK: //?? 1384 case WM_BUTTON1DBLCLK: 1385 case WM_BUTTON2DOWN: 1386 case WM_BUTTON2DBLCLK: 1387 case WM_BUTTON2CLICK: //?? 1388 case WM_BUTTON3DOWN: 1389 case WM_BUTTON3DBLCLK: 1390 case WM_BUTTON3CLICK: //?? 1391 return true; 1392 case WM_BUTTON1UP: 1393 case WM_BUTTON2UP: 1394 case WM_BUTTON3UP: 1395 return false; 1396 default: 1397 return false; 1398 } 1399 } 1400 1401 void 1402 CPMScreen::updateKeysCB(void*) 1616 1403 { 1617 1404 // record which keys we think are down … … 1646 1433 1647 1434 void 1648 C MSWindowsScreen::forceShowCursor()1649 { 1650 // check for mouse 1651 m_hasMouse = (GetSystemMetrics(SM_MOUSEPRESENT) != 0);1435 CPMScreen::forceShowCursor() 1436 { 1437 // check for mouse - probably not required. 1438 m_hasMouse = WinQuerySysValue(HWND_DESKTOP, SV_MOUSEPRESENT) != FALSE; 1652 1439 1653 1440 // decide if we should show the mouse … … 1656 1443 // show/hide the mouse 1657 1444 if (showMouse != m_showingMouse) { 1658 if (showMouse) { 1659 m_oldMouseKeys.cbSize = sizeof(m_oldMouseKeys); 1660 m_gotOldMouseKeys = 1661 (SystemParametersInfo(SPI_GETMOUSEKEYS, 1662 m_oldMouseKeys.cbSize, &m_oldMouseKeys, 0) != 0); 1663 if (m_gotOldMouseKeys) { 1664 m_mouseKeys = m_oldMouseKeys; 1665 m_showingMouse = true; 1666 updateForceShowCursor(); 1667 } 1668 } 1669 else { 1670 if (m_gotOldMouseKeys) { 1671 SystemParametersInfo(SPI_SETMOUSEKEYS, 1672 m_oldMouseKeys.cbSize, 1673 &m_oldMouseKeys, SPIF_SENDCHANGE); 1674 m_showingMouse = false; 1675 } 1676 } 1677 } 1678 } 1679 1680 void 1681 CMSWindowsScreen::updateForceShowCursor() 1682 { 1683 DWORD oldFlags = m_mouseKeys.dwFlags; 1684 1685 // turn on MouseKeys 1686 m_mouseKeys.dwFlags = MKF_AVAILABLE | MKF_MOUSEKEYSON; 1687 1688 // make sure MouseKeys is active in whatever state the NumLock is 1689 // not currently in. 1690 if ((m_keyState->getActiveModifiers() & KeyModifierNumLock) != 0) { 1691 m_mouseKeys.dwFlags |= MKF_REPLACENUMBERS; 1692 } 1693 1694 // update MouseKeys 1695 if (oldFlags != m_mouseKeys.dwFlags) { 1696 SystemParametersInfo(SPI_SETMOUSEKEYS, 1697 m_mouseKeys.cbSize, &m_mouseKeys, SPIF_SENDCHANGE); 1698 } 1699 } 1700 1701 LRESULT CALLBACK 1702 CMSWindowsScreen::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1445 WinShowPointer(HWND_DESKTOP, showMouse); 1446 m_showingMouse = WinQuerySysValue(HWND_DESKTOP, SV_POINTERLEVEL) != 0; 1447 } 1448 } 1449 1450 void 1451 CPMScreen::updateForceShowCursor() 1452 { 1453 //??? 1454 } 1455 1456 HRESULT EXPENTRY 1457 CPMScreen::wndProc(HWND hwnd, UINT msg, MPARAM mp1, MPARAM mp2) 1703 1458 { 1704 1459 assert(s_screen != NULL); 1705 1460 1706 LRESULT result= 0;1707 if (!s_screen->onEvent(hwnd, msg, wParam, lParam, &result)) {1708 result = DefWindowProc(hwnd, msg, wParam, lParam);1709 } 1710 1711 return result;1461 HRESULT mr = 0; 1462 if (!s_screen->onEvent(hwnd, msg, mp1, mp2, &result)) { 1463 mr = WinDefWindowProc(hwnd, msg, mp1, mp2); 1464 } 1465 1466 return mr; 1712 1467 } 1713 1468 1714 1469 1715 1470 // 1716 // C MSWindowsScreen::CHotKeyItem1471 // CPMScreen::CHotKeyItem 1717 1472 // 1718 1473 1719 C MSWindowsScreen::CHotKeyItem::CHotKeyItem(UINT keycode, UINT mask) :1474 CPMScreen::CHotKeyItem::CHotKeyItem(UINT keycode, UINT mask) : 1720 1475 m_keycode(keycode), 1721 1476 m_mask(mask) … … 1725 1480 1726 1481 UINT 1727 C MSWindowsScreen::CHotKeyItem::getVirtualKey() const1482 CPMScreen::CHotKeyItem::getVirtualKey() const 1728 1483 { 1729 1484 return m_keycode; … … 1731 1486 1732 1487 bool 1733 C MSWindowsScreen::CHotKeyItem::operator<(const CHotKeyItem& x) const1488 CPMScreen::CHotKeyItem::operator<(const CHotKeyItem& x) const 1734 1489 { 1735 1490 return (m_keycode < x.m_keycode || -
trunk/synergy/lib/platform/CPMScreen.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2002 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C MSWINDOWSSCREEN_H16 #define C MSWINDOWSSCREEN_H16 #ifndef CPMSCREEN_H 17 #define CPMSCREEN_H 17 18 18 19 #include "CPlatformScreen.h" 19 #include "C SynergyHook.h"20 #include "CPMSynergyHook.h" 20 21 #include "CCondVar.h" 21 22 #include "CMutex.h" 22 23 #include "CString.h" 23 #define WIN32_LEAN_AND_MEAN 24 #include <windows.h> 24 #define INCL_ERRORS 25 #define INCL_BASE 26 #define INCL_PM 27 #include <os2.h> 28 25 29 26 30 class CEventQueueTimer; 27 class C MSWindowsDesks;28 class C MSWindowsKeyState;29 class C MSWindowsScreenSaver;31 class CPMDesks; 32 class CPMKeyState; 33 class CPMScreenSaver; 30 34 class CThread; 31 35 32 //! Implementation of IPlatformScreen for Microsoft Windows33 class C MSWindowsScreen : public CPlatformScreen {36 //! Implementation of IPlatformScreen for PM 37 class CPMScreen : public CPlatformScreen { 34 38 public: 35 CMSWindowsScreen(bool isPrimary); 36 virtual ~CMSWindowsScreen(); 37 38 //! @name manipulators 39 //@{ 40 41 //! Initialize 42 /*! 43 Saves the application's HINSTANCE. This \b must be called by 44 WinMain with the HINSTANCE it was passed. 45 */ 46 static void init(HINSTANCE); 47 48 //@} 49 //! @name accessors 50 //@{ 51 52 //! Get instance 53 /*! 54 Returns the application instance handle passed to init(). 55 */ 56 static HINSTANCE getInstance(); 57 58 //@} 39 CPMScreen(bool isPrimary); 40 virtual ~CPMScreen(); 59 41 60 42 // IScreen overrides 61 43 virtual void* getEventTarget() const; 62 44 virtual bool getClipboard(ClipboardID id, IClipboard*) const; 63 virtual void getShape(SInt32& x, SInt32& y, 64 SInt32& width, SInt32& height) const; 45 virtual void getShape(SInt32& x, SInt32& y, SInt32& cx, SInt32& cy) const; 65 46 virtual void getCursorPos(SInt32& x, SInt32& y) const; 66 47 … … 115 96 private: 116 97 // initialization and shutdown operations 117 HINSTANCE openHookLibrary(const char* name); 118 void closeHookLibrary(HINSTANCE hookLibrary) const; 119 HCURSOR createBlankCursor() const; 120 void destroyCursor(HCURSOR cursor) const; 98 HMODULE openHookLibrary(const char* name); 99 void closeHookLibrary(HMODULE hookLibrary) const; 121 100 ATOM createWindowClass() const; 122 101 ATOM createDeskWindowClass(bool isPrimary) const; … … 131 110 // handle message before it gets dispatched. returns true iff 132 111 // the message should not be dispatched. 133 bool onPreDispatch(HWND, U INT, WPARAM, LPARAM);112 bool onPreDispatch(HWND, ULONG, MPARAM, MPARAM); 134 113 135 114 // handle message before it gets dispatched. returns true iff 136 115 // the message should not be dispatched. 137 bool onPreDispatchPrimary(HWND, U INT, WPARAM, LPARAM);116 bool onPreDispatchPrimary(HWND, ULONG, MPARAM, MPARAM); 138 117 139 118 // handle message. returns true iff handled and optionally sets 140 119 // \c *result (which defaults to 0). 141 bool onEvent(HWND, U INT, WPARAM, LPARAM, LRESULT* result);120 bool onEvent(HWND, ULONG, MPARAM, MPARAM, MRESULT*); 142 121 143 122 // message handlers 144 123 bool onMark(UInt32 mark); 145 bool onKey( WPARAM, LPARAM);146 bool onHotKey( WPARAM, LPARAM);147 bool onMouseButton( WPARAM, LPARAM);124 bool onKey(MPARAM, MPARAM); 125 bool onHotKey(MPARAM, MPARAM); 126 bool onMouseButton(MPARAM, MPARAM); 148 127 bool onMouseMove(SInt32 x, SInt32 y); 149 128 bool onMouseWheel(SInt32 xDelta, SInt32 yDelta); … … 167 146 void handleFixes(const CEvent&, void*); 168 147 169 // fix the clipboard viewer chain170 void fixClipboardViewer();171 172 148 // enable/disable special key combinations so we can catch/pass them 173 149 void enableSpecialKeys(bool) const; 174 150 175 151 // map a button event to a button ID 176 ButtonID mapButtonFromEvent( WPARAM msg, LPARAM button) const;152 ButtonID mapButtonFromEvent(ULONG msg, MPARAM button) const; 177 153 178 154 // map a button event to a press (true) or release (false) 179 bool mapPressFromEvent( WPARAM msg, LPARAM button) const;155 bool mapPressFromEvent(ULONG msg, MPARAM button) const; 180 156 181 157 // job to update the key state … … 193 169 194 170 // our window proc 195 static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);171 static MRESULT EXPENTRY wndProc(HWND, ULONG, MPARAM, MPARAM); 196 172 197 173 private: 198 174 struct CHotKeyItem { 199 175 public: 200 CHotKeyItem(U INT vk, UINTmodifiers);201 202 U INTgetVirtualKey() const;176 CHotKeyItem(ULONG vk, ULONG modifiers); 177 178 ULONG getVirtualKey() const; 203 179 204 180 bool operator<(const CHotKeyItem&) const; 205 181 206 182 private: 207 U INTm_keycode;208 U INTm_mask;183 ULONG m_keycode; 184 ULONG m_mask; 209 185 }; 210 186 typedef std::map<UInt32, CHotKeyItem> HotKeyMap; … … 212 188 typedef std::map<CHotKeyItem, UInt32> HotKeyToIDMap; 213 189 214 static HINSTANCE s_instance;215 216 190 // true if screen is being used as a primary screen, false otherwise 217 191 bool m_isPrimary; 218 219 // true if windows 95/98/me220 bool m_is95Family;221 222 // true if mouse has entered the screen223 192 bool m_isOnScreen; 224 193 … … 228 197 // screen shape stuff 229 198 SInt32 m_x, m_y; 230 SInt32 m_ w, m_h;199 SInt32 m_cx, m_cy; 231 200 SInt32 m_xCenter, m_yCenter; 232 201 … … 245 214 246 215 // the main loop's thread id 247 DWORDm_threadID;216 int m_threadID; 248 217 249 218 // timer for periodically checking stuff that requires polling 250 219 CEventQueueTimer* m_fixTimer; 251 220 252 // the keyboard layout to use when off primary screen253 HKL m_keyLayout;254 255 221 // screen saver stuff 256 C MSWindowsScreenSaver* m_screensaver;222 CPMScreenSaver* m_screensaver; 257 223 bool m_screensaverNotify; 258 224 bool m_screensaverActive; … … 264 230 bool m_ownClipboard; 265 231 266 // one desk per desktop and a cond var to communicate with it267 CMSWindowsDesks* m_desks;268 269 232 // hook library stuff 270 H INSTANCE m_hookLibrary;233 HMODULE m_hmodHook; 271 234 InitFunc m_init; 272 235 CleanupFunc m_cleanup; … … 276 239 277 240 // keyboard stuff 278 C MSWindowsKeyState*m_keyState;241 CPMKeyState* m_keyState; 279 242 280 243 // hot key stuff … … 286 249 bool m_buttons[1 + kButtonExtra0 + 1]; 287 250 288 // the system shows the mouse cursor when an internal display count289 // is >= 0. this count is maintained per application but there's290 // apparently a system wide count added to the application's count.291 // this system count is 0 if there's a mouse attached to the system292 // and -1 otherwise. the MouseKeys accessibility feature can modify293 // this system count by making the system appear to have a mouse.294 //295 // m_hasMouse is true iff there's a mouse attached to the system or296 // MouseKeys is simulating one. we track this so we can force the297 // cursor to be displayed when the user has entered this screen.298 // m_showingMouse is true when we're doing that.299 251 bool m_hasMouse; 300 252 bool m_showingMouse; 301 bool m_gotOldMouseKeys; 302 MOUSEKEYS m_mouseKeys; 303 MOUSEKEYS m_oldMouseKeys; 304 305 static CMSWindowsScreen* s_screen; 253 254 static CPMScreen* s_screen; 306 255 }; 307 256 -
trunk/synergy/lib/platform/CPMScreenSaver.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2002 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "CMSWindowsScreenSaver.h" 16 #include "CMSWindowsScreen.h" 17 #include "CThread.h" 18 #include "CLog.h" 19 #include "TMethodJob.h" 20 #include "CArch.h" 21 #include "CArchMiscWindows.h" 22 #include <malloc.h> 23 #include <tchar.h> 24 25 #if !defined(SPI_GETSCREENSAVERRUNNING) 26 #define SPI_GETSCREENSAVERRUNNING 114 27 #endif 28 29 static const TCHAR* g_isSecureNT = "ScreenSaverIsSecure"; 30 static const TCHAR* g_isSecure9x = "ScreenSaveUsePassword"; 31 static const TCHAR* const g_pathScreenSaverIsSecure[] = { 32 "Control Panel", 33 "Desktop", 34 NULL 35 }; 16 #include "CPMScreenSaver.h" 36 17 37 18 // 38 // C MSWindowsScreenSaver19 // CPMScreenSaver 39 20 // 40 21 41 CMSWindowsScreenSaver::CMSWindowsScreenSaver() : 42 m_wasSecure(false), 43 m_wasSecureAnInt(false), 44 m_process(NULL), 45 m_watch(NULL), 46 m_threadID(0), 47 m_active(false) 22 CPMScreenSaver::CPMScreenSaver() 48 23 { 49 // detect OS50 m_is95Family = false;51 m_is95 = false;52 m_isNT = false;53 OSVERSIONINFO info;54 info.dwOSVersionInfoSize = sizeof(info);55 if (GetVersionEx(&info)) {56 m_is95Family = (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);57 if (info.dwPlatformId == VER_PLATFORM_WIN32_NT &&58 info.dwMajorVersion <= 4) {59 m_isNT = true;60 }61 else if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS &&62 info.dwMajorVersion == 4 &&63 info.dwMinorVersion == 0) {64 m_is95 = true;65 }66 }67 68 // check if screen saver is enabled69 SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &m_wasEnabled, 0);70 24 } 71 25 72 C MSWindowsScreenSaver::~CMSWindowsScreenSaver()26 CPMScreenSaver::~CPMScreenSaver() 73 27 { 74 unwatchProcess(); 28 } 29 30 void 31 CPMScreenSaver::enable() 32 { 33 } 34 35 void 36 CPMScreenSaver::disable() 37 { 38 } 39 40 void 41 CPMScreenSaver::activate() 42 { 43 } 44 45 void 46 CPMScreenSaver::deactivate() 47 { 75 48 } 76 49 77 50 bool 78 C MSWindowsScreenSaver::checkStarted(UINT msg, WPARAM wParam, LPARAM lParam)51 CPMScreenSaver::isActive() const 79 52 { 80 // if already started then say it didn't just start 81 if (m_active) { 82 return false; 83 } 84 85 // screen saver may have started. look for it and get 86 // the process. if we can't find it then assume it 87 // didn't really start. we wait a moment before 88 // looking to give the screen saver a chance to start. 89 // this shouldn't be a problem since we only get here 90 // if the screen saver wants to kick in, meaning that 91 // the system is idle or the user deliberately started 92 // the screen saver. 93 Sleep(250); 94 95 // set parameters common to all screen saver handling 96 m_threadID = GetCurrentThreadId(); 97 m_msg = msg; 98 m_wParam = wParam; 99 m_lParam = lParam; 100 101 // we handle the screen saver differently for the windows 102 // 95 and nt families. 103 if (m_is95Family) { 104 // on windows 95 we wait for the screen saver process 105 // to terminate. get the process. 106 DWORD processID = findScreenSaver(); 107 HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, processID); 108 if (process == NULL) { 109 // didn't start 110 LOG((CLOG_DEBUG2 "can't open screen saver process")); 111 return false; 112 } 113 114 // watch for the process to exit 115 watchProcess(process); 116 } 117 else { 118 // on the windows nt family we wait for the desktop to 119 // change until it's neither the Screen-Saver desktop 120 // nor a desktop we can't open (the login desktop). 121 // since windows will send the request-to-start-screen- 122 // saver message even when the screen saver is disabled 123 // we first check that the screen saver is indeed active 124 // before watching for it to stop. 125 if (!isActive()) { 126 LOG((CLOG_DEBUG2 "can't open screen saver desktop")); 127 return false; 128 } 129 130 watchDesktop(); 131 } 132 133 return true; 53 return false; 134 54 } 135 55 136 void137 CMSWindowsScreenSaver::enable()138 {139 SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, m_wasEnabled, 0, 0);140 141 // restore password protection142 if (m_wasSecure) {143 setSecure(true, m_wasSecureAnInt);144 }145 146 // restore display power down147 CArchMiscWindows::removeBusyState(CArchMiscWindows::kDISPLAY);148 }149 150 void151 CMSWindowsScreenSaver::disable()152 {153 SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &m_wasEnabled, 0);154 SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, 0, 0);155 156 // disable password protected screensaver157 m_wasSecure = isSecure(&m_wasSecureAnInt);158 if (m_wasSecure) {159 setSecure(false, m_wasSecureAnInt);160 }161 162 // disable display power down163 CArchMiscWindows::addBusyState(CArchMiscWindows::kDISPLAY);164 }165 166 void167 CMSWindowsScreenSaver::activate()168 {169 // don't activate if already active170 if (!isActive()) {171 // activate172 HWND hwnd = GetForegroundWindow();173 if (hwnd != NULL) {174 PostMessage(hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0);175 }176 else {177 // no foreground window. pretend we got the event instead.178 DefWindowProc(NULL, WM_SYSCOMMAND, SC_SCREENSAVE, 0);179 }180 181 // restore power save when screen saver activates182 CArchMiscWindows::removeBusyState(CArchMiscWindows::kDISPLAY);183 }184 }185 186 void187 CMSWindowsScreenSaver::deactivate()188 {189 bool killed = false;190 if (!m_is95Family) {191 // NT runs screen saver in another desktop192 HDESK desktop = OpenDesktop("Screen-saver", 0, FALSE,193 DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS);194 if (desktop != NULL) {195 EnumDesktopWindows(desktop,196 &CMSWindowsScreenSaver::killScreenSaverFunc,197 reinterpret_cast<LPARAM>(&killed));198 CloseDesktop(desktop);199 }200 }201 202 // if above failed or wasn't tried, try the windows 95 way203 if (!killed) {204 // find screen saver window and close it205 HWND hwnd = FindWindow("WindowsScreenSaverClass", NULL);206 if (hwnd == NULL) {207 // win2k may use a different class208 hwnd = FindWindow("Default Screen Saver", NULL);209 }210 if (hwnd != NULL) {211 PostMessage(hwnd, WM_CLOSE, 0, 0);212 }213 }214 215 // force timer to restart216 SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &m_wasEnabled, 0);217 SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,218 !m_wasEnabled, 0, SPIF_SENDWININICHANGE);219 SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,220 m_wasEnabled, 0, SPIF_SENDWININICHANGE);221 222 // disable display power down223 CArchMiscWindows::removeBusyState(CArchMiscWindows::kDISPLAY);224 }225 226 bool227 CMSWindowsScreenSaver::isActive() const228 {229 if (m_is95) {230 return (FindWindow("WindowsScreenSaverClass", NULL) != NULL);231 }232 else if (m_isNT) {233 // screen saver runs on a separate desktop234 HDESK desktop = OpenDesktop("Screen-saver", 0, FALSE, MAXIMUM_ALLOWED);235 if (desktop == NULL && GetLastError() != ERROR_ACCESS_DENIED) {236 // desktop doesn't exist so screen saver is not running237 return false;238 }239 240 // desktop exists. this should indicate that the screen saver241 // is running but an OS bug can cause a valid handle to be242 // returned even if the screen saver isn't running (Q230117).243 // we'll try to enumerate the windows on the desktop and, if244 // there are any, we assume the screen saver is running. (note245 // that if we don't have permission to enumerate then we'll246 // assume that the screen saver is not running.) that'd be247 // easy enough except there's another OS bug (Q198590) that can248 // cause EnumDesktopWindows() to enumerate the windows of249 // another desktop if the requested desktop has no windows. to250 // work around that we have to verify that the enumerated251 // windows are, in fact, on the expected desktop.252 CFindScreenSaverInfo info;253 info.m_desktop = desktop;254 info.m_window = NULL;255 EnumDesktopWindows(desktop,256 &CMSWindowsScreenSaver::findScreenSaverFunc,257 reinterpret_cast<LPARAM>(&info));258 259 // done with desktop260 CloseDesktop(desktop);261 262 // screen saver is running if a window was found263 return (info.m_window != NULL);264 }265 else {266 BOOL running;267 SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &running, 0);268 return (running != FALSE);269 }270 }271 272 BOOL CALLBACK273 CMSWindowsScreenSaver::findScreenSaverFunc(HWND hwnd, LPARAM arg)274 {275 CFindScreenSaverInfo* info = reinterpret_cast<CFindScreenSaverInfo*>(arg);276 277 if (info->m_desktop != NULL) {278 DWORD threadID = GetWindowThreadProcessId(hwnd, NULL);279 HDESK desktop = GetThreadDesktop(threadID);280 if (desktop != NULL && desktop != info->m_desktop) {281 // stop enumerating -- wrong desktop282 return FALSE;283 }284 }285 286 // found a window287 info->m_window = hwnd;288 289 // don't need to enumerate further290 return FALSE;291 }292 293 BOOL CALLBACK294 CMSWindowsScreenSaver::killScreenSaverFunc(HWND hwnd, LPARAM arg)295 {296 if (IsWindowVisible(hwnd)) {297 HINSTANCE instance = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);298 if (instance != CMSWindowsScreen::getInstance()) {299 PostMessage(hwnd, WM_CLOSE, 0, 0);300 *reinterpret_cast<bool*>(arg) = true;301 }302 }303 return TRUE;304 }305 306 DWORD307 CMSWindowsScreenSaver::findScreenSaver()308 {309 // try windows 95 way310 HWND hwnd = FindWindow("WindowsScreenSaverClass", NULL);311 312 // get process ID of process that owns the window, if found313 if (hwnd != NULL) {314 DWORD processID;315 GetWindowThreadProcessId(hwnd, &processID);316 return processID;317 }318 319 // not found320 return 0;321 }322 323 void324 CMSWindowsScreenSaver::watchDesktop()325 {326 // stop watching previous process/desktop327 unwatchProcess();328 329 // watch desktop in another thread330 LOG((CLOG_DEBUG "watching screen saver desktop"));331 m_active = true;332 m_watch = new CThread(new TMethodJob<CMSWindowsScreenSaver>(this,333 &CMSWindowsScreenSaver::watchDesktopThread));334 }335 336 void337 CMSWindowsScreenSaver::watchProcess(HANDLE process)338 {339 // stop watching previous process/desktop340 unwatchProcess();341 342 // watch new process in another thread343 if (process != NULL) {344 LOG((CLOG_DEBUG "watching screen saver process"));345 m_process = process;346 m_active = true;347 m_watch = new CThread(new TMethodJob<CMSWindowsScreenSaver>(this,348 &CMSWindowsScreenSaver::watchProcessThread));349 }350 }351 352 void353 CMSWindowsScreenSaver::unwatchProcess()354 {355 if (m_watch != NULL) {356 LOG((CLOG_DEBUG "stopped watching screen saver process/desktop"));357 m_watch->cancel();358 m_watch->wait();359 delete m_watch;360 m_watch = NULL;361 m_active = false;362 }363 if (m_process != NULL) {364 CloseHandle(m_process);365 m_process = NULL;366 }367 }368 369 void370 CMSWindowsScreenSaver::watchDesktopThread(void*)371 {372 DWORD reserved = 0;373 TCHAR* name = NULL;374 375 for (;;) {376 // wait a bit377 ARCH->sleep(0.2);378 379 if (m_isNT) {380 // get current desktop381 HDESK desk = OpenInputDesktop(0, FALSE, GENERIC_READ);382 if (desk == NULL) {383 // can't open desktop so keep waiting384 continue;385 }386 387 // get current desktop name length388 DWORD size;389 GetUserObjectInformation(desk, UOI_NAME, NULL, 0, &size);390 391 // allocate more space for the name, if necessary392 if (size > reserved) {393 reserved = size;394 name = (TCHAR*)alloca(reserved + sizeof(TCHAR));395 }396 397 // get current desktop name398 GetUserObjectInformation(desk, UOI_NAME, name, size, &size);399 CloseDesktop(desk);400 401 // compare name to screen saver desktop name402 if (_tcsicmp(name, TEXT("Screen-saver")) == 0) {403 // still the screen saver desktop so keep waiting404 continue;405 }406 }407 else {408 // 2000/XP have a sane way to detect a runnin screensaver.409 BOOL running;410 SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &running, 0);411 if (running) {412 continue;413 }414 }415 416 // send screen saver deactivation message417 m_active = false;418 PostThreadMessage(m_threadID, m_msg, m_wParam, m_lParam);419 return;420 }421 }422 423 void424 CMSWindowsScreenSaver::watchProcessThread(void*)425 {426 for (;;) {427 CThread::testCancel();428 if (WaitForSingleObject(m_process, 50) == WAIT_OBJECT_0) {429 // process terminated430 LOG((CLOG_DEBUG "screen saver died"));431 432 // send screen saver deactivation message433 m_active = false;434 PostThreadMessage(m_threadID, m_msg, m_wParam, m_lParam);435 return;436 }437 }438 }439 440 void441 CMSWindowsScreenSaver::setSecure(bool secure, bool saveSecureAsInt)442 {443 HKEY hkey =444 CArchMiscWindows::addKey(HKEY_CURRENT_USER, g_pathScreenSaverIsSecure);445 if (hkey == NULL) {446 return;447 }448 449 const TCHAR* isSecure = m_is95Family ? g_isSecure9x : g_isSecureNT;450 if (saveSecureAsInt) {451 CArchMiscWindows::setValue(hkey, isSecure, secure ? 1 : 0);452 }453 else {454 CArchMiscWindows::setValue(hkey, isSecure, secure ? "1" : "0");455 }456 457 CArchMiscWindows::closeKey(hkey);458 }459 460 bool461 CMSWindowsScreenSaver::isSecure(bool* wasSecureFlagAnInt) const462 {463 // get the password protection setting key464 HKEY hkey =465 CArchMiscWindows::openKey(HKEY_CURRENT_USER, g_pathScreenSaverIsSecure);466 if (hkey == NULL) {467 return false;468 }469 470 // get the value. the value may be an int or a string, depending471 // on the version of windows.472 bool result;473 const TCHAR* isSecure = m_is95Family ? g_isSecure9x : g_isSecureNT;474 switch (CArchMiscWindows::typeOfValue(hkey, isSecure)) {475 default:476 result = false;477 break;478 479 case CArchMiscWindows::kUINT: {480 DWORD value =481 CArchMiscWindows::readValueInt(hkey, isSecure);482 *wasSecureFlagAnInt = true;483 result = (value != 0);484 break;485 }486 487 case CArchMiscWindows::kSTRING: {488 std::string value =489 CArchMiscWindows::readValueString(hkey, isSecure);490 *wasSecureFlagAnInt = false;491 result = (value != "0");492 break;493 }494 }495 496 CArchMiscWindows::closeKey(hkey);497 return result;498 } -
trunk/synergy/lib/platform/CPMScreenSaver.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2002 Chris Schoeneman 4 * Copyright (C) 2006 Knut St Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C MSWINDOWSSCREENSAVER_H16 #define C MSWINDOWSSCREENSAVER_H16 #ifndef CPMSCREENSAVER_H 17 #define CPMSCREENSAVER_H 17 18 18 19 #include "IScreenSaver.h" 19 20 #include "CString.h" 20 #define WIN32_LEAN_AND_MEAN 21 #include <windows.h> 21 #define INCL_ERRORS 22 #define INCL_BASE 23 #define INCL_PM 24 #include <os2.h> 22 25 23 26 class CThread; 24 27 25 //! Microsoft windows screen saver implementation26 class C MSWindowsScreenSaver : public IScreenSaver {28 //! PM screen saver implementation (stub) 29 class CPMScreenSaver : public IScreenSaver { 27 30 public: 28 CMSWindowsScreenSaver(); 29 virtual ~CMSWindowsScreenSaver(); 30 31 //! @name manipulators 32 //@{ 33 34 //! Check if screen saver started 35 /*! 36 Check if the screen saver really started. Returns false if it 37 hasn't, true otherwise. When the screen saver stops, \c msg will 38 be posted to the current thread's message queue with the given 39 parameters. 40 */ 41 bool checkStarted(UINT msg, WPARAM, LPARAM); 42 43 //@} 31 CPMScreenSaver(); 32 virtual ~CPMScreenSaver(); 44 33 45 34 // IScreenSaver overrides … … 51 40 52 41 private: 53 class CFindScreenSaverInfo {54 public:55 HDESK m_desktop;56 HWND m_window;57 };58 59 static BOOL CALLBACK findScreenSaverFunc(HWND hwnd, LPARAM lParam);60 static BOOL CALLBACK killScreenSaverFunc(HWND hwnd, LPARAM lParam);61 62 DWORD findScreenSaver();63 void watchDesktop();64 void watchProcess(HANDLE process);65 void unwatchProcess();66 void watchDesktopThread(void*);67 void watchProcessThread(void*);68 69 void setSecure(bool secure, bool saveSecureAsInt);70 bool isSecure(bool* wasSecureAnInt) const;71 72 private:73 bool m_is95Family;74 bool m_is95;75 bool m_isNT;76 BOOL m_wasEnabled;77 bool m_wasSecure;78 bool m_wasSecureAnInt;79 80 HANDLE m_process;81 CThread* m_watch;82 DWORD m_threadID;83 UINT m_msg;84 WPARAM m_wParam;85 LPARAM m_lParam;86 87 // checkActive state. true if the screen saver is being watched88 // for deactivation (and is therefore active).89 bool m_active;90 42 }; 91 43 -
trunk/synergy/lib/platform/CPMSynergyHook.h
r2751 r2752 17 17 18 18 #include "BasicTypes.h" 19 #define WIN32_LEAN_AND_MEAN 20 #include <windows.h> 19 #define INCL_BASE 20 #define INCL_ERRORS 21 #define INCL_PM 22 #include <os2.h> 21 23 22 24 #if defined(SYNRGYHK_EXPORTS) 23 # define CSYNERGYHOOK_API __declspec(dllexport)25 # define CSYNERGYHOOK_API __declspec(dllexport) 24 26 #else 25 # define CSYNERGYHOOK_API __declspec(dllimport)27 # define CSYNERGYHOOK_API __declspec(dllimport) 26 28 #endif 27 29 28 #define SYNERGY_MSG_MARK WM_ APP+ 0x0011 // mark id; <unused>29 #define SYNERGY_MSG_KEY WM_ APP+ 0x0012 // vk code; key data30 #define SYNERGY_MSG_MOUSE_BUTTON WM_ APP+ 0x0013 // button msg; <unused>31 #define SYNERGY_MSG_MOUSE_WHEEL WM_ APP+ 0x0014 // delta; <unused>32 #define SYNERGY_MSG_MOUSE_MOVE WM_ APP+ 0x0015 // x; y33 #define SYNERGY_MSG_POST_WARP WM_ APP+ 0x0016 // <unused>; <unused>34 #define SYNERGY_MSG_PRE_WARP WM_ APP+ 0x0017 // x; y35 #define SYNERGY_MSG_SCREEN_SAVER WM_ APP+ 0x0018 // activated; <unused>36 #define SYNERGY_MSG_DEBUG WM_ APP+ 0x0019 // data, data30 #define SYNERGY_MSG_MARK WM_USER + 0x0011 // mark id; <unused> 31 #define SYNERGY_MSG_KEY WM_USER + 0x0012 // vk code; key data 32 #define SYNERGY_MSG_MOUSE_BUTTON WM_USER + 0x0013 // button msg; <unused> 33 #define SYNERGY_MSG_MOUSE_WHEEL WM_USER + 0x0014 // delta; <unused> 34 #define SYNERGY_MSG_MOUSE_MOVE WM_USER + 0x0015 // x; y 35 #define SYNERGY_MSG_POST_WARP WM_USER + 0x0016 // <unused>; <unused> 36 #define SYNERGY_MSG_PRE_WARP WM_USER + 0x0017 // x; y 37 #define SYNERGY_MSG_SCREEN_SAVER WM_USER + 0x0018 // activated; <unused> 38 #define SYNERGY_MSG_DEBUG WM_USER + 0x0019 // data, data 37 39 #define SYNERGY_MSG_INPUT_FIRST SYNERGY_MSG_KEY 38 40 #define SYNERGY_MSG_INPUT_LAST SYNERGY_MSG_PRE_WARP … … 56 58 }; 57 59 58 typedef int (*InitFunc)( DWORD targetQueueThreadID);60 typedef int (*InitFunc)(HMQ hmq, int tid, int pid); 59 61 typedef int (*CleanupFunc)(void); 60 62 typedef EHookResult (*InstallFunc)(void); … … 66 68 typedef void (*SetModeFunc)(int); 67 69 68 CSYNERGYHOOK_API int init( DWORD);70 CSYNERGYHOOK_API int init(HMQ hmq, int tid, int pid); 69 71 CSYNERGYHOOK_API int cleanup(void); 70 72 CSYNERGYHOOK_API EHookResult install(void); … … 73 75 CSYNERGYHOOK_API int uninstallScreenSaver(void); 74 76 CSYNERGYHOOK_API void setSides(UInt32 sides); 75 CSYNERGYHOOK_API void setZone(SInt32 x, SInt32 y, SInt32 w, SInt32 h, 76 SInt32 jumpZoneSize); 77 CSYNERGYHOOK_API void setZone(SInt32 x, SInt32 y, SInt32 cx, SInt32 cy, SInt32 jumpZoneSize); 77 78 CSYNERGYHOOK_API void setMode(EHookMode mode); 78 79 -
trunk/synergy/lib/platform/CPMUtil.cpp
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #include "C MSWindowsUtil.h"16 #include "CPMUtil.h" 16 17 #include "CStringUtil.h" 17 18 #include <stdio.h> 18 19 19 20 // 20 // C MSWindowsUtil21 // CPMUtil 21 22 // 22 23 23 24 CString 24 C MSWindowsUtil::getString(HINSTANCE instance, DWORDid)25 CPMUtil::getString(HMODULE hmod, ULONG id) 25 26 { 26 char buffer[1024]; 27 int size = static_cast<int>(sizeof(buffer) / sizeof(buffer[0])); 28 char* msg = buffer; 27 char szBuf[1024]; 29 28 30 29 // load string 31 int n = LoadString(instance, id, msg, size); 32 msg[n] = '\0'; 33 if (n < size) { 34 return msg; 30 LONG cch = WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP), hmod, id, sizeof(szBuf), (PSZ)szBuf); 31 if(cch < 0) { 32 szBuf[cch] = '\0'; 33 char *psz = szBuf; 34 return psz; 35 35 } 36 37 // not enough buffer space. keep trying larger buffers until 38 // we get the whole string. 39 msg = NULL; 40 do { 41 size <<= 1; 42 delete[] msg; 43 char* msg = new char[size]; 44 n = LoadString(instance, id, msg, size); 45 } while (n == size); 46 msg[n] = '\0'; 47 48 CString result(msg); 49 delete[] msg; 50 return result; 36 return ""; 51 37 } 52 38 53 39 CString 54 C MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWORDid)40 CPMUtil::getErrorString(HMODULE hmod, ULONG error, ULONG id) 55 41 { 42 #if 1 43 char szMsg[80]; 44 snprintf(szMsg, sizeof(szMsg), "sys error %#lx (%d)\n", error, error); 45 char *pszMsg = szMsg; 46 return CString(pszMsg); 47 48 #else 56 49 char* buffer; 57 50 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | … … 73 66 return result; 74 67 } 68 #endif 75 69 } 70 71 HAB CPMUtil::getHAB(void) 72 { 73 return WinQueryAnchorBlock(HWND_DESKTOP); 74 } 75 -
trunk/synergy/lib/platform/CPMUtil.h
r2751 r2752 2 2 * synergy -- mouse and keyboard sharing utility 3 3 * Copyright (C) 2004 Chris Schoeneman 4 * Copyright (C) 2006 Knut St. Osmundsen 4 5 * 5 6 * This package is free software; you can redistribute it and/or … … 13 14 */ 14 15 15 #ifndef C MSWINDOWSUTIL_H16 #define C MSWINDOWSUTIL_H16 #ifndef CPMUTIL_H 17 #define CPMUTIL_H 17 18 18 19 #include "CString.h" 19 #define WINDOWS_LEAN_AND_MEAN 20 #include <windows.h> 20 #define INCL_BASE 21 #define INCL_ERRORS 22 #define INCL_PM 23 #include <os2.h> 21 24 22 class C MSWindowsUtil {25 class CPMUtil { 23 26 public: 24 27 //! Get message string … … 26 29 Gets a string for \p id from the string table of \p instance. 27 30 */ 28 static CString getString(H INSTANCE instance, DWORDid);31 static CString getString(HMODULE hmod, ULONG id); 29 32 30 33 //! Get error string … … 33 36 found return the string for \p id, replacing ${1} with \p error. 34 37 */ 35 static CString getErrorString(HINSTANCE, DWORD error, DWORD id); 38 static CString getErrorString(HMODULE hmod, ULONG error, ULONG id); 39 40 static HAB getHAB(void); 41 36 42 }; 37 43
Note:
See TracChangeset
for help on using the changeset viewer.