Updates to support OS X. This improves support for building on

multiple systems with automake, with X Windows and Carbon window
system APIs supported.  It's also a starting port for supporting
win32 builds using mingw.  OS X support is incomplete;  the tree
will compile and link but the binaries will not function.
This commit is contained in:
crs 2004-04-11 14:58:08 +00:00
parent 619dd75f0d
commit 530be3ff9d
36 changed files with 1757 additions and 277 deletions

42
PORTING
View File

@ -333,16 +333,25 @@ other files. On Unix, synergy uses autoconf/automake which produces
a `configure' script that generates makefiles. On Windows, synergy
uses Visual C++ workspace and project files. If you're porting to
another Unix variant, you may need to adjust `configure.in',
`acinclude.m4', and Unix flavor dependent code in lib/arch.
`acinclude.m4', and Unix flavor dependent code in lib/arch. Note
especially the SYSAPI_* and WINAPI_* macro definitions in
ARCH_CFLAGS. Exactly one of each must be defined. It should also
add AM_CONDITIONALs if a new SYSAPI_* or WINAPI_* was added.
Adjusting lib/common/common.h:
The lib/common/common.h header file is included directly or indirectly
by every other file. It prepares some platform dependent macros for
integer sizes and defines a macro for conveniently testing which
platform we're building on. That macro is named *_LIKE (e.g. UNIX_LIKE)
and has the value `1'. Exactly one *_LIKE macro must be defined by
common.h.
by every other file. Its primary job is to include config.h, which
defines macros depending on what the 'configure' script discovered
about the system. If the platform does not use the 'configure' script
it must define the appropriate SYSAPI_* and WINAPI_* macro. It may
also do other platform specific setup.
Adjusting lib/common/BasicTypes.h:
No changes should be necessary in BasicTypes.h. However, if the
platform's system header files define SInt8, et al. you may need
to adjust the typedefs to match the system's definitions.
Implementing lib/arch:
@ -355,6 +364,18 @@ CArchMiscXXX where XXX is the platform name. The class should have
only static methods. Clients can include the appropriate header
file and make calls directly, surrounded by a suitable #ifdef/#endif.
If using automake, the Makefile.am should list the system specific
files in a XXX_SOURCE_FILES macro where XXX matches the appropriate
AM_CONDITIONAL symbol. XXX_SOURCE_FILES must be added to EXTRA_DIST
and the following added above the INCLUDES macro:
if XXX
libarch_a_SOURCES = \
$(COMMON_SOURCE_FILES) \
$(XXX_SOURCE_FILES) \
$(NULL)
endif
Implementing lib/platform:
Most of the remaining platform dependent code lives in lib/platform.
@ -381,6 +402,15 @@ classes should be derived and implemented:
* CXXXScreenSaver : IScreenSaver
Provides screen saver operations.
If using automake, the Makefile.am should list the window system
specific files in a XXX_SOURCE_FILES macro where XXX matches the
appropriate AM_CONDITIONAL symbol. XXX_SOURCE_FILES must be added
to EXTRA_DIST and the following added above the INCLUDES macro:
if XXX
libplatform_a_SOURCES = $(XXX_SOURCE_FILES)
endif
Tweaks:
Finally, each platform typically requires various adjustments here

View File

@ -0,0 +1,56 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "COSXClientTaskBarReceiver.h"
#include "CArch.h"
//
// COSXClientTaskBarReceiver
//
COSXClientTaskBarReceiver::COSXClientTaskBarReceiver(
const CBufferedLogOutputter*)
{
// add ourself to the task bar
ARCH->addReceiver(this);
}
COSXClientTaskBarReceiver::~COSXClientTaskBarReceiver()
{
ARCH->removeReceiver(this);
}
void
COSXClientTaskBarReceiver::showStatus()
{
// do nothing
}
void
COSXClientTaskBarReceiver::runMenu(int, int)
{
// do nothing
}
void
COSXClientTaskBarReceiver::primaryAction()
{
// do nothing
}
const IArchTaskBarReceiver::Icon
COSXClientTaskBarReceiver::getIcon() const
{
return NULL;
}

View File

@ -0,0 +1,35 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef COSXCLIENTTASKBARRECEIVER_H
#define COSXCLIENTTASKBARRECEIVER_H
#include "CClientTaskBarReceiver.h"
class CBufferedLogOutputter;
//! Implementation of CClientTaskBarReceiver for OS X
class COSXClientTaskBarReceiver : public CClientTaskBarReceiver {
public:
COSXClientTaskBarReceiver(const CBufferedLogOutputter*);
virtual ~COSXClientTaskBarReceiver();
// IArchTaskBarReceiver overrides
virtual void showStatus();
virtual void runMenu(int x, int y);
virtual void primaryAction();
virtual const Icon getIcon() const;
};
#endif

View File

@ -13,17 +13,36 @@
## Process this file with automake to produce Makefile.in
NULL =
EXTRA_DIST = \
COMMON_SOURCE_FILES = \
CClientTaskBarReceiver.cpp \
CClientTaskBarReceiver.h \
synergyc.cpp \
$(NULL)
XWINDOWS_SOURCE_FILES = \
CXWindowsClientTaskBarReceiver.cpp \
CXWindowsClientTaskBarReceiver.h \
$(NULL)
MSWINDOWS_SOURCE_FILES = \
CMSWindowsClientTaskBarReceiver.cpp \
CMSWindowsClientTaskBarReceiver.h \
resource.h \
synergyc.rc \
$(NULL)
CARBON_SOURCE_FILES = \
COSXClientTaskBarReceiver.cpp \
COSXClientTaskBarReceiver.h \
$(NULL)
EXTRA_DIST = \
synergyc.dsp \
synergyc.ico \
synergyc.rc \
tb_error.ico \
tb_idle.ico \
tb_run.ico \
tb_wait.ico \
$(XWINDOWS_SOURCE_FILES) \
$(MSWINDOWS_SOURCE_FILES) \
$(CARBON_SOURCE_FILES) \
$(NULL)
MAINTAINERCLEANFILES = \
@ -31,13 +50,24 @@ MAINTAINERCLEANFILES = \
$(NULL)
bin_PROGRAMS = synergyc
if XWINDOWS
synergyc_SOURCES = \
CClientTaskBarReceiver.cpp \
CClientTaskBarReceiver.h \
CXWindowsClientTaskBarReceiver.cpp \
CXWindowsClientTaskBarReceiver.h \
synergyc.cpp \
$(COMMON_SOURCE_FILES) \
$(XWINDOWS_SOURCE_FILES) \
$(NULL)
endif
if MSWINDOWS
synergyc_SOURCES = \
$(COMMON_SOURCE_FILES) \
$(MSWINDOWS_SOURCE_FILES) \
$(NULL)
endif
if CARBON
synergyc_SOURCES = \
$(COMMON_SOURCE_FILES) \
$(CARBON_SOURCE_FILES) \
$(NULL)
endif
synergyc_LDADD = \
$(top_builddir)/lib/client/libclient.a \
$(top_builddir)/lib/platform/libplatform.a \
@ -48,12 +78,6 @@ synergyc_LDADD = \
$(top_builddir)/lib/base/libbase.a \
$(top_builddir)/lib/common/libcommon.a \
$(top_builddir)/lib/arch/libarch.a \
$(X_LIBS) \
$(X_PRE_LIBS) \
-lXtst \
-lXext \
-lX11 \
$(X_EXTRA_LIBS) \
$(NULL)
INCLUDES = \
-I$(top_srcdir)/lib/common \

View File

@ -34,7 +34,7 @@
#include <cstring>
#define DAEMON_RUNNING(running_)
#if WINDOWS_LIKE
#if WINAPI_MSWINDOWS
#include "CArchMiscWindows.h"
#include "CMSWindowsScreen.h"
#include "CMSWindowsUtil.h"
@ -42,22 +42,25 @@
#include "resource.h"
#undef DAEMON_RUNNING
#define DAEMON_RUNNING(running_) CArchMiscWindows::daemonRunning(running_)
#elif UNIX_LIKE
#elif WINAPI_XWINDOWS
#include "CXWindowsScreen.h"
#include "CXWindowsClientTaskBarReceiver.h"
#elif WINAPI_CARBON
#include "COSXScreen.h"
#include "COSXClientTaskBarReceiver.h"
#endif
// platform dependent name of a daemon
#if WINDOWS_LIKE
#if SYSAPI_WIN32
#define DAEMON_NAME "Synergy Client"
#elif UNIX_LIKE
#elif SYSAPI_UNIX
#define DAEMON_NAME "synergyc"
#endif
typedef int (*StartupFunc)(int, char**);
static bool startClient();
static void parse(int argc, const char* const* argv);
#if WINDOWS_LIKE
#if WINAPI_MSWINDOWS
static void handleSystemSuspend(void*);
static void handleSystemResume(void*);
#endif
@ -102,12 +105,14 @@ static
CScreen*
createScreen()
{
#if WINDOWS_LIKE
#if WINAPI_MSWINDOWS
return new CScreen(new CMSWindowsScreen(false,
new CFunctionJob(&handleSystemSuspend),
new CFunctionJob(&handleSystemResume)));
#elif UNIX_LIKE
#elif WINAPI_XWINDOWS
return new CScreen(new CXWindowsScreen(false));
#elif WINAPI_CARBON
return new CScreen(new COSXScreen(false));
#endif
}
@ -115,11 +120,13 @@ static
CClientTaskBarReceiver*
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer)
{
#if WINDOWS_LIKE
#if WINAPI_MSWINDOWS
return new CMSWindowsClientTaskBarReceiver(
CMSWindowsScreen::getInstance(), logBuffer);
#elif UNIX_LIKE
#elif WINAPI_XWINDOWS
return new CXWindowsClientTaskBarReceiver(logBuffer);
#elif WINAPI_CARBON
return new COSXClientTaskBarReceiver(logBuffer);
#endif
}
@ -190,7 +197,7 @@ handleScreenError(const CEvent&, void*)
EVENTQUEUE->addEvent(CEvent(CEvent::kQuit));
}
#if WINDOWS_LIKE
#if WINAPI_MSWINDOWS
static
void
handleSystemSuspend(void*)
@ -676,7 +683,7 @@ parse(int argc, const char* const* argv)
// increase default filter level for daemon. the user must
// explicitly request another level for a daemon.
if (ARG->m_daemon && ARG->m_logFilter == NULL) {
#if WINDOWS_LIKE
#if SYSAPI_WIN32
if (CArchMiscWindows::isWindows95Family()) {
// windows 95 has no place for logging so avoid showing
// the log console window.
@ -702,7 +709,7 @@ parse(int argc, const char* const* argv)
// platform dependent entry points
//
#if WINDOWS_LIKE
#if SYSAPI_WIN32
static bool s_hasImportantLogMessages = false;
@ -825,7 +832,7 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
}
}
#elif UNIX_LIKE
#elif SYSAPI_UNIX
int
main(int argc, char** argv)

View File

@ -0,0 +1,56 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "COSXServerTaskBarReceiver.h"
#include "CArch.h"
//
// COSXServerTaskBarReceiver
//
COSXServerTaskBarReceiver::COSXServerTaskBarReceiver(
const CBufferedLogOutputter*)
{
// add ourself to the task bar
ARCH->addReceiver(this);
}
COSXServerTaskBarReceiver::~COSXServerTaskBarReceiver()
{
ARCH->removeReceiver(this);
}
void
COSXServerTaskBarReceiver::showStatus()
{
// do nothing
}
void
COSXServerTaskBarReceiver::runMenu(int, int)
{
// do nothing
}
void
COSXServerTaskBarReceiver::primaryAction()
{
// do nothing
}
const IArchTaskBarReceiver::Icon
COSXServerTaskBarReceiver::getIcon() const
{
return NULL;
}

View File

@ -0,0 +1,35 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef COSXSERVERTASKBARRECEIVER_H
#define COSXSERVERTASKBARRECEIVER_H
#include "CServerTaskBarReceiver.h"
class CBufferedLogOutputter;
//! Implementation of CServerTaskBarReceiver for OS X
class COSXServerTaskBarReceiver : public CServerTaskBarReceiver {
public:
COSXServerTaskBarReceiver(const CBufferedLogOutputter*);
virtual ~COSXServerTaskBarReceiver();
// IArchTaskBarReceiver overrides
virtual void showStatus();
virtual void runMenu(int x, int y);
virtual void primaryAction();
virtual const Icon getIcon() const;
};
#endif

View File

@ -13,17 +13,36 @@
## Process this file with automake to produce Makefile.in
NULL =
EXTRA_DIST = \
COMMON_SOURCE_FILES = \
CServerTaskBarReceiver.cpp \
CServerTaskBarReceiver.h \
synergys.cpp \
$(NULL)
XWINDOWS_SOURCE_FILES = \
CXWindowsServerTaskBarReceiver.cpp \
CXWindowsServerTaskBarReceiver.h \
$(NULL)
MSWINDOWS_SOURCE_FILES = \
CMSWindowsServerTaskBarReceiver.cpp \
CMSWindowsServerTaskBarReceiver.h \
resource.h \
synergys.ico \
synergys.dsp \
synergys.rc \
$(NULL)
CARBON_SOURCE_FILES = \
COSXServerTaskBarReceiver.cpp \
COSXServerTaskBarReceiver.h \
$(NULL)
EXTRA_DIST = \
synergys.dsp \
synergys.ico \
tb_error.ico \
tb_idle.ico \
tb_run.ico \
tb_wait.ico \
$(XWINDOWS_SOURCE_FILES) \
$(MSWINDOWS_SOURCE_FILES) \
$(CARBON_SOURCE_FILES) \
$(NULL)
MAINTAINERCLEANFILES = \
@ -31,13 +50,24 @@ MAINTAINERCLEANFILES = \
$(NULL)
bin_PROGRAMS = synergys
if XWINDOWS
synergys_SOURCES = \
CServerTaskBarReceiver.cpp \
CServerTaskBarReceiver.h \
CXWindowsServerTaskBarReceiver.cpp \
CXWindowsServerTaskBarReceiver.h \
synergys.cpp \
$(COMMON_SOURCE_FILES) \
$(XWINDOWS_SOURCE_FILES) \
$(NULL)
endif
if MSWINDOWS
synergys_SOURCES = \
$(COMMON_SOURCE_FILES) \
$(MSWINDOWS_SOURCE_FILES) \
$(NULL)
endif
if CARBON
synergys_SOURCES = \
$(COMMON_SOURCE_FILES) \
$(CARBON_SOURCE_FILES) \
$(NULL)
endif
synergys_LDADD = \
$(top_builddir)/lib/server/libserver.a \
$(top_builddir)/lib/platform/libplatform.a \
@ -48,12 +78,6 @@ synergys_LDADD = \
$(top_builddir)/lib/base/libbase.a \
$(top_builddir)/lib/common/libcommon.a \
$(top_builddir)/lib/arch/libarch.a \
$(X_LIBS) \
$(X_PRE_LIBS) \
-lXtst \
-lXext \
-lX11 \
$(X_EXTRA_LIBS) \
$(NULL)
INCLUDES = \
-I$(top_srcdir)/lib/common \

View File

@ -37,7 +37,7 @@
#include <cstring>
#define DAEMON_RUNNING(running_)
#if WINDOWS_LIKE
#if WINAPI_MSWINDOWS
#include "CArchMiscWindows.h"
#include "CMSWindowsScreen.h"
#include "CMSWindowsUtil.h"
@ -45,23 +45,26 @@
#include "resource.h"
#undef DAEMON_RUNNING
#define DAEMON_RUNNING(running_) CArchMiscWindows::daemonRunning(running_)
#elif UNIX_LIKE
#elif WINAPI_XWINDOWS
#include "CXWindowsScreen.h"
#include "CXWindowsServerTaskBarReceiver.h"
#elif WINAPI_CARBON
#include "COSXScreen.h"
#include "COSXServerTaskBarReceiver.h"
#endif
// platform dependent name of a daemon
#if WINDOWS_LIKE
#if SYSAPI_WIN32
#define DAEMON_NAME "Synergy Server"
#elif UNIX_LIKE
#elif SYSAPI_UNIX
#define DAEMON_NAME "synergys"
#endif
// configuration file name
#if WINDOWS_LIKE
#if SYSAPI_WIN32
#define USR_CONFIG_NAME "synergy.sgc"
#define SYS_CONFIG_NAME "synergy.sgc"
#elif UNIX_LIKE
#elif SYSAPI_UNIX
#define USR_CONFIG_NAME ".synergy.conf"
#define SYS_CONFIG_NAME "synergy.conf"
#endif
@ -113,10 +116,12 @@ static
CScreen*
createScreen()
{
#if WINDOWS_LIKE
#if WINAPI_MSWINDOWS
return new CScreen(new CMSWindowsScreen(true, NULL, NULL));
#elif UNIX_LIKE
#elif WINAPI_XWINDOWS
return new CScreen(new CXWindowsScreen(true));
#elif WINAPI_CARBON
return new CScreen(new COSXScreen(true));
#endif
}
@ -124,11 +129,13 @@ static
CServerTaskBarReceiver*
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer)
{
#if WINDOWS_LIKE
#if WINAPI_MSWINDOWS
return new CMSWindowsServerTaskBarReceiver(
CMSWindowsScreen::getInstance(), logBuffer);
#elif UNIX_LIKE
#elif WINAPI_XWINDOWS
return new CXWindowsServerTaskBarReceiver(logBuffer);
#elif WINAPI_CARBON
return new COSXServerTaskBarReceiver(logBuffer);
#endif
}
@ -579,7 +586,7 @@ static
void
help()
{
#if WINDOWS_LIKE
#if SYSAPI_WIN32
# define PLATFORM_ARGS \
" {--daemon|--no-daemon}"
@ -778,7 +785,7 @@ parse(int argc, const char* const* argv)
// increase default filter level for daemon. the user must
// explicitly request another level for a daemon.
if (ARG->m_daemon && ARG->m_logFilter == NULL) {
#if WINDOWS_LIKE
#if SYSAPI_WIN32
if (CArchMiscWindows::isWindows95Family()) {
// windows 95 has no place for logging so avoid showing
// the log console window.
@ -870,7 +877,7 @@ loadConfig()
// platform dependent entry points
//
#if WINDOWS_LIKE
#if SYSAPI_WIN32
static bool s_hasImportantLogMessages = false;
@ -994,7 +1001,7 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
}
}
#elif UNIX_LIKE
#elif SYSAPI_UNIX
int
main(int argc, char** argv)

View File

@ -27,6 +27,33 @@ AM_CONFIG_HEADER(config.h)
dnl information on the package
dnl decide on platform
ARCH_LIBS=""
ARCH_CFLAGS=""
AC_CANONICAL_HOST
case $host in
*-*-windows*)
acx_host_arch="WIN32"
acx_host_winapi="MSWINDOWS"
ARCH_CFLAGS="$ARCH_CFLAGS -DSYSAPI_WIN32=1 -DWINAPI_MSWINDOWS=1"
;;
*-*-darwin*)
acx_host_arch="UNIX"
acx_host_winapi="CARBON"
ARCH_CFLAGS="$ARCH_CFLAGS -DSYSAPI_UNIX=1 -DWINAPI_CARBON=1"
;;
*)
acx_host_arch="UNIX"
acx_host_winapi="XWINDOWS"
ARCH_CFLAGS="$ARCH_CFLAGS -DSYSAPI_UNIX=1 -DWINAPI_XWINDOWS=1"
;;
esac
AM_CONDITIONAL(WIN32, test x$acx_host_arch = xWIN32)
AM_CONDITIONAL(UNIX, test x$acx_host_arch = xUNIX)
AM_CONDITIONAL(MSWINDOWS, test x$acx_host_winapi = xMSWINDOWS)
AM_CONDITIONAL(CARBON, test x$acx_host_winapi = xCARBON)
AM_CONDITIONAL(XWINDOWS, test x$acx_host_winapi = xXWINDOWS)
dnl checks for programs
AC_PROG_CXX
AC_PROG_RANLIB
@ -45,7 +72,14 @@ dnl macros we should do testing with
CXXFLAGS="$CXXFLAGS -D_BSD_SOURCE -D_XOPEN_SOURCE=500"
dnl checks for libraries
if test x"$acx_host_arch" = xUNIX; then
ACX_PTHREAD(,AC_MSG_ERROR(You must have pthreads to compile synergy))
ARCH_LIBS="$PTHREAD_LIBS $ARCH_LIBS"
ARCH_CFLAGS="$ARCH_CFLAGS $PTHREAD_CFLAGS"
fi
if test x"$acx_host_winapi" = xCARBON; then
ARCH_LIBS="-framework Carbon $ARCH_LIBS"
fi
ACX_CHECK_NANOSLEEP
ACX_CHECK_INET_ATON
@ -55,14 +89,33 @@ AC_CHECK_HEADERS([unistd.h sys/time.h sys/types.h wchar.h])
AC_CHECK_HEADERS([sys/socket.h sys/select.h])
AC_CHECK_HEADERS([istream ostream sstream])
AC_HEADER_TIME
if test x"$acx_host_winapi" = xXWINDOWS; then
AC_PATH_X
AC_PATH_XTRA
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$X_CFLAGS $CPPFLAGS"
AC_CHECK_HEADERS([X11/extensions/XTest.h])
AC_CHECK_LIB(Xinerama, XineramaQueryExtension, AC_CHECK_HEADERS([X11/extensions/Xinerama.h]) [X_LIBS="$X_LIBS -lXinerama"], , [$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])
AC_CHECK_LIB(Xext, DPMSQueryExtension, AC_CHECK_HEADERS([X11/extensions/dpms.h]) [X_LIBS="$X_LIBS -lXext"], , [$X_LIBS -lX11 $X_EXTRA_LIBS])
AC_CHECK_LIB(Xtst,
XTestQueryExtension,
AC_CHECK_HEADERS([X11/extensions/XTest.h],
[X_LIBS="$X_LIBS -lXtst"],
AC_MSG_ERROR(Your must have the XTest headers to compile synergy)),
AC_MSG_ERROR(You must have the XTest library to build synergy),
[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])
AC_CHECK_LIB(Xinerama,
XineramaQueryExtension,
AC_CHECK_HEADERS([X11/extensions/Xinerama.h],
[X_LIBS="$X_LIBS -lXinerama"]),
,
[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])
AC_CHECK_LIB(Xext,
DPMSQueryExtension,
AC_CHECK_HEADERS([X11/extensions/dpms.h]),
,
[$X_LIBS -lX11 $X_EXTRA_LIBS])
CPPFLAGS="$save_CPPFLAGS"
ARCH_LIBS="$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS $ARCH_LIBS"
ARCH_CFLAGS="$ARCH_CFLAGS $X_CFLAGS"
fi
dnl checks for types
AC_TYPE_SIZE_T
@ -100,9 +153,9 @@ dnl enable maximum compiler warnings and warnings are errors.
ACX_CXX_WARNINGS
ACX_CXX_WARNINGS_ARE_ERRORS
dnl adjust variables for X11 and pthreads
CXXFLAGS="$CXXFLAGS $SYNERGY_CXXFLAGS $X_CFLAGS $PTHREAD_CFLAGS"
LIBS="$NANOSLEEP_LIBS $INET_ATON_LIBS $PTHREAD_LIBS $LIBS"
dnl adjust compiler and linker variables
CXXFLAGS="$CXXFLAGS $SYNERGY_CXXFLAGS $ARCH_CFLAGS"
LIBS="$NANOSLEEP_LIBS $INET_ATON_LIBS $ARCH_LIBS $LIBS"
AC_OUTPUT([
Makefile

View File

@ -27,7 +27,7 @@
#undef ARCH_TIME
// include appropriate architecture implementation
#if WINDOWS_LIKE
#if SYSAPI_WIN32
# include "CArchConsoleWindows.h"
# include "CArchDaemonWindows.h"
# include "CArchFileWindows.h"
@ -39,7 +39,7 @@
# include "CArchStringWindows.h"
# include "CArchTaskBarWindows.h"
# include "CArchTimeWindows.h"
#elif UNIX_LIKE
#elif SYSAPI_UNIX
# include "CArchConsoleUnix.h"
# include "CArchDaemonUnix.h"
# include "CArchFileUnix.h"
@ -118,7 +118,7 @@ CArch::CArch(ARCH_ARGS* args)
m_daemon = new ARCH_DAEMON;
m_taskbar = new ARCH_TASKBAR(args);
#if WINDOWS_LIKE
#if SYSAPI_WIN32
CArchMiscWindows::init();
#endif
}

View File

@ -20,9 +20,6 @@
#include <fcntl.h>
#include <errno.h>
// we derive from CArchDaemonNone
#include "CArchDaemonNone.cpp"
//
// CArchDaemonUnix
//

View File

@ -13,6 +13,7 @@
*/
#include "CArchFileUnix.h"
#include <stdio.h>
#include <unistd.h>
#include <pwd.h>
#include <sys/types.h>

View File

@ -1,45 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "common.h"
// include appropriate architecture implementation
#if WINDOWS_LIKE
# include "CArchMiscWindows.cpp"
# include "CArchConsoleWindows.cpp"
# include "CArchDaemonWindows.cpp"
# include "CArchFileWindows.cpp"
# include "CArchLogWindows.cpp"
# include "CArchMultithreadWindows.cpp"
# include "CArchNetworkWinsock.cpp"
# include "CArchSleepWindows.cpp"
# include "CArchStringWindows.cpp"
# include "CArchTaskBarWindows.cpp"
# include "CArchTimeWindows.cpp"
# include "XArchWindows.cpp"
#elif UNIX_LIKE
# include "CArchConsoleUnix.cpp"
# include "CArchDaemonUnix.cpp"
# include "CArchFileUnix.cpp"
# include "CArchLogUnix.cpp"
# if HAVE_PTHREAD
# include "CArchMultithreadPosix.cpp"
# endif
# include "CArchNetworkBSD.cpp"
# include "CArchSleepUnix.cpp"
# include "CArchStringUnix.cpp"
# include "CArchTaskBarXWindows.cpp"
# include "CArchTimeUnix.cpp"
# include "XArchUnix.cpp"
#endif

View File

@ -14,6 +14,7 @@
#include "CArchNetworkBSD.h"
#include "CArch.h"
#include "CArchMultithreadPosix.h"
#include "XArchUnix.h"
#if HAVE_SYS_TYPES_H
# include <sys/types.h>

View File

@ -17,7 +17,7 @@
#include "common.h"
#if (HAVE_MBSINIT && HAVE_MBRTOWC && HAVE_WCRTOMB) || WINDOWS_LIKE
#if (HAVE_MBSINIT && HAVE_MBRTOWC && HAVE_WCRTOMB) || SYSAPI_WIN32
#include "CMultibyteOS.cpp"
#else
#include "CMultibyteEmu.cpp"

View File

@ -14,6 +14,7 @@
#include <string.h>
#include <cwchar>
#include <limits.h>
class CArchMBStateImpl {
public:

View File

@ -13,8 +13,50 @@
## Process this file with automake to produce Makefile.in
NULL =
EXTRA_DIST = \
arch.dsp \
COMMON_SOURCE_FILES = \
CArch.cpp \
CArchDaemonNone.cpp \
CArchDaemonNone.h \
XArch.cpp \
CArch.h \
IArchConsole.h \
IArchDaemon.h \
IArchFile.h \
IArchLog.h \
IArchMultithread.h \
IArchNetwork.h \
IArchSleep.h \
IArchString.h \
IArchTaskBar.h \
IArchTaskBarReceiver.h \
IArchTime.h \
XArch.h \
$(NULL)
UNIX_SOURCE_FILES = \
CArchConsoleUnix.cpp \
CArchDaemonUnix.cpp \
CArchFileUnix.cpp \
CArchLogUnix.cpp \
CArchMultithreadPosix.cpp \
CArchNetworkBSD.cpp \
CArchSleepUnix.cpp \
CArchStringUnix.cpp \
CArchTaskBarXWindows.cpp \
CArchTimeUnix.cpp \
XArchUnix.cpp \
CArchConsoleUnix.h \
CArchDaemonUnix.h \
CArchFileUnix.h \
CArchLogUnix.h \
CArchMultithreadPosix.h \
CArchNetworkBSD.h \
CArchSleepUnix.h \
CArchStringUnix.h \
CArchTaskBarXWindows.h \
CArchTimeUnix.h \
XArchUnix.h \
$(NULL)
WIN32_SOURCE_FILES = \
CArchConsoleWindows.cpp \
CArchDaemonWindows.cpp \
CArchFileWindows.cpp \
@ -41,59 +83,33 @@ EXTRA_DIST = \
XArchWindows.h \
$(NULL)
EXTRA_DIST = \
arch.dsp \
CMultibyte.cpp \
CMultibyteEmu.cpp \
CMultibyteOS.cpp \
vsnprintf.cpp \
$(UNIX_SOURCE_FILES) \
$(WIN32_SOURCE_FILES) \
$(NULL)
MAINTAINERCLEANFILES = \
Makefile.in \
$(NULL)
noinst_LIBRARIES = libarch.a
if UNIX
libarch_a_SOURCES = \
CArch.cpp \
CArchImpl.cpp \
XArch.cpp \
CArch.h \
IArchConsole.h \
IArchDaemon.h \
IArchFile.h \
IArchLog.h \
IArchMultithread.h \
IArchNetwork.h \
IArchSleep.h \
IArchString.h \
IArchTaskBar.h \
IArchTaskBarReceiver.h \
IArchTime.h \
XArch.h \
$(COMMON_SOURCE_FILES) \
$(UNIX_SOURCE_FILES) \
$(NULL)
EXTRA_libarch_a_SOURCES = \
CArchConsoleUnix.cpp \
CArchDaemonNone.cpp \
CArchDaemonUnix.cpp \
CArchFileUnix.cpp \
CArchLogUnix.cpp \
CArchMultithreadPosix.cpp \
CArchNetworkBSD.cpp \
CArchSleepUnix.cpp \
CArchStringUnix.cpp \
CArchTaskBarXWindows.cpp \
CArchTimeUnix.cpp \
CMultibyte.cpp \
CMultibyteOS.cpp \
CMultibyteEmu.cpp \
XArchUnix.cpp \
vsnprintf.cpp \
CArchConsoleUnix.h \
CArchDaemonNone.h \
CArchDaemonUnix.h \
CArchFileUnix.h \
CArchLogUnix.h \
CArchMultithreadPosix.h \
CArchNetworkBSD.h \
CArchSleepUnix.h \
CArchStringUnix.h \
CArchTaskBarXWindows.h \
CArchTimeUnix.h \
XArchUnix.h \
endif
if WIN32
libarch_a_SOURCES = \
$(COMMON_SOURCE_FILES) \
$(WIN32_SOURCE_FILES) \
$(NULL)
endif
INCLUDES = \
-I$(top_srcdir)/lib/common \
$(NULL)

View File

@ -28,7 +28,7 @@ ARCH_STRING::vsnprintf(char* str, int size, const char* fmt, va_list ap)
return n;
}
#elif UNIX_LIKE // !HAVE_VSNPRINTF
#elif SYSAPI_UNIX // !HAVE_VSNPRINTF
#include <stdio.h>
@ -54,7 +54,7 @@ ARCH_STRING::vsnprintf(char* str, int size, const char* fmt, va_list ap)
}
}
#else // !HAVE_VSNPRINTF && !UNIX_LIKE
#else // !HAVE_VSNPRINTF && !SYSAPI_UNIX
#error vsnprintf not implemented

View File

@ -26,7 +26,7 @@ it sorts by std::greater, it has a forward iterator through the elements
(which can appear in any order), and its contents can be swapped.
*/
template <class T, class Container = std::vector<T>,
#if WINDOWS_LIKE
#if defined(_MSC_VER)
class Compare = std::greater<Container::value_type> >
#else
class Compare = std::greater<typename Container::value_type> >

View File

@ -36,7 +36,8 @@
#endif
#if !defined(TYPE_OF_SIZE_4)
# if SIZEOF_INT == 4
// Carbon defines SInt32 and UInt32 in terms of long
# if SIZEOF_INT == 4 && !defined(__APPLE__)
# define TYPE_OF_SIZE_4 int
# else
# define TYPE_OF_SIZE_4 long
@ -83,5 +84,3 @@ typedef unsigned TYPE_OF_SIZE_4 UInt32;
#undef TYPE_OF_SIZE_4
#endif

View File

@ -19,11 +19,13 @@
#if HAVE_CONFIG_H
# include "config.h"
#endif
// check if win32 platform
#else
// we may not have run configure on win32
# if defined(_WIN32)
# define WINDOWS_LIKE 1
# define SYSAPI_WIN32 1
# define WINAPI_MSWINDOWS 1
# endif
#endif
// VC++ specific
#if (_MSC_VER >= 1200)
@ -42,7 +44,6 @@
# pragma warning(disable: 4702) // unreachable code
# pragma warning(disable: 4701) // variable maybe used uninitialized
# endif
#endif // (_MSC_VER >= 1200)
// VC++ has built-in sized types
@ -56,11 +57,13 @@
# define SIZE_OF_INT 4
# define SIZE_OF_LONG 4
#endif
#endif // defined(_WIN32)
// unix-like if not like anything else
#if (!defined(WINDOWS_LIKE) || WINDOWS_LIKE == 0)
# define UNIX_LIKE 1
// FIXME -- including fp.h from Carbon.h causes a undefined symbol error
// on my build system. the symbol is scalb. since we don't need any
// math functions we define __FP__, the include guard macro for fp.h, to
// prevent fp.h from being included.
#if defined(__APPLE__)
#define __FP__
#endif
// define NULL

View File

@ -0,0 +1,70 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "COSXClipboard.h"
#include <Carbon/Carbon.h>
// FIXME -- implement this
//
// COSXClipboard
//
COSXClipboard::COSXClipboard()
{
}
COSXClipboard::~COSXClipboard()
{
}
bool
COSXClipboard::empty()
{
return true;
}
void
COSXClipboard::add(EFormat, const CString&)
{
}
bool
COSXClipboard::open(Time) const
{
return false;
}
void
COSXClipboard::close() const
{
}
IClipboard::Time
COSXClipboard::getTime() const
{
return 0;
}
bool
COSXClipboard::has(EFormat) const
{
return false;
}
CString
COSXClipboard::get(EFormat) const
{
return "";
}

View File

@ -0,0 +1,36 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef COSXCLIPBOARD_H
#define COSXCLIPBOARD_H
#include "IClipboard.h"
//! OS X clipboard implementation
class COSXClipboard : public IClipboard {
public:
COSXClipboard();
virtual ~COSXClipboard();
// IClipboard overrides
virtual bool empty();
virtual void add(EFormat, const CString& data);
virtual bool open(Time) const;
virtual void close() const;
virtual Time getTime() const;
virtual bool has(EFormat) const;
virtual CString get(EFormat) const;
};
#endif

View File

@ -0,0 +1,76 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "COSXEventQueueBuffer.h"
//
// COSXEventQueueBuffer
//
COSXEventQueueBuffer::COSXEventQueueBuffer()
{
// FIXME
}
COSXEventQueueBuffer::~COSXEventQueueBuffer()
{
// FIXME
}
void
COSXEventQueueBuffer::waitForEvent(double timeout)
{
EventRef event;
ReceiveNextEvent(0, NULL, timeout, false, &event);
}
IEventQueueBuffer::Type
COSXEventQueueBuffer::getEvent(CEvent& event, UInt32& dataID)
{
// FIXME
(void)event;
(void)dataID;
return kNone;
}
bool
COSXEventQueueBuffer::addEvent(UInt32 dataID)
{
// FIXME
(void)dataID;
return false;
}
bool
COSXEventQueueBuffer::isEmpty() const
{
EventRef event;
OSStatus status = ReceiveNextEvent(0, NULL, 0.0, false, &event);
return (status != eventLoopTimedOutErr);
}
CEventQueueTimer*
COSXEventQueueBuffer::newTimer(double duration, bool oneShot) const
{
// FIXME
(void)duration;
(void)oneShot;
return NULL;
}
void
COSXEventQueueBuffer::deleteTimer(CEventQueueTimer*) const
{
// FIXME
}

View File

@ -0,0 +1,40 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef COSXEVENTQUEUEBUFFER_H
#define COSXEVENTQUEUEBUFFER_H
#include "IEventQueueBuffer.h"
#include <Carbon/Carbon.h>
//! Event queue buffer for OS X
class COSXEventQueueBuffer : public IEventQueueBuffer {
public:
COSXEventQueueBuffer();
virtual ~COSXEventQueueBuffer();
// IEventQueueBuffer overrides
virtual void waitForEvent(double timeout);
virtual Type getEvent(CEvent& event, UInt32& dataID);
virtual bool addEvent(UInt32 dataID);
virtual bool isEmpty() const;
virtual CEventQueueTimer*
newTimer(double duration, bool oneShot) const;
virtual void deleteTimer(CEventQueueTimer*) const;
private:
// FIXME
};
#endif

View File

@ -0,0 +1,294 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "COSXKeyState.h"
#include "CLog.h"
struct CKeyEntry {
public:
KeyID m_keyID;
KeyButton m_button;
};
static const CKeyEntry s_keys[] = {
/* ASCII */
{ ' ', 49 },
{ '!', 18 },
{ '\"', 39 },
{ '#', 20 },
{ '$', 21 },
{ '%', 23 },
{ '&', 26 },
{ '\'', 39 },
{ '(', 25 },
{ ')', 29 },
{ '*', 28 },
{ '+', 24 },
{ ',', 43 },
{ '-', 27 },
{ '.', 47 },
{ '/', 44 },
{ '0', 29 },
{ '1', 18 },
{ '2', 19 },
{ '3', 20 },
{ '4', 21 },
{ '5', 23 },
{ '6', 22 },
{ '7', 26 },
{ '8', 28 },
{ '9', 25 },
{ ':', 41 },
{ ';', 41 },
{ '<', 43 },
{ '=', 24 },
{ '>', 47 },
{ '?', 44 },
{ '@', 19 },
{ 'A', 0 },
{ 'B', 11 },
{ 'C', 8 },
{ 'D', 2 },
{ 'E', 14 },
{ 'F', 3 },
{ 'G', 5 },
{ 'H', 4 },
{ 'I', 34 },
{ 'J', 38 },
{ 'K', 40 },
{ 'L', 37 },
{ 'M', 46 },
{ 'N', 45 },
{ 'O', 31 },
{ 'P', 35 },
{ 'Q', 12 },
{ 'R', 15 },
{ 'S', 1 },
{ 'T', 17 },
{ 'U', 32 },
{ 'V', 9 },
{ 'W', 13 },
{ 'X', 7 },
{ 'Y', 16 },
{ 'Z', 6 },
{ '[', 33 },
{ '\\', 42 },
{ ']', 30 },
{ '^', 22 },
{ '_', 27 },
{ '`', 50 },
{ 'a', 0 },
{ 'b', 11 },
{ 'c', 8 },
{ 'd', 2 },
{ 'e', 14 },
{ 'f', 3 },
{ 'g', 5 },
{ 'h', 4 },
{ 'i', 34 },
{ 'j', 38 },
{ 'k', 40 },
{ 'l', 37 },
{ 'm', 46 },
{ 'n', 45 },
{ 'o', 31 },
{ 'p', 35 },
{ 'q', 12 },
{ 'r', 15 },
{ 's', 1 },
{ 't', 17 },
{ 'u', 32 },
{ 'v', 9 },
{ 'w', 13 },
{ 'x', 7 },
{ 'y', 16 },
{ 'z', 6 },
{ '{', 33 },
{ '|', 42 },
{ '}', 30 },
{ '~', 50 },
/* TTY functions */
{ kKeyBackSpace, 51 },
{ kKeyTab, 48 },
{ kKeyLinefeed, 36 },
// { kKeyClear, 0xFFFF },
{ kKeyReturn, 36 },
{ kKeyPause, 113 },
{ kKeyScrollLock, 107 },
// { kKeySysReq, 0xFFFF }, /* no mapping on apple */
{ kKeyEscape, 53 },
{ kKeyDelete, 117 },
/* cursor control */
{ kKeyHome, 115 },
{ kKeyLeft, 123 },
{ kKeyUp, 126 },
{ kKeyRight, 124 },
{ kKeyDown, 125 },
{ kKeyPageUp, 116 },
{ kKeyPageDown, 121 },
{ kKeyEnd, 119 },
{ kKeyBegin, 115 },
/* numeric keypad */
{ kKeyKP_Space, 49 },
{ kKeyKP_0, 82 },
{ kKeyKP_1, 83 },
{ kKeyKP_2, 84 },
{ kKeyKP_3, 85 },
{ kKeyKP_4, 86 },
{ kKeyKP_5, 87 },
{ kKeyKP_6, 88 },
{ kKeyKP_7, 89 },
{ kKeyKP_8, 91 },
{ kKeyKP_9, 92 },
{ kKeyKP_Enter, 76 },
{ kKeyKP_Decimal, 65 },
{ kKeyKP_Add, 69 },
{ kKeyKP_Subtract, 78 },
{ kKeyKP_Multiply, 67 },
{ kKeyKP_Divide, 75 },
/* Function keys */
{ kKeyF1, 122 },
{ kKeyF2, 120 },
{ kKeyF3, 99 },
{ kKeyF4, 118 },
{ kKeyF5, 96 },
{ kKeyF6, 97 },
{ kKeyF7, 98 },
{ kKeyF8, 100 },
{ kKeyF9, 101 },
{ kKeyF10, 109 },
{ kKeyF11, 103 },
{ kKeyF12, 111 },
/* Modifier keys */
{ kKeyShift_L, 56 },
{ kKeyShift_R, 56 },
{ kKeyControl_L, 59 },
{ kKeyControl_R, 59 },
{ kKeyAlt_L, 55 },
{ kKeyAlt_R, 55 },
{ kKeyCapsLock, 57 },
{ kKeyNumLock, 71 },
{ kKeyMeta_L, 58 },
{ kKeyMeta_R, 58 },
{ kKeySuper_L, 58 },
{ kKeySuper_R, 58 },
{ kKeyLeftTab, 48 }
};
//
// COSXKeyState
//
COSXKeyState::COSXKeyState()
{
// FIXME
}
COSXKeyState::~COSXKeyState()
{
// FIXME
}
bool
COSXKeyState::fakeCtrlAltDel()
{
// pass keys through unchanged
return false;
}
const char*
COSXKeyState::getKeyName(KeyButton) const
{
// FIXME
return "";
}
void
COSXKeyState::doUpdateKeys()
{
// FIXME -- get the current keyboard state. call setKeyDown(),
// setToggled(), and addModifier() as appropriate.
// save key mapping
// FIXME -- this probably needs to be more dynamic to support
// non-english keyboards. also need to map modifiers needed
// for each KeyID.
for (UInt32 i = 0; i < sizeof(s_keys) / sizeof(s_keys[0]); ++i) {
m_keyMap.insert(std::make_pair(s_keys[i].m_keyID, s_keys[i].m_button));
}
}
void
COSXKeyState::doFakeKeyEvent(KeyButton button, bool press, bool)
{
// let system figure out character for us
CGPostKeyboardEvent(0, static_cast<CGKeyCode>(button), press);
}
KeyButton
COSXKeyState::mapKey(Keystrokes& keys, KeyID id,
KeyModifierMask desiredMask,
bool isAutoRepeat) const
{
// look up virtual key
CKeyMap::const_iterator keyIndex = m_keyMap.find(id);
if (keyIndex == m_keyMap.end()) {
return 0;
}
CGKeyCode keyCode = keyIndex->second;
// adjust the modifiers to match the desired modifiers
Keystrokes undo;
if (!adjustModifiers(keys, undo, desiredMask)) {
LOG((CLOG_DEBUG2 "failed to adjust modifiers"));
return 0;
}
// add the key event
Keystroke keystroke;
keystroke.m_key = keyCode;
if (!isAutoRepeat) {
keystroke.m_press = true;
keystroke.m_repeat = false;
keys.push_back(keystroke);
}
else {
keystroke.m_press = false;
keystroke.m_repeat = true;
keys.push_back(keystroke);
keystroke.m_press = true;
keys.push_back(keystroke);
}
// put undo keystrokes at end of keystrokes in reverse order
while (!undo.empty()) {
keys.push_back(undo.back());
undo.pop_back();
}
return keyCode;
}
bool
COSXKeyState::adjustModifiers(Keystrokes& /*keys*/,
Keystrokes& /*undo*/,
KeyModifierMask /*desiredMask*/) const
{
// FIXME -- should add necessary modifier events to keys and undo
return true;
}

View File

@ -0,0 +1,55 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef COSXKEYSTATE_H
#define COSXKEYSTATE_H
#include "CKeyState.h"
#include "stdmap.h"
#include <Carbon/Carbon.h>
//! OS X key state
/*!
A key state for OS X.
*/
class COSXKeyState : public CKeyState {
public:
COSXKeyState();
virtual ~COSXKeyState();
// IKeyState overrides
virtual bool fakeCtrlAltDel();
virtual const char* getKeyName(KeyButton) const;
protected:
// IKeyState overrides
virtual void doUpdateKeys();
virtual void doFakeKeyEvent(KeyButton button,
bool press, bool isAutoRepeat);
virtual KeyButton mapKey(Keystrokes& keys, KeyID id,
KeyModifierMask desiredMask,
bool isAutoRepeat) const;
private:
bool adjustModifiers(Keystrokes& keys,
Keystrokes& undo,
KeyModifierMask desiredMask) const;
private:
typedef std::map<KeyID, KeyButton> CKeyMap;
CKeyMap m_keyMap;
};
#endif

407
lib/platform/COSXScreen.cpp Normal file
View File

@ -0,0 +1,407 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "COSXScreen.h"
#include "COSXClipboard.h"
#include "COSXEventQueueBuffer.h"
#include "COSXKeyState.h"
#include "COSXScreenSaver.h"
#include "CClipboard.h"
#include "CLog.h"
#include "IEventQueue.h"
#include "TMethodEventJob.h"
//
// COSXScreen
//
COSXScreen::COSXScreen(bool isPrimary) :
m_isPrimary(isPrimary),
m_isOnScreen(m_isPrimary),
m_cursorHidden(false),
m_keyState(NULL),
m_sequenceNumber(0),
m_screensaver(NULL),
m_screensaverNotify(false)
{
try {
m_displayID = CGMainDisplayID();
updateScreenShape();
m_screensaver = new COSXScreenSaver();
m_keyState = new COSXKeyState();
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d", m_x, m_y, m_w, m_h));
}
catch (...) {
delete m_keyState;
delete m_screensaver;
throw;
}
// install event handlers
EVENTQUEUE->adoptHandler(CEvent::kSystem, IEventQueue::getSystemTarget(),
new TMethodEventJob<COSXScreen>(this,
&COSXScreen::handleSystemEvent));
// install the platform event queue
EVENTQUEUE->adoptBuffer(new COSXEventQueueBuffer);
}
COSXScreen::~COSXScreen()
{
disable();
EVENTQUEUE->adoptBuffer(NULL);
EVENTQUEUE->removeHandler(CEvent::kSystem, IEventQueue::getSystemTarget());
delete m_keyState;
delete m_screensaver;
}
void*
COSXScreen::getEventTarget() const
{
return const_cast<COSXScreen*>(this);
}
bool
COSXScreen::getClipboard(ClipboardID, IClipboard* dst) const
{
COSXClipboard src;
CClipboard::copy(dst, &src);
return true;
}
void
COSXScreen::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
{
x = m_x;
y = m_y;
w = m_w;
h = m_h;
}
void
COSXScreen::getCursorPos(SInt32& x, SInt32& y) const
{
Point mouse;
GetGlobalMouse(&mouse);
x = mouse.h;
y = mouse.v;
}
void
COSXScreen::reconfigure(UInt32 activeSides)
{
// FIXME
(void)activeSides;
}
void
COSXScreen::warpCursor(SInt32 x, SInt32 y)
{
// move cursor without generating events
CGPoint pos;
pos.x = x;
pos.y = y;
CGWarpMouseCursorPosition(pos);
// save new cursor position
m_xCursor = x;
m_yCursor = y;
}
SInt32
COSXScreen::getJumpZoneSize() const
{
// FIXME -- is this correct?
return 1;
}
bool
COSXScreen::isAnyMouseButtonDown() const
{
// FIXME
return false;
}
void
COSXScreen::getCursorCenter(SInt32& x, SInt32& y) const
{
x = m_xCenter;
y = m_yCenter;
}
void
COSXScreen::fakeMouseButton(ButtonID id, bool press) const
{
// get button index
UInt32 index = id - kButtonLeft;
if (index >= sizeof(m_buttons) / sizeof(m_buttons[0])) {
return;
}
// update state
m_buttons[index] = press;
// synthesize event. CGPostMouseEvent is a particularly good
// example of a bad API. we have to shadow the mouse state to
// use this API and if we want to support more buttons we have
// to recompile.
CGPoint pos;
pos.x = m_xCursor;
pos.y = m_yCursor;
CGPostMouseEvent(pos, false, sizeof(m_buttons) / sizeof(m_buttons[0]),
m_buttons[0],
m_buttons[1],
m_buttons[2],
m_buttons[3],
m_buttons[4]);
}
void
COSXScreen::fakeMouseMove(SInt32 x, SInt32 y) const
{
// synthesize event
CGPoint pos;
pos.x = x;
pos.y = y;
// FIXME -- is it okay to pass no buttons here?
CGPostMouseEvent(pos, true, 0, m_buttons[0]);
// save new cursor position
m_xCursor = x;
m_yCursor = y;
}
void
COSXScreen::fakeMouseWheel(SInt32 delta) const
{
CGPostScrollWheelEvent(1, delta / 120);
}
void
COSXScreen::enable()
{
// FIXME -- install clipboard snooper (if we need one)
if (m_isPrimary) {
// FIXME -- start watching jump zones
}
else {
// FIXME -- prevent system from entering power save mode
// hide cursor
if (!m_cursorHidden) {
CGDisplayHideCursor(m_displayID);
m_cursorHidden = true;
}
// warp the mouse to the cursor center
fakeMouseMove(m_xCenter, m_yCenter);
// FIXME -- prepare to show cursor if it moves
}
updateKeys();
}
void
COSXScreen::disable()
{
if (m_isPrimary) {
// FIXME -- stop watching jump zones, stop capturing input
}
else {
// show cursor
if (m_cursorHidden) {
CGDisplayShowCursor(m_displayID);
m_cursorHidden = false;
}
// FIXME -- allow system to enter power saving mode
}
// FIXME -- uninstall clipboard snooper (if we needed one)
m_isOnScreen = m_isPrimary;
}
void
COSXScreen::enter()
{
if (m_isPrimary) {
// FIXME -- stop capturing input, watch jump zones
}
else {
// show cursor
if (m_cursorHidden) {
CGDisplayShowCursor(m_displayID);
m_cursorHidden = false;
}
// reset buttons
for (UInt32 i = 0; i < sizeof(m_buttons) / sizeof(m_buttons[0]); ++i) {
m_buttons[i] = false;
}
}
// now on screen
m_isOnScreen = true;
}
bool
COSXScreen::leave()
{
// FIXME -- choose keyboard layout if per-process and activate it here
if (m_isPrimary) {
// update key and button state
updateKeys();
// warp to center
warpCursor(m_xCenter, m_yCenter);
// capture events
// FIXME
}
else {
// hide cursor
if (!m_cursorHidden) {
CGDisplayHideCursor(m_displayID);
m_cursorHidden = true;
}
// warp the mouse to the cursor center
fakeMouseMove(m_xCenter, m_yCenter);
// FIXME -- prepare to show cursor if it moves
// take keyboard focus
// FIXME
}
// now off screen
m_isOnScreen = false;
return true;
}
bool
COSXScreen::setClipboard(ClipboardID, const IClipboard* src)
{
COSXClipboard dst;
if (src != NULL) {
// save clipboard data
return CClipboard::copy(&dst, src);
}
else {
// assert clipboard ownership
if (!dst.open(0)) {
return false;
}
dst.empty();
dst.close();
return true;
}
}
void
COSXScreen::checkClipboards()
{
// FIXME -- do nothing if we're always up to date
}
void
COSXScreen::openScreensaver(bool notify)
{
m_screensaverNotify = notify;
if (!m_screensaverNotify) {
m_screensaver->disable();
}
}
void
COSXScreen::closeScreensaver()
{
if (!m_screensaverNotify) {
m_screensaver->enable();
}
}
void
COSXScreen::screensaver(bool activate)
{
if (activate) {
m_screensaver->activate();
}
else {
m_screensaver->deactivate();
}
}
void
COSXScreen::resetOptions()
{
// no options
}
void
COSXScreen::setOptions(const COptionsList&)
{
// no options
}
void
COSXScreen::setSequenceNumber(UInt32 seqNum)
{
m_sequenceNumber = seqNum;
}
bool
COSXScreen::isPrimary() const
{
return m_isPrimary;
}
void
COSXScreen::handleSystemEvent(const CEvent&, void*)
{
// FIXME
}
void
COSXScreen::updateButtons()
{
// FIXME -- get current button state into m_buttons[]
}
IKeyState*
COSXScreen::getKeyState() const
{
return m_keyState;
}
void
COSXScreen::updateScreenShape()
{
// FIXME -- handle multiple monitors
// get shape of default screen
m_x = 0;
m_y = 0;
m_w = CGDisplayPixelsWide(m_displayID);
m_h = CGDisplayPixelsHigh(m_displayID);
// get center of default screen
m_xCenter = m_x + (m_w >> 1);
m_yCenter = m_y + (m_h >> 1);
}

110
lib/platform/COSXScreen.h Normal file
View File

@ -0,0 +1,110 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef COSXSCREEN_H
#define COSXSCREEN_H
#include "CPlatformScreen.h"
#include "stdvector.h"
#include <Carbon/Carbon.h>
class COSXKeyState;
class COSXScreenSaver;
//! Implementation of IPlatformScreen for OS X
class COSXScreen : public CPlatformScreen {
public:
COSXScreen(bool isPrimary);
virtual ~COSXScreen();
//! @name manipulators
//@{
//@}
// IScreen overrides
virtual void* getEventTarget() const;
virtual bool getClipboard(ClipboardID id, IClipboard*) const;
virtual void getShape(SInt32& x, SInt32& y,
SInt32& width, SInt32& height) const;
virtual void getCursorPos(SInt32& x, SInt32& y) const;
// IPrimaryScreen overrides
virtual void reconfigure(UInt32 activeSides);
virtual void warpCursor(SInt32 x, SInt32 y);
virtual SInt32 getJumpZoneSize() const;
virtual bool isAnyMouseButtonDown() const;
virtual void getCursorCenter(SInt32& x, SInt32& y) const;
// ISecondaryScreen overrides
virtual void fakeMouseButton(ButtonID id, bool press) const;
virtual void fakeMouseMove(SInt32 x, SInt32 y) const;
virtual void fakeMouseWheel(SInt32 delta) const;
// IPlatformScreen overrides
virtual void enable();
virtual void disable();
virtual void enter();
virtual bool leave();
virtual bool setClipboard(ClipboardID, const IClipboard*);
virtual void checkClipboards();
virtual void openScreensaver(bool notify);
virtual void closeScreensaver();
virtual void screensaver(bool activate);
virtual void resetOptions();
virtual void setOptions(const COptionsList& options);
virtual void setSequenceNumber(UInt32);
virtual bool isPrimary() const;
protected:
// IPlatformScreen overrides
virtual void handleSystemEvent(const CEvent&, void*);
virtual void updateButtons();
virtual IKeyState* getKeyState() const;
private:
void updateScreenShape();
private:
// true if screen is being used as a primary screen, false otherwise
bool m_isPrimary;
// true if mouse has entered the screen
bool m_isOnScreen;
// the display
CGDirectDisplayID m_displayID;
// screen shape stuff
SInt32 m_x, m_y;
SInt32 m_w, m_h;
SInt32 m_xCenter, m_yCenter;
// mouse state
mutable SInt32 m_xCursor, m_yCursor;
mutable boolean_t m_buttons[5];
bool m_cursorHidden;
// keyboard stuff
COSXKeyState* m_keyState;
// clipboards
UInt32 m_sequenceNumber;
// screen saver stuff
COSXScreenSaver* m_screensaver;
bool m_screensaverNotify;
};
#endif

View File

@ -0,0 +1,56 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "COSXScreenSaver.h"
#include <Carbon/Carbon.h>
// FIXME -- implement this
//
// COSXScreenSaver
//
COSXScreenSaver::COSXScreenSaver()
{
}
COSXScreenSaver::~COSXScreenSaver()
{
}
void
COSXScreenSaver::enable()
{
}
void
COSXScreenSaver::disable()
{
}
void
COSXScreenSaver::activate()
{
}
void
COSXScreenSaver::deactivate()
{
}
bool
COSXScreenSaver::isActive() const
{
return false;
}

View File

@ -0,0 +1,34 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef COSXSCREENSAVER_H
#define COSXSCREENSAVER_H
#include "IScreenSaver.h"
//! OSX screen saver implementation
class COSXScreenSaver : public IScreenSaver {
public:
COSXScreenSaver();
virtual ~COSXScreenSaver();
// IScreenSaver overrides
virtual void enable();
virtual void disable();
virtual void activate();
virtual void deactivate();
virtual bool isActive() const;
};
#endif

View File

@ -16,13 +16,8 @@
#define CSYNERGYHOOK_H
#include "BasicTypes.h"
#if WINDOWS_LIKE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#error CSynergyHook is a win32 specific file
#endif
#if defined(SYNRGYHK_EXPORTS)
#define CSYNERGYHOOK_API __declspec(dllexport)

View File

@ -16,7 +16,6 @@
#include "CThread.h"
#include "CEvent.h"
#include "IEventQueue.h"
#if UNIX_LIKE
#if HAVE_POLL
# include <sys/poll.h>
#else
@ -33,7 +32,6 @@
# include <unistd.h>
# endif
#endif
#endif
//
// CEventQueueTimer

View File

@ -45,24 +45,6 @@
}
# endif
#endif
#if UNIX_LIKE
# if HAVE_POLL
# include <sys/poll.h>
# else
# if HAVE_SYS_SELECT_H
# include <sys/select.h>
# endif
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# endif
# if HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
# if HAVE_UNISTD_H
# include <unistd.h>
# endif
# endif
#endif
#include "CArch.h"
// map "Internet" keys to KeyIDs

View File

@ -13,10 +13,27 @@
## Process this file with automake to produce Makefile.in
NULL =
EXTRA_DIST = \
makehook.dsp \
platform.dsp \
synrgyhk.dsp \
XWINDOWS_SOURCE_FILES = \
CXWindowsClipboard.cpp \
CXWindowsClipboardTextConverter.cpp \
CXWindowsClipboardUCS2Converter.cpp \
CXWindowsClipboardUTF8Converter.cpp \
CXWindowsEventQueueBuffer.cpp \
CXWindowsKeyState.cpp \
CXWindowsScreen.cpp \
CXWindowsScreenSaver.cpp \
CXWindowsUtil.cpp \
CXWindowsClipboard.h \
CXWindowsClipboardTextConverter.h \
CXWindowsClipboardUCS2Converter.h \
CXWindowsClipboardUTF8Converter.h \
CXWindowsEventQueueBuffer.h \
CXWindowsKeyState.h \
CXWindowsScreen.h \
CXWindowsScreenSaver.h \
CXWindowsUtil.h \
$(NULL)
MSWINDOWS_SOURCE_FILES = \
CMSWindowsClipboard.cpp \
CMSWindowsClipboardAnyTextConverter.cpp \
CMSWindowsClipboardTextConverter.cpp \
@ -40,32 +57,42 @@ EXTRA_DIST = \
CMSWindowsUtil.h \
CSynergyHook.h \
$(NULL)
CARBON_SOURCE_FILES = \
COSXClipboard.cpp \
COSXEventQueueBuffer.cpp \
COSXKeyState.cpp \
COSXScreen.cpp \
COSXScreenSaver.cpp \
COSXClipboard.h \
COSXEventQueueBuffer.h \
COSXKeyState.h \
COSXScreen.h \
COSXScreenSaver.h \
$(NULL)
EXTRA_DIST = \
makehook.dsp \
platform.dsp \
synrgyhk.dsp \
$(XWINDOWS_SOURCE_FILES) \
$(MSWINDOWS_SOURCE_FILES) \
$(CARBON_SOURCE_FILES) \
$(NULL)
MAINTAINERCLEANFILES = \
Makefile.in \
$(NULL)
noinst_LIBRARIES = libplatform.a
libplatform_a_SOURCES = \
CXWindowsClipboard.cpp \
CXWindowsClipboardTextConverter.cpp \
CXWindowsClipboardUCS2Converter.cpp \
CXWindowsClipboardUTF8Converter.cpp \
CXWindowsEventQueueBuffer.cpp \
CXWindowsKeyState.cpp \
CXWindowsScreen.cpp \
CXWindowsScreenSaver.cpp \
CXWindowsUtil.cpp \
CXWindowsClipboard.h \
CXWindowsClipboardTextConverter.h \
CXWindowsClipboardUCS2Converter.h \
CXWindowsClipboardUTF8Converter.h \
CXWindowsEventQueueBuffer.h \
CXWindowsKeyState.h \
CXWindowsScreen.h \
CXWindowsScreenSaver.h \
CXWindowsUtil.h \
$(NULL)
if XWINDOWS
libplatform_a_SOURCES = $(XWINDOWS_SOURCE_FILES)
endif
if MSWINDOWS
libplatform_a_SOURCES = $(MSWINDOWS_SOURCE_FILES)
endif
if CARBON
libplatform_a_SOURCES = $(CARBON_SOURCE_FILES)
endif
INCLUDES = \
-I$(top_srcdir)/lib/common \
-I$(top_srcdir)/lib/arch \