Added -display option for X11 version.

This commit is contained in:
crs 2004-11-02 20:43:55 +00:00
parent f10ef9a97c
commit 2513ae8972
4 changed files with 64 additions and 18 deletions

View File

@ -79,6 +79,7 @@ public:
m_restartable(true),
m_daemon(true),
m_logFilter(NULL),
m_display(NULL),
m_serverAddress(NULL)
{ s_instance = this; }
~CArgs() { s_instance = NULL; }
@ -90,6 +91,7 @@ public:
bool m_restartable;
bool m_daemon;
const char* m_logFilter;
const char* m_display;
CString m_name;
CNetworkAddress* m_serverAddress;
};
@ -110,7 +112,7 @@ createScreen()
new CFunctionJob(&handleSystemSuspend),
new CFunctionJob(&handleSystemResume)));
#elif WINAPI_XWINDOWS
return new CScreen(new CXWindowsScreen(false));
return new CScreen(new CXWindowsScreen(ARG->m_display, false));
#elif WINAPI_CARBON
return new CScreen(new COSXScreen(false));
#endif
@ -521,19 +523,31 @@ static
void
help()
{
#if WINAPI_XWINDOWS
# define USAGE_DISPLAY_ARG \
" [--display <display>]"
# define USAGE_DISPLAY_INFO \
" --display <display> connect to the X server at <display>\n"
#else
# define USAGE_DISPLAY_ARG
# define USAGE_DISPLAY_INFO
#endif
LOG((CLOG_PRINT
"Usage: %s"
" [--daemon|--no-daemon]"
" [--debug <level>]"
USAGE_DISPLAY_ARG
" [--name <screen-name>]"
" [--restart|--no-restart]"
" <server-address>\n"
"\n"
" <server-address>"
"\n\n"
"Start the synergy mouse/keyboard sharing server.\n"
"\n"
" -d, --debug <level> filter out log messages with priorty below level.\n"
" level may be: FATAL, ERROR, WARNING, NOTE, INFO,\n"
" DEBUG, DEBUG1, DEBUG2.\n"
USAGE_DISPLAY_INFO
" -f, --no-daemon run the client in the foreground.\n"
"* --daemon run the client as a daemon.\n"
" -n, --name <screen-name> use screen-name instead the hostname to identify\n"
@ -619,6 +633,13 @@ parse(int argc, const char* const* argv)
ARG->m_daemon = true;
}
#if WINAPI_XWINDOWS
else if (isArg(i, argc, argv, "-display", "--display", 1)) {
// use alternative display
ARG->m_display = argv[++i];
}
#endif
else if (isArg(i, argc, argv, "-1", "--no-restart")) {
// don't try to restart
ARG->m_restartable = false;

View File

@ -88,7 +88,10 @@ public:
m_restartable(true),
m_daemon(true),
m_configFile(),
m_logFilter(NULL)
m_logFilter(NULL),
m_display(NULL),
m_synergyAddress(NULL),
m_config(NULL)
{ s_instance = this; }
~CArgs() { s_instance = NULL; }
@ -100,6 +103,7 @@ public:
bool m_daemon;
CString m_configFile;
const char* m_logFilter;
const char* m_display;
CString m_name;
CNetworkAddress* m_synergyAddress;
CConfig* m_config;
@ -119,7 +123,7 @@ createScreen()
#if WINAPI_MSWINDOWS
return new CScreen(new CMSWindowsScreen(true, NULL, NULL));
#elif WINAPI_XWINDOWS
return new CScreen(new CXWindowsScreen(true));
return new CScreen(new CXWindowsScreen(ARG->m_display, true));
#elif WINAPI_CARBON
return new CScreen(new COSXScreen(true));
#endif
@ -613,10 +617,20 @@ static
void
help()
{
#if WINAPI_XWINDOWS
# define USAGE_DISPLAY_ARG \
" [--display <display>]"
# define USAGE_DISPLAY_INFO \
" --display <display> connect to the X server at <display>\n"
#else
# define USAGE_DISPLAY_ARG
# define USAGE_DISPLAY_INFO
#endif
#if SYSAPI_WIN32
# define PLATFORM_ARGS \
" {--daemon|--no-daemon}"
" [--daemon|--no-daemon]"
# define PLATFORM_DESC
# define PLATFORM_EXTRA \
"At least one command line argument is required. If you don't otherwise\n" \
@ -637,10 +651,11 @@ help()
" [--address <address>]"
" [--config <pathname>]"
" [--debug <level>]"
USAGE_DISPLAY_ARG
" [--name <screen-name>]"
" [--restart|--no-restart]\n"
" [--restart|--no-restart]"
PLATFORM_ARGS
"\n"
"\n\n"
"Start the synergy mouse/keyboard sharing server.\n"
"\n"
" -a, --address <address> listen for clients on the given address.\n"
@ -648,6 +663,7 @@ PLATFORM_ARGS
" -d, --debug <level> filter out log messages with priorty below level.\n"
" level may be: FATAL, ERROR, WARNING, NOTE, INFO,\n"
" DEBUG, DEBUG1, DEBUG2.\n"
USAGE_DISPLAY_INFO
" -f, --no-daemon run the server in the foreground.\n"
"* --daemon run the server as a daemon.\n"
" -n, --name <screen-name> use screen-name instead the hostname to identify\n"
@ -750,6 +766,13 @@ parse(int argc, const char* const* argv)
ARG->m_configFile = argv[++i];
}
#if WINAPI_XWINDOWS
else if (isArg(i, argc, argv, "-display", "--display", 1)) {
// use alternative display
ARG->m_display = argv[++i];
}
#endif
else if (isArg(i, argc, argv, "-f", "--no-daemon")) {
// not a daemon
ARG->m_daemon = false;

View File

@ -103,7 +103,7 @@ static const KeySym g_map1008FF[] =
CXWindowsScreen* CXWindowsScreen::s_screen = NULL;
CXWindowsScreen::CXWindowsScreen(bool isPrimary) :
CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary) :
m_isPrimary(isPrimary),
m_display(NULL),
m_root(None),
@ -132,7 +132,7 @@ CXWindowsScreen::CXWindowsScreen(bool isPrimary) :
XSetIOErrorHandler(&CXWindowsScreen::ioErrorHandler);
try {
m_display = openDisplay();
m_display = openDisplay(displayName);
m_root = DefaultRootWindow(m_display);
saveShape();
m_window = openWindow();
@ -599,13 +599,15 @@ CXWindowsScreen::fakeMouseWheel(SInt32 delta) const
}
Display*
CXWindowsScreen::openDisplay() const
CXWindowsScreen::openDisplay(const char* displayName) const
{
// get the DISPLAY
const char* displayName = getenv("DISPLAY");
if (displayName == NULL) {
displayName = getenv("DISPLAY");
if (displayName == NULL) {
displayName = ":0.0";
}
}
// open the display
LOG((CLOG_DEBUG "XOpenDisplay(\"%s\")", displayName));

View File

@ -30,7 +30,7 @@ class CXWindowsScreenSaver;
//! Implementation of IPlatformScreen for X11
class CXWindowsScreen : public CPlatformScreen {
public:
CXWindowsScreen(bool isPrimary);
CXWindowsScreen(const char* displayName, bool isPrimary);
virtual ~CXWindowsScreen();
//! @name manipulators
@ -111,7 +111,7 @@ private:
KeyCode m_keycode;
};
Display* openDisplay() const;
Display* openDisplay(const char* displayName) const;
void saveShape();
Window openWindow() const;
void openIM();