Change mouse and wheel QPA events to use QPointF.
At least QMouseEvent already uses QPointF so there is no reason to restrict handleMouseEvent to integer positions. Change-Id: I9c72d2e0e99518b40a1898aec9ad2b3421a3e9e2 Reviewed-on: http://codereview.qt.nokia.com/2739 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
parent
991033cf46
commit
ffb279a149
@ -76,8 +76,8 @@ QWidget *qt_button_down = 0; // widget got last button-down
|
|||||||
static bool app_do_modal = false;
|
static bool app_do_modal = false;
|
||||||
extern QWidgetList *qt_modal_stack; // stack of modal widgets
|
extern QWidgetList *qt_modal_stack; // stack of modal widgets
|
||||||
|
|
||||||
int qt_last_x = 0;
|
qreal qt_last_x = 0;
|
||||||
int qt_last_y = 0;
|
qreal qt_last_y = 0;
|
||||||
QPointer<QWidget> qt_last_mouse_receiver = 0;
|
QPointer<QWidget> qt_last_mouse_receiver = 0;
|
||||||
|
|
||||||
static Qt::MouseButtons buttons = Qt::NoButton;
|
static Qt::MouseButtons buttons = Qt::NoButton;
|
||||||
@ -621,7 +621,7 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mouse
|
|||||||
QEvent::Type type;
|
QEvent::Type type;
|
||||||
// move first
|
// move first
|
||||||
Qt::MouseButtons stateChange = e->buttons ^ buttons;
|
Qt::MouseButtons stateChange = e->buttons ^ buttons;
|
||||||
if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) {
|
if (e->globalPos != QPointF(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) {
|
||||||
QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent =
|
QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent =
|
||||||
new QWindowSystemInterfacePrivate::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons);
|
new QWindowSystemInterfacePrivate::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons);
|
||||||
QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
|
QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
|
||||||
@ -630,8 +630,8 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mouse
|
|||||||
|
|
||||||
QWidget * tlw = e->widget.data();
|
QWidget * tlw = e->widget.data();
|
||||||
|
|
||||||
QPoint localPoint = e->localPos;
|
QPointF localPoint = e->localPos;
|
||||||
QPoint globalPoint = e->globalPos;
|
QPointF globalPoint = e->globalPos;
|
||||||
QWidget *mouseWindow = tlw;
|
QWidget *mouseWindow = tlw;
|
||||||
|
|
||||||
Qt::MouseButton button = Qt::NoButton;
|
Qt::MouseButton button = Qt::NoButton;
|
||||||
@ -694,7 +694,7 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mouse
|
|||||||
|
|
||||||
// find the tlw if we didn't get it from the plugin
|
// find the tlw if we didn't get it from the plugin
|
||||||
if (!mouseWindow) {
|
if (!mouseWindow) {
|
||||||
mouseWindow = QApplication::topLevelAt(globalPoint);
|
mouseWindow = QApplication::topLevelAt(globalPoint.toPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mouseWindow && !implicit_mouse_grabber)
|
if (!mouseWindow && !implicit_mouse_grabber)
|
||||||
@ -702,13 +702,13 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mouse
|
|||||||
|
|
||||||
if (mouseWindow && mouseWindow != tlw) {
|
if (mouseWindow && mouseWindow != tlw) {
|
||||||
//we did not get a sensible localPoint from the window system, so let's calculate it
|
//we did not get a sensible localPoint from the window system, so let's calculate it
|
||||||
localPoint = mouseWindow->mapFromGlobal(globalPoint);
|
localPoint = mouseWindow->mapFromGlobal(globalPoint.toPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
// which child should have it?
|
// which child should have it?
|
||||||
QWidget *mouseWidget = mouseWindow;
|
QWidget *mouseWidget = mouseWindow;
|
||||||
if (mouseWindow) {
|
if (mouseWindow) {
|
||||||
QWidget *w = mouseWindow->childAt(localPoint);
|
QWidget *w = mouseWindow->childAt(localPoint.toPoint());
|
||||||
if (w) {
|
if (w) {
|
||||||
mouseWidget = w;
|
mouseWidget = w;
|
||||||
}
|
}
|
||||||
@ -724,13 +724,13 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mouse
|
|||||||
mouseWidget = implicit_mouse_grabber.data();
|
mouseWidget = implicit_mouse_grabber.data();
|
||||||
mouseWindow = mouseWidget->window();
|
mouseWindow = mouseWidget->window();
|
||||||
if (mouseWindow != tlw)
|
if (mouseWindow != tlw)
|
||||||
localPoint = mouseWindow->mapFromGlobal(globalPoint);
|
localPoint = mouseWindow->mapFromGlobal(globalPoint.toPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_ASSERT(mouseWidget);
|
Q_ASSERT(mouseWidget);
|
||||||
|
|
||||||
//localPoint is local to mouseWindow, but it needs to be local to mouseWidget
|
//localPoint is local to mouseWindow, but it needs to be local to mouseWidget
|
||||||
localPoint = mouseWidget->mapFrom(mouseWindow, localPoint);
|
localPoint = mouseWidget->mapFrom(mouseWindow, localPoint.toPoint());
|
||||||
|
|
||||||
if (buttons == Qt::NoButton) {
|
if (buttons == Qt::NoButton) {
|
||||||
//qDebug() << "resetting mouse grabber";
|
//qDebug() << "resetting mouse grabber";
|
||||||
@ -760,7 +760,7 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mouse
|
|||||||
|
|
||||||
#ifndef QT_NO_CONTEXTMENU
|
#ifndef QT_NO_CONTEXTMENU
|
||||||
if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
|
if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
|
||||||
QContextMenuEvent e(QContextMenuEvent::Mouse, localPoint, globalPoint, QApplication::keyboardModifiers());
|
QContextMenuEvent e(QContextMenuEvent::Mouse, localPoint.toPoint(), globalPoint.toPoint(), QApplication::keyboardModifiers());
|
||||||
QApplication::sendSpontaneousEvent(mouseWidget, &e);
|
QApplication::sendSpontaneousEvent(mouseWidget, &e);
|
||||||
}
|
}
|
||||||
#endif // QT_NO_CONTEXTMENU
|
#endif // QT_NO_CONTEXTMENU
|
||||||
@ -772,7 +772,7 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mouse
|
|||||||
void QApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e)
|
void QApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e)
|
||||||
{
|
{
|
||||||
// QPoint localPoint = ev.pos();
|
// QPoint localPoint = ev.pos();
|
||||||
QPoint globalPoint = e->globalPos;
|
QPointF globalPoint = e->globalPos;
|
||||||
// bool trustLocalPoint = !!tlw; //is there something the local point can be local to?
|
// bool trustLocalPoint = !!tlw; //is there something the local point can be local to?
|
||||||
QWidget *mouseWidget;
|
QWidget *mouseWidget;
|
||||||
|
|
||||||
@ -783,7 +783,7 @@ void QApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wheel
|
|||||||
|
|
||||||
// find the tlw if we didn't get it from the plugin
|
// find the tlw if we didn't get it from the plugin
|
||||||
if (!mouseWindow) {
|
if (!mouseWindow) {
|
||||||
mouseWindow = QApplication::topLevelAt(globalPoint);
|
mouseWindow = QApplication::topLevelAt(globalPoint.toPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mouseWindow)
|
if (!mouseWindow)
|
||||||
@ -795,11 +795,11 @@ void QApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wheel
|
|||||||
qDebug() << "modal blocked wheel event" << mouseWindow;
|
qDebug() << "modal blocked wheel event" << mouseWindow;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QPoint p = mouseWindow->mapFromGlobal(globalPoint);
|
QPointF p = mouseWindow->mapFromGlobal(globalPoint.toPoint());
|
||||||
QWidget *w = mouseWindow->childAt(p);
|
QWidget *w = mouseWindow->childAt(p.toPoint());
|
||||||
if (w) {
|
if (w) {
|
||||||
mouseWidget = w;
|
mouseWidget = w;
|
||||||
p = mouseWidget->mapFromGlobal(globalPoint);
|
p = mouseWidget->mapFromGlobal(globalPoint.toPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
QWheelEvent ev(p, globalPoint, e->delta, buttons, QApplication::keyboardModifiers(),
|
QWheelEvent ev(p, globalPoint, e->delta, buttons, QApplication::keyboardModifiers(),
|
||||||
|
@ -107,11 +107,11 @@ void QCursorData::update()
|
|||||||
|
|
||||||
#endif //QT_NO_CURSOR
|
#endif //QT_NO_CURSOR
|
||||||
|
|
||||||
extern int qt_last_x,qt_last_y;
|
extern qreal qt_last_x,qt_last_y;
|
||||||
|
|
||||||
QPoint QCursor::pos()
|
QPoint QCursor::pos()
|
||||||
{
|
{
|
||||||
return QPoint(qt_last_x, qt_last_y);
|
return QPointF(qt_last_x, qt_last_y).toPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCursor::setPos(int x, int y)
|
void QCursor::setPos(int x, int y)
|
||||||
|
@ -115,12 +115,12 @@ void QWindowSystemInterface::handleCloseEvent(QWidget *tlw)
|
|||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void QWindowSystemInterface::handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
|
void QWindowSystemInterface::handleMouseEvent(QWidget *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b) {
|
||||||
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
|
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
|
||||||
handleMouseEvent(w, time, local, global, b);
|
handleMouseEvent(w, time, local, global, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
|
void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b)
|
||||||
{
|
{
|
||||||
if (tlw) {
|
if (tlw) {
|
||||||
QWidgetData *data = qt_qwidget_data(tlw);
|
QWidgetData *data = qt_qwidget_data(tlw);
|
||||||
@ -180,12 +180,12 @@ void QWindowSystemInterface::handleExtendedKeyEvent(QWidget *tlw, ulong timestam
|
|||||||
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
|
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWindowSystemInterface::handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
|
void QWindowSystemInterface::handleWheelEvent(QWidget *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o) {
|
||||||
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
|
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
|
||||||
handleWheelEvent(w, time, local, global, d, o);
|
handleWheelEvent(w, time, local, global, d, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
|
void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o)
|
||||||
{
|
{
|
||||||
if (tlw) {
|
if (tlw) {
|
||||||
QWidgetData *data = qt_qwidget_data(tlw);
|
QWidgetData *data = qt_qwidget_data(tlw);
|
||||||
|
@ -58,8 +58,8 @@ QT_MODULE(Gui)
|
|||||||
class Q_GUI_EXPORT QWindowSystemInterface
|
class Q_GUI_EXPORT QWindowSystemInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
|
static void handleMouseEvent(QWidget *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b);
|
||||||
static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
|
static void handleMouseEvent(QWidget *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b);
|
||||||
|
|
||||||
static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
|
static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
|
||||||
static void handleKeyEvent(QWidget *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
|
static void handleKeyEvent(QWidget *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
|
||||||
@ -75,8 +75,8 @@ public:
|
|||||||
const QString& text = QString(), bool autorep = false,
|
const QString& text = QString(), bool autorep = false,
|
||||||
ushort count = 1);
|
ushort count = 1);
|
||||||
|
|
||||||
static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
|
static void handleWheelEvent(QWidget *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o);
|
||||||
static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
|
static void handleWheelEvent(QWidget *w, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o);
|
||||||
|
|
||||||
struct TouchPoint {
|
struct TouchPoint {
|
||||||
int id; // for application use
|
int id; // for application use
|
||||||
|
@ -121,20 +121,20 @@ public:
|
|||||||
|
|
||||||
class MouseEvent : public UserEvent {
|
class MouseEvent : public UserEvent {
|
||||||
public:
|
public:
|
||||||
MouseEvent(QWidget * w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
|
MouseEvent(QWidget * w, ulong time, const QPointF & local, const QPointF & global, Qt::MouseButtons b)
|
||||||
: UserEvent(w, time, Mouse), localPos(local), globalPos(global), buttons(b) { }
|
: UserEvent(w, time, Mouse), localPos(local), globalPos(global), buttons(b) { }
|
||||||
QPoint localPos;
|
QPointF localPos;
|
||||||
QPoint globalPos;
|
QPointF globalPos;
|
||||||
Qt::MouseButtons buttons;
|
Qt::MouseButtons buttons;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WheelEvent : public UserEvent {
|
class WheelEvent : public UserEvent {
|
||||||
public:
|
public:
|
||||||
WheelEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
|
WheelEvent(QWidget *w, ulong time, const QPointF & local, const QPointF & global, int d, Qt::Orientation o)
|
||||||
: UserEvent(w, time, Wheel), delta(d), localPos(local), globalPos(global), orient(o) { }
|
: UserEvent(w, time, Wheel), delta(d), localPos(local), globalPos(global), orient(o) { }
|
||||||
int delta;
|
int delta;
|
||||||
QPoint localPos;
|
QPointF localPos;
|
||||||
QPoint globalPos;
|
QPointF globalPos;
|
||||||
Qt::Orientation orient;
|
Qt::Orientation orient;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user