From 893ea2600e662ba3862d627ef2166f24cc51e967 Mon Sep 17 00:00:00 2001
From: obarun <eric@obarun.org>
Date: Tue, 6 Feb 2018 14:37:06 +1100
Subject: [PATCH] upgrel : 5.10.0-5

---
 PKGBUILD          | 11 +++++---
 qtbug-59261.patch | 65 +++++++++++++++++++++++++++++++++++++++++++
 qtbug-65235.patch | 70 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 142 insertions(+), 4 deletions(-)
 create mode 100644 qtbug-59261.patch
 create mode 100644 qtbug-65235.patch

diff --git a/PKGBUILD b/PKGBUILD
index 993a34a..2f7670b 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -7,7 +7,7 @@ pkgbase=qt5-base
 pkgname=(qt5-base qt5-xcb-private-headers)
 _qtver=5.10.0
 pkgver=${_qtver/-/}
-pkgrel=4
+pkgrel=5
 arch=(x86_64)
 url='http://qt-project.org/'
 license=('GPL3' 'LGPL3' 'FDL' 'custom')
@@ -28,9 +28,11 @@ conflicts=('qtchooser')
 groups=('qt' 'qt5')
 _pkgfqn="${pkgbase/5-/}-everywhere-src-${_qtver}"
 source=("http://download.qt.io/official_releases/qt/${pkgver%.*}/${_qtver}/submodules/${_pkgfqn}.tar.xz"
-		qtbug-65235.patch::"https://github.com/qt/qtbase/commit/79d78d81.patch")
+		qtbug-65235.patch::"https://github.com/qt/qtbase/commit/79d78d81.patch"
+		qtbug-59261.patch::"https://github.com/qt/qtbase/commit/d1960360.patch")
 sha256sums=('fd5578cd320a13617c12cf2b19439386b203d6d45548e855f94e07be9829f762'
-            '32d71a129adad13fc90e2ec9b15d0a21d9dd3f02bd8094882b18e4451d39ffe7')
+            '32d71a129adad13fc90e2ec9b15d0a21d9dd3f02bd8094882b18e4451d39ffe7'
+            '91c89eb302316c32cbe5018ac92d8fcd96201eed3e6e11cb40f410f45cb17138')
 validpgpkeys=('6DD4217456569BA711566AC7F06E8FDE7B45DAAC') # Eric Vidal
 
 prepare() {
@@ -51,7 +53,8 @@ prepare() {
   sed -e '/CMAKE_NO_PRIVATE_INCLUDES\ \=\ true/d' -i mkspecs/features/create_cmake.prf
   
   # https://bugreports.qt.io/browse/QTBUG-65235
-  patch -p1 -i ../qtbug-65235.patch 
+  patch -p1 -i ../qtbug-65235.patch
+  patch -p1 -i ../qtbug-59261.patch # https://bugreports.qt.io/browse/QTBUG-59261
 }
 
 build() {
diff --git a/qtbug-59261.patch b/qtbug-59261.patch
new file mode 100644
index 0000000..34990bb
--- /dev/null
+++ b/qtbug-59261.patch
@@ -0,0 +1,65 @@
+From d196036024697a75868c1f1626525710495ca428 Mon Sep 17 00:00:00 2001
+From: Allan Sandfeld Jensen <allan.jensen@qt.io>
+Date: Thu, 23 Nov 2017 14:25:04 +0100
+Subject: [PATCH] Avoid providing bad pixelDeltas on X11
+
+With libinput we now get a hardcoded resolution that is unrelated to
+the hardware. So avoid using that as a real pixel delta and document
+pixel deltas as being driver specific and unreliable on X11.
+
+Task-number: QTBUG-59261
+Change-Id: I9fe86d80e7ccd290ed2e4091d7eafa52cb537d34
+Reviewed-by: David Edmundson <davidedmundson@kde.org>
+Reviewed-by: Marco Martin <mart@kde.org>
+Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
+---
+ src/gui/kernel/qevent.cpp                        |  1 +
+ src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 14 ++++++++------
+ 2 files changed, 9 insertions(+), 6 deletions(-)
+
+diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
+index 06d52aa78d..c68f9afa56 100644
+--- a/src/gui/kernel/qevent.cpp
++++ b/src/gui/kernel/qevent.cpp
+@@ -971,6 +971,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
+     \li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
+     \li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).
+     \endlist
++    \note On X11 this value is driver specific and unreliable, use angleDelta() instead
+ */
+ 
+ /*!
+diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+index d1d97affe8..94f543fd39 100644
+--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
++++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+@@ -953,10 +953,12 @@ void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollin
+                     double delta = scrollingDevice.lastScrollPosition.y() - value;
+                     scrollingDevice.lastScrollPosition.setY(value);
+                     angleDelta.setY((delta / scrollingDevice.verticalIncrement) * 120);
+-                    // We do not set "pixel" delta if it is only measured in ticks.
+-                    if (scrollingDevice.verticalIncrement > 1)
++                    // With most drivers the increment is 1 for wheels.
++                    // For libinput it is hardcoded to a useless 15.
++                    // For a proper touchpad driver it should be in the same order of magnitude as 120
++                    if (scrollingDevice.verticalIncrement > 15)
+                         rawDelta.setY(delta);
+-                    else if (scrollingDevice.verticalIncrement < -1)
++                    else if (scrollingDevice.verticalIncrement < -15)
+                         rawDelta.setY(-delta);
+                 }
+             }
+@@ -965,10 +967,10 @@ void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollin
+                     double delta = scrollingDevice.lastScrollPosition.x() - value;
+                     scrollingDevice.lastScrollPosition.setX(value);
+                     angleDelta.setX((delta / scrollingDevice.horizontalIncrement) * 120);
+-                    // We do not set "pixel" delta if it is only measured in ticks.
+-                    if (scrollingDevice.horizontalIncrement > 1)
++                    // See comment under vertical
++                    if (scrollingDevice.horizontalIncrement > 15)
+                         rawDelta.setX(delta);
+-                    else if (scrollingDevice.horizontalIncrement < -1)
++                    else if (scrollingDevice.horizontalIncrement < -15)
+                         rawDelta.setX(-delta);
+                 }
+             }
diff --git a/qtbug-65235.patch b/qtbug-65235.patch
new file mode 100644
index 0000000..5b7e51d
--- /dev/null
+++ b/qtbug-65235.patch
@@ -0,0 +1,70 @@
+From 79d78d814acad4e183e281aea9b131f396abe3fb Mon Sep 17 00:00:00 2001
+From: Gatis Paeglis <gatis.paeglis@qt.io>
+Date: Thu, 7 Dec 2017 11:49:49 +0100
+Subject: [PATCH] xcb: verify if xrandr present before using xcb_randr* APIs
+
+Not doing so might break the connection. We have had similar
+issues before, e.g. QTBUG-45312.
+
+Change-Id: I95f15d24773fc92b052578bd72d1ba264d0a5f63
+Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
+Reviewed-by: Uli Schlachter <psychon@znc.in>
+---
+ src/plugins/platforms/xcb/qxcbscreen.cpp | 35 +++++++++++++++++++++-----------
+ 1 file changed, 23 insertions(+), 12 deletions(-)
+
+diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
+index ec0f9ba561..67c96b2d80 100644
+--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
++++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
+@@ -446,17 +446,24 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe
+ 
+     m_cursor = new QXcbCursor(connection, this);
+ 
+-    // Parse EDID
+-    if (m_edid.parse(getEdid()))
+-        qCDebug(lcQpaScreen, "EDID data for output \"%s\": identifier '%s', manufacturer '%s', model '%s', serial '%s', physical size: %.2fx%.2f",
+-                name().toLatin1().constData(),
+-                m_edid.identifier.toLatin1().constData(),
+-                m_edid.manufacturer.toLatin1().constData(),
+-                m_edid.model.toLatin1().constData(),
+-                m_edid.serialNumber.toLatin1().constData(),
+-                m_edid.physicalSize.width(), m_edid.physicalSize.height());
+-    else
+-        qCDebug(lcQpaScreen) << "Failed to parse EDID data for output" << name(); // keep this debug, not warning
++    if (connection->hasXRandr()) { // Parse EDID
++        QByteArray edid = getEdid();
++        if (m_edid.parse(edid)) {
++            qCDebug(lcQpaScreen, "EDID data for output \"%s\": identifier '%s', manufacturer '%s',"
++                                 "model '%s', serial '%s', physical size: %.2fx%.2f",
++                    name().toLatin1().constData(),
++                    m_edid.identifier.toLatin1().constData(),
++                    m_edid.manufacturer.toLatin1().constData(),
++                    m_edid.model.toLatin1().constData(),
++                    m_edid.serialNumber.toLatin1().constData(),
++                    m_edid.physicalSize.width(), m_edid.physicalSize.height());
++        } else {
++            // This property is defined by the xrandr spec. Parsing failure indicates a valid error,
++            // but keep this as debug, for details see 4f515815efc318ddc909a0399b71b8a684962f38.
++            qCDebug(lcQpaScreen) << "Failed to parse EDID data for output" << name() <<
++                                    "edid data: " << edid;
++        }
++    }
+ }
+ 
+ QXcbScreen::~QXcbScreen()
+@@ -899,9 +906,13 @@ QByteArray QXcbScreen::getOutputProperty(xcb_atom_t atom) const
+ 
+ QByteArray QXcbScreen::getEdid() const
+ {
++    QByteArray result;
++    if (!connection()->hasXRandr())
++        return result;
++
+     // Try a bunch of atoms
+     xcb_atom_t atom = connection()->internAtom("EDID");
+-    QByteArray result = getOutputProperty(atom);
++    result = getOutputProperty(atom);
+     if (result.isEmpty()) {
+         atom = connection()->internAtom("EDID_DATA");
+         result = getOutputProperty(atom);
-- 
GitLab