#include "config.h"
#include "WheelEvent.h"
#include "PlatformMouseEvent.h"
#include "PlatformWheelEvent.h"
#include "Scrollbar.h"
#include <QGraphicsSceneWheelEvent>
#include <QWheelEvent>
#include <qapplication.h>
namespace WebCore {
void PlatformWheelEvent::applyDelta(int delta, Qt::Orientation orientation)
{
bool fullTick = !(delta % 120);
if (orientation == Qt::Horizontal) {
m_deltaX = (fullTick) ? delta / 120.0f : delta;
m_deltaY = 0;
} else {
m_deltaX = 0;
m_deltaY = (fullTick) ? delta / 120.0f : delta;
}
m_wheelTicksX = m_deltaX;
m_wheelTicksY = m_deltaY;
#ifndef QT_NO_WHEELEVENT
static const float cDefaultQtScrollStep = 20.f;
m_deltaX *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1;
m_deltaY *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1;
#endif
}
PlatformWheelEvent::PlatformWheelEvent(QGraphicsSceneWheelEvent* e)
#ifndef QT_NO_WHEELEVENT
: m_position(e->pos().toPoint())
, m_globalPosition(e->screenPos())
, m_granularity(ScrollByPixelWheelEvent)
, m_isAccepted(false)
, m_shiftKey(e->modifiers() & Qt::ShiftModifier)
, m_ctrlKey(e->modifiers() & Qt::ControlModifier)
, m_altKey(e->modifiers() & Qt::AltModifier)
, m_metaKey(e->modifiers() & Qt::MetaModifier)
#endif
{
#ifndef QT_NO_WHEELEVENT
applyDelta(e->delta(), e->orientation());
#else
Q_UNUSED(e);
#endif
}
PlatformWheelEvent::PlatformWheelEvent(QWheelEvent* e)
#ifndef QT_NO_WHEELEVENT
: m_position(e->pos())
, m_globalPosition(e->globalPos())
, m_granularity(ScrollByPixelWheelEvent)
, m_isAccepted(false)
, m_shiftKey(e->modifiers() & Qt::ShiftModifier)
, m_ctrlKey(e->modifiers() & Qt::ControlModifier)
, m_altKey(e->modifiers() & Qt::AltModifier)
, m_metaKey(e->modifiers() & Qt::MetaModifier)
#endif
{
#ifndef QT_NO_WHEELEVENT
applyDelta(e->delta(), e->orientation());
#else
Q_UNUSED(e);
#endif
}
}