diff options
-rwxr-xr-x | build/gyp_qtwebengine | 2 | ||||
-rw-r--r-- | lib/render_widget_host_view_qt.cpp | 64 | ||||
-rw-r--r-- | lib/render_widget_host_view_qt.h | 1 | ||||
-rw-r--r-- | lib/web_event_factory.cpp | 43 | ||||
-rw-r--r-- | lib/web_event_factory.h | 2 | ||||
-rw-r--r-- | patches/0001-Build-files-necessary-for-touch-and-gestures.patch | 67 | ||||
-rwxr-xr-x | patches/patch-chromium.sh | 1 |
7 files changed, 133 insertions, 47 deletions
diff --git a/build/gyp_qtwebengine b/build/gyp_qtwebengine index 04dece7eb..23d065831 100755 --- a/build/gyp_qtwebengine +++ b/build/gyp_qtwebengine @@ -134,6 +134,8 @@ if __name__ == '__main__': # Disable it along with the -Wl,--threads flag just in case gold isn't installed on the system. args.extend(['-D', 'linux_use_gold_binary=0']) args.extend(['-D', 'linux_use_gold_flags=0']) + # Trigger Qt-specific build conditions. + args.extend(['-D', 'use_qt=1']) # Tweak the output location and format (hardcode ninja for now) args.extend(['--generator-output', os.path.abspath(get_output_dir())]) args.extend(['-Goutput_dir='+ os.path.abspath(get_output_dir())]) diff --git a/lib/render_widget_host_view_qt.cpp b/lib/render_widget_host_view_qt.cpp index 82ec9ea83..5ee1ff359 100644 --- a/lib/render_widget_host_view_qt.cpp +++ b/lib/render_widget_host_view_qt.cpp @@ -48,7 +48,9 @@ #include "shared/shared_globals.h" #include "content/browser/renderer_host/render_view_host_impl.h" +#include "content/browser/renderer_host/ui_events_helper.h" #include "content/common/gpu/gpu_messages.h" +#include "ui/base/events/event.h" #include "ui/gfx/size_conversions.h" #include <QEvent> @@ -59,6 +61,38 @@ #include <QWheelEvent> #include <QWindow> +static inline ui::EventType toUIEventType(Qt::TouchPointState state) +{ + switch (state) { + case Qt::TouchPointPressed: + return ui::ET_TOUCH_PRESSED; + case Qt::TouchPointMoved: + return ui::ET_TOUCH_MOVED; + case Qt::TouchPointStationary: + return ui::ET_TOUCH_STATIONARY; + case Qt::TouchPointReleased: + return ui::ET_TOUCH_RELEASED; + default: + Q_ASSERT(false); + return ui::ET_UNKNOWN; + } +} + +static inline gfx::Point toGfxPoint(const QPoint& point) +{ + return gfx::Point(point.x(), point.y()); +} + +static void UpdateWebTouchEventAfterDispatch(WebKit::WebTouchEvent* event, WebKit::WebTouchPoint* point) { + if (point->state != WebKit::WebTouchPoint::StateReleased && + point->state != WebKit::WebTouchPoint::StateCancelled) + return; + --event->touchesLength; + for (unsigned i = point - event->touches; i < event->touchesLength; ++i) { + event->touches[i] = event->touches[i + 1]; + } +} + RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget) : m_host(content::RenderWidgetHostImpl::From(widget)) { @@ -469,8 +503,34 @@ void RenderWidgetHostViewQt::handleWheelEvent(QWheelEvent *ev) void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) { - if (m_host->ShouldForwardTouchEvent()) - m_host->ForwardTouchEventWithLatencyInfo(WebEventFactory::toWebTouchEvent(ev), ui::LatencyInfo()); + // Convert each of our QTouchEvent::TouchPoint to the simpler ui::TouchEvent to + // be able to use the same code path for both gesture recognition and WebTouchEvents. + // It's a waste to do a double QTouchEvent -> ui::TouchEvent -> WebKit::WebTouchEvent + // conversion but this should hopefully avoid a few bugs in the future. + // FIXME: Carry Qt::TouchCancel from the event to each TouchPoint. + base::TimeDelta timestamp = base::TimeDelta::FromMilliseconds(ev->timestamp()); + Q_FOREACH (const QTouchEvent::TouchPoint& touchPoint, ev->touchPoints()) { + // Stationary touch points are already in our accumulator. + if (touchPoint.state() == Qt::TouchPointStationary) + continue; + + ui::TouchEvent uiEvent( + toUIEventType(touchPoint.state()), + toGfxPoint(touchPoint.pos().toPoint()), + 0, // flags + touchPoint.id(), + timestamp, + 0, 0, // radius + 0, // angle + touchPoint.pressure()); + + WebKit::WebTouchPoint *point = content::UpdateWebTouchEventFromUIEvent(uiEvent, &m_accumTouchEvent); + if (point) { + if (m_host->ShouldForwardTouchEvent()) + m_host->ForwardTouchEventWithLatencyInfo(m_accumTouchEvent, ui::LatencyInfo()); + UpdateWebTouchEventAfterDispatch(&m_accumTouchEvent, point); + } + } } void RenderWidgetHostViewQt::handleFocusEvent(QFocusEvent *ev) diff --git a/lib/render_widget_host_view_qt.h b/lib/render_widget_host_view_qt.h index 05713d2b2..542448424 100644 --- a/lib/render_widget_host_view_qt.h +++ b/lib/render_widget_host_view_qt.h @@ -151,6 +151,7 @@ private: bool IsPopup() const; content::RenderWidgetHostImpl *m_host; + WebKit::WebTouchEvent m_accumTouchEvent; scoped_ptr<RenderWidgetHostViewQtDelegate> m_delegate; gfx::Size m_requestedSize; }; diff --git a/lib/web_event_factory.cpp b/lib/web_event_factory.cpp index 40b6b5e6f..8ba4a159d 100644 --- a/lib/web_event_factory.cpp +++ b/lib/web_event_factory.cpp @@ -44,7 +44,6 @@ #include "third_party/WebKit/Source/core/platform/WindowsKeyboardCodes.h" #include <QElapsedTimer> -#include <QEvent> #include <QKeyEvent> #include <QMouseEvent> #include <QWheelEvent> @@ -524,26 +523,6 @@ static WebInputEvent::Type webEventTypeForEvent(const QEvent* event) } } -static WebKit::WebTouchPoint::State toWebTouchPointState(Qt::TouchPointState state) { - switch (state) { - case Qt::TouchPointPressed: - return WebKit::WebTouchPoint::StatePressed; - case Qt::TouchPointMoved: - return WebKit::WebTouchPoint::StateMoved; - case Qt::TouchPointStationary: - return WebKit::WebTouchPoint::StateStationary; - case Qt::TouchPointReleased: - return WebKit::WebTouchPoint::StateReleased; - default: - Q_ASSERT(false); - return WebKit::WebTouchPoint::StateUndefined; - } -} - -static inline WebKit::WebPoint toWebPoint(const QPoint& point) { - return WebKit::WebPoint(point.x(), point.y()); -} - WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev) { WebMouseEvent webKitEvent; @@ -604,28 +583,6 @@ WebKit::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev) return webEvent; } -WebKit::WebTouchEvent WebEventFactory::toWebTouchEvent(QTouchEvent *ev) -{ - WebTouchEvent webEvent; - webEvent.type = webEventTypeForEvent(ev); - webEvent.timeStampSeconds = currentTimeForEvent(ev); - webEvent.modifiers = modifiersForEvent(ev); - - webEvent.touchesLength = ev->touchPoints().size(); - webEvent.changedTouchesLength = 0; - for (unsigned i = 0; i < webEvent.touchesLength; ++i) { - const QTouchEvent::TouchPoint& touchPoint = ev->touchPoints()[i]; - WebTouchPoint& webTouchPoint = webEvent.touches[i]; - webTouchPoint.id = touchPoint.id(); - webTouchPoint.state = toWebTouchPointState(touchPoint.state()); - webTouchPoint.screenPosition = toWebPoint(touchPoint.screenPos().toPoint()); - webTouchPoint.position = toWebPoint(touchPoint.pos().toPoint()); - if (webTouchPoint.state != WebKit::WebTouchPoint::StateStationary) - webEvent.changedTouches[webEvent.changedTouchesLength++] = webTouchPoint; - } - return webEvent; -} - content::NativeWebKeyboardEvent WebEventFactory::toWebKeyboardEvent(QKeyEvent *ev) { content::NativeWebKeyboardEvent webKitEvent; diff --git a/lib/web_event_factory.h b/lib/web_event_factory.h index a8f5ab306..bacb7132c 100644 --- a/lib/web_event_factory.h +++ b/lib/web_event_factory.h @@ -47,7 +47,6 @@ class QMouseEvent; class QKeyEvent; -class QTouchEvent; class QWheelEvent; class WebEventFactory { @@ -55,7 +54,6 @@ class WebEventFactory { public: static WebKit::WebMouseEvent toWebMouseEvent(QMouseEvent*); static WebKit::WebMouseWheelEvent toWebWheelEvent(QWheelEvent*); - static WebKit::WebTouchEvent toWebTouchEvent(QTouchEvent*); static content::NativeWebKeyboardEvent toWebKeyboardEvent(QKeyEvent*); }; diff --git a/patches/0001-Build-files-necessary-for-touch-and-gestures.patch b/patches/0001-Build-files-necessary-for-touch-and-gestures.patch new file mode 100644 index 000000000..db04322df --- /dev/null +++ b/patches/0001-Build-files-necessary-for-touch-and-gestures.patch @@ -0,0 +1,67 @@ +From 883f355400eb42d8c8ed1b3094b06055941a6932 Mon Sep 17 00:00:00 2001 +From: Jocelyn Turcotte <jocelyn.turcotte@digia.com> +Date: Thu, 25 Jul 2013 17:25:47 +0200 +Subject: [PATCH] Build files necessary for touch and gestures. + +Also guard the use of MessagePumpAuraX11 in events_x.cc. We need to +build it to get symbols depending on base::NativeEvent. +--- + content/content_browser.gypi | 2 +- + ui/base/x/events_x.cc | 4 ++++ + ui/ui.gyp | 4 ++-- + 3 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/content/content_browser.gypi b/content/content_browser.gypi +index a985d0b..091b425 100644 +--- a/content/content_browser.gypi ++++ b/content/content_browser.gypi +@@ -1389,7 +1389,7 @@ + ['exclude', '^browser/geolocation/wifi_data_provider_linux\\.cc$'], + ], + }], +- ['use_aura!=1 and OS!="win"', { ++ ['use_aura!=1 and use_qt!=1 and OS!="win"', { + 'sources!': [ + 'browser/renderer_host/ui_events_helper.cc', + 'browser/renderer_host/ui_events_helper.h', +diff --git a/ui/base/x/events_x.cc b/ui/base/x/events_x.cc +index cfed6ce..f50cfa5 100644 +--- a/ui/base/x/events_x.cc ++++ b/ui/base/x/events_x.cc +@@ -273,7 +273,11 @@ double GetTouchParamFromXEvent(XEvent* xev, + + Atom GetNoopEventAtom() { + return XInternAtom( ++#if defined(USE_AURA) + base::MessagePumpAuraX11::GetDefaultXDisplay(), ++#else ++ XOpenDisplay(NULL), ++#endif + "noop", False); + } + +diff --git a/ui/ui.gyp b/ui/ui.gyp +index a0eff77..bd1e59d 100644 +--- a/ui/ui.gyp ++++ b/ui/ui.gyp +@@ -687,7 +687,7 @@ + ['exclude', 'base/dragdrop/drag_utils_aura.cc'], + ], + }], +- ['use_aura==0 and toolkit_views==0', { ++ ['use_aura==0 and use_qt==0 and toolkit_views==0', { + 'sources/': [ + ['exclude', '^base/gestures/*'], + ] +@@ -859,7 +859,7 @@ + 'base/cursor/cursor_loader_null.h', + ], + }], +- ['toolkit_views==0', { ++ ['use_qt==0 and toolkit_views==0', { + 'sources!': [ + 'base/events/event.cc', + 'base/events/event.h', +-- +1.8.3 + diff --git a/patches/patch-chromium.sh b/patches/patch-chromium.sh index 41f27a992..d1fc7c271 100755 --- a/patches/patch-chromium.sh +++ b/patches/patch-chromium.sh @@ -63,6 +63,7 @@ git am $PATCH_DIR/0001-Mac-Use-libc-instead-of-stdlibc.patch git am $PATCH_DIR/0002-Clang-libc-does-not-support-incomplete-types-in-temp.patch git am $PATCH_DIR/0001-Mac-Do-not-modify-the-child-path.patch git am $PATCH_DIR/0001-Do-not-warn-for-header-hygiene.patch +git am $PATCH_DIR/0001-Build-files-necessary-for-touch-and-gestures.patch cd $CHROMIUM_SRC_DIR/third_party/WebKit echo "Entering $PWD" |