SYNERGY-1454 Scroll direction refactoring (#7141)
* SYNERGY-1454 MacOS part * SYNERGY-1454 Windows part * SYNERGY-1454 Linux part * SYNERGY-1454 Fix comments * SYNERGY-1454 Move common code to parent class. MacOS * SYNERGY-1454 Move common code to parent class. Linux * SYNERGY-1454 Move common code to parent class. Windows * SYNERGY-1454 ChangeLog and code smell fix
This commit is contained in:
parent
af4c88e531
commit
bf102d4601
10 changed files with 69 additions and 33 deletions
|
|
@ -3,6 +3,7 @@ v1.14.3-snapshot
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
- #7135 Fix issue with function keys on macOS
|
- #7135 Fix issue with function keys on macOS
|
||||||
- #7140 Configure scroll direction on a per-computer basis
|
- #7140 Configure scroll direction on a per-computer basis
|
||||||
|
- #7141 Code refactoring for the configure scroll direction task
|
||||||
===========
|
===========
|
||||||
|
|
||||||
v1.14.2-stable
|
v1.14.2-stable
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,10 @@ MSWindowsScreen::MSWindowsScreen(
|
||||||
bool isPrimary,
|
bool isPrimary,
|
||||||
bool noHooks,
|
bool noHooks,
|
||||||
bool stopOnDeskSwitch,
|
bool stopOnDeskSwitch,
|
||||||
IEventQueue* events) :
|
IEventQueue* events,
|
||||||
PlatformScreen(events),
|
bool enableLangSync,
|
||||||
|
lib::synergy::ClientScrollDirection scrollDirection) :
|
||||||
|
PlatformScreen(events, scrollDirection),
|
||||||
m_isPrimary(isPrimary),
|
m_isPrimary(isPrimary),
|
||||||
m_noHooks(noHooks),
|
m_noHooks(noHooks),
|
||||||
m_isOnScreen(m_isPrimary),
|
m_isOnScreen(m_isPrimary),
|
||||||
|
|
@ -146,7 +148,7 @@ MSWindowsScreen::MSWindowsScreen(
|
||||||
stopOnDeskSwitch);
|
stopOnDeskSwitch);
|
||||||
m_keyState = new MSWindowsKeyState(m_desks, getEventTarget(), m_events,
|
m_keyState = new MSWindowsKeyState(m_desks, getEventTarget(), m_events,
|
||||||
AppUtil::instance().getKeyboardLayoutList(),
|
AppUtil::instance().getKeyboardLayoutList(),
|
||||||
ClientApp::instance().args().m_enableLangSync);
|
enableLangSync);
|
||||||
|
|
||||||
updateScreenShape();
|
updateScreenShape();
|
||||||
m_class = createWindowClass();
|
m_class = createWindowClass();
|
||||||
|
|
@ -825,8 +827,8 @@ MSWindowsScreen::fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const
|
||||||
void
|
void
|
||||||
MSWindowsScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const
|
MSWindowsScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const
|
||||||
{
|
{
|
||||||
xDelta *= ClientApp::instance().args().m_clientScrollDirection;
|
xDelta = mapClientScrollDirection(xDelta);
|
||||||
yDelta *= ClientApp::instance().args().m_clientScrollDirection;
|
yDelta = mapClientScrollDirection(yDelta);
|
||||||
m_desks->fakeMouseWheel(xDelta, yDelta);
|
m_desks->fakeMouseWheel(xDelta, yDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include "platform/MSWindowsPowerManager.h"
|
#include "platform/MSWindowsPowerManager.h"
|
||||||
#include "synergy/PlatformScreen.h"
|
#include "synergy/PlatformScreen.h"
|
||||||
#include "synergy/DragInformation.h"
|
#include "synergy/DragInformation.h"
|
||||||
|
#include "synergy/ClientArgs.h"
|
||||||
#include "platform/synwinhk.h"
|
#include "platform/synwinhk.h"
|
||||||
#include "mt/CondVar.h"
|
#include "mt/CondVar.h"
|
||||||
#include "mt/Mutex.h"
|
#include "mt/Mutex.h"
|
||||||
|
|
@ -44,7 +45,9 @@ public:
|
||||||
bool isPrimary,
|
bool isPrimary,
|
||||||
bool noHooks,
|
bool noHooks,
|
||||||
bool stopOnDeskSwitch,
|
bool stopOnDeskSwitch,
|
||||||
IEventQueue* events);
|
IEventQueue* events,
|
||||||
|
bool enableLangSync = false,
|
||||||
|
lib::synergy::ClientScrollDirection scrollDirection = lib::synergy::ClientScrollDirection::SERVER);
|
||||||
virtual ~MSWindowsScreen();
|
virtual ~MSWindowsScreen();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,11 @@ class Mutex;
|
||||||
//! Implementation of IPlatformScreen for OS X
|
//! Implementation of IPlatformScreen for OS X
|
||||||
class OSXScreen : public PlatformScreen {
|
class OSXScreen : public PlatformScreen {
|
||||||
public:
|
public:
|
||||||
OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCursor=true);
|
OSXScreen(IEventQueue* events,
|
||||||
|
bool isPrimary,
|
||||||
|
bool enableLangSync = false,
|
||||||
|
lib::synergy::ClientScrollDirection scrollDirection = lib::synergy::ClientScrollDirection::SERVER);
|
||||||
|
|
||||||
virtual ~OSXScreen();
|
virtual ~OSXScreen();
|
||||||
|
|
||||||
IEventQueue* getEvents() const { return m_events; }
|
IEventQueue* getEvents() const { return m_events; }
|
||||||
|
|
@ -330,9 +334,6 @@ private:
|
||||||
SInt32 m_lastSingleClickXCursor;
|
SInt32 m_lastSingleClickXCursor;
|
||||||
SInt32 m_lastSingleClickYCursor;
|
SInt32 m_lastSingleClickYCursor;
|
||||||
|
|
||||||
// cursor will hide and show on enable and disable if true.
|
|
||||||
bool m_autoShowHideCursor;
|
|
||||||
|
|
||||||
IEventQueue* m_events;
|
IEventQueue* m_events;
|
||||||
|
|
||||||
Thread* m_getDropTargetThread;
|
Thread* m_getDropTargetThread;
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,11 @@ void avoidHesitatingCursor();
|
||||||
bool OSXScreen::s_testedForGHOM = false;
|
bool OSXScreen::s_testedForGHOM = false;
|
||||||
bool OSXScreen::s_hasGHOM = false;
|
bool OSXScreen::s_hasGHOM = false;
|
||||||
|
|
||||||
OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCursor) :
|
OSXScreen::OSXScreen(IEventQueue* events,
|
||||||
PlatformScreen(events),
|
bool isPrimary,
|
||||||
|
bool enableLangSync,
|
||||||
|
lib::synergy::ClientScrollDirection scrollDirection) :
|
||||||
|
PlatformScreen(events, scrollDirection),
|
||||||
m_isPrimary(isPrimary),
|
m_isPrimary(isPrimary),
|
||||||
m_isOnScreen(m_isPrimary),
|
m_isOnScreen(m_isPrimary),
|
||||||
m_cursorPosValid(false),
|
m_cursorPosValid(false),
|
||||||
|
|
@ -113,7 +116,6 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso
|
||||||
m_clickState(1),
|
m_clickState(1),
|
||||||
m_lastSingleClickXCursor(0),
|
m_lastSingleClickXCursor(0),
|
||||||
m_lastSingleClickYCursor(0),
|
m_lastSingleClickYCursor(0),
|
||||||
m_autoShowHideCursor(autoShowHideCursor),
|
|
||||||
m_events(events),
|
m_events(events),
|
||||||
m_getDropTargetThread(NULL),
|
m_getDropTargetThread(NULL),
|
||||||
m_impl(NULL)
|
m_impl(NULL)
|
||||||
|
|
@ -127,7 +129,7 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso
|
||||||
m_screensaver = new OSXScreenSaver(m_events, getEventTarget());
|
m_screensaver = new OSXScreenSaver(m_events, getEventTarget());
|
||||||
m_keyState = new OSXKeyState(m_events,
|
m_keyState = new OSXKeyState(m_events,
|
||||||
AppUtil::instance().getKeyboardLayoutList(),
|
AppUtil::instance().getKeyboardLayoutList(),
|
||||||
ClientApp::instance().args().m_enableLangSync);
|
enableLangSync);
|
||||||
|
|
||||||
if (App::instance().argsBase().m_preventSleep) {
|
if (App::instance().argsBase().m_preventSleep) {
|
||||||
m_powerManager.disableSleep();
|
m_powerManager.disableSleep();
|
||||||
|
|
@ -786,9 +788,7 @@ OSXScreen::enable()
|
||||||
else {
|
else {
|
||||||
// FIXME -- prevent system from entering power save mode
|
// FIXME -- prevent system from entering power save mode
|
||||||
|
|
||||||
if (m_autoShowHideCursor) {
|
hideCursor();
|
||||||
hideCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
// warp the mouse to the cursor center
|
// warp the mouse to the cursor center
|
||||||
fakeMouseMove(m_xCenter, m_yCenter);
|
fakeMouseMove(m_xCenter, m_yCenter);
|
||||||
|
|
@ -819,9 +819,7 @@ OSXScreen::enable()
|
||||||
void
|
void
|
||||||
OSXScreen::disable()
|
OSXScreen::disable()
|
||||||
{
|
{
|
||||||
if (m_autoShowHideCursor) {
|
showCursor();
|
||||||
showCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME -- stop watching jump zones, stop capturing input
|
// FIXME -- stop watching jump zones, stop capturing input
|
||||||
|
|
||||||
|
|
@ -1469,7 +1467,7 @@ OSXScreen::mapScrollWheelFromSynergy(SInt32 x) const
|
||||||
// use server's acceleration with a little boost since other platforms
|
// use server's acceleration with a little boost since other platforms
|
||||||
// take one wheel step as a larger step than the mac does.
|
// take one wheel step as a larger step than the mac does.
|
||||||
auto result = static_cast<SInt32>(3.0 * x / 120.0);
|
auto result = static_cast<SInt32>(3.0 * x / 120.0);
|
||||||
return (result * ClientApp::instance().args().m_clientScrollDirection);
|
return mapClientScrollDirection(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,9 @@ XWindowsScreen::XWindowsScreen(
|
||||||
bool isPrimary,
|
bool isPrimary,
|
||||||
bool disableXInitThreads,
|
bool disableXInitThreads,
|
||||||
int mouseScrollDelta,
|
int mouseScrollDelta,
|
||||||
IEventQueue* events) :
|
IEventQueue* events,
|
||||||
|
lib::synergy::ClientScrollDirection scrollDirection) :
|
||||||
|
PlatformScreen(events, scrollDirection),
|
||||||
m_isPrimary(isPrimary),
|
m_isPrimary(isPrimary),
|
||||||
m_mouseScrollDelta(mouseScrollDelta),
|
m_mouseScrollDelta(mouseScrollDelta),
|
||||||
m_display(NULL),
|
m_display(NULL),
|
||||||
|
|
@ -125,8 +127,7 @@ XWindowsScreen::XWindowsScreen(
|
||||||
m_xkb(false),
|
m_xkb(false),
|
||||||
m_xi2detected(false),
|
m_xi2detected(false),
|
||||||
m_xrandr(false),
|
m_xrandr(false),
|
||||||
m_events(events),
|
m_events(events)
|
||||||
PlatformScreen(events)
|
|
||||||
{
|
{
|
||||||
assert(s_screen == NULL);
|
assert(s_screen == NULL);
|
||||||
|
|
||||||
|
|
@ -876,7 +877,7 @@ XWindowsScreen::fakeMouseWheel(SInt32, SInt32 yDelta) const
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
yDelta *= ClientApp::instance().args().m_clientScrollDirection;
|
yDelta = mapClientScrollDirection(yDelta);
|
||||||
|
|
||||||
// choose button depending on rotation direction
|
// choose button depending on rotation direction
|
||||||
const unsigned int xButton = mapButtonToX(static_cast<ButtonID>(
|
const unsigned int xButton = mapButtonToX(static_cast<ButtonID>(
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "synergy/PlatformScreen.h"
|
#include "synergy/PlatformScreen.h"
|
||||||
#include "synergy/KeyMap.h"
|
#include "synergy/KeyMap.h"
|
||||||
|
#include "synergy/ClientArgs.h"
|
||||||
#include "common/stdset.h"
|
#include "common/stdset.h"
|
||||||
#include "common/stdvector.h"
|
#include "common/stdvector.h"
|
||||||
#include "platform/XWindowsPowerManager.h"
|
#include "platform/XWindowsPowerManager.h"
|
||||||
|
|
@ -40,7 +41,8 @@ class XWindowsScreen : public PlatformScreen {
|
||||||
public:
|
public:
|
||||||
XWindowsScreen(const char* displayName, bool isPrimary,
|
XWindowsScreen(const char* displayName, bool isPrimary,
|
||||||
bool disableXInitThreads, int mouseScrollDelta,
|
bool disableXInitThreads, int mouseScrollDelta,
|
||||||
IEventQueue* events);
|
IEventQueue* events,
|
||||||
|
lib::synergy::ClientScrollDirection m_clientScrollDirection = lib::synergy::ClientScrollDirection::SERVER);
|
||||||
virtual ~XWindowsScreen();
|
virtual ~XWindowsScreen();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
|
|
||||||
|
|
@ -180,13 +180,17 @@ ClientApp::createScreen()
|
||||||
{
|
{
|
||||||
#if WINAPI_MSWINDOWS
|
#if WINAPI_MSWINDOWS
|
||||||
return new synergy::Screen(new MSWindowsScreen(
|
return new synergy::Screen(new MSWindowsScreen(
|
||||||
false, args().m_noHooks, args().m_stopOnDeskSwitch, m_events), m_events);
|
false, args().m_noHooks, args().m_stopOnDeskSwitch, m_events,
|
||||||
|
args().m_enableLangSync, args().m_clientScrollDirection), m_events);
|
||||||
#elif WINAPI_XWINDOWS
|
#elif WINAPI_XWINDOWS
|
||||||
return new synergy::Screen(new XWindowsScreen(
|
return new synergy::Screen(new XWindowsScreen(
|
||||||
args().m_display, false, args().m_disableXInitThreads,
|
args().m_display, false, args().m_disableXInitThreads,
|
||||||
args().m_yscroll, m_events), m_events);
|
args().m_yscroll, m_events, args().m_clientScrollDirection), m_events);
|
||||||
#elif WINAPI_CARBON
|
#elif WINAPI_CARBON
|
||||||
return new synergy::Screen(new OSXScreen(m_events, false), m_events);
|
return new synergy::Screen(new OSXScreen(m_events, false,
|
||||||
|
args().m_enableLangSync,
|
||||||
|
args().m_clientScrollDirection),
|
||||||
|
m_events);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,11 @@
|
||||||
#include "synergy/App.h"
|
#include "synergy/App.h"
|
||||||
#include "synergy/ArgsBase.h"
|
#include "synergy/ArgsBase.h"
|
||||||
|
|
||||||
PlatformScreen::PlatformScreen(IEventQueue* events) :
|
PlatformScreen::PlatformScreen(IEventQueue* events, lib::synergy::ClientScrollDirection scrollDirection) :
|
||||||
IPlatformScreen(events),
|
IPlatformScreen(events),
|
||||||
m_draggingStarted(false),
|
m_draggingStarted(false),
|
||||||
m_fakeDraggingStarted(false)
|
m_fakeDraggingStarted(false),
|
||||||
|
m_clientScrollDirection(scrollDirection)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,3 +122,10 @@ PlatformScreen::isDraggingStarted()
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SInt32
|
||||||
|
PlatformScreen::mapClientScrollDirection(SInt32 x) const
|
||||||
|
{
|
||||||
|
return (x * m_clientScrollDirection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "synergy/IPlatformScreen.h"
|
#include "synergy/IPlatformScreen.h"
|
||||||
#include "synergy/DragInformation.h"
|
#include "synergy/DragInformation.h"
|
||||||
|
#include "synergy/ClientArgs.h"
|
||||||
#include "common/stdexcept.h"
|
#include "common/stdexcept.h"
|
||||||
|
|
||||||
//! Base screen implementation
|
//! Base screen implementation
|
||||||
|
|
@ -30,7 +31,7 @@ subclasses to implement the rest.
|
||||||
*/
|
*/
|
||||||
class PlatformScreen : public IPlatformScreen {
|
class PlatformScreen : public IPlatformScreen {
|
||||||
public:
|
public:
|
||||||
PlatformScreen(IEventQueue* events);
|
PlatformScreen(IEventQueue* events, lib::synergy::ClientScrollDirection scrollDirection = lib::synergy::ClientScrollDirection::SERVER);
|
||||||
virtual ~PlatformScreen();
|
virtual ~PlatformScreen();
|
||||||
|
|
||||||
// IScreen overrides
|
// IScreen overrides
|
||||||
|
|
@ -120,8 +121,23 @@ protected:
|
||||||
// IPlatformScreen overrides
|
// IPlatformScreen overrides
|
||||||
virtual void handleSystemEvent(const Event& event, void*) = 0;
|
virtual void handleSystemEvent(const Event& event, void*) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief mapClientScrollDirection
|
||||||
|
* Convert scroll according to client scroll directio
|
||||||
|
* \return converted value according to the client scroll direction
|
||||||
|
*/
|
||||||
|
virtual SInt32 mapClientScrollDirection(SInt32) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
String m_draggingFilename;
|
String m_draggingFilename;
|
||||||
bool m_draggingStarted;
|
bool m_draggingStarted;
|
||||||
bool m_fakeDraggingStarted;
|
bool m_fakeDraggingStarted;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*!
|
||||||
|
* \brief m_clientScrollDirection
|
||||||
|
* This member contains client scroll direction.
|
||||||
|
* This member is used only on client side.
|
||||||
|
*/
|
||||||
|
lib::synergy::ClientScrollDirection m_clientScrollDirection = lib::synergy::ClientScrollDirection::SERVER;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue