refactor: use bool for invert scrolling
This commit is contained in:
parent
2cb36777f9
commit
5fc00f7af4
11 changed files with 24 additions and 39 deletions
|
|
@ -146,11 +146,12 @@ const char *ClientApp::daemonInfo() const
|
|||
|
||||
deskflow::Screen *ClientApp::createScreen()
|
||||
{
|
||||
const bool invertScrolling = Settings::value(Settings::Client::InvertScrollDirection).toBool();
|
||||
#if WINAPI_MSWINDOWS
|
||||
return new deskflow::Screen(
|
||||
new MSWindowsScreen(
|
||||
false, Settings::value(Settings::Core::UseHooks).toBool(), getEvents(),
|
||||
Settings::value(Settings::Client::LanguageSync).toBool(), args().m_clientScrollDirection
|
||||
Settings::value(Settings::Client::LanguageSync).toBool(), invertScrolling
|
||||
),
|
||||
getEvents()
|
||||
);
|
||||
|
|
@ -160,9 +161,7 @@ deskflow::Screen *ClientApp::createScreen()
|
|||
if (deskflow::platform::isWayland()) {
|
||||
#if WINAPI_LIBEI
|
||||
LOG_INFO("using ei screen for wayland");
|
||||
return new deskflow::Screen(
|
||||
new deskflow::EiScreen(false, getEvents(), true, args().m_clientScrollDirection), getEvents()
|
||||
);
|
||||
return new deskflow::Screen(new deskflow::EiScreen(false, getEvents(), true, invertScrolling), getEvents());
|
||||
#else
|
||||
throw XNoEiSupport();
|
||||
#endif
|
||||
|
|
@ -174,7 +173,7 @@ deskflow::Screen *ClientApp::createScreen()
|
|||
return new deskflow::Screen(
|
||||
new XWindowsScreen(
|
||||
qPrintable(Settings::value(Settings::Core::Display).toString()), false,
|
||||
Settings::value(Settings::Client::ScrollSpeed).toInt(), getEvents(), args().m_clientScrollDirection
|
||||
Settings::value(Settings::Client::ScrollSpeed).toInt(), getEvents(), invertScrolling
|
||||
),
|
||||
getEvents()
|
||||
);
|
||||
|
|
@ -183,9 +182,7 @@ deskflow::Screen *ClientApp::createScreen()
|
|||
|
||||
#if WINAPI_CARBON
|
||||
return new deskflow::Screen(
|
||||
new OSXScreen(
|
||||
getEvents(), false, Settings::value(Settings::Client::LanguageSync).toBool(), args().m_clientScrollDirection
|
||||
),
|
||||
new OSXScreen(getEvents(), false, Settings::value(Settings::Client::LanguageSync).toBool(), invertScrolling),
|
||||
getEvents()
|
||||
);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@
|
|||
|
||||
#include "deskflow/PlatformScreen.h"
|
||||
#include "base/DirectionTypes.h"
|
||||
#include "common/Settings.h"
|
||||
#include "deskflow/App.h"
|
||||
|
||||
PlatformScreen::PlatformScreen(IEventQueue *events, deskflow::ClientScrollDirection scrollDirection)
|
||||
PlatformScreen::PlatformScreen(IEventQueue *events, bool invertScrolling)
|
||||
: IPlatformScreen(events),
|
||||
m_clientScrollDirection(scrollDirection)
|
||||
m_invertScrollDirection(invertScrolling)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
|
@ -86,7 +87,7 @@ void PlatformScreen::pollPressedKeys(KeyButtonSet &pressedKeys) const
|
|||
|
||||
int32_t PlatformScreen::mapClientScrollDirection(int32_t x) const
|
||||
{
|
||||
return (x * static_cast<int>(m_clientScrollDirection));
|
||||
return (m_invertScrollDirection ? -x : x);
|
||||
}
|
||||
|
||||
std::string PlatformScreen::sidesMaskToString(uint32_t sides)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/Settings.h"
|
||||
#include "deskflow/ClientArgs.h"
|
||||
#include "deskflow/IPlatformScreen.h"
|
||||
|
||||
|
|
@ -21,9 +22,7 @@ subclasses to implement the rest.
|
|||
class PlatformScreen : public IPlatformScreen
|
||||
{
|
||||
public:
|
||||
explicit PlatformScreen(
|
||||
IEventQueue *events, deskflow::ClientScrollDirection scrollDirection = deskflow::ClientScrollDirection::Normal
|
||||
);
|
||||
explicit PlatformScreen(IEventQueue *events, bool invertScrollDirection);
|
||||
~PlatformScreen() override = default;
|
||||
|
||||
// IScreen overrides
|
||||
|
|
@ -117,5 +116,5 @@ private:
|
|||
* This member contains client scroll direction.
|
||||
* This member is used only on client side.
|
||||
*/
|
||||
deskflow::ClientScrollDirection m_clientScrollDirection = deskflow::ClientScrollDirection::Normal;
|
||||
bool m_invertScrollDirection = false;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ struct ScrollRemainder
|
|||
|
||||
namespace deskflow {
|
||||
|
||||
EiScreen::EiScreen(bool isPrimary, IEventQueue *events, bool usePortal, deskflow::ClientScrollDirection scrollDirection)
|
||||
: PlatformScreen{events, scrollDirection},
|
||||
EiScreen::EiScreen(bool isPrimary, IEventQueue *events, bool usePortal, bool invertScrolling)
|
||||
: PlatformScreen{events, invertScrolling},
|
||||
m_isPrimary{isPrimary},
|
||||
m_events{events},
|
||||
m_w{1},
|
||||
|
|
|
|||
|
|
@ -33,10 +33,7 @@ class PortalInputCapture;
|
|||
class EiScreen : public PlatformScreen
|
||||
{
|
||||
public:
|
||||
EiScreen(
|
||||
bool isPrimary, IEventQueue *events, bool usePortal,
|
||||
deskflow::ClientScrollDirection scrollDirection = deskflow::ClientScrollDirection::Normal
|
||||
);
|
||||
EiScreen(bool isPrimary, IEventQueue *events, bool usePortal, bool invertScrolling = false);
|
||||
~EiScreen() override;
|
||||
|
||||
// IScreen overrides
|
||||
|
|
|
|||
|
|
@ -81,10 +81,9 @@ HINSTANCE MSWindowsScreen::s_windowInstance = nullptr;
|
|||
MSWindowsScreen *MSWindowsScreen::s_screen = nullptr;
|
||||
|
||||
MSWindowsScreen::MSWindowsScreen(
|
||||
bool isPrimary, bool noHooks, IEventQueue *events, bool enableLangSync,
|
||||
deskflow::ClientScrollDirection scrollDirection
|
||||
bool isPrimary, bool noHooks, IEventQueue *events, bool enableLangSync, bool invertScrolling
|
||||
)
|
||||
: PlatformScreen(events, scrollDirection),
|
||||
: PlatformScreen(events, invertScrolling),
|
||||
m_isPrimary(isPrimary),
|
||||
m_noHooks(noHooks),
|
||||
m_isOnScreen(m_isPrimary),
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ class MSWindowsScreen : public PlatformScreen
|
|||
{
|
||||
public:
|
||||
MSWindowsScreen(
|
||||
bool isPrimary, bool noHooks, IEventQueue *events, bool enableLangSync = false,
|
||||
deskflow::ClientScrollDirection scrollDirection = deskflow::ClientScrollDirection::Normal
|
||||
bool isPrimary, bool noHooks, IEventQueue *events, bool enableLangSync = false, bool invetScrolling = false
|
||||
);
|
||||
~MSWindowsScreen() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,10 +44,7 @@ class Mutex;
|
|||
class OSXScreen : public PlatformScreen
|
||||
{
|
||||
public:
|
||||
OSXScreen(
|
||||
IEventQueue *events, bool isPrimary, bool enableLangSync = false,
|
||||
deskflow::ClientScrollDirection scrollDirection = deskflow::ClientScrollDirection::Normal
|
||||
);
|
||||
OSXScreen(IEventQueue *events, bool isPrimary, bool enableLangSync = false, bool invertScrolling = false);
|
||||
|
||||
virtual ~OSXScreen();
|
||||
|
||||
|
|
|
|||
|
|
@ -73,10 +73,8 @@ void avoidHesitatingCursor();
|
|||
bool OSXScreen::s_testedForGHOM = false;
|
||||
bool OSXScreen::s_hasGHOM = false;
|
||||
|
||||
OSXScreen::OSXScreen(
|
||||
IEventQueue *events, bool isPrimary, bool enableLangSync, deskflow::ClientScrollDirection scrollDirection
|
||||
)
|
||||
: PlatformScreen(events, scrollDirection),
|
||||
OSXScreen::OSXScreen(IEventQueue *events, bool isPrimary, bool enableLangSync, bool invertScrolling)
|
||||
: PlatformScreen(events, invertScrolling),
|
||||
m_isPrimary(isPrimary),
|
||||
m_isOnScreen(m_isPrimary),
|
||||
m_cursorPosValid(false),
|
||||
|
|
|
|||
|
|
@ -84,10 +84,9 @@ static int xi_opcode;
|
|||
XWindowsScreen *XWindowsScreen::s_screen = nullptr;
|
||||
|
||||
XWindowsScreen::XWindowsScreen(
|
||||
const char *displayName, bool isPrimary, int mouseScrollDelta, IEventQueue *events,
|
||||
deskflow::ClientScrollDirection scrollDirection
|
||||
const char *displayName, bool isPrimary, int mouseScrollDelta, IEventQueue *events, bool invertScrolling
|
||||
)
|
||||
: PlatformScreen(events, scrollDirection),
|
||||
: PlatformScreen(events, invertScrolling),
|
||||
m_isPrimary(isPrimary),
|
||||
m_mouseScrollDelta(mouseScrollDelta),
|
||||
m_isOnScreen(m_isPrimary),
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ class XWindowsScreen : public PlatformScreen
|
|||
{
|
||||
public:
|
||||
XWindowsScreen(
|
||||
const char *displayName, bool isPrimary, int mouseScrollDelta, IEventQueue *events,
|
||||
deskflow::ClientScrollDirection m_clientScrollDirection = deskflow::ClientScrollDirection::Normal
|
||||
const char *displayName, bool isPrimary, int mouseScrollDelta, IEventQueue *events, bool invertScrolling = false
|
||||
);
|
||||
~XWindowsScreen() override;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue