added support for mouse wheel on X.

This commit is contained in:
crs 2002-05-23 15:50:38 +00:00
parent 4542bb9e40
commit 24f5b66cf3
2 changed files with 23 additions and 2 deletions

View File

@ -293,10 +293,23 @@ void CXWindowsSecondaryScreen::mouseMove(SInt32 x, SInt32 y)
XSync(display, False);
}
void CXWindowsSecondaryScreen::mouseWheel(SInt32)
void CXWindowsSecondaryScreen::mouseWheel(SInt32 delta)
{
// choose button depending on rotation direction
const unsigned int button = (delta >= 0) ? 4 : 5;
// now use absolute value of delta
if (delta < 0) {
delta = -delta;
}
// send as many clicks as necessary
CDisplayLock display(this);
// FIXME
for (; delta >= 120; delta -= 120) {
XTestFakeButtonEvent(display, button, True, CurrentTime);
XTestFakeButtonEvent(display, button, False, CurrentTime);
}
XSync(display, False);
}
void CXWindowsSecondaryScreen::setClipboard(

View File

@ -124,6 +124,14 @@ void CXWindowsPrimaryScreen::run()
if (button != kButtonNone) {
m_server->onMouseUp(button);
}
else if (xevent.xbutton.button == 4) {
// wheel forward (away from user)
m_server->onMouseWheel(120);
}
else if (xevent.xbutton.button == 5) {
// wheel backward (toward user)
m_server->onMouseWheel(-120);
}
break;
}