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