From 539f3d92c540ec451b970c484055f99122dbfa7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Mon, 11 Feb 2019 15:53:49 +1000
Subject: Make sure libs are searched in the develop/ dir by CMake

Static libs at least are not in the lib[/x86] dirs...

diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
index 24ed125..52f637e 100644
--- a/mkspecs/features/create_cmake.prf
+++ b/mkspecs/features/create_cmake.prf
@@ -112,6 +112,9 @@ win32:!static:!staticlib {
         CMAKE_DLL_DIR = $$[QT_INSTALL_BINS]/
         CMAKE_DLL_DIR_IS_ABSOLUTE = True
     }
+} else:haiku {
+    CMAKE_DLL_DIR = develop/$$CMAKE_LIB_DIR
+    CMAKE_DLL_DIR_IS_ABSOLUTE = $$CMAKE_LIB_DIR_IS_ABSOLUTE
 } else {
     CMAKE_DLL_DIR = $$CMAKE_LIB_DIR
     CMAKE_DLL_DIR_IS_ABSOLUTE = $$CMAKE_LIB_DIR_IS_ABSOLUTE
-- 
2.30.2


From 3e2630d33503d1411af771d6fc4bfb9a7034946b Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 11 Feb 2019 15:56:12 +1000
Subject: Fix QStandartPaths for Haiku


diff --git a/src/corelib/io/qstandardpaths_haiku.cpp b/src/corelib/io/qstandardpaths_haiku.cpp
index 044d69f..1f255a9 100644
--- a/src/corelib/io/qstandardpaths_haiku.cpp
+++ b/src/corelib/io/qstandardpaths_haiku.cpp
@@ -145,22 +145,22 @@ QString QStandardPaths::writableLocation(StandardLocation type)
         return haikuStandardPath(B_USER_NONPACKAGED_BIN_DIRECTORY);
     case TempLocation:
         return haikuStandardPath(B_SYSTEM_TEMP_DIRECTORY);
-    case AppDataLocation: // fall through
+    case AppDataLocation:
+    	return haikuAppStandardPath(B_SYSTEM_CACHE_DIRECTORY);
     case AppLocalDataLocation:
-        return haikuAppStandardPath(B_USER_NONPACKAGED_DATA_DIRECTORY);
+        return haikuAppStandardPath(B_USER_CACHE_DIRECTORY);
     case GenericDataLocation:
-        return haikuStandardPath(B_USER_NONPACKAGED_DATA_DIRECTORY);
+        return haikuAppStandardPath(B_SYSTEM_CACHE_DIRECTORY);
     case CacheLocation:
         return haikuAppStandardPath(B_USER_CACHE_DIRECTORY);
     case GenericCacheLocation:
-        return haikuStandardPath(B_USER_CACHE_DIRECTORY);
-    case ConfigLocation: // fall through
+        return haikuStandardPath(B_SYSTEM_CACHE_DIRECTORY);
+    case ConfigLocation:
     case AppConfigLocation:
-        return haikuAppStandardPath(B_USER_SETTINGS_DIRECTORY);
     case GenericConfigLocation:
-        return haikuStandardPath(B_USER_SETTINGS_DIRECTORY);
+        return haikuAppStandardPath(B_USER_SETTINGS_DIRECTORY);
     default:
-        return QString();
+        return haikuAppStandardPath(B_USER_SETTINGS_DIRECTORY);
     }
 }
 
@@ -179,7 +179,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
     case MoviesLocation:
     case DownloadLocation:
     case HomeLocation:
-        paths += haikuStandardPath(B_USER_NONPACKAGED_DIRECTORY);
+        paths += haikuStandardPath(B_USER_DIRECTORY);
         break;
     case FontsLocation:
         paths += haikuStandardPaths(B_FIND_PATH_FONTS_DIRECTORY);
@@ -203,7 +203,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
         break;
     case ConfigLocation: // fall through
     case AppConfigLocation:
-        paths += haikuAppStandardPath(B_SYSTEM_SETTINGS_DIRECTORY);
+        paths += haikuAppStandardPath(B_USER_SETTINGS_DIRECTORY);
         break;
     case GenericConfigLocation:
         paths += haikuStandardPath(B_SYSTEM_SETTINGS_DIRECTORY);
-- 
2.30.2


From 908d945943b0563451f4aa1027df3a7afd427148 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 11 Feb 2019 15:56:39 +1000
Subject: QSslSocketPrivate::unixRootCertDirectories(): add ssl path for Haiku.


diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 003bbf0..8c48db1 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -2980,6 +2980,7 @@ QList<QByteArray> QSslSocketPrivate::unixRootCertDirectories()
                                << "/usr/local/ssl/certs/" // Solaris
                                << "/etc/openssl/certs/" // BlackBerry
                                << "/opt/openssl/certs/" // HP-UX
+                               << "/system/data/ssl/" // Haiku
                                << "/etc/ssl/"; // OpenBSD
 }
 
-- 
2.30.2


From 7e582bb843a2a46efa11c7a9365114fa944eaa85 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 11 Feb 2019 15:56:59 +1000
Subject: Fix build for Haiku platform


diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf
index 0040b6c..9a729bb 100644
--- a/mkspecs/features/toolchain.prf
+++ b/mkspecs/features/toolchain.prf
@@ -263,7 +263,7 @@ isEmpty($${target_prefix}.INCDIRS) {
                 }
             }
         }
-        if(!darwin:clang)|intel_icc {
+        if(!darwin:clang)|haiku|intel_icc {
             # Clang on a non-Apple system (that is, a system without ld64 -- say, with GNU ld
             # or gold under Linux) will not print any library search path. Need to use another
             # invocation with different options (which in turn doesn't print include search
-- 
2.30.2


From 0a68bc64a38a6104917b2f510cd054cada753e7a Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 11 Feb 2019 15:57:54 +1000
Subject: Fix endian detection


diff --git a/src/3rdparty/sha3/brg_endian.h b/src/3rdparty/sha3/brg_endian.h
index 9bb306e..9f0ea58 100644
--- a/src/3rdparty/sha3/brg_endian.h
+++ b/src/3rdparty/sha3/brg_endian.h
@@ -39,10 +39,10 @@ Changes for ARM 9/9/2010 [Downstream relative to Gladman's GitHub, upstream to Q
 #elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \
       defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ )
 #  include <machine/endian.h>
-#elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
+#elif defined( __linux__ ) || defined( __HAIKU__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
 #  if !defined( __MINGW32__ ) && !defined( _AIX ) && !defined(Q_OS_QNX)
 #    include <endian.h>
-#    if !defined( __BEOS__ ) && !defined(Q_OS_RTEMS)
+#    if !defined( __BEOS__ ) && !defined( __HAIKU__ ) && !defined(Q_OS_RTEMS)
 #      include <byteswap.h>
 #    endif
 #  endif
-- 
2.30.2


From 8494b1bd7cfd532ddb859e68e6b68bd691ce3cb4 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 27 May 2020 19:54:30 +1000
Subject: Disable LibResolv for Haiku


diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 9b0a2ee..480671b 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -87,7 +87,7 @@ typedef void (*res_nclose_proto)(res_state_ptr);
 static res_nclose_proto local_res_nclose = nullptr;
 static res_state_ptr local_res = nullptr;
 
-#if QT_CONFIG(library) && !defined(Q_OS_QNX)
+#if QT_CONFIG(library) && !defined(Q_OS_QNX) && !defined(Q_OS_HAIKU)
 namespace {
 struct LibResolv
 {
-- 
2.30.2


From 9bc157e738691749706fe03b6bfe219b596d9eb7 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 8 Sep 2019 00:17:19 +1000
Subject: Don't use ifaddrs for Haiku


diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp
index b1e351a..705033c 100644
--- a/src/network/kernel/qnetworkinterface_unix.cpp
+++ b/src/network/kernel/qnetworkinterface_unix.cpp
@@ -53,7 +53,7 @@
 #  include "qdatetime.h"
 #endif
 
-#if defined(QT_LINUXBASE)
+#if defined(QT_LINUXBASE) || defined(Q_OS_HAIKU)
 #  define QT_NO_GETIFADDRS
 #endif
 
-- 
2.30.2


From 8e3ff77b9c2be9219e1c8cee83420c08ecfc39e3 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 27 May 2020 19:54:58 +1000
Subject: Disable sharedmemory feature for bootstrap


diff --git a/src/tools/bootstrap/CMakeLists.txt b/src/tools/bootstrap/CMakeLists.txt
index 511313e..f997489 100644
--- a/src/tools/bootstrap/CMakeLists.txt
+++ b/src/tools/bootstrap/CMakeLists.txt
@@ -109,6 +109,7 @@ qt_internal_extend_target(Bootstrap
         QT_NO_CAST_FROM_ASCII
         QT_NO_CAST_TO_ASCII
         QT_NO_FOREACH
+        QT_NO_SHAREDMEMORY
     INCLUDE_DIRECTORIES
         ..
         ../../3rdparty/tinycbor/src
-- 
2.30.2


From 244d13ddddf14efcb0e33e6e3b157b769ba1d215 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 29 Dec 2019 18:13:19 +1000
Subject: Fix build for x86_gcc2


diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c
index c29ebc2..c6309a2 100644
--- a/src/3rdparty/forkfd/forkfd.c
+++ b/src/3rdparty/forkfd/forkfd.c
@@ -722,7 +722,7 @@ int forkfd(int flags, pid_t *ppid)
         /* parent process */
         info->deathPipe = death_pipe[1];
         fd = death_pipe[0];
-        ffd_atomic_store(&info->pid, pid, FFD_ATOMIC_RELEASE);
+        ffd_atomic_store(&info->pid, (int32_t)pid, FFD_ATOMIC_RELEASE);
 
         /* release the child */
 #ifdef HAVE_EVENTFD
-- 
2.30.2


From 044d412caee2a8ee8713a796b9ae1617439b6a91 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 4 Jun 2020 23:11:17 +1000
Subject: Implement QFilesystemWatcher for Haiku


diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 0bcc3b7..6132bba 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -426,6 +426,14 @@ qt_internal_extend_target(Core CONDITION MSVC AND (TEST_architecture_arch STREQU
         "/BASE:0x67000000"
 )
 
+qt_internal_extend_target(Core CONDITION HAIKU
+    SOURCES
+        kernel/qsharedmemory_haiku.cpp
+        kernel/qsystemsemaphore_posix.cpp
+        kernel/qsystemsemaphore_systemv.cpp
+        kernel/qsystemsemaphore_unix.cpp
+)
+
 # QtCore can't be compiled with -Wl,-no-undefined because it uses the
 # "environ" variable and FreeBSD does not include a weak symbol for it
 # in libc.
@@ -895,6 +903,11 @@ qt_internal_extend_target(Core CONDITION MACOS AND QT_FEATURE_filesystemwatcher
         io/qfilesystemwatcher_fsevents.mm io/qfilesystemwatcher_fsevents_p.h
 )
 
+qt_internal_extend_target(Core CONDITION HAIKU AND QT_FEATURE_filesystemwatcher
+    SOURCES
+        io/qfilesystemwatcher_haiku.cpp io/qfilesystemwatcher_haiku_p.h
+)
+
 qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND QT_FEATURE_inotify AND UNIX AND NOT MACOS
     SOURCES
         io/qfilesystemwatcher_inotify.cpp io/qfilesystemwatcher_inotify_p.h
@@ -1072,7 +1085,7 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_clock_gettime AND UNIX
         WrapRt::WrapRt
 )
 
-qt_internal_extend_target(Core CONDITION UNIX AND NOT ANDROID
+qt_internal_extend_target(Core CONDITION UNIX AND NOT ANDROID AND NOT HAIKU
     SOURCES
         kernel/qsharedmemory_posix.cpp
         kernel/qsharedmemory_systemv.cpp
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index bd5a73d..a3825f8 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -54,6 +54,8 @@
 #include "qfilesystemwatcher_polling_p.h"
 #if defined(Q_OS_WIN)
 #  include "qfilesystemwatcher_win_p.h"
+#elif defined(Q_OS_HAIKU)
+#  include "qfilesystemwatcher_haiku_p.h"
 #elif defined(USE_INOTIFY)
 #  include "qfilesystemwatcher_inotify_p.h"
 #elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(QT_PLATFORM_UIKIT)
@@ -73,6 +75,8 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject
 {
 #if defined(Q_OS_WIN)
     return new QWindowsFileSystemWatcherEngine(parent);
+#elif defined(Q_OS_HAIKU)
+    return new QHaikuFileSystemWatcherEngine(parent);
 #elif defined(USE_INOTIFY)
     // there is a chance that inotify may fail on Linux pre-2.6.13 (August
     // 2005), so we can't just new inotify directly.
diff --git a/src/corelib/io/qfilesystemwatcher_haiku.cpp b/src/corelib/io/qfilesystemwatcher_haiku.cpp
new file mode 100644
index 0000000..8355ca8
--- /dev/null
+++ b/src/corelib/io/qfilesystemwatcher_haiku.cpp
@@ -0,0 +1,254 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2015-2020 Gerasim Troeglazov,
+** Contact: 3dEyes@gmail.com
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "qfilesystemwatcher_haiku_p.h"
+#include <QtCore/qscopeguard.h>
+#include <QtCore/qtimer.h>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QHaikuFileWatcher::QHaikuFileWatcher() : QObject(), BLooper() {};
+QHaikuDirWatcher::QHaikuDirWatcher() : QObject(), BLooper() {};
+
+QHaikuFileSystemWatcherEngine::QHaikuFileSystemWatcherEngine(QObject *parent)
+	: QFileSystemWatcherEngine(parent)
+{
+	fileLooper = new QHaikuFileWatcher();
+	connect(fileLooper, SIGNAL(fileChanged(const QString &, bool)), SLOT(bfsFileChanged(const QString &, bool)));
+	fileLooper->Run();
+
+	dirLooper = new QHaikuDirWatcher();
+	connect(dirLooper, SIGNAL(directoryChanged(const QString &, bool)), SLOT(bfsDirectoryChanged(const QString &, bool)));
+	dirLooper->Run();
+}
+
+QHaikuFileSystemWatcherEngine::~QHaikuFileSystemWatcherEngine()
+{
+	stop_watching(fileLooper);
+	if (fileLooper->Lock())
+		fileLooper->Quit();
+
+	stop_watching(dirLooper);
+	if (dirLooper->Lock())
+		dirLooper->Quit();
+}
+
+QStringList QHaikuFileSystemWatcherEngine::addPaths(const QStringList &paths,
+                                                      QStringList *files,
+                                                      QStringList *directories)
+{
+	QStringList unhandled;
+	for (const QString &path : paths) {
+		QFileInfo fi(path);
+		bool isDir = fi.isDir();
+		auto sg = qScopeGuard([&]{ unhandled.push_back(path); });
+		if (isDir) {
+			if (directories->contains(path))
+				continue;
+		} else {
+			if (files->contains(path))
+				continue;
+		}
+
+		BEntry entry(path.toUtf8().constData());       
+		if (!entry.Exists())
+			continue;
+
+		node_ref nref;
+		entry.GetNodeRef(&nref);
+		status_t status = isDir ?
+			watch_node(&nref, (B_WATCH_NAME | B_WATCH_ATTR | B_WATCH_STAT | B_WATCH_DIRECTORY), dirLooper):
+			watch_node(&nref, (B_WATCH_NAME | B_WATCH_ATTR | B_WATCH_STAT), fileLooper);
+
+		if (status != B_OK) {
+			qWarning("watch_node(%ls) failed:", path.constData());
+			continue;
+		}
+
+		sg.dismiss();
+
+		if (isDir)
+			directories->append(path);
+		else
+			files->append(path);
+	}
+	return unhandled;
+}
+
+QStringList QHaikuFileSystemWatcherEngine::removePaths(const QStringList &paths,
+                                                         QStringList *files,
+                                                         QStringList *directories)
+{
+	QStringList unhandled;
+	for (const QString &path : paths) {
+		auto sg = qScopeGuard([&]{ unhandled.push_back(path); });
+
+		BEntry entry(path.toUtf8().constData());
+		node_ref nref;
+		entry.GetNodeRef(&nref);
+
+		if (directories->contains(path)) {
+			directories->removeAll(path);
+			status_t status = watch_node(&nref, B_STOP_WATCHING, dirLooper);
+		} else if (files->contains(path)) {
+			files->removeAll(path);
+			status_t status = watch_node(&nref, B_STOP_WATCHING, fileLooper);
+		} else {
+			continue;
+		}
+
+		sg.dismiss();
+	}
+
+	return unhandled;
+}
+
+void
+QHaikuDirWatcher::MessageReceived(BMessage* message)
+{
+	if (message->what == B_NODE_MONITOR) {
+		int32 opcode;
+
+		if (message->FindInt32("opcode", &opcode) != B_OK)
+			return;
+
+		switch (opcode) {
+			case B_ENTRY_MOVED:
+				{
+					int32 device = 0;
+					int64 srcFolder = 0;
+					int64 dstFolder = 0;
+					const char* name = NULL;
+					if (message->FindInt32("device", &device) != B_OK
+						|| message->FindInt64("to directory", &dstFolder) != B_OK
+						|| message->FindInt64("from directory", &srcFolder) != B_OK
+						|| message->FindString("name", &name) != B_OK)
+							break;
+
+					entry_ref ref(device, srcFolder, name);
+					BEntry entry(&ref);
+
+					BEntry dirEntry;
+					entry.GetParent(&dirEntry);
+
+					BPath path;
+					dirEntry.GetPath(&path);
+					
+					QString qpath = QString::fromUtf8(path.Path());
+
+					emit directoryChanged(qpath, false);
+				}
+				break;
+			case B_ENTRY_CREATED:
+			case B_ENTRY_REMOVED:
+				{
+					int64 directory;
+					int32 device;
+					int64 node;
+					const char *name;
+					if (message->FindInt64("directory", &directory) != B_OK
+						|| message->FindInt32("device", &device) != B_OK
+						|| message->FindInt64("node", &node) != B_OK
+						|| message->FindString("name", &name) != B_OK)
+							break;
+
+					entry_ref ref(device, directory, name);
+					BEntry entry(&ref);				
+					BEntry dirEntry;
+					entry.GetParent(&dirEntry);
+
+					BPath path;
+					dirEntry.GetPath(&path);
+
+					QString qpath = QString::fromUtf8(path.Path());
+					emit directoryChanged(qpath, opcode == B_ENTRY_REMOVED);
+				}
+				break;
+		}
+	}
+}
+
+void
+QHaikuFileWatcher::MessageReceived(BMessage* message)
+{
+	if (message->what == B_NODE_MONITOR) {
+		int32 opcode;
+		node_ref nref;
+		const char *name;
+
+		if (message->FindInt32("opcode", &opcode) != B_OK)
+			return;
+
+		switch (opcode) {
+			case B_ENTRY_MOVED:
+				{
+					int32 device = 0;
+					int64 srcFolder = 0;
+					int64 dstFolder = 0;
+					const char* name = NULL;
+					if (message->FindInt32("device", &device) != B_OK
+						|| message->FindInt64("to directory", &dstFolder) != B_OK
+						|| message->FindInt64("from directory", &srcFolder) != B_OK
+						|| message->FindString("name", &name) != B_OK)
+							break;
+
+					entry_ref ref(device, srcFolder, name);
+					BEntry entry(&ref);
+
+					BPath path;
+					entry.GetPath(&path);
+
+					QString qpath = QString::fromUtf8(path.Path());
+
+					emit fileChanged(qpath, false);
+				}
+				break;
+			case B_STAT_CHANGED:
+			case B_ATTR_CHANGED:
+				BString path;
+				if (message->FindString("path", &path) == B_OK) {
+					QString qpath = QString::fromUtf8(path.String());
+
+			        QFileInfo fi(qpath);
+			        if (!fi.exists())
+			            emit fileChanged(qpath, true);
+			        else
+			            emit fileChanged(qpath, false);
+				}
+				break;
+		}
+	}
+}
+
+void 
+QHaikuFileSystemWatcherEngine::bfsDirectoryChanged(const QString &path, bool removed)
+{
+	emit directoryChanged(path, removed);
+}
+
+void
+QHaikuFileSystemWatcherEngine::bfsFileChanged(const QString &path, bool removed)
+{
+	emit fileChanged(path, removed);
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qfilesystemwatcher_haiku_p.cpp"
diff --git a/src/corelib/io/qfilesystemwatcher_haiku_p.h b/src/corelib/io/qfilesystemwatcher_haiku_p.h
new file mode 100644
index 0000000..8a8d75a
--- /dev/null
+++ b/src/corelib/io/qfilesystemwatcher_haiku_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2015-2020 Gerasim Troeglazov,
+** Contact: 3dEyes@gmail.com
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#ifndef QFILESYSTEMWATCHER_HAIKU_P_H
+#define QFILESYSTEMWATCHER_HAIKU_P_H
+
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qhash.h>
+
+#include <Application.h>
+#include <NodeMonitor.h>
+#include <Looper.h>
+#include <String.h>
+#include <Autolock.h>
+#include <Handler.h>
+#include <Entry.h>
+#include <Path.h>
+
+#include "qfilesystemwatcher_p.h"
+
+QT_REQUIRE_CONFIG(filesystemwatcher);
+QT_BEGIN_NAMESPACE
+
+class QHaikuDirWatcher : public QObject, public BLooper {
+	Q_OBJECT
+public:
+	QHaikuDirWatcher();
+	virtual	void MessageReceived(BMessage* msg);
+Q_SIGNALS:
+	void directoryChanged(const QString &path, bool removed);
+};
+
+class QHaikuFileWatcher : public QObject, public BLooper {
+	Q_OBJECT
+public:
+	QHaikuFileWatcher();
+	virtual	void MessageReceived(BMessage* msg);
+Q_SIGNALS:
+	void fileChanged(const QString &path, bool removed);
+};
+
+class QHaikuFileSystemWatcherEngine : public QFileSystemWatcherEngine
+{
+    Q_OBJECT
+
+public:
+    QHaikuFileSystemWatcherEngine(QObject *parent);
+    ~QHaikuFileSystemWatcherEngine();
+
+    QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories) override;
+    QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories) override;
+
+private:
+	QHaikuDirWatcher *dirLooper;
+	QHaikuFileWatcher *fileLooper;
+
+private Q_SLOTS:
+	void bfsDirectoryChanged(const QString &path, bool removed);
+	void bfsFileChanged(const QString &path, bool removed);
+};
+
+QT_END_NAMESPACE
+#endif // QFILESYSTEMWATCHER_HAIKU_P_H
+
-- 
2.30.2


From 2924289d25898a4010670f75e8e9ca7884af1eba Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Tue, 16 Jun 2020 18:06:57 +1000
Subject: Don't use AF_INET6 for new sockets


diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index e6704a3..930bc80 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -232,8 +232,12 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
     }
     int protocol = 0;
 #endif // QT_NO_SCTP
+#ifdef Q_OS_HAIKU
+	int domain = AF_INET;
+#else
     int domain = (socketProtocol == QAbstractSocket::IPv6Protocol
                   || socketProtocol == QAbstractSocket::AnyIPProtocol) ? AF_INET6 : AF_INET;
+#endif
     int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM;
 
     int socket = qt_safe_socket(domain, type, protocol, O_NONBLOCK);
-- 
2.30.2


From 2061a362b203542035b88d70b5d5c504b8831f66 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 5 Oct 2020 19:40:40 +1000
Subject: Disable Haswell CPU feature for plugins


diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index 05b2c92..6e89a5e 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -192,7 +192,7 @@ bool QLibraryPrivate::load_sys()
         prefixes.append(QString());
     }
 
-#if defined(Q_PROCESSOR_X86) && !defined(Q_OS_DARWIN)
+#if defined(Q_PROCESSOR_X86) && !defined(Q_OS_DARWIN) && !defined(Q_OS_HAIKU)
     if (qCpuHasFeature(ArchHaswell)) {
         auto transform = [](QStringList &list, void (*f)(QString *)) {
             QStringList tmp;
-- 
2.30.2


From 889f5e27c62afb9b6215401aaf97ed8bb9fa8e3b Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 12 Nov 2020 17:50:04 +0100
Subject: Haiku build setup


diff --git a/cmake/QtRpathHelpers.cmake b/cmake/QtRpathHelpers.cmake
index 6e3414b..8d16ac4 100644
--- a/cmake/QtRpathHelpers.cmake
+++ b/cmake/QtRpathHelpers.cmake
@@ -22,6 +22,8 @@ function(qt_compute_relative_rpath_base rpath install_location out_var)
         set(rpath_rel_base "@loader_path")
     elseif(LINUX OR SOLARIS OR FREEBSD)
         set(rpath_rel_base "$ORIGIN")
+    elseif(HAIKU)
+        set(rpath_rel_base "$ORIGIN")
     else()
         message(WARNING "No known RPATH_REL_BASE for target platform.")
         set(rpath_rel_base "NO_KNOWN_RPATH_REL_BASE")
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
index 7de8dfc..0880961 100644
--- a/cmake/QtSetup.cmake
+++ b/cmake/QtSetup.cmake
@@ -55,7 +55,7 @@ elseif(APPLE)
 endif()
 
 ## Position independent code:
-set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
 
 # Do not relink dependent libraries when no header has changed:
 set(CMAKE_LINK_DEPENDS_NO_SHARED ON)
-- 
2.30.2


From 18cc6325b911225fb8b0408f1eb095a7c95717a6 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 12 Nov 2020 22:33:56 +0100
Subject: Haiku: link against libnetwork


diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt
index 1ab3c20..534a7e7 100644
--- a/src/network/CMakeLists.txt
+++ b/src/network/CMakeLists.txt
@@ -200,6 +200,11 @@ qt_internal_extend_target(Network CONDITION QT_FEATURE_dnslookup AND WIN32
         kernel/qdnslookup_win.cpp
 )
 
+qt_internal_extend_target(Network CONDITION HAIKU
+    LIBRARIES
+        network
+)
+
 qt_internal_extend_target(Network CONDITION APPLE AND NOT UIKIT
     LIBRARIES
         ${FWCoreServices}
-- 
2.30.2


From 0ce7a1db826d6e17e2a406f20b0d8609f01ded8a Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 31 Oct 2021 22:57:22 +1000
Subject: QSharedMemory implementation


diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp
index 3dbbe75..6303b77 100644
--- a/src/corelib/kernel/qsharedmemory.cpp
+++ b/src/corelib/kernel/qsharedmemory.cpp
@@ -46,6 +46,9 @@
 #ifdef Q_OS_WIN
 #  include <qt_windows.h>
 #endif
+#ifdef Q_OS_HAIKU
+#  include <OS.h>
+#endif
 
 #if defined(Q_OS_DARWIN)
 #  include "qcore_mac_p.h"
@@ -104,6 +107,12 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
 
 #ifdef Q_OS_WIN
     return result;
+#elif defined(Q_OS_HAIKU)
+    if (key.length() < B_OS_NAME_LENGTH)
+        return key;
+    result = key;
+    result.truncate(B_OS_NAME_LENGTH - 4);
+    return result + QLatin1Char('_') + QString::number(qChecksum(key.toUtf8()), 16);
 #elif defined(QT_POSIX_IPC)
     return QLatin1Char('/') + result;
 #else
diff --git a/src/corelib/kernel/qsharedmemory_haiku.cpp b/src/corelib/kernel/qsharedmemory_haiku.cpp
new file mode 100644
index 0000000..469b81c
--- /dev/null
+++ b/src/corelib/kernel/qsharedmemory_haiku.cpp
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 Gerasim Troeglazov,
+** Contact: 3dEyes@gmail.com
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "qsharedmemory.h"
+#include "qsharedmemory_p.h"
+#include <qdebug.h>
+
+#include <OS.h>
+
+#ifndef QT_NO_SHAREDMEMORY
+QT_BEGIN_NAMESPACE
+
+QSharedMemoryPrivate::QSharedMemoryPrivate()
+	: QObjectPrivate(), memory(0), size(0), error(QSharedMemory::NoError),
+#ifndef QT_NO_SYSTEMSEMAPHORE
+	systemSemaphore(QString()), lockedByMe(false),
+#endif
+	hand(-1)
+{
+}
+
+void QSharedMemoryPrivate::setErrorString(QLatin1String function)
+{
+	Q_UNUSED(function);
+}
+
+key_t QSharedMemoryPrivate::handle()
+{
+	const QString safeKey = makePlatformSafeKey(key);
+	if (safeKey.isEmpty()) {
+		errorString = QSharedMemory::tr("%1: key is empty").arg(QLatin1String("QSharedMemory::handle"));
+		error = QSharedMemory::KeyError;
+		return 0;
+	}
+
+	return 1;
+}
+
+#endif // QT_NO_SHAREDMEMORY
+
+#if !(defined(QT_NO_SHAREDMEMORY) && defined(QT_NO_SYSTEMSEMAPHORE))
+int QSharedMemoryPrivate::createUnixKeyFile(const QString &fileName)
+{
+	Q_UNUSED(fileName);
+	return 0;
+}
+#endif // QT_NO_SHAREDMEMORY && QT_NO_SYSTEMSEMAPHORE
+
+#ifndef QT_NO_SHAREDMEMORY
+
+bool QSharedMemoryPrivate::cleanHandle()
+{
+	if (hand > 0)
+		delete_area(hand);
+
+	hand = -1;
+
+	return true;
+}
+
+bool QSharedMemoryPrivate::create(qsizetype size)
+{
+	if (!handle())
+		return false;
+
+	const QLatin1String function("QSharedMemory::create");
+
+	const QString areaName = makePlatformSafeKey(key);
+
+	if (find_area(areaName.toUtf8().constData()) > 0) {
+		errorString = QSharedMemory::tr("%1: already exists").arg(function);
+		error = QSharedMemory::AlreadyExists;
+		return false;
+	}
+
+	hand = create_area(areaName.toUtf8().constData(), &memory, B_ANY_ADDRESS, size,
+		B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
+
+	if (hand <= B_ERROR) {
+		switch (hand) {
+			case B_NO_MEMORY:
+				errorString = QSharedMemory::tr("%1: not enough memory").arg(function);
+				error = QSharedMemory::OutOfResources;
+				break;
+			case B_BAD_VALUE:
+				errorString = QSharedMemory::tr("%1: bad area name").arg(function);
+				error = QSharedMemory::KeyError;
+				break;
+			default:
+				errorString = QSharedMemory::tr("%1: unknown error").arg(function);
+				error = QSharedMemory::UnknownError;
+				break;
+		}
+		return false;
+	}
+
+	return true;
+}
+
+bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
+{
+	const QLatin1String function("QSharedMemory::attach");
+
+	const QString areaName = makePlatformSafeKey(key);
+
+	uint32 permissions = mode == QSharedMemory::ReadOnly ? B_READ_AREA : B_READ_AREA | B_WRITE_AREA;
+
+	if (hand <= B_ERROR) {
+		area_id baseArea = find_area(areaName.toUtf8().constData());
+		if (baseArea <= B_ERROR) {
+			error = QSharedMemory::NotFound;
+			errorString = QSharedMemory::tr("%1: doesn't exist").arg(function);
+			cleanHandle();
+			return false;
+		}
+
+		hand = clone_area(areaName.toUtf8().constData(), &memory, B_ANY_ADDRESS, permissions, baseArea);
+		if (hand <= B_ERROR) {
+			error = QSharedMemory::UnknownError;
+			errorString = QSharedMemory::tr("%1: clone_area failed").arg(function);
+			cleanHandle();
+			return false;
+		}
+	}
+
+	area_info info;
+	if (get_area_info(hand, &info) != B_OK) {
+		error = QSharedMemory::UnknownError;
+		errorString = QSharedMemory::tr("%1: size query failed").arg(function);
+		cleanHandle();
+		return false;
+	}
+
+	size = info.size;
+	memory = info.address;
+
+	return true;
+}
+
+bool QSharedMemoryPrivate::detach()
+{
+	const QLatin1String function("QSharedMemory::detach");
+
+	area_id id = area_for(memory);
+
+	if (id == B_ERROR) {
+		error = QSharedMemory::NotFound;
+		errorString = QSharedMemory::tr("%1: doesn't exist").arg(function);
+		return false;
+	}
+
+	if (delete_area(id) != B_OK) {
+		error = QSharedMemory::UnknownError;
+		errorString = QSharedMemory::tr("%1: delete_area failed").arg(function);
+		return false;
+	}
+
+	memory = 0;
+	size = 0;
+
+	return cleanHandle();
+}
+
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SHAREDMEMORY
diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h
index e06e7e8..e0bd23f 100644
--- a/src/corelib/kernel/qsharedmemory_p.h
+++ b/src/corelib/kernel/qsharedmemory_p.h
@@ -78,10 +78,14 @@ QT_END_NAMESPACE
 # include "private/qobject_p.h"
 #endif
 
-#if !defined(Q_OS_WIN) && !defined(Q_OS_ANDROID) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_RTEMS)
+#if !defined(Q_OS_WIN) && !defined(Q_OS_ANDROID) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_RTEMS) && !defined(Q_OS_HAIKU)
 #  include <sys/sem.h>
 #endif
 
+#if defined(Q_OS_HAIKU)
+#  include <OS.h>
+#endif
+
 QT_BEGIN_NAMESPACE
 
 #ifndef QT_NO_SYSTEMSEMAPHORE
@@ -144,6 +148,8 @@ public:
             const QString &prefix = QLatin1String("qipc_sharedmemory_"));
 #ifdef Q_OS_WIN
     Qt::HANDLE handle();
+#elif defined(Q_OS_HAIKU)
+	area_id handle();
 #elif defined(QT_POSIX_IPC)
     int handle();
 #else
@@ -171,6 +177,8 @@ public:
 private:
 #ifdef Q_OS_WIN
     Qt::HANDLE hand;
+#elif defined(Q_OS_HAIKU)
+	area_id hand;
 #elif defined(QT_POSIX_IPC)
     int hand;
 #else
-- 
2.30.2


From 8ba3a2f911ad035b0847068bdde1ee87c93cf274 Mon Sep 17 00:00:00 2001
From: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Date: Tue, 2 Nov 2021 09:02:45 +0100
Subject: [PATCH] Revert "Code style fix"

This reverts commit e1d7df5ce9eb1d370e1b6dcd31ced4029082d63d.

The offending patch removed handling of page-up and page-down
shortcuts in QScrollView (including subclasses like QTextBrowser).

Pick-to: 6.2
Fixes: QTBUG-97908
Fixes: QTBUG-90352
Change-Id: If760e983a082edb53e12e1311e2c7f2676d80bb2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
---
 src/widgets/widgets/qabstractscrollarea.cpp | 82 ++++++++++++++++-------------
 1 file changed, 45 insertions(+), 37 deletions(-)

diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 4ad8a3b4110..627dbaa1d6e 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -1232,49 +1232,57 @@ void QAbstractScrollArea::contextMenuEvent(QContextMenuEvent *e)
 void QAbstractScrollArea::keyPressEvent(QKeyEvent * e)
 {
     Q_D(QAbstractScrollArea);
-
+    if (false){
+#ifndef QT_NO_SHORTCUT
+    } else if (e == QKeySequence::MoveToPreviousPage) {
+        d->vbar->triggerAction(QScrollBar::SliderPageStepSub);
+    } else if (e == QKeySequence::MoveToNextPage) {
+        d->vbar->triggerAction(QScrollBar::SliderPageStepAdd);
+#endif
+    } else {
 #ifdef QT_KEYPAD_NAVIGATION
-    if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) {
-        e->ignore();
-        return;
-    }
+        if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) {
+            e->ignore();
+            return;
+        }
 #endif
-    switch (e->key()) {
-    case Qt::Key_Up:
-        d->vbar->triggerAction(QScrollBar::SliderSingleStepSub);
-        break;
-    case Qt::Key_Down:
-        d->vbar->triggerAction(QScrollBar::SliderSingleStepAdd);
-        break;
-    case Qt::Key_Left:
+        switch (e->key()) {
+        case Qt::Key_Up:
+            d->vbar->triggerAction(QScrollBar::SliderSingleStepSub);
+            break;
+        case Qt::Key_Down:
+            d->vbar->triggerAction(QScrollBar::SliderSingleStepAdd);
+            break;
+        case Qt::Key_Left:
 #ifdef QT_KEYPAD_NAVIGATION
-    if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()
-        && (!d->hbar->isVisible() || d->hbar->value() == d->hbar->minimum())) {
-        //if we aren't using the hbar or we are already at the leftmost point ignore
-        e->ignore();
-        return;
-    }
+        if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()
+            && (!d->hbar->isVisible() || d->hbar->value() == d->hbar->minimum())) {
+            //if we aren't using the hbar or we are already at the leftmost point ignore
+            e->ignore();
+            return;
+        }
 #endif
-        d->hbar->triggerAction(
-            layoutDirection() == Qt::LeftToRight
-            ? QScrollBar::SliderSingleStepSub : QScrollBar::SliderSingleStepAdd);
-        break;
-    case Qt::Key_Right:
+            d->hbar->triggerAction(
+                layoutDirection() == Qt::LeftToRight
+                ? QScrollBar::SliderSingleStepSub : QScrollBar::SliderSingleStepAdd);
+            break;
+        case Qt::Key_Right:
 #ifdef QT_KEYPAD_NAVIGATION
-    if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()
-        && (!d->hbar->isVisible() || d->hbar->value() == d->hbar->maximum())) {
-        //if we aren't using the hbar or we are already at the rightmost point ignore
-        e->ignore();
-        return;
-    }
+        if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()
+            && (!d->hbar->isVisible() || d->hbar->value() == d->hbar->maximum())) {
+            //if we aren't using the hbar or we are already at the rightmost point ignore
+            e->ignore();
+            return;
+        }
 #endif
-        d->hbar->triggerAction(
-            layoutDirection() == Qt::LeftToRight
-            ? QScrollBar::SliderSingleStepAdd : QScrollBar::SliderSingleStepSub);
-        break;
-    default:
-        e->ignore();
-        return;
+            d->hbar->triggerAction(
+                layoutDirection() == Qt::LeftToRight
+                ? QScrollBar::SliderSingleStepAdd : QScrollBar::SliderSingleStepSub);
+            break;
+        default:
+            e->ignore();
+            return;
+        }
     }
     e->accept();
 }
-- 
2.16.3
