View
@@ -30,7 +30,8 @@ class LicenseManager: public QObject
public:
LicenseManager(AppConfig* appConfig);
- std::pair<bool, QString> setSerialKey(QString serialKey, bool acceptExpired = false);
+ std::pair<bool, QString> setSerialKey(SerialKey serialKey,
+ bool acceptExpired = false);
void refresh();
Edition activeEdition() const;
QString activeEditionName() const;
View
@@ -808,25 +808,6 @@ bool MainWindow::serverArgs(QStringList& args, QString& app)
args << "--serial-key" << appConfig().serialKey();
}
-#if defined(Q_OS_WIN)
- // pass in physical resolution and primary screen center
- // TODO: get this information in the core binary even when
- // high DPI is used
- int height = QApplication::desktop()->height();
- int width = QApplication::desktop()->width();
-
- QRect rec = QApplication::desktop()->screenGeometry();
- int heightCenter = rec.height() / 2;
- int widthCenter = rec.width() / 2;
-
- appendLogDebug(tr("screen resolution: %1 %2 primary screen center: %3 %4")
- .arg(width).arg(height).arg(widthCenter).arg(heightCenter));
-
- args << "--res-w" << QString::number(width);
- args << "--res-h" << QString::number(height);
- args << "--prm-wc" << QString::number(widthCenter);
- args << "--prm-hc" << QString::number(heightCenter);
- #endif
return true;
}
View
@@ -119,8 +119,8 @@ int waitForTray()
if (++trayAttempts > TRAY_RETRY_COUNT)
{
QMessageBox::critical(NULL, "Synergy",
- QObject::tr("System tray is unavailable, quitting."));
- return false;
+ QObject::tr("System tray is unavailable, don't close your window."));
+ return true;
}
QThreadImpl::msleep(TRAY_RETRY_WAIT);
@@ -159,7 +159,8 @@ bool checkMacAssistiveDevices()
QMessageBox::information(
NULL, "Synergy",
"Please enable access to assistive devices "
- "(System Preferences), then re-open Synergy.");
+ "System Preferences -> Security & Privacy -> "
+ "Privacy -> Accessibility, then re-open Synergy.");
}
return result;
View
@@ -117,9 +117,11 @@ ArchDaemonUnix::daemonize(const char* name, DaemonFunc func)
open("/dev/null", O_RDWR);
int dupErr = dup(1);
- if (dupErr)
+
+ if (dupErr < 0) {
// NB: file logging actually isn't working at this point!
LOG((CLOG_ERR "dup error: %i", dupErr));
+ }
#ifdef __APPLE__
return execSelfNonDaemonized();
View
@@ -76,5 +76,5 @@ ArchSystemUnix::setting(const std::string&, const std::string&) const
std::string
ArchSystemUnix::getLibsUsed(void) const
{
- return "not implmented.\nuse lsof on shell";
+ return "not implemented.\nuse lsof on shell";
}
View
@@ -146,7 +146,7 @@ IpcClientProxy::send(const IpcMessage& message)
switch (message.type()) {
case kIpcLogLine: {
const IpcLogLineMessage& llm = static_cast<const IpcLogLineMessage&>(message);
- String logLine = llm.logLine();
+ const String logLine = llm.logLine();
ProtocolUtil::writef(&m_stream, kIpcMsgLogLine, &logLine);
break;
}
View
@@ -94,7 +94,7 @@ IpcServerProxy::send(const IpcMessage& message)
case kIpcCommand: {
const IpcCommandMessage& cm = static_cast<const IpcCommandMessage&>(message);
- String command = cm.command();
+ const String command = cm.command();
ProtocolUtil::writef(&m_stream, kIpcMsgCommand, &command);
break;
}
View
@@ -61,11 +61,11 @@ const KeyID MSWindowsKeyState::s_virtualKey[] =
/* 0x012 */ { kKeyAlt_L }, // VK_MENU
/* 0x013 */ { kKeyPause }, // VK_PAUSE
/* 0x014 */ { kKeyCapsLock }, // VK_CAPITAL
- /* 0x015 */ { kKeyHangulKana }, // VK_HANGUL, VK_KANA
+ /* 0x015 */ { kKeyKana }, // VK_HANGUL, VK_KANA
/* 0x016 */ { kKeyNone }, // undefined
/* 0x017 */ { kKeyNone }, // VK_JUNJA
/* 0x018 */ { kKeyNone }, // VK_FINAL
- /* 0x019 */ { kKeyHanjaKanzi }, // VK_KANJI
+ /* 0x019 */ { kKeyKanzi }, // VK_HANJA, VK_KANJI
/* 0x01a */ { kKeyNone }, // undefined
/* 0x01b */ { kKeyEscape }, // VK_ESCAPE
/* 0x01c */ { kKeyHenkan }, // VK_CONVERT
@@ -318,11 +318,11 @@ const KeyID MSWindowsKeyState::s_virtualKey[] =
/* 0x112 */ { kKeyAlt_R }, // VK_MENU
/* 0x113 */ { kKeyNone }, // VK_PAUSE
/* 0x114 */ { kKeyNone }, // VK_CAPITAL
- /* 0x115 */ { kKeyNone }, // VK_KANA
- /* 0x116 */ { kKeyNone }, // VK_HANGUL
+ /* 0x115 */ { kKeyHangul }, // VK_HANGUL
+ /* 0x116 */ { kKeyNone }, // undefined
/* 0x117 */ { kKeyNone }, // VK_JUNJA
/* 0x118 */ { kKeyNone }, // VK_FINAL
- /* 0x119 */ { kKeyNone }, // VK_KANJI
+ /* 0x119 */ { kKeyHanja }, // VK_HANJA
/* 0x11a */ { kKeyNone }, // undefined
/* 0x11b */ { kKeyNone }, // VK_ESCAPE
/* 0x11c */ { kKeyNone }, // VK_CONVERT
@@ -728,6 +728,10 @@ MSWindowsKeyState::mapKeyFromEvent(WPARAM charAndVirtKey,
// that so we clear it.
active &= ~s_controlAlt;
}
+ if (id == kKeyHangul) {
+ // If shift-space is used to change input mode, clear shift modifier.
+ active &= ~KeyModifierShift;
+ }
*maskOut = active;
}
@@ -1071,13 +1075,8 @@ MSWindowsKeyState::getKeyMap(synergy::KeyMap& keyMap)
}
}
- // add alt+printscreen
- if (m_buttonToVK[0x54u] == 0) {
- m_buttonToVK[0x54u] = VK_SNAPSHOT;
- }
-
// set virtual key to button table
- if (GetKeyboardLayout(0) == m_groups[g]) {
+ if (activeLayout == m_groups[g]) {
for (KeyButton i = 0; i < 512; ++i) {
if (m_buttonToVK[i] != 0) {
if (m_virtualKeyToButton[m_buttonToVK[i]] == 0) {
@@ -1339,8 +1338,20 @@ MSWindowsKeyState::setWindowGroup(SInt32 group)
}
KeyID
-MSWindowsKeyState::getKeyID(UINT virtualKey, KeyButton button)
+MSWindowsKeyState::getKeyID(UINT virtualKey, KeyButton button) const
{
+ // Some virtual keycodes have same values.
+ // VK_HANGUL == VK_KANA, VK_HANJA == NK_KANJI
+ // which are used to change the input mode of IME.
+ // But they have different X11 keysym. So we should distinguish them.
+ if ((LOWORD(m_keyLayout) & 0xffffu) == 0x0412u) { // 0x0412 : Korean Locale ID
+ if (virtualKey == VK_HANGUL || virtualKey == VK_HANJA) {
+ // If shift-space is used to change the input mode,
+ // the extented bit is not set. So add it to get right key id.
+ button |= 0x100u;
+ }
+ }
+
if ((button & 0x100u) != 0) {
virtualKey += 0x100u;
}
@@ -1392,3 +1403,4 @@ MSWindowsKeyState::addKeyEntry(synergy::KeyMap& keyMap, synergy::KeyMap::KeyItem
m_keyToVKMap[item.m_id] = static_cast<UINT>(item.m_client);
}
}
+
View
@@ -122,7 +122,7 @@ class MSWindowsKeyState : public KeyState {
(button should include the extended key bit), or kKeyNone if there is
no such key.
*/
- static KeyID getKeyID(UINT virtualKey, KeyButton button);
+ KeyID getKeyID(UINT virtualKey, KeyButton button) const;
//! Map button to virtual key
/*!
View
@@ -31,7 +31,6 @@
#include "synergy/App.h"
#include "synergy/ArgsBase.h"
#include "synergy/ClientApp.h"
-#include "synergy/DpiHelper.h"
#include "mt/Lock.h"
#include "mt/Thread.h"
#include "arch/win32/ArchMiscWindows.h"
@@ -105,7 +104,6 @@ MSWindowsScreen::MSWindowsScreen(
m_xCenter(0), m_yCenter(0),
m_multimon(false),
m_xCursor(0), m_yCursor(0),
- m_xFractionalMove(0.0f), m_yFractionalMove(0.0f),
m_sequenceNumber(0),
m_mark(0),
m_markReceived(0),
@@ -146,10 +144,6 @@ MSWindowsScreen::MSWindowsScreen(
stopOnDeskSwitch);
m_keyState = new MSWindowsKeyState(m_desks, getEventTarget(), m_events);
- DpiHelper::calculateDpi(
- GetSystemMetrics(SM_CXVIRTUALSCREEN),
- GetSystemMetrics(SM_CYVIRTUALSCREEN));
-
updateScreenShape();
m_class = createWindowClass();
m_window = createWindow(m_class, "Synergy");
@@ -348,8 +342,7 @@ MSWindowsScreen::leave()
// warp to center
LOG((CLOG_DEBUG1 "warping cursor to center: %+d, %+d", m_xCenter, m_yCenter));
- float dpi = DpiHelper::getDpi();
- warpCursor(m_xCenter / dpi, m_yCenter / dpi);
+ warpCursor(m_xCenter, m_yCenter);
// disable special key sequences on win95 family
enableSpecialKeys(false);
@@ -576,21 +569,6 @@ void MSWindowsScreen::saveMousePosition(SInt32 x, SInt32 y) {
LOG((CLOG_DEBUG5 "saved mouse position for next delta: %+d,%+d", x,y));
}
-void MSWindowsScreen::accumulateFractionalMove(float x, float y, SInt32& intX, SInt32& intY)
-{
- // Accumulate together the move into the running total
- m_xFractionalMove += x;
- m_yFractionalMove += y;
-
- // Return the integer part
- intX = (SInt32)m_xFractionalMove;
- intY = (SInt32)m_yFractionalMove;
-
- // And keep only the fractional part
- m_xFractionalMove -= intX;
- m_yFractionalMove -= intY;
-}
-
UInt32
MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask)
{
@@ -1369,20 +1347,10 @@ MSWindowsScreen::onMouseButton(WPARAM wParam, LPARAM lParam)
bool
MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my)
{
- SInt32 originalMX = mx;
- SInt32 originalMY = my;
- float scaledMX = (float)mx;
- float scaledMY = (float)my;
-
- if (DpiHelper::s_dpiScaled) {
- scaledMX /= DpiHelper::getDpi();
- scaledMY /= DpiHelper::getDpi();
- }
-
// compute motion delta (relative to the last known
// mouse position)
- float x = scaledMX - m_xCursor;
- float y = scaledMY - m_yCursor;
+ SInt32 x = mx - m_xCursor;
+ SInt32 y = my - m_yCursor;
LOG((CLOG_DEBUG3
"mouse move - motion delta: %+d=(%+d - %+d),%+d=(%+d - %+d)",
@@ -1395,14 +1363,14 @@ MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my)
}
// save position to compute delta of next motion
- saveMousePosition((SInt32)scaledMX, (SInt32)scaledMY);
+ saveMousePosition(mx, my);
if (m_isOnScreen) {
// motion on primary screen
sendEvent(
m_events->forIPrimaryScreen().motionOnPrimary(),
- MotionInfo::alloc(originalMX, originalMY));
+ MotionInfo::alloc(m_xCursor, m_yCursor));
if (m_buttons[kButtonLeft] == true && m_draggingStarted == false) {
m_draggingStarted = true;
@@ -1415,27 +1383,24 @@ MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my)
// will always try to return to the original entry point on the
// secondary screen.
LOG((CLOG_DEBUG5 "warping server cursor to center: %+d,%+d", m_xCenter, m_yCenter));
- float dpi = DpiHelper::getDpi();
- warpCursorNoFlush(m_xCenter / dpi, m_yCenter / dpi);
+ warpCursorNoFlush(m_xCenter, m_yCenter);
// examine the motion. if it's about the distance
// from the center of the screen to an edge then
// it's probably a bogus motion that we want to
// ignore (see warpCursorNoFlush() for a further
// description).
static SInt32 bogusZoneSize = 10;
- if (-x + bogusZoneSize > (m_xCenter - m_x) / dpi ||
- x + bogusZoneSize > (m_x + m_w - m_xCenter) / dpi ||
- -y + bogusZoneSize > (m_yCenter - m_y) / dpi ||
- y + bogusZoneSize > (m_y + m_h - m_yCenter) / dpi) {
+ if (-x + bogusZoneSize > m_xCenter - m_x ||
+ x + bogusZoneSize > m_x + m_w - m_xCenter ||
+ -y + bogusZoneSize > m_yCenter - m_y ||
+ y + bogusZoneSize > m_y + m_h - m_yCenter) {
LOG((CLOG_DEBUG "dropped bogus delta motion: %+d,%+d", x, y));
}
else {
// send motion
- SInt32 ix, iy;
- accumulateFractionalMove(x, y, ix, iy);
- sendEvent(m_events->forIPrimaryScreen().motionOnSecondary(), MotionInfo::alloc(ix, iy));
+ sendEvent(m_events->forIPrimaryScreen().motionOnSecondary(), MotionInfo::alloc(x, y));
}
}
@@ -1623,26 +1588,13 @@ void
MSWindowsScreen::updateScreenShape()
{
// get shape and center
- if (DpiHelper::s_dpiScaled) {
- // use the original resolution size for width and height
- m_w = (SInt32)DpiHelper::s_resolutionWidth;
- m_h = (SInt32)DpiHelper::s_resolutionHeight;
-
- // calculate center position according to the original size
- m_xCenter = (SInt32)DpiHelper::s_primaryWidthCenter;
- m_yCenter = (SInt32)DpiHelper::s_primaryHeightCenter;
- }
- else {
- m_w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
- m_h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
-
- m_xCenter = GetSystemMetrics(SM_CXSCREEN) >> 1;
- m_yCenter = GetSystemMetrics(SM_CYSCREEN) >> 1;
- }
-
- // get position
+ m_w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+ m_h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
m_x = GetSystemMetrics(SM_XVIRTUALSCREEN);
m_y = GetSystemMetrics(SM_YVIRTUALSCREEN);
+ m_xCenter = GetSystemMetrics(SM_CXSCREEN) >> 1;
+ m_yCenter = GetSystemMetrics(SM_CYSCREEN) >> 1;
+
// check for multiple monitors
m_multimon = (m_w != GetSystemMetrics(SM_CXSCREEN) ||
m_h != GetSystemMetrics(SM_CYSCREEN));
View
@@ -216,10 +216,6 @@ class MSWindowsScreen : public PlatformScreen {
// save last position of mouse to compute next delta movement
void saveMousePosition(SInt32 x, SInt32 y);
- // accumulates together a series of fractional pixel moves, each time
- // taking away and returning just the integer part of the running total.
- void accumulateFractionalMove(float x, float y, SInt32& intX, SInt32& intY);
-
// check if it is a modifier key repeating message
bool isModifierRepeat(KeyModifierMask oldState,
KeyModifierMask state, WPARAM wParam) const;
@@ -270,9 +266,6 @@ class MSWindowsScreen : public PlatformScreen {
// last mouse position
SInt32 m_xCursor, m_yCursor;
- // accumulated fractional pixel moves
- float m_xFractionalMove, m_yFractionalMove;
-
// last clipboard
UInt32 m_sequenceNumber;
View
@@ -23,6 +23,7 @@
#include "base/Log.h"
#include <Carbon/Carbon.h>
+#include <IOKit/hidsystem/IOHIDLib.h>
// Note that some virtual keys codes appear more than once. The
// first instance of a virtual key code maps to the KeyID that we
@@ -469,6 +470,105 @@ OSXKeyState::getKeyMap(synergy::KeyMap& keyMap)
}
}
+static io_connect_t getEventDriver(void)
+{
+ static mach_port_t sEventDrvrRef = 0;
+ mach_port_t masterPort, service, iter;
+ kern_return_t kr;
+
+ if (!sEventDrvrRef) {
+ // Get master device port
+ kr = IOMasterPort(bootstrap_port, &masterPort);
+ assert(KERN_SUCCESS == kr);
+
+ kr = IOServiceGetMatchingServices(masterPort,
+ IOServiceMatching(kIOHIDSystemClass), &iter);
+ assert(KERN_SUCCESS == kr);
+
+ service = IOIteratorNext(iter);
+ assert(service);
+
+ kr = IOServiceOpen(service, mach_task_self(),
+ kIOHIDParamConnectType, &sEventDrvrRef);
+ assert(KERN_SUCCESS == kr);
+
+ IOObjectRelease(service);
+ IOObjectRelease(iter);
+ }
+
+ return sEventDrvrRef;
+}
+
+void
+OSXKeyState::postHIDVirtualKey(const UInt8 virtualKeyCode,
+ const bool postDown)
+{
+ static UInt32 modifiers = 0;
+
+ NXEventData event;
+ IOGPoint loc = { 0, 0 };
+ UInt32 modifiersDelta = 0;
+
+ bzero(&event, sizeof(NXEventData));
+
+ switch (virtualKeyCode)
+ {
+ case s_shiftVK:
+ case s_superVK:
+ case s_altVK:
+ case s_controlVK:
+ case s_capsLockVK:
+ switch (virtualKeyCode)
+ {
+ case s_shiftVK:
+ modifiersDelta = NX_SHIFTMASK;
+ m_shiftPressed = postDown;
+ break;
+ case s_superVK:
+ modifiersDelta = NX_COMMANDMASK;
+ m_superPressed = postDown;
+ break;
+ case s_altVK:
+ modifiersDelta = NX_ALTERNATEMASK;
+ m_altPressed = postDown;
+ break;
+ case s_controlVK:
+ modifiersDelta = NX_CONTROLMASK;
+ m_controlPressed = postDown;
+ break;
+ case s_capsLockVK:
+ modifiersDelta = NX_ALPHASHIFTMASK;
+ m_capsPressed = postDown;
+ break;
+ }
+
+ // update the modifier bit
+ if (postDown) {
+ modifiers |= modifiersDelta;
+ }
+ else {
+ modifiers &= ~modifiersDelta;
+ }
+
+ kern_return_t kr;
+ kr = IOHIDPostEvent(getEventDriver(), NX_FLAGSCHANGED, loc,
+ &event, kNXEventDataVersion, modifiers, true);
+ assert(KERN_SUCCESS == kr);
+ break;
+
+ default:
+ event.key.repeat = false;
+ event.key.keyCode = virtualKeyCode;
+ event.key.origCharSet = event.key.charSet = NX_ASCIISET;
+ event.key.origCharCode = event.key.charCode = 0;
+ kr = IOHIDPostEvent(getEventDriver(),
+ postDown ? NX_KEYDOWN : NX_KEYUP,
+ loc, &event, kNXEventDataVersion, 0, false);
+ assert(KERN_SUCCESS == kr);
+ break;
+ }
+}
+
void
OSXKeyState::fakeKey(const Keystroke& keystroke)
{
@@ -477,76 +577,14 @@ OSXKeyState::fakeKey(const Keystroke& keystroke)
KeyButton button = keystroke.m_data.m_button.m_button;
bool keyDown = keystroke.m_data.m_button.m_press;
- UInt32 client = keystroke.m_data.m_button.m_client;
- CGEventSourceRef source = 0;
CGKeyCode virtualKey = mapKeyButtonToVirtualKey(button);
LOG((CLOG_DEBUG1
- " button=0x%04x virtualKey=0x%04x keyDown=%s client=0x%04x",
- button, virtualKey, keyDown ? "down" : "up", client));
+ " button=0x%04x virtualKey=0x%04x keyDown=%s",
+ button, virtualKey, keyDown ? "down" : "up"));
- CGEventRef ref = CGEventCreateKeyboardEvent(
- source, virtualKey, keyDown);
-
- if (ref == NULL) {
- LOG((CLOG_CRIT "unable to create keyboard event for keystroke"));
- return;
- }
-
- // persist modifier state.
- if (virtualKey == s_shiftVK) {
- m_shiftPressed = keyDown;
- }
-
- if (virtualKey == s_controlVK) {
- m_controlPressed = keyDown;
- }
-
- if (virtualKey == s_altVK) {
- m_altPressed = keyDown;
- }
-
- if (virtualKey == s_superVK) {
- m_superPressed = keyDown;
- }
-
- if (virtualKey == s_capsLockVK) {
- m_capsPressed = keyDown;
- }
+ postHIDVirtualKey(virtualKey, keyDown);
- // set the event flags for special keys
- // http://tinyurl.com/pxl742y
- CGEventFlags modifiers = 0;
-
- if (m_shiftPressed) {
- modifiers |= kCGEventFlagMaskShift;
- }
-
- if (m_controlPressed) {
- modifiers |= kCGEventFlagMaskControl;
- }
-
- if (m_altPressed) {
- modifiers |= kCGEventFlagMaskAlternate;
- }
-
- if (m_superPressed) {
- modifiers |= kCGEventFlagMaskCommand;
- }
-
- if (m_capsPressed) {
- modifiers |= kCGEventFlagMaskAlphaShift;
- }
-
- CGEventSetFlags(ref, modifiers);
- CGEventPost(kCGHIDEventTap, ref);
- CFRelease(ref);
-
- // add a delay if client data isn't zero
- // FIXME -- why?
- if (client != 0) {
- ARCH->sleep(0.01);
- }
break;
}
View
@@ -149,6 +149,12 @@ class OSXKeyState : public KeyState {
static UInt32 mapKeyButtonToVirtualKey(KeyButton keyButton);
void init();
+
+ // Post a key event to HID manager. It posts an event to HID client, a
+ // much lower level than window manager which's the target from carbon
+ // CGEventPost
+ void postHIDVirtualKey(const UInt8 virtualKeyCode,
+ const bool postDown);
private:
// OS X uses a physical key if 0 for the 'A' key. synergy reserves
View
@@ -496,7 +496,23 @@
// Fix for sticky keys
CGEventFlags modifiers = m_keyState->getModifierStateAsOSXFlags();
CGEventSetFlags(event, modifiers);
-
+
+ // Set movement deltas to fix issues with certain 3D programs
+ SInt64 deltaX = pos.x;
+ deltaX -= m_xCursor;
+
+ SInt64 deltaY = pos.y;
+ deltaY -= m_yCursor;
+
+ CGEventSetIntegerValueField(event, kCGMouseEventDeltaX, deltaX);
+ CGEventSetIntegerValueField(event, kCGMouseEventDeltaY, deltaY);
+
+ double deltaFX = deltaX;
+ double deltaFY = deltaY;
+
+ CGEventSetDoubleValueField(event, kCGMouseEventDeltaX, deltaFX);
+ CGEventSetDoubleValueField(event, kCGMouseEventDeltaY, deltaFY);
+
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);
View
@@ -160,15 +160,12 @@ XWindowsScreen::XWindowsScreen(
// primary/secondary screen only initialization
if (m_isPrimary) {
- // start watching for events on other windows
- selectEvents(m_root);
+#ifdef HAVE_XI2
m_xi2detected = detectXI2();
-
if (m_xi2detected) {
-#ifdef HAVE_XI2
selectXIRawMotion();
-#endif
} else
+#endif
{
// start watching for events on other windows
selectEvents(m_root);
@@ -745,7 +742,7 @@ XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask)
LOG((CLOG_WARN "failed to register hotkey %s (id=%04x mask=%04x)", synergy::KeyMap::formatKey(key, mask).c_str(), key, mask));
return 0;
}
-
+
LOG((CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", synergy::KeyMap::formatKey(key, mask).c_str(), key, mask, id));
return id;
}
@@ -827,7 +824,7 @@ void
XWindowsScreen::fakeMouseButton(ButtonID button, bool press)
{
const unsigned int xButton = mapButtonToX(button);
- if (xButton != 0) {
+ if (xButton > 0 && xButton < 11) {
XTestFakeButtonEvent(m_display, xButton,
press ? True : False, CurrentTime);
XFlush(m_display);
@@ -977,22 +974,6 @@ XWindowsScreen::saveShape()
m_w = WidthOfScreen(DefaultScreenOfDisplay(m_display));
m_h = HeightOfScreen(DefaultScreenOfDisplay(m_display));
-#if HAVE_X11_EXTENSIONS_XRANDR_H
- if (m_xrandr){
- int numSizes;
- XRRScreenSize* xrrs;
- Rotation rotation;
- xrrs = XRRSizes(m_display, DefaultScreen(m_display), &numSizes);
- XRRRotations(m_display, DefaultScreen(m_display), &rotation);
- if (xrrs != NULL) {
- if (rotation & (RR_Rotate_90|RR_Rotate_270) ){
- m_w = xrrs->height;
- m_h = xrrs->width;
- }
- }
- }
-#endif
-
// get center of default screen
m_xCenter = m_x + (m_w >> 1);
m_yCenter = m_y + (m_h >> 1);
@@ -1300,7 +1281,7 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*)
// handle the event ourself
switch (xevent->type) {
case CreateNotify:
- if (m_isPrimary) {
+ if (m_isPrimary && !m_xi2detected) {
// select events on new window
selectEvents(xevent->xcreatewindow.window);
}
View
@@ -2096,11 +2096,11 @@ ConfigReadContext::parseInterval(const ArgList& args) const
}
char* end;
- long startValue = strtol(args[0].c_str(), &end, 10);
+ double startValue = strtod(args[0].c_str(), &end);
if (end[0] != '\0') {
throw XConfigRead(*this, "invalid interval \"%{1}\"", concatArgs(args));
}
- long endValue = strtol(args[1].c_str(), &end, 10);
+ double endValue = strtod(args[1].c_str(), &end);
if (end[0] != '\0') {
throw XConfigRead(*this, "invalid interval \"%{1}\"", concatArgs(args));
}
View
@@ -33,7 +33,6 @@
#include "synergy/KeyState.h"
#include "synergy/Screen.h"
#include "synergy/PacketStreamFilter.h"
-#include "synergy/DpiHelper.h"
#include "net/TCPSocket.h"
#include "net/IDataSocket.h"
#include "net/IListenSocket.h"
@@ -1767,52 +1766,66 @@ Server::onMouseMovePrimary(SInt32 x, SInt32 y)
}
// see if we should change screens
- EDirection dir;
+ // when the cursor is in a corner, there may be a screen either
+ // horizontally or vertically. check both directions.
+ EDirection dirh = kNoDirection, dirv = kNoDirection;
+ SInt32 xh = x, yv = y;
if (x < ax + zoneSize) {
- x -= zoneSize;
- dir = kLeft;
+ xh -= zoneSize;
+ dirh = kLeft;
}
else if (x >= ax + aw - zoneSize) {
- x += zoneSize;
- dir = kRight;
+ xh += zoneSize;
+ dirh = kRight;
}
- else if (y < ay + zoneSize) {
- y -= zoneSize;
- dir = kTop;
+ if (y < ay + zoneSize) {
+ yv -= zoneSize;
+ dirv = kTop;
}
else if (y >= ay + ah - zoneSize) {
- y += zoneSize;
- dir = kBottom;
+ yv += zoneSize;
+ dirv = kBottom;
}
- else {
+ if (dirh == kNoDirection && dirv == kNoDirection) {
// still on local screen
noSwitch(x, y);
return false;
}
- // get jump destination
- BaseClientProxy* newScreen = mapToNeighbor(m_active, dir, x, y);
+ // check both horizontally and vertically
+ EDirection dirs[] = {dirh, dirv};
+ SInt32 xs[] = {xh, x}, ys[] = {y, yv};
+ for (int i = 0; i < 2; ++i) {
+ EDirection dir = dirs[i];
+ if (dir == kNoDirection) {
+ continue;
+ }
+ x = xs[i], y = ys[i];
+
+ // get jump destination
+ BaseClientProxy* newScreen = mapToNeighbor(m_active, dir, x, y);
+
+ // should we switch or not?
+ if (isSwitchOkay(newScreen, dir, x, y, xc, yc)) {
+ if (m_args.m_enableDragDrop
+ && m_screen->isDraggingStarted()
+ && m_active != newScreen
+ && m_waitDragInfoThread) {
+ if (m_sendDragInfoThread == NULL) {
+ m_sendDragInfoThread = new Thread(
+ new TMethodJob<Server>(
+ this,
+ &Server::sendDragInfoThread, newScreen));
+ }
- // should we switch or not?
- if (isSwitchOkay(newScreen, dir, x, y, xc, yc)) {
- if (m_args.m_enableDragDrop
- && m_screen->isDraggingStarted()
- && m_active != newScreen
- && m_waitDragInfoThread) {
- if (m_sendDragInfoThread == NULL) {
- m_sendDragInfoThread = new Thread(
- new TMethodJob<Server>(
- this,
- &Server::sendDragInfoThread, newScreen));
+ return false;
}
- return false;
+ // switch screen
+ switchScreen(newScreen, x, y, false);
+ m_waitDragInfoThread = true;
+ return true;
}
-
- // switch screen
- switchScreen(newScreen, x, y, false);
- m_waitDragInfoThread = true;
- return true;
}
return false;
@@ -2004,14 +2017,6 @@ Server::onMouseMoveSecondary(SInt32 dx, SInt32 dy)
SInt32 newX = m_x;
SInt32 newY = m_y;
- if (DpiHelper::s_dpiScaled) {
- // only scale if it's going back to server
- if (newScreen->isPrimary()) {
- newX = (SInt32)(newX / DpiHelper::getDpi());
- newY = (SInt32)(newY / DpiHelper::getDpi());
- }
- }
-
// switch screens
switchScreen(newScreen, newX, newY, false);
}
View
@@ -23,7 +23,6 @@
#include "synergy/ClientArgs.h"
#include "synergy/ToolArgs.h"
#include "synergy/ArgsBase.h"
-#include "synergy/DpiHelper.h"
#include "base/Log.h"
#include "base/String.h"
@@ -58,18 +57,6 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv)
// save configuration file path
args.m_configFile = argv[++i];
}
- else if (isArg(i, argc, argv, "", "--res-w", 1)) {
- DpiHelper::s_resolutionWidth = synergy::string::stringToSizeType(argv[++i]);
- }
- else if (isArg(i, argc, argv, "", "--res-h", 1)) {
- DpiHelper::s_resolutionHeight = synergy::string::stringToSizeType(argv[++i]);
- }
- else if (isArg(i, argc, argv, "", "--prm-wc", 1)) {
- DpiHelper::s_primaryWidthCenter = synergy::string::stringToSizeType(argv[++i]);
- }
- else if (isArg(i, argc, argv, "", "--prm-hc", 1)) {
- DpiHelper::s_primaryHeightCenter = synergy::string::stringToSizeType(argv[++i]);
- }
else if (isArg(i, argc, argv, "", "--serial-key", 1)) {
args.m_serial = SerialKey(argv[++i]);
}
@@ -332,6 +319,26 @@ ArgParser::parseDeprecatedArgs(int argc, const char* const* argv, int& i)
i++;
return true;
}
+ else if (isArg(i, argc, argv, NULL, "--res-w")) {
+ LOG((CLOG_NOTE "--res-w is deprecated"));
+ i++;
+ return true;
+ }
+ else if (isArg(i, argc, argv, NULL, "--res-h")) {
+ LOG((CLOG_NOTE "--res-h is deprecated"));
+ i++;
+ return true;
+ }
+ else if (isArg(i, argc, argv, NULL, "--prm-wc")) {
+ LOG((CLOG_NOTE "--prm-wc is deprecated"));
+ i++;
+ return true;
+ }
+ else if (isArg(i, argc, argv, NULL, "--prm-hc")) {
+ LOG((CLOG_NOTE "--prm-hc is deprecated"));
+ i++;
+ return true;
+ }
return false;
}
View
@@ -118,7 +118,7 @@ ClipboardChunk::assemble(synergy::IStream* stream,
return kFinish;
}
- LOG((CLOG_ERR "clipboard transmission failed: unknow error"));
+ LOG((CLOG_ERR "clipboard transmission failed: unknown error"));
return kError;
}
View
@@ -1,53 +0,0 @@
-/*
- * synergy -- mouse and keyboard sharing utility
- * Copyright (C) 2015 Synergy Seamless Inc.
- *
- * 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 LICENSE 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "synergy/DpiHelper.h"
-#include "base/Log.h"
-
-#include <assert.h>
-
-size_t DpiHelper::s_dpi = kDefaultDpi;
-bool DpiHelper::s_dpiScaled = false;
-size_t DpiHelper::s_resolutionWidth = 0;
-size_t DpiHelper::s_resolutionHeight = 0;
-size_t DpiHelper::s_primaryWidthCenter = 0;
-size_t DpiHelper::s_primaryHeightCenter = 0;
-
-void DpiHelper::calculateDpi(size_t width, size_t height)
-{
- if (s_resolutionWidth == 0 ||
- s_resolutionHeight == 0 ||
- s_primaryWidthCenter == 0 ||
- s_primaryHeightCenter == 0) {
- return;
- }
-
- size_t dpiTest1 = s_resolutionWidth * 100 / width;
- size_t dpiTest2 = s_resolutionHeight * 100 / height;
-
- if (dpiTest1 == dpiTest2) {
- s_dpi = dpiTest1;
-
- if (s_dpi != kDefaultDpi) {
- s_dpiScaled = true;
-
- LOG((CLOG_DEBUG "DPI: %d%%", s_dpi));
- LOG((CLOG_DEBUG "physical resolution: %d, %d scaled resolution: %d, %d",
- s_resolutionWidth, s_resolutionHeight, width, height));
- }
- }
-}
View
@@ -1,38 +0,0 @@
-/*
- * synergy -- mouse and keyboard sharing utility
- * Copyright (C) 2015 Synergy Seamless Inc.
- *
- * 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 LICENSE 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include "common/common.h"
-
-class DpiHelper {
-public:
- enum EDpi {
- kDefaultDpi = 100
- };
-
- static void calculateDpi(size_t width, size_t height);
- static float getDpi() { return (float)(s_dpi / 100.0f); }
-
-public:
- static size_t s_dpi;
- static bool s_dpiScaled;
- static size_t s_resolutionWidth;
- static size_t s_resolutionHeight;
- static size_t s_primaryWidthCenter;
- static size_t s_primaryHeightCenter;
-};
View
@@ -110,10 +110,12 @@ static const KeyID kKeyScrollLock = 0xEF14;
static const KeyID kKeySysReq = 0xEF15;
static const KeyID kKeyEscape = 0xEF1B;
static const KeyID kKeyHenkan = 0xEF23; /* Start/Stop Conversion */
-static const KeyID kKeyHangulKana = 0xEF26; /* Hangul, Kana */
+static const KeyID kKeyKana = 0xEF26; /* Kana */
static const KeyID kKeyHiraganaKatakana = 0xEF27; /* Hiragana/Katakana toggle */
static const KeyID kKeyZenkaku = 0xEF2A; /* Zenkaku/Hankaku */
-static const KeyID kKeyHanjaKanzi = 0xEF2A; /* Hanja, Kanzi */
+static const KeyID kKeyKanzi = 0xEF2A; /* Kanzi */
+static const KeyID kKeyHangul = 0xEF31; /* Hangul */
+static const KeyID kKeyHanja = 0xEF34; /* Hanja */
static const KeyID kKeyDelete = 0xEFFF; /* Delete, rubout */
// cursor control
View
@@ -46,7 +46,7 @@ extern "C" {
#error "Can't define both USYNERGY_LITTLE_ENDIAN and USYNERGY_BIG_ENDIAN"
#elif !defined(USYNERGY_LITTLE_ENDIAN) && !defined(USYNERGY_BIG_ENDIAN)
/* Attempt to auto detect */
- #if defined(__LITTLE_ENDIAN__) || defined(LITTLE_ENDIAN) || (_BYTE_ORDER == _LITTLE_ENDIAN)
+ #if defined(__LITTLE_ENDIAN__) || defined(LITTLE_ENDIAN)
#define USYNERGY_LITTLE_ENDIAN
#elif defined(__BIG_ENDIAN__) || defined(BIG_ENDIAN) || (_BYTE_ORDER == _BIG_ENDIAN)
#define USYNERGY_BIG_ENDIAN
View
@@ -28,8 +28,23 @@
<ComponentGroupRef Id="ProductComponents" />
<ComponentGroupRef Id="OpenSslComponents" />
<MergeRef Id="CRT" />
+ <ComponentRef Id="RegistryEntries" />
</Feature>
+ <DirectoryRef Id="TARGETDIR">
+ <Component Id="RegistryEntries" Guid="7CF3564D-1F8E-4D3D-9781-E1EE22D5BD67">
+ <RegistryKey Root="HKLM"
+ Key="Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
+ Action="createAndRemoveOnUninstall">
+ <RegistryValue Type="string" Name="[INSTALLFOLDER]synergys.exe" Value="~ HIGHDPIAWARE WIN7RTM"/>
+ </RegistryKey>
+
+ <Condition>
+ <![CDATA[Installed OR (VersionNT >= 602)]]>
+ </Condition>
+ </Component>
+ </DirectoryRef>
+
<Icon Id="synergy.ico" SourceFile="$(var.ResPath)/synergy.ico"/>
<WixVariable Id="WixUILicenseRtf" Value="$(var.ResPath)\License.rtf" />
View
@@ -121,3 +121,24 @@ TEST_F(MSWindowsKeyStateTests, saveModifiers_noModifiers_savedModifiers0)
ASSERT_EQ(0, keyState.getSavedModifiers());
delete desks;
}
+
+TEST_F(MSWindowsKeyStateTests, testKoreanLocale_inputModeKey_resultCorrectKeyID)
+{
+ NiceMock<MockEventQueue> eventQueue;
+ MSWindowsDesks* desks = newDesks(&eventQueue);
+ MockKeyMap keyMap;
+ MSWindowsKeyState keyState(desks, getEventTarget(), &eventQueue, keyMap);
+
+ keyState.setKeyLayout((HKL)0x00000412u); // for ko-KR local ID
+ ASSERT_EQ(0xEF31, keyState.getKeyID(0x15u, 0x1f2u)); // VK_HANGUL from Hangul key
+ ASSERT_EQ(0xEF34, keyState.getKeyID(0x19u, 0x1f1u)); // VK_HANJA from Hanja key
+ ASSERT_EQ(0xEF31, keyState.getKeyID(0x15u, 0x11du)); // VK_HANGUL from R-Alt key
+ ASSERT_EQ(0xEF34, keyState.getKeyID(0x19u, 0x138u)); // VK_HANJA from R-Ctrl key
+
+ keyState.setKeyLayout((HKL)0x00000411); // for ja-jp locale ID
+ ASSERT_EQ(0xEF26, keyState.getKeyID(0x15u, 0x1du)); // VK_KANA
+ ASSERT_EQ(0xEF2A, keyState.getKeyID(0x19u, 0x38u)); // VK_KANJI
+
+ delete desks;
+}
+
View
@@ -26,9 +26,11 @@ TEST(ClipboardChunkTests, start_formatStartChunk)
UInt32 sequence = 0;
String mockDataSize("10");
ClipboardChunk* chunk = ClipboardChunk::start(id, sequence, mockDataSize);
+ UInt32 temp_m_chunk;
+ memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4);
EXPECT_EQ(id, chunk->m_chunk[0]);
- EXPECT_EQ(sequence, (UInt32)chunk->m_chunk[1]);
+ EXPECT_EQ(sequence, temp_m_chunk);
EXPECT_EQ(kDataStart, chunk->m_chunk[5]);
EXPECT_EQ('1', chunk->m_chunk[6]);
EXPECT_EQ('0', chunk->m_chunk[7]);
@@ -43,9 +45,11 @@ TEST(ClipboardChunkTests, data_formatDataChunk)
UInt32 sequence = 1;
String mockData("mock data");
ClipboardChunk* chunk = ClipboardChunk::data(id, sequence, mockData);
+ UInt32 temp_m_chunk;
+ memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4);
EXPECT_EQ(id, chunk->m_chunk[0]);
- EXPECT_EQ(sequence, (UInt32)chunk->m_chunk[1]);
+ EXPECT_EQ(sequence, temp_m_chunk);
EXPECT_EQ(kDataChunk, chunk->m_chunk[5]);
EXPECT_EQ('m', chunk->m_chunk[6]);
EXPECT_EQ('o', chunk->m_chunk[7]);
@@ -66,9 +70,11 @@ TEST(ClipboardChunkTests, end_formatDataChunk)
ClipboardID id = 1;
UInt32 sequence = 1;
ClipboardChunk* chunk = ClipboardChunk::end(id, sequence);
+ UInt32 temp_m_chunk;
+ memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4);
EXPECT_EQ(id, chunk->m_chunk[0]);
- EXPECT_EQ(sequence, (UInt32)chunk->m_chunk[1]);
+ EXPECT_EQ(sequence, temp_m_chunk);
EXPECT_EQ(kDataEnd, chunk->m_chunk[5]);
EXPECT_EQ('\0', chunk->m_chunk[6]);
View
@@ -1,70 +0,0 @@
-/*
- * synergy -- mouse and keyboard sharing utility
- * Copyright (C) 2015 Synergy Seamless Inc.
- *
- * 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 LICENSE 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "synergy/DpiHelper.h"
-
-#include "test/global/gtest.h"
-
-void resetStaticVariables()
-{
- DpiHelper::s_resolutionWidth = 0;
- DpiHelper::s_resolutionHeight = 0;
- DpiHelper::s_primaryWidthCenter = 0;
- DpiHelper::s_primaryHeightCenter = 0;
- DpiHelper::s_dpi = DpiHelper::kDefaultDpi;
- DpiHelper::s_dpiScaled = false;
-}
-
-TEST(DpiHelperTests, calculateDpi_samePhysicalAndVirtualResolutions_defaultDpi)
-{
- resetStaticVariables();
-
- DpiHelper::s_resolutionWidth = 1920;
- DpiHelper::s_resolutionHeight = 1080;
- DpiHelper::s_primaryWidthCenter = 960;
- DpiHelper::s_primaryHeightCenter = 540;
-
- DpiHelper::calculateDpi(1920, 1080);
-
- EXPECT_FALSE(DpiHelper::s_dpiScaled);
- EXPECT_EQ(DpiHelper::kDefaultDpi, DpiHelper::s_dpi);
-}
-
-TEST(DpiHelperTests, calculateDpi_differentPhysicalAndVirtualResolutions_scaledDpi)
-{
- resetStaticVariables();
-
- DpiHelper::s_resolutionWidth = 1920;
- DpiHelper::s_resolutionHeight = 1080;
- DpiHelper::s_primaryWidthCenter = 960;
- DpiHelper::s_primaryHeightCenter = 540;
-
- DpiHelper::calculateDpi(960, 540);
-
- EXPECT_TRUE(DpiHelper::s_dpiScaled);
- EXPECT_EQ(200, DpiHelper::s_dpi);
-}
-
-TEST(DpiHelperTests, calculateDpi_defaultStaticValues_defaultDpi)
-{
- resetStaticVariables();
-
- DpiHelper::calculateDpi(1920, 1080);
-
- EXPECT_FALSE(DpiHelper::s_dpiScaled);
- EXPECT_EQ(DpiHelper::kDefaultDpi, DpiHelper::s_dpi);
-}