https://bugs.webkit.org/show_bug.cgi?id=69105
This changes QDesktopWebView and QDesktopWebPageProxy to use QMouseEvent instead
of QGraphicsSceneMouseEvent.
Further it removes an endless loop introduced by the QSGItem::event() function
delivering inputMethodEvents but no other events.
Patch by Zeno Albisser <zeno.albisser@nokia.com> on 2011-09-30
Reviewed by Andreas Kling.
* Shared/NativeWebMouseEvent.h:
(WebKit::NativeWebMouseEvent::nativeEvent):
* Shared/NativeWebWheelEvent.h:
(WebKit::NativeWebWheelEvent::nativeEvent):
* Shared/qt/NativeWebMouseEventQt.cpp:
(WebKit::NativeWebMouseEvent::NativeWebMouseEvent):
* Shared/qt/NativeWebWheelEventQt.cpp:
(WebKit::NativeWebWheelEvent::NativeWebWheelEvent):
* Shared/qt/WebEventFactoryQt.cpp:
(WebKit::mouseButtonForEvent):
(WebKit::webEventTypeForEvent):
(WebKit::WebEventFactory::createWebMouseEvent):
(WebKit::WebEventFactory::createWebWheelEvent):
* Shared/qt/WebEventFactoryQt.h:
* UIProcess/API/qt/qdesktopwebview.cpp:
(QDesktopWebView::mousePressEvent):
(QDesktopWebView::mouseMoveEvent):
(QDesktopWebView::mouseReleaseEvent):
(QDesktopWebView::mouseDoubleClickEvent):
(QDesktopWebView::wheelEvent):
(QDesktopWebView::event):
* UIProcess/API/qt/qdesktopwebview.h:
* UIProcess/qt/qdesktopwebpageproxy.cpp:
(QDesktopWebPageProxy::handleEvent):
(QDesktopWebPageProxy::handleMouseMoveEvent):
(QDesktopWebPageProxy::handleMousePressEvent):
(QDesktopWebPageProxy::handleMouseReleaseEvent):
(QDesktopWebPageProxy::handleMouseDoubleClickEvent):
(QDesktopWebPageProxy::handleWheelEvent):
(QDesktopWebPageProxy::handleHoverMoveEvent):
* UIProcess/qt/qdesktopwebpageproxy.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96399
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-30 Zeno Albisser <zeno.albisser@nokia.com>
+
+ [Qt][WK2] Event delivery in QDesktopWebView is broken after merge of Qt5 refactor
+ https://bugs.webkit.org/show_bug.cgi?id=69105
+
+ This changes QDesktopWebView and QDesktopWebPageProxy to use QMouseEvent instead
+ of QGraphicsSceneMouseEvent.
+ Further it removes an endless loop introduced by the QSGItem::event() function
+ delivering inputMethodEvents but no other events.
+
+ Reviewed by Andreas Kling.
+
+ * Shared/NativeWebMouseEvent.h:
+ (WebKit::NativeWebMouseEvent::nativeEvent):
+ * Shared/NativeWebWheelEvent.h:
+ (WebKit::NativeWebWheelEvent::nativeEvent):
+ * Shared/qt/NativeWebMouseEventQt.cpp:
+ (WebKit::NativeWebMouseEvent::NativeWebMouseEvent):
+ * Shared/qt/NativeWebWheelEventQt.cpp:
+ (WebKit::NativeWebWheelEvent::NativeWebWheelEvent):
+ * Shared/qt/WebEventFactoryQt.cpp:
+ (WebKit::mouseButtonForEvent):
+ (WebKit::webEventTypeForEvent):
+ (WebKit::WebEventFactory::createWebMouseEvent):
+ (WebKit::WebEventFactory::createWebWheelEvent):
+ * Shared/qt/WebEventFactoryQt.h:
+ * UIProcess/API/qt/qdesktopwebview.cpp:
+ (QDesktopWebView::mousePressEvent):
+ (QDesktopWebView::mouseMoveEvent):
+ (QDesktopWebView::mouseReleaseEvent):
+ (QDesktopWebView::mouseDoubleClickEvent):
+ (QDesktopWebView::wheelEvent):
+ (QDesktopWebView::event):
+ * UIProcess/API/qt/qdesktopwebview.h:
+ * UIProcess/qt/qdesktopwebpageproxy.cpp:
+ (QDesktopWebPageProxy::handleEvent):
+ (QDesktopWebPageProxy::handleMouseMoveEvent):
+ (QDesktopWebPageProxy::handleMousePressEvent):
+ (QDesktopWebPageProxy::handleMouseReleaseEvent):
+ (QDesktopWebPageProxy::handleMouseDoubleClickEvent):
+ (QDesktopWebPageProxy::handleWheelEvent):
+ (QDesktopWebPageProxy::handleHoverMoveEvent):
+ * UIProcess/qt/qdesktopwebpageproxy.h:
+
2011-09-29 Ravi Phaneendra Kasibhatla <ravi.kasibhatla@motorola.com>
Initial implementation of WebInspector for WebKit2 GTK port.
#include <wtf/RetainPtr.h>
OBJC_CLASS NSView;
#elif PLATFORM(QT)
-#include <qgraphicssceneevent.h>
+#include <qevent.h>
#elif PLATFORM(GTK)
#include <GOwnPtrGtk.h>
typedef union _GdkEvent GdkEvent;
#elif PLATFORM(WIN)
NativeWebMouseEvent(HWND, UINT message, WPARAM, LPARAM, bool);
#elif PLATFORM(QT)
- explicit NativeWebMouseEvent(QGraphicsSceneMouseEvent*, int);
+ explicit NativeWebMouseEvent(QMouseEvent*, int);
#elif PLATFORM(GTK)
NativeWebMouseEvent(const NativeWebMouseEvent&);
NativeWebMouseEvent(GdkEvent*, int);
#elif PLATFORM(WIN)
const MSG* nativeEvent() const { return &m_nativeEvent; }
#elif PLATFORM(QT)
- const QGraphicsSceneMouseEvent* nativeEvent() const { return m_nativeEvent; }
+ const QMouseEvent* nativeEvent() const { return m_nativeEvent; }
#elif PLATFORM(GTK)
const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
#elif PLATFORM(EFL)
#elif PLATFORM(WIN)
MSG m_nativeEvent;
#elif PLATFORM(QT)
- QGraphicsSceneMouseEvent* m_nativeEvent;
+ QMouseEvent* m_nativeEvent;
#elif PLATFORM(GTK)
GOwnPtr<GdkEvent> m_nativeEvent;
#elif PLATFORM(EFL)
#include <wtf/RetainPtr.h>
OBJC_CLASS NSView;
#elif PLATFORM(QT)
-#include <qgraphicssceneevent.h>
+#include <qevent.h>
#elif PLATFORM(GTK)
#include <GOwnPtrGtk.h>
typedef union _GdkEvent GdkEvent;
#elif PLATFORM(WIN)
NativeWebWheelEvent(HWND, UINT message, WPARAM, LPARAM);
#elif PLATFORM(QT)
- explicit NativeWebWheelEvent(QGraphicsSceneWheelEvent*);
+ explicit NativeWebWheelEvent(QWheelEvent*);
#elif PLATFORM(GTK)
NativeWebWheelEvent(const NativeWebWheelEvent&);
NativeWebWheelEvent(GdkEvent*);
#elif PLATFORM(WIN)
const MSG* nativeEvent() const { return &m_nativeEvent; }
#elif PLATFORM(QT)
- const QGraphicsSceneWheelEvent* nativeEvent() const { return m_nativeEvent; }
+ const QWheelEvent* nativeEvent() const { return m_nativeEvent; }
#elif PLATFORM(GTK)
const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
#elif PLATFORM(EFL)
#elif PLATFORM(WIN)
MSG m_nativeEvent;
#elif PLATFORM(QT)
- QGraphicsSceneWheelEvent* m_nativeEvent;
+ QWheelEvent* m_nativeEvent;
#elif PLATFORM(GTK)
GOwnPtr<GdkEvent> m_nativeEvent;
#elif PLATFORM(EFL)
namespace WebKit {
-NativeWebMouseEvent::NativeWebMouseEvent(QGraphicsSceneMouseEvent* event, int eventClickCount)
+NativeWebMouseEvent::NativeWebMouseEvent(QMouseEvent* event, int eventClickCount)
: WebMouseEvent(WebEventFactory::createWebMouseEvent(event, eventClickCount))
, m_nativeEvent(event)
{
namespace WebKit {
-NativeWebWheelEvent::NativeWebWheelEvent(QGraphicsSceneWheelEvent* event)
+NativeWebWheelEvent::NativeWebWheelEvent(QWheelEvent* event)
: WebWheelEvent(WebEventFactory::createWebWheelEvent(event))
, m_nativeEvent(event)
{
namespace WebKit {
-static WebMouseEvent::Button mouseButtonForEvent(QGraphicsSceneMouseEvent *event)
+static WebMouseEvent::Button mouseButtonForEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton || (event->buttons() & Qt::LeftButton))
return WebMouseEvent::LeftButton;
static WebEvent::Type webEventTypeForEvent(const QEvent* event)
{
switch (event->type()) {
- case QEvent::GraphicsSceneMouseDoubleClick:
- case QEvent::GraphicsSceneMousePress:
- return WebEvent::MouseDown;
- case QEvent::GraphicsSceneMouseRelease:
- return WebEvent::MouseUp;
- case QEvent::GraphicsSceneMouseMove:
- return WebEvent::MouseMove;
- case QEvent::Wheel:
- return WebEvent::Wheel;
- case QEvent::KeyPress:
- return WebEvent::KeyDown;
- case QEvent::KeyRelease:
- return WebEvent::KeyUp;
+ case QEvent::MouseButtonDblClick:
+ case QEvent::MouseButtonPress:
+ return WebEvent::MouseDown;
+ case QEvent::MouseButtonRelease:
+ return WebEvent::MouseUp;
+ case QEvent::MouseMove:
+ return WebEvent::MouseMove;
+ case QEvent::Wheel:
+ return WebEvent::Wheel;
+ case QEvent::KeyPress:
+ return WebEvent::KeyDown;
+ case QEvent::KeyRelease:
+ return WebEvent::KeyUp;
#if ENABLE(TOUCH_EVENTS)
- case QEvent::TouchBegin:
- return WebEvent::TouchStart;
- case QEvent::TouchUpdate:
- return WebEvent::TouchMove;
- case QEvent::TouchEnd:
- return WebEvent::TouchEnd;
+ case QEvent::TouchBegin:
+ return WebEvent::TouchStart;
+ case QEvent::TouchUpdate:
+ return WebEvent::TouchMove;
+ case QEvent::TouchEnd:
+ return WebEvent::TouchEnd;
#endif
- default:
- // assert
- return WebEvent::MouseMove;
+ default:
+ // assert
+ return WebEvent::MouseMove;
}
}
return (WebEvent::Modifiers)result;
}
-WebMouseEvent WebEventFactory::createWebMouseEvent(QGraphicsSceneMouseEvent* event, int eventClickCount)
+WebMouseEvent WebEventFactory::createWebMouseEvent(QMouseEvent* event, int eventClickCount)
{
- FloatPoint delta(event->pos().x() - event->lastPos().x(), event->pos().y() - event->lastPos().y());
+ static FloatPoint lastPos = FloatPoint(0, 0);
WebEvent::Type type = webEventTypeForEvent(event);
WebMouseEvent::Button button = mouseButtonForEvent(event);
- float deltaX = delta.x();
- float deltaY = delta.y();
+ float deltaX = event->pos().x() - lastPos.x();
+ float deltaY = event->pos().y() - lastPos.y();
int clickCount = eventClickCount;
WebEvent::Modifiers modifiers = modifiersForEvent(event->modifiers());
double timestamp = WTF::currentTime();
+ lastPos.set(event->localPos().x(), event->localPos().y());
- return WebMouseEvent(type, button, event->pos().toPoint(), event->screenPos(), deltaX, deltaY, 0.0f, clickCount, modifiers, timestamp);
+ return WebMouseEvent(type, button, event->localPos().toPoint(), event->screenPos().toPoint(), deltaX, deltaY, 0.0f, clickCount, modifiers, timestamp);
}
-WebWheelEvent WebEventFactory::createWebWheelEvent(QGraphicsSceneWheelEvent* e)
+WebWheelEvent WebEventFactory::createWebWheelEvent(QWheelEvent* e)
{
float deltaX = 0;
float deltaY = 0;
deltaX *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1;
deltaY *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1;
- return WebWheelEvent(WebEvent::Wheel, e->pos().toPoint(), e->screenPos(), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, modifiers, timestamp);
+ return WebWheelEvent(WebEvent::Wheel, e->posF().toPoint(), e->globalPosF().toPoint(), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, modifiers, timestamp);
}
WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(QKeyEvent* event)
class QTouchEvent;
#endif
-class QGraphicsSceneMouseEvent;
-class QGraphicsSceneWheelEvent;
+class QMouseEvent;
+class QWheelEvent;
class QKeyEvent;
namespace WebKit {
class WebEventFactory {
public:
- static WebMouseEvent createWebMouseEvent(QGraphicsSceneMouseEvent* event, int eventClickCount);
- static WebWheelEvent createWebWheelEvent(QGraphicsSceneWheelEvent* event);
- static WebKeyboardEvent createWebKeyboardEvent(QKeyEvent* event);
+ static WebMouseEvent createWebMouseEvent(QMouseEvent*, int eventClickCount);
+ static WebWheelEvent createWebWheelEvent(QWheelEvent*);
+ static WebKeyboardEvent createWebKeyboardEvent(QKeyEvent*);
#if ENABLE(TOUCH_EVENTS)
static WebTouchEvent createWebTouchEvent(const QTouchEvent*);
#endif
this->event(event);
}
-void QDesktopWebView::mousePressEvent(QGraphicsSceneMouseEvent* event)
+void QDesktopWebView::mousePressEvent(QMouseEvent* event)
{
this->event(event);
}
-void QDesktopWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
+void QDesktopWebView::mouseMoveEvent(QMouseEvent* event)
{
this->event(event);
}
-void QDesktopWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
+void QDesktopWebView::mouseReleaseEvent(QMouseEvent* event)
{
this->event(event);
}
-void QDesktopWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
+void QDesktopWebView::mouseDoubleClickEvent(QMouseEvent* event)
{
this->event(event);
}
void QDesktopWebView::wheelEvent(QWheelEvent* event)
{
- // FIXME: for some reason, the scene graph delivers QWheelEvent instead of QGraphicsSceneWheelEvent.
- // We transform them in QGraphicsSceneWheelEvent for consistency. Otherwise the position would be complete magic.
- // We shoud modify the scenegraph to get the correct type of events.
- QGraphicsSceneWheelEvent graphicsEvent(QEvent::GraphicsSceneWheel);
- graphicsEvent.setPos(event->pos());
- graphicsEvent.setButtons(event->buttons());
- graphicsEvent.setDelta(event->delta());
- graphicsEvent.setModifiers(event->modifiers());
- graphicsEvent.setOrientation(event->orientation());
- graphicsEvent.setScenePos(mapToScene(event->pos()));
- graphicsEvent.setScreenPos(event->globalPos());
- this->event(&graphicsEvent);
+ this->event(event);
}
void QDesktopWebView::touchEvent(QTouchEvent* event)
{
if (d->page.handleEvent(ev))
return true;
+ if (ev->type() == QEvent::InputMethod)
+ return false; // This is necessary to avoid an endless loop in connection with QSGItem::event().
return QSGItem::event(ev);
}
QT_BEGIN_NAMESPACE
class QFocusEvent;
-class QGraphicsSceneMouseEvent;
+class QMouseEvent;
class QHoverEvent;
class QInputMethodEvent;
class QKeyEvent;
virtual void inputMethodEvent(QInputMethodEvent*);
virtual void focusInEvent(QFocusEvent*);
virtual void focusOutEvent(QFocusEvent*);
- virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
- virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
- virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
- virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
+ virtual void mousePressEvent(QMouseEvent *);
+ virtual void mouseMoveEvent(QMouseEvent *);
+ virtual void mouseReleaseEvent(QMouseEvent *);
+ virtual void mouseDoubleClickEvent(QMouseEvent *);
virtual void wheelEvent(QWheelEvent*);
virtual void touchEvent(QTouchEvent*);
virtual void hoverEnterEvent(QHoverEvent*);
bool QDesktopWebPageProxy::handleEvent(QEvent* ev)
{
switch (ev->type()) {
- case QEvent::GraphicsSceneMouseMove:
- return handleMouseMoveEvent(reinterpret_cast<QGraphicsSceneMouseEvent*>(ev));
- case QEvent::GraphicsSceneMousePress:
- return handleMousePressEvent(reinterpret_cast<QGraphicsSceneMouseEvent*>(ev));
- case QEvent::GraphicsSceneMouseRelease:
- return handleMouseReleaseEvent(reinterpret_cast<QGraphicsSceneMouseEvent*>(ev));
- case QEvent::GraphicsSceneMouseDoubleClick:
- return handleMouseDoubleClickEvent(reinterpret_cast<QGraphicsSceneMouseEvent*>(ev));
- case QEvent::GraphicsSceneWheel:
- return handleWheelEvent(reinterpret_cast<QGraphicsSceneWheelEvent*>(ev));
+ case QEvent::MouseMove:
+ return handleMouseMoveEvent(reinterpret_cast<QMouseEvent*>(ev));
+ case QEvent::MouseButtonPress:
+ return handleMousePressEvent(reinterpret_cast<QMouseEvent*>(ev));
+ case QEvent::MouseButtonRelease:
+ return handleMouseReleaseEvent(reinterpret_cast<QMouseEvent*>(ev));
+ case QEvent::MouseButtonDblClick:
+ return handleMouseDoubleClickEvent(reinterpret_cast<QMouseEvent*>(ev));
+ case QEvent::Wheel:
+ return handleWheelEvent(reinterpret_cast<QWheelEvent*>(ev));
case QEvent::HoverMove:
return handleHoverMoveEvent(reinterpret_cast<QHoverEvent*>(ev));
case QEvent::GraphicsSceneDragEnter:
return QtWebPageProxy::handleEvent(ev);
}
-bool QDesktopWebPageProxy::handleMouseMoveEvent(QGraphicsSceneMouseEvent* ev)
+bool QDesktopWebPageProxy::handleMouseMoveEvent(QMouseEvent* ev)
{
// For some reason mouse press results in mouse hover (which is
// converted to mouse move for WebKit). We ignore these hover
return ev->isAccepted();
}
-bool QDesktopWebPageProxy::handleMousePressEvent(QGraphicsSceneMouseEvent* ev)
+bool QDesktopWebPageProxy::handleMousePressEvent(QMouseEvent* ev)
{
if (m_tripleClickTimer.isActive() && (ev->pos() - m_tripleClick).manhattanLength() < QApplication::startDragDistance()) {
m_webPageProxy->handleMouseEvent(NativeWebMouseEvent(ev, /*eventClickCount=*/3));
return ev->isAccepted();
}
-bool QDesktopWebPageProxy::handleMouseReleaseEvent(QGraphicsSceneMouseEvent* ev)
+bool QDesktopWebPageProxy::handleMouseReleaseEvent(QMouseEvent* ev)
{
m_webPageProxy->handleMouseEvent(NativeWebMouseEvent(ev, /*eventClickCount=*/0));
return ev->isAccepted();
}
-bool QDesktopWebPageProxy::handleMouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev)
+bool QDesktopWebPageProxy::handleMouseDoubleClickEvent(QMouseEvent* ev)
{
m_webPageProxy->handleMouseEvent(NativeWebMouseEvent(ev, /*eventClickCount=*/2));
m_tripleClickTimer.start(QApplication::doubleClickInterval(), this);
- m_tripleClick = ev->pos().toPoint();
+ m_tripleClick = ev->localPos().toPoint();
return ev->isAccepted();
}
-bool QDesktopWebPageProxy::handleWheelEvent(QGraphicsSceneWheelEvent* ev)
+bool QDesktopWebPageProxy::handleWheelEvent(QWheelEvent* ev)
{
m_webPageProxy->handleWheelEvent(NativeWebWheelEvent(ev));
return ev->isAccepted();
bool QDesktopWebPageProxy::handleHoverMoveEvent(QHoverEvent* ev)
{
- QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseMove);
- me.setPos(ev->pos());
+ QMouseEvent me(QEvent::MouseMove, ev->pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
me.setAccepted(ev->isAccepted());
return handleMouseMoveEvent(&me);
virtual void timerEvent(QTimerEvent*);
- bool handleMouseMoveEvent(QGraphicsSceneMouseEvent*);
- bool handleMousePressEvent(QGraphicsSceneMouseEvent*);
- bool handleMouseReleaseEvent(QGraphicsSceneMouseEvent*);
- bool handleMouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
- bool handleWheelEvent(QGraphicsSceneWheelEvent*);
+ bool handleMouseMoveEvent(QMouseEvent*);
+ bool handleMousePressEvent(QMouseEvent*);
+ bool handleMouseReleaseEvent(QMouseEvent*);
+ bool handleMouseDoubleClickEvent(QMouseEvent*);
+ bool handleWheelEvent(QWheelEvent*);
bool handleHoverMoveEvent(QHoverEvent*);
bool handleDragEnterEvent(QGraphicsSceneDragDropEvent*);
bool handleDragLeaveEvent(QGraphicsSceneDragDropEvent*);