Index: files/patch-bug57-keypress.diff
===================================================================
--- files/patch-bug57-keypress.diff	(revision 0)
+++ files/patch-bug57-keypress.diff	(revision 0)
@@ -0,0 +1,49 @@
+Index: src/lib/platform/COSXScreen.cpp
+===================================================================
+--- src/lib/platform/COSXScreen.cpp	(revision 909)
++++ src/lib/platform/COSXScreen.cpp	(working copy)
+@@ -620,7 +620,7 @@
+ 		// FIXME -- start watching jump zones
+ 		
+ 		// kCGEventTapOptionDefault = 0x00000000 (Missing in 10.4, so specified literally)
+-		m_eventTapPort=CGEventTapCreate(kCGHIDEventTap, kCGHIDEventTap, 0, 
++		m_eventTapPort=CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap, 0, 
+ 										kCGEventMaskForAllEvents, 
+ 										handleCGInputEvent, 
+ 										this);
+@@ -640,7 +640,7 @@
+                 // there may be a better way to do this, but we register an event handler even if we're
+                 // not on the primary display (acting as a client). This way, if a local event comes in
+                 // (either keyboard or mouse), we can make sure to show the cursor if we've hidden it. 
+-		m_eventTapPort=CGEventTapCreate(kCGHIDEventTap, kCGHIDEventTap, 0, 
++		m_eventTapPort=CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap, 0, 
+ 										kCGEventMaskForAllEvents, 
+ 										handleCGInputEventSecondary, 
+ 										this);
+Index: src/lib/platform/COSXKeyState.cpp
+===================================================================
+--- src/lib/platform/COSXKeyState.cpp	(revision 909)
++++ src/lib/platform/COSXKeyState.cpp	(working copy)
+@@ -284,22 +284,6 @@
+ #endif
+ 
+ 	if (layoutValid) {
+-
+-		// choose action
+-		UInt16 action;
+-		switch (eventKind) {
+-		case kEventRawKeyDown:
+-			action = kUCKeyActionDown;
+-			break;
+-
+-		case kEventRawKeyRepeat:
+-			action = kUCKeyActionAutoKey;
+-			break;
+-
+-		default:
+-			return 0;
+-		}
+-
+ 		// translate key
+ 		UniCharCount count;
+ 		UniChar chars[2];
Index: files/patch-configure.diff
===================================================================
--- files/patch-configure.diff	(revision 83164)
+++ files/patch-configure.diff	(working copy)
@@ -1,11 +0,0 @@
---- configure.orig	2005-06-22 13:15:24.000000000 -0700
-+++ configure	2005-06-22 13:39:40.000000000 -0700
-@@ -6870,7 +6870,7 @@
- 	echo "$as_me:6870: checking for C++ compiler warning are errors flags" >&5
- echo $ECHO_N "checking for C++ compiler warning are errors flags... $ECHO_C" >&6
- 	if test "$GXX" = "yes"; then
--		acx_cxx_warnings_are_errors="-Werror"
-+		acx_cxx_warnings_are_errors=""
- 	fi
- 	if test -n "$acx_cxx_warnings_are_errors"; then
- 		CXXFLAGS="$CXXFLAGS $acx_cxx_warnings_are_errors"
Index: files/patch-CArchFileUnix.cpp.diff
===================================================================
--- files/patch-CArchFileUnix.cpp.diff	(revision 83164)
+++ files/patch-CArchFileUnix.cpp.diff	(working copy)
@@ -1,5 +1,5 @@
---- lib/arch/CArchFileUnix.cpp.orig	Wed Feb  9 13:29:56 2005
-+++ lib/arch/CArchFileUnix.cpp	Wed Feb  9 13:30:27 2005
+--- src/lib/arch/CArchFileUnix.cpp.orig	Wed Feb  9 13:29:56 2005
++++ src/lib/arch/CArchFileUnix.cpp	Wed Feb  9 13:30:27 2005
 @@ -80,7 +80,7 @@
  std::string
  CArchFileUnix::getSystemDirectory()
Index: files/patch-bug57-modifiers.diff
===================================================================
--- files/patch-bug57-modifiers.diff	(revision 0)
+++ files/patch-bug57-modifiers.diff	(revision 0)
@@ -0,0 +1,80 @@
+Index: src/lib/platform/COSXScreen.cpp
+===================================================================
+--- src/lib/platform/COSXScreen.cpp	(revision 1077)
++++ src/lib/platform/COSXScreen.cpp	(working copy)
+@@ -1097,14 +1097,14 @@
+ 
+ 	// get the key and active modifiers
+ 	UInt32 virtualKey = CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
+-	CGEventFlags macMask = CGEventGetFlags(event);
++	CGEventFlags macMaskCarbon = m_keyState->mapModifiersToCarbon(CGEventGetFlags(event));
+ 	LOG((CLOG_DEBUG1 "event: Key event kind: %d, keycode=%d", eventKind, virtualKey));
+ 
+ 	// Special handling to track state of modifiers
+ 	if (eventKind == kCGEventFlagsChanged) {
+ 		// get old and new modifier state
+ 		KeyModifierMask oldMask = getActiveModifiers();
+-		KeyModifierMask newMask = m_keyState->mapModifiersFromOSX(macMask);
++		KeyModifierMask newMask = m_keyState->mapModifiersFromOsxCarbon(macMaskCarbon);
+ 		m_keyState->handleModifierKeys(getEventTarget(), oldMask, newMask);
+ 
+ 		// if the current set of modifiers exactly matches a modifiers-only
+@@ -1141,9 +1141,7 @@
+ 	// so we check for a key/modifier match in our hot key map.
+ 	if (!m_isOnScreen) {
+ 		HotKeyToIDMap::const_iterator i =
+-			m_hotKeyToIDMap.find(CHotKeyItem(virtualKey, 
+-											 m_keyState->mapModifiersToCarbon(macMask) 
+-											 & 0xff00u));
++			m_hotKeyToIDMap.find(CHotKeyItem(virtualKey, macMaskCarbon & 0xff00u));
+ 		if (i != m_hotKeyToIDMap.end()) {
+ 			UInt32 id = i->second;
+ 	
+Index: src/lib/platform/COSXKeyState.cpp
+===================================================================
+--- src/lib/platform/COSXKeyState.cpp	(revision 1077)
++++ src/lib/platform/COSXKeyState.cpp	(working copy)
+@@ -155,7 +155,7 @@
+ }
+ 
+ KeyModifierMask
+-COSXKeyState::mapModifiersFromOSX(UInt32 mask) const
++COSXKeyState::mapModifiersFromOsxCarbon(UInt32 mask) const
+ {
+ 	LOG((CLOG_DEBUG1 "mask: %04x", mask));
+ 
+@@ -336,7 +336,7 @@
+ KeyModifierMask
+ COSXKeyState::pollActiveModifiers() const
+ {
+-	return mapModifiersFromOSX(GetCurrentKeyModifiers());
++	return mapModifiersFromOsxCarbon(GetCurrentKeyModifiers());
+ }
+ 
+ SInt32
+@@ -620,10 +620,10 @@
+ 			}
+ 
+ 			// now add a key entry for each key/required modifier pair.
+-			item.m_sensitive = mapModifiersFromOSX(sensitive << 8);
++			item.m_sensitive = mapModifiersFromOsxCarbon(sensitive << 8);
+ 			for (std::set<UInt32>::iterator k = required.begin();
+ 											k != required.end(); ++k) {
+-				item.m_required = mapModifiersFromOSX(*k << 8);
++				item.m_required = mapModifiersFromOsxCarbon(*k << 8);
+ 				keyMap.addKeyEntry(item);
+ 			}
+ 		}
+Index: src/lib/platform/COSXKeyState.h
+===================================================================
+--- src/lib/platform/COSXKeyState.h	(revision 1077)
++++ src/lib/platform/COSXKeyState.h	(working copy)
+@@ -62,7 +62,7 @@
+ 	Returns the synergy modifier mask corresponding to the OS X modifier
+ 	mask in \p mask.
+ 	*/
+-	KeyModifierMask		mapModifiersFromOSX(UInt32 mask) const;
++	KeyModifierMask		mapModifiersFromOsxCarbon(UInt32 mask) const;
+ 
+ 	//! Convert CG flags-style modifier mask to old-style Carbon
+ 	/*!
Index: Portfile
===================================================================
--- Portfile	(revision 83164)
+++ Portfile	(working copy)
@@ -1,10 +1,11 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
 # $Id$
 
 PortSystem 1.0
+PortGroup		cmake 1.0
 
 name			synergy
-set sf_proj		synergy2
-version			1.3.1
+version			1.3.7
 categories		sysutils
 platforms		darwin
 maintainers		gmail.com:ascarter
@@ -16,33 +17,38 @@
 				own display.
 
 homepage		http://synergy-foss.org/
-master_sites	sourceforge
-master_sites.mirror_subdir	${sf_proj}
+master_sites	googlecode
 
-checksums		md5 a6e09d6b71cb217f23069980060abf27
+distname		synergy-${version}-Source
 
-configure.args	--sysconfdir=${prefix}/etc/${name}
-patchfiles		patch-CArchFileUnix.cpp.diff patch-configure.diff
+checksums       rmd160  5f28bd102293437481a8c5808d5cbfc8722ee1ae \
+                sha256  9ca584261a4155041dc788614f1942614d20388996a4adaed923aab24e2e2d30
 
+patchfiles		patch-CArchFileUnix.cpp.diff
+
+# See http://synergy-foss.org/pm/issues/57
+patchfiles-append patch-bug57-keypress.diff \
+                  patch-bug57-modifiers.diff
+
 post-patch {
-	reinplace "s|__SYSCONFDIR|${prefix}/etc/${name}|g" ${worksrcpath}/lib/arch/CArchFileUnix.cpp
+	reinplace "s|__SYSCONFDIR|${prefix}/etc/${name}|g" ${worksrcpath}/src/lib/arch/CArchFileUnix.cpp
+    reinplace "s|ppc;i386|${configure.build_arch}|g" ${worksrcpath}/CMakeLists.txt
 }
 
-variant server {
-	startupitem.create	yes
-	startupitem.name	Synergy
-	startupitem.start	"${prefix}/bin/synergys --daemon &"
-	startupitem.stop	"/usr/bin/killall synergys"
-}
+startupitem.create	yes
+startupitem.name	Synergy
+startupitem.start	"${prefix}/bin/synergys --daemon &"
+startupitem.stop	"/usr/bin/killall synergys"
 
-post-destroot {
+destroot {
+    xinstall -m 755 -W ${worksrcpath}/bin synergys synergyc ${destroot}${prefix}/bin
 	xinstall -m 755 -d ${destroot}${prefix}/etc/${name}
-	xinstall -m 644 -c ${worksrcpath}/examples/synergy.conf \
-		${destroot}${prefix}/etc/${name}/synergy.conf.sample
+	xinstall -m 644 -c ${worksrcpath}/doc/synergy.conf.example \
+		${destroot}${prefix}/etc/${name}/
+    
+    xinstall -m 644 ${worksrcpath}/doc/synergyc.man ${destroot}${prefix}/share/man/man1/synergyc.1
+    xinstall -m 644 ${worksrcpath}/doc/synergys.man ${destroot}${prefix}/share/man/man1/synergys.1
 }
 
-livecheck.name	${sf_proj}
-livecheck.regex	<title>Sources (.*) released.*</title>
-
 # Force 32-bit, all kinds of Carbon cruft in here. (#20908)
 supported_archs	i386 ppc
