refactor: XWindowsScreen use a fixed minimum step value in place of the scroll speed setting
This commit is contained in:
parent
857326b274
commit
0f6ec6c196
4 changed files with 7 additions and 18 deletions
|
|
@ -130,8 +130,7 @@ deskflow::Screen *ClientApp::createScreen()
|
||||||
LOG_INFO("using legacy x windows screen");
|
LOG_INFO("using legacy x windows screen");
|
||||||
return new deskflow::Screen(
|
return new deskflow::Screen(
|
||||||
new XWindowsScreen(
|
new XWindowsScreen(
|
||||||
qPrintable(Settings::value(Settings::Core::Display).toString()), false,
|
qPrintable(Settings::value(Settings::Core::Display).toString()), false, getEvents(), invertScrolling
|
||||||
Settings::value(Settings::Client::ScrollSpeed).toInt(), getEvents(), invertScrolling
|
|
||||||
),
|
),
|
||||||
getEvents()
|
getEvents()
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -419,7 +419,7 @@ deskflow::Screen *ServerApp::createScreen()
|
||||||
#if WINAPI_XWINDOWS
|
#if WINAPI_XWINDOWS
|
||||||
LOG_INFO("using legacy x windows screen");
|
LOG_INFO("using legacy x windows screen");
|
||||||
return new deskflow::Screen(
|
return new deskflow::Screen(
|
||||||
new XWindowsScreen(qPrintable(Settings::value(Settings::Core::Display).toString()), true, 0, getEvents()),
|
new XWindowsScreen(qPrintable(Settings::value(Settings::Core::Display).toString()), true, getEvents()),
|
||||||
getEvents()
|
getEvents()
|
||||||
);
|
);
|
||||||
#elif WINAPI_CARBON
|
#elif WINAPI_CARBON
|
||||||
|
|
|
||||||
|
|
@ -82,19 +82,13 @@ static int xi_opcode;
|
||||||
|
|
||||||
XWindowsScreen *XWindowsScreen::s_screen = nullptr;
|
XWindowsScreen *XWindowsScreen::s_screen = nullptr;
|
||||||
|
|
||||||
XWindowsScreen::XWindowsScreen(
|
XWindowsScreen::XWindowsScreen(const char *displayName, bool isPrimary, IEventQueue *events, bool invertScrolling)
|
||||||
const char *displayName, bool isPrimary, int mouseScrollDelta, IEventQueue *events, bool invertScrolling
|
|
||||||
)
|
|
||||||
: PlatformScreen(events, invertScrolling),
|
: PlatformScreen(events, invertScrolling),
|
||||||
m_isPrimary(isPrimary),
|
m_isPrimary(isPrimary),
|
||||||
m_mouseScrollDelta(mouseScrollDelta),
|
|
||||||
m_isOnScreen(m_isPrimary),
|
m_isOnScreen(m_isPrimary),
|
||||||
m_events(events)
|
m_events(events)
|
||||||
{
|
{
|
||||||
assert(s_screen == nullptr);
|
assert(s_screen == nullptr);
|
||||||
|
|
||||||
if (mouseScrollDelta == 0)
|
|
||||||
m_mouseScrollDelta = 120;
|
|
||||||
s_screen = this;
|
s_screen = this;
|
||||||
|
|
||||||
if (XInitThreads() == 0) {
|
if (XInitThreads() == 0) {
|
||||||
|
|
@ -823,12 +817,11 @@ void XWindowsScreen::fakeMouseWheel(int32_t, int32_t yDelta) const
|
||||||
yDelta = -yDelta;
|
yDelta = -yDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yDelta < m_mouseScrollDelta) {
|
// Delta for a "click"
|
||||||
LOG_WARN("wheel scroll delta (%d) smaller than threshold (%d)", yDelta, m_mouseScrollDelta);
|
static const auto s_mouseDelta = 120;
|
||||||
}
|
|
||||||
|
|
||||||
// send as many clicks as necessary
|
// send as many clicks as necessary
|
||||||
for (; yDelta >= m_mouseScrollDelta; yDelta -= m_mouseScrollDelta) {
|
for (; yDelta >= 0; yDelta -= s_mouseDelta) {
|
||||||
XTestFakeButtonEvent(m_display, xButton, True, CurrentTime);
|
XTestFakeButtonEvent(m_display, xButton, True, CurrentTime);
|
||||||
XTestFakeButtonEvent(m_display, xButton, False, CurrentTime);
|
XTestFakeButtonEvent(m_display, xButton, False, CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,7 @@ class XWindowsScreenSaver;
|
||||||
class XWindowsScreen : public PlatformScreen
|
class XWindowsScreen : public PlatformScreen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XWindowsScreen(
|
XWindowsScreen(const char *displayName, bool isPrimary, IEventQueue *events, bool invertScrolling = false);
|
||||||
const char *displayName, bool isPrimary, int mouseScrollDelta, IEventQueue *events, bool invertScrolling = false
|
|
||||||
);
|
|
||||||
~XWindowsScreen() override;
|
~XWindowsScreen() override;
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
|
@ -167,7 +165,6 @@ private:
|
||||||
|
|
||||||
// true if screen is being used as a primary screen, false otherwise
|
// true if screen is being used as a primary screen, false otherwise
|
||||||
bool m_isPrimary;
|
bool m_isPrimary;
|
||||||
int m_mouseScrollDelta;
|
|
||||||
|
|
||||||
Display *m_display = nullptr;
|
Display *m_display = nullptr;
|
||||||
Window m_root = None;
|
Window m_root = None;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue