From bac6e971e3be3b6ab901d895f08035085960d524 Mon Sep 17 00:00:00 2001 From: tehwan Date: Fri, 21 Jan 2011 03:56:00 +0000 Subject: [PATCH] 1.3 merge r870 into trunk and 1.4 --- cmd/launcher/CGlobalOptions.cpp | 33 +++++++++++++++++++++++++++++ cmd/launcher/launcher.rc | 37 ++++++++++++++++++++------------- cmd/launcher/resource.h | 3 +++ lib/server/CConfig.cpp | 21 +++++++++++++++++++ lib/server/CServer.cpp | 31 ++++++++++++++++++++++++++- lib/server/CServer.h | 5 +++++ lib/synergy/OptionTypes.h | 3 +++ 7 files changed, 118 insertions(+), 15 deletions(-) diff --git a/cmd/launcher/CGlobalOptions.cpp b/cmd/launcher/CGlobalOptions.cpp index 9f9ea6dc..2e007884 100644 --- a/cmd/launcher/CGlobalOptions.cpp +++ b/cmd/launcher/CGlobalOptions.cpp @@ -73,6 +73,12 @@ CGlobalOptions::init(HWND hwnd) setItemChecked(child, false); child = getItem(hwnd, IDC_GLOBAL_TWO_TAP_TIME); setWindowText(child, buffer); + child = getItem(hwnd, IDC_GLOBAL_NEEDS_SHIFT); + setItemChecked(child, false); + child = getItem(hwnd, IDC_GLOBAL_NEEDS_CONTROL); + setItemChecked(child, false); + child = getItem(hwnd, IDC_GLOBAL_NEEDS_ALT); + setItemChecked(child, false); sprintf(buffer, "%d", m_heartbeatTime); child = getItem(hwnd, IDC_GLOBAL_HEARTBEAT_CHECK); setItemChecked(child, false); @@ -110,6 +116,18 @@ CGlobalOptions::init(HWND hwnd) setWindowText(child, buffer); } } + else if (id == kOptionScreenSwitchNeedsShift) { + child = getItem(hwnd, IDC_GLOBAL_NEEDS_SHIFT); + setItemChecked(child, (value != 0)); + } + else if (id == kOptionScreenSwitchNeedsControl) { + child = getItem(hwnd, IDC_GLOBAL_NEEDS_CONTROL); + setItemChecked(child, (value != 0)); + } + else if (id == kOptionScreenSwitchNeedsAlt) { + child = getItem(hwnd, IDC_GLOBAL_NEEDS_ALT); + setItemChecked(child, (value != 0)); + } else if (id == kOptionHeartbeat) { if (value > 0) { sprintf(buffer, "%d", value); @@ -197,6 +215,9 @@ CGlobalOptions::save(HWND hwnd) m_config->removeOption("", kOptionScreenSaverSync); m_config->removeOption("", kOptionRelativeMouseMoves); m_config->removeOption("", kOptionWin32KeepForeground); + m_config->removeOption("", kOptionScreenSwitchNeedsAlt); + m_config->removeOption("", kOptionScreenSwitchNeedsShift); + m_config->removeOption("", kOptionScreenSwitchNeedsControl); // add requested options child = getItem(hwnd, IDC_GLOBAL_DELAY_CHECK); @@ -207,6 +228,18 @@ CGlobalOptions::save(HWND hwnd) if (isItemChecked(child)) { m_config->addOption("", kOptionScreenSwitchTwoTap, newTwoTapTime); } + child = getItem(hwnd, IDC_GLOBAL_NEEDS_SHIFT); + if (isItemChecked(child)) { + m_config->addOption("", kOptionScreenSwitchNeedsShift, 1); + } + child = getItem(hwnd, IDC_GLOBAL_NEEDS_CONTROL); + if (isItemChecked(child)) { + m_config->addOption("", kOptionScreenSwitchNeedsControl, 1); + } + child = getItem(hwnd, IDC_GLOBAL_NEEDS_ALT); + if (isItemChecked(child)) { + m_config->addOption("", kOptionScreenSwitchNeedsAlt, 1); + } child = getItem(hwnd, IDC_GLOBAL_HEARTBEAT_CHECK); if (isItemChecked(child)) { m_config->addOption("", kOptionHeartbeat, newHeartbeatTime); diff --git a/cmd/launcher/launcher.rc b/cmd/launcher/launcher.rc index 21cfeef1..aae2b3e3 100644 --- a/cmd/launcher/launcher.rc +++ b/cmd/launcher/launcher.rc @@ -174,7 +174,7 @@ BEGIN IDC_STATIC,7,43,181,17 END -IDD_GLOBAL_OPTIONS DIALOG DISCARDABLE 0, 0, 207, 290 +IDD_GLOBAL_OPTIONS DIALOG DISCARDABLE 0, 0, 207, 354 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Options" FONT 8, "MS Sans Serif" @@ -195,26 +195,35 @@ BEGIN EDITTEXT IDC_GLOBAL_TWO_TAP_TIME,112,98,45,12,ES_AUTOHSCROLL | ES_NUMBER LTEXT "ms",IDC_STATIC,159,100,10,8 - LTEXT "Synergy can periodically check that clients are still alive and connected. Use this only if synergy doesn't detect when clients disconnect.", - IDC_STATIC,7,122,193,24 + LTEXT "Synergy can be restricted to switch only if certain modifiers are pressed.", + IDC_STATIC,7,119,193,19 CONTROL "Check clients every",IDC_GLOBAL_HEARTBEAT_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,153,78,10 - EDITTEXT IDC_GLOBAL_HEARTBEAT_TIME,112,152,45,12,ES_AUTOHSCROLL | + BS_AUTOCHECKBOX | WS_TABSTOP,7,220,78,10 + EDITTEXT IDC_GLOBAL_HEARTBEAT_TIME,112,219,45,12,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "ms",IDC_STATIC,159,154,10,8 + LTEXT "ms",IDC_STATIC,159,221,10,8 LTEXT "Synergy can synchronize screen savers across all screens.", - IDC_STATIC,7,176,193,8 + IDC_STATIC,7,243,193,8 CONTROL "Synchronize screen savers",IDC_GLOBAL_SCREENSAVER_SYNC, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,192,101,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,259,101,10 LTEXT "Relative mouse moves on secondary screens.",IDC_STATIC, - 7,213,193,8 + 7,280,193,8 CONTROL "Use relative mouse moves",IDC_GLOBAL_RELATIVE_MOVES, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,229,99,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,296,99,10 CONTROL "Don't take foreground window on Windows servers", IDC_GLOBAL_LEAVE_FOREGROUND,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,7,250,177,10 - DEFPUSHBUTTON "OK",IDOK,94,269,50,14 - PUSHBUTTON "Cancel",IDCANCEL,150,269,50,14 + WS_TABSTOP,7,317,177,10 + DEFPUSHBUTTON "OK",IDOK,94,333,50,14 + PUSHBUTTON "Cancel",IDCANCEL,150,333,50,14 + LTEXT "Synergy can periodically check that clients are still alive and connected. Use this only if synergy doesn't detect when clients disconnect.", + IDC_STATIC,7,189,193,24 + CONTROL "Only switch when shift pressed.",IDC_GLOBAL_NEEDS_SHIFT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,143,115,10 + CONTROL "Only switch when control pressed.", + IDC_GLOBAL_NEEDS_CONTROL,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,7,155,123,10 + CONTROL "Only switch when alt pressed.",IDC_GLOBAL_NEEDS_ALT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,167,109,10 END IDD_ADVANCED_OPTIONS DIALOG DISCARDABLE 0, 0, 230, 186 @@ -445,7 +454,7 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 200 TOPMARGIN, 7 - BOTTOMMARGIN, 283 + BOTTOMMARGIN, 347 END IDD_ADVANCED_OPTIONS, DIALOG diff --git a/cmd/launcher/resource.h b/cmd/launcher/resource.h index f284fd62..14f9885d 100644 --- a/cmd/launcher/resource.h +++ b/cmd/launcher/resource.h @@ -117,7 +117,10 @@ #define IDC_GLOBAL_RELATIVE_MOVES 1048 #define IDC_ADVANCED_DEFAULTS 1049 #define IDC_GLOBAL_LEAVE_FOREGROUND 1049 +#define IDC_GLOBAL_NEEDS_SHIFT 1050 +#define IDC_GLOBAL_NEEDS_CONTROL 1051 #define IDC_ADD_DC_SIZE 1052 +#define IDC_GLOBAL_NEEDS_ALT 1052 #define IDC_ADD_DC_TOP_LEFT 1053 #define IDC_ADD_DC_TOP_RIGHT 1054 #define IDC_ADD_DC_BOTTOM_LEFT 1055 diff --git a/lib/server/CConfig.cpp b/lib/server/CConfig.cpp index d906429c..b9978149 100644 --- a/lib/server/CConfig.cpp +++ b/lib/server/CConfig.cpp @@ -738,6 +738,15 @@ CConfig::readSectionOptions(CConfigReadContext& s) else if (name == "switchDoubleTap") { addOption("", kOptionScreenSwitchTwoTap, s.parseInt(value)); } + else if (name == "switchNeedsShift") { + addOption("", kOptionScreenSwitchNeedsShift, s.parseBoolean(value)); + } + else if (name == "switchNeedsControl") { + addOption("", kOptionScreenSwitchNeedsControl, s.parseBoolean(value)); + } + else if (name == "switchNeedsAlt") { + addOption("", kOptionScreenSwitchNeedsAlt, s.parseBoolean(value)); + } else if (name == "screenSaverSync") { addOption("", kOptionScreenSaverSync, s.parseBoolean(value)); } @@ -1327,6 +1336,15 @@ CConfig::getOptionName(OptionID id) if (id == kOptionScreenSwitchTwoTap) { return "switchDoubleTap"; } + if (id == kOptionScreenSwitchNeedsShift) { + return "switchNeedsShift"; + } + if (id == kOptionScreenSwitchNeedsControl) { + return "switchNeedsControl"; + } + if (id == kOptionScreenSwitchNeedsAlt) { + return "switchNeedsAlt"; + } if (id == kOptionScreenSaverSync) { return "screenSaverSync"; } @@ -1351,6 +1369,9 @@ CConfig::getOptionValue(OptionID id, OptionValue value) if (id == kOptionHalfDuplexCapsLock || id == kOptionHalfDuplexNumLock || id == kOptionHalfDuplexScrollLock || + id == kOptionScreenSwitchNeedsShift || + id == kOptionScreenSwitchNeedsControl || + id == kOptionScreenSwitchNeedsAlt || id == kOptionScreenSaverSync || id == kOptionXTestXineramaUnaware || id == kOptionRelativeMouseMoves || diff --git a/lib/server/CServer.cpp b/lib/server/CServer.cpp index 9e093ccc..ae26bdaf 100644 --- a/lib/server/CServer.cpp +++ b/lib/server/CServer.cpp @@ -31,6 +31,7 @@ #include "CLog.h" #include "TMethodEventJob.h" #include "CArch.h" +#include "CKeyState.h" #include #include @@ -65,6 +66,9 @@ CServer::CServer(const CConfig& config, CPrimaryClient* primaryClient) : m_switchTwoTapEngaged(false), m_switchTwoTapArmed(false), m_switchTwoTapZone(3), + m_switchNeedsShift(false), + m_switchNeedsControl(false), + m_switchNeedsAlt(false), m_relativeMoves(false), m_keyboardBroadcasting(false), m_lockedToScreen(false) @@ -873,6 +877,19 @@ CServer::isSwitchOkay(CBaseClientProxy* newScreen, stopSwitch(); } + // check for optional needed modifiers + KeyModifierMask mods = this->m_primaryClient->getToggleMask( ); + + if (!preventSwitch && ( + (this->m_switchNeedsShift && ((mods & KeyModifierShift) != KeyModifierShift)) || + (this->m_switchNeedsControl && ((mods & KeyModifierControl) != KeyModifierControl)) || + (this->m_switchNeedsAlt && ((mods & KeyModifierAlt) != KeyModifierAlt)) + )) { + LOG((CLOG_DEBUG1 "need modifiers to switch")); + preventSwitch = true; + stopSwitch(); + } + return !preventSwitch; } @@ -1115,6 +1132,10 @@ CServer::processOptions() return; } + m_switchNeedsShift = false; // it seems if i don't add these + m_switchNeedsControl = false; // lines, the 'reload config' option + m_switchNeedsAlt = false; // doesnt' work correct. + bool newRelativeMoves = m_relativeMoves; for (CConfig::CScreenOptions::const_iterator index = options->begin(); index != options->end(); ++index) { @@ -1134,11 +1155,19 @@ CServer::processOptions() } stopSwitchTwoTap(); } + else if (id == kOptionScreenSwitchNeedsControl) { + m_switchNeedsControl = (value != 0); + } + else if (id == kOptionScreenSwitchNeedsShift) { + m_switchNeedsShift = (value != 0); + } + else if (id == kOptionScreenSwitchNeedsAlt) { + m_switchNeedsAlt = (value != 0); + } else if (id == kOptionRelativeMouseMoves) { newRelativeMoves = (value != 0); } } - if (m_relativeMoves && !newRelativeMoves) { stopRelativeMoves(); } diff --git a/lib/server/CServer.h b/lib/server/CServer.h index d56ef058..0250ccbd 100644 --- a/lib/server/CServer.h +++ b/lib/server/CServer.h @@ -444,6 +444,11 @@ private: bool m_switchTwoTapArmed; SInt32 m_switchTwoTapZone; + // modifiers needed before switching + bool m_switchNeedsShift; + bool m_switchNeedsControl; + bool m_switchNeedsAlt; + // relative mouse move option bool m_relativeMoves; diff --git a/lib/synergy/OptionTypes.h b/lib/synergy/OptionTypes.h index 719ed4b6..1e2aa8ac 100644 --- a/lib/synergy/OptionTypes.h +++ b/lib/synergy/OptionTypes.h @@ -58,6 +58,9 @@ static const OptionID kOptionScreenSwitchCorners = OPTION_CODE("SSCM"); static const OptionID kOptionScreenSwitchCornerSize = OPTION_CODE("SSCS"); static const OptionID kOptionScreenSwitchDelay = OPTION_CODE("SSWT"); static const OptionID kOptionScreenSwitchTwoTap = OPTION_CODE("SSTT"); +static const OptionID kOptionScreenSwitchNeedsShift = OPTION_CODE("SSNS"); +static const OptionID kOptionScreenSwitchNeedsControl = OPTION_CODE("SSNC"); +static const OptionID kOptionScreenSwitchNeedsAlt = OPTION_CODE("SSNA"); static const OptionID kOptionScreenSaverSync = OPTION_CODE("SSVR"); static const OptionID kOptionXTestXineramaUnaware = OPTION_CODE("XTXU"); static const OptionID kOptionScreenPreserveFocus = OPTION_CODE("SFOC");