From 6fb7720333d79c7070d2c443ad8176786f946044 Mon Sep 17 00:00:00 2001
From: Kevin Mihelich <kevin@archlinuxarm.org>
Date: Sun, 8 May 2016 17:40:23 +0000
Subject: [PATCH] extra/qt5-base gcc6 fix

---
 extra/qt5-base/PKGBUILD           |  9 +++++--
 extra/qt5-base/bswap16-gcc6.patch | 11 ++++++++
 extra/qt5-base/qtbug-45812.patch  | 43 +++++++++++++++++++++----------
 3 files changed, 48 insertions(+), 15 deletions(-)
 create mode 100644 extra/qt5-base/bswap16-gcc6.patch

diff --git a/extra/qt5-base/PKGBUILD b/extra/qt5-base/PKGBUILD
index 3931a623f..41e3bc8f5 100644
--- a/extra/qt5-base/PKGBUILD
+++ b/extra/qt5-base/PKGBUILD
@@ -6,6 +6,7 @@
 #  - -no-reduce-relocations -- not available on ARM
 #  - explicitly disable x86 optimizations
 #  - use OpenGLES 2.0
+#  - patch for __builtin_bswqp16 now requiring NEON under GCC 6
 
 pkgname=qt5-base
 _qtver=5.6.0
@@ -32,13 +33,14 @@ conflicts=('qt')
 groups=('qt' 'qt5')
 _pkgfqn="${pkgname/5-/}-opensource-src-${_qtver}"
 source=("http://download.qt.io/official_releases/qt/${pkgver%.*}/${_qtver}/submodules/${_pkgfqn}.tar.xz" qt5-alsa1.11.patch
-        qtbug-51648.patch qtbug-51649.patch qtbug-51676.patch qtbug-45812.patch)
+        qtbug-51648.patch qtbug-51649.patch qtbug-51676.patch qtbug-45812.patch bswap16-gcc6.patch)
 md5sums=('d6b6cfd333c22829c6c85fc52ceed019'
          '5e96b5cfa248b8b071919adb27abc715'
          'b09aa4f5763f013b06153fbdbc844404'
          'ef981ff6892337cdab424ebb113b3c39'
          'f59a1ea0f10a055ba930a53832933482'
-         '6f03c2ae236cd9698f9291bd8adcbea9')
+         '7f152c40947027acba56023e9d693260'
+         '974ef9e9110a1606e293aef3d37c841f')
 
 prepare() {
   cd ${_pkgfqn}
@@ -67,6 +69,9 @@ prepare() {
 
   # Fix drag and drop from some applications
   patch -p1 -i ../qtbug-45812.patch
+
+  # Fix for __builtin_bswqp16 now requiring NEON under GCC 6
+  patch -p0 -i ../bswap16-gcc6.patch
 }
 
 build() {
diff --git a/extra/qt5-base/bswap16-gcc6.patch b/extra/qt5-base/bswap16-gcc6.patch
new file mode 100644
index 000000000..025ab6494
--- /dev/null
+++ b/extra/qt5-base/bswap16-gcc6.patch
@@ -0,0 +1,11 @@
+--- src/corelib/global/qendian.h.orig	2016-05-08 11:03:09.827707031 -0600
++++ src/corelib/global/qendian.h	2016-05-08 11:04:53.968007202 -0600
+@@ -136,7 +136,7 @@
+         | ((source & 0xff000000) >> 24);
+ }
+ #endif // GCC & Clang intrinsics
+-#if (defined(Q_CC_GNU) && Q_CC_GNU >= 408) || QT_HAS_BUILTIN(__builtin_bswap16)
++#if defined(__ARM_NEON__) && ((defined(Q_CC_GNU) && Q_CC_GNU >= 408) || QT_HAS_BUILTIN(__builtin_bswap16))
+ template <> inline quint16 qbswap<quint16>(quint16 source)
+ {
+     return __builtin_bswap16(source);
diff --git a/extra/qt5-base/qtbug-45812.patch b/extra/qt5-base/qtbug-45812.patch
index e8490da30..15243871d 100644
--- a/extra/qt5-base/qtbug-45812.patch
+++ b/extra/qt5-base/qtbug-45812.patch
@@ -1,8 +1,11 @@
-From 9f5c5d799ed45faff6cb31333b531444d68c2c9a Mon Sep 17 00:00:00 2001
+From 269fdbdd2bedda5f5eacb751224d3a3fc3eed5bc Mon Sep 17 00:00:00 2001
 From: Urs Fleisch <ufleisch@users.sourceforge.net>
 Date: Fri, 26 Feb 2016 17:46:09 +0100
 Subject: [PATCH] xcb: Fix drag and drop to applications like Emacs and
  Chromium.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
 
 Drops without matching time stamp do not work. I have fixed the issue by
 reanimating the findXdndAwareParent() function (adapted to XCB) and
@@ -10,15 +13,18 @@ using it to find a matching transaction if all else fails.
 
 Task-number: QTBUG-45812
 Change-Id: Ibca15bbab02ccf2f25280418e9edf36972ebf9a0
+Reviewed-by: Błażej Szczygieł <spaz16@wp.pl>
+Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
+Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
 ---
- src/plugins/platforms/xcb/qxcbdrag.cpp | 44 ++++++++++++++++++++++++++++++++++
- 1 file changed, 44 insertions(+)
+ src/plugins/platforms/xcb/qxcbdrag.cpp | 55 +++++++++++++++++++++++++++-------
+ 1 file changed, 44 insertions(+), 11 deletions(-)
 
 diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
-index 1d13adf..b22f4af 100644
+index f5cc873..f1428d0 100644
 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp
 +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
-@@ -1074,6 +1074,40 @@ void QXcbDrag::cancel()
+@@ -1072,6 +1072,40 @@ void QXcbDrag::cancel()
          send_leave();
  }
  
@@ -41,8 +47,8 @@ index 1d13adf..b22f4af 100644
 +        }
 +
 +        // try window's parent
-+        xcb_query_tree_cookie_t qtCookie = xcb_query_tree_unchecked(
-+            c->xcb_connection(), window);
++        xcb_query_tree_cookie_t qtCookie = Q_XCB_CALL(
++            xcb_query_tree_unchecked(c->xcb_connection(), window));
 +        xcb_query_tree_reply_t *qtReply = xcb_query_tree_reply(
 +            c->xcb_connection(), qtCookie, NULL);
 +        if (!qtReply)
@@ -59,23 +65,34 @@ index 1d13adf..b22f4af 100644
  
  void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event)
  {
-@@ -1101,6 +1135,16 @@ void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event
+@@ -1099,17 +1133,16 @@ void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event
              // xcb_convert_selection() that we sent the XdndDrop event to.
              at = findTransactionByWindow(event->requestor);
          }
+-//        if (at == -1 && event->time == XCB_CURRENT_TIME) {
+-//            // previous Qt versions always requested the data on a child of the target window
+-//            // using CurrentTime... but it could be asking for either drop data or the current drag's data
+-//            Window target = findXdndAwareParent(event->requestor);
+-//            if (target) {
+-//                if (current_target && current_target == target)
+-//                    at = -2;
+-//                else
+-//                    at = findXdndDropTransactionByWindow(target);
+-//            }
+-//        }
 +
 +        if (at == -1 && event->time == XCB_CURRENT_TIME) {
 +            xcb_window_t target = findXdndAwareParent(connection(), event->requestor);
 +            if (target) {
-+                if (current_target && current_target == target)
++                if (current_target == target)
 +                    at = -2;
 +                else
 +                    at = findTransactionByWindow(target);
 +            }
 +        }
- //        if (at == -1 && event->time == XCB_CURRENT_TIME) {
- //            // previous Qt versions always requested the data on a child of the target window
- //            // using CurrentTime... but it could be asking for either drop data or the current drag's data
+     }
+ 
+     QDrag *transactionDrag = 0;
 -- 
-2.7.4
+2.7.1