krita-4.2.7.1.patchset revision e4a51550
1From a9f8a63397cacc3f5ad0da2eca30e24c095e13d6 Mon Sep 17 00:00:00 2001
2From: Gerasim Troeglazov <3dEyes@gmail.com>
3Date: Mon, 14 Oct 2019 00:06:41 +1000
4Subject: Fix haiku build
5
6
7diff --git a/CMakeLists.txt b/CMakeLists.txt
8index 6eeb998..8a22768 100644
9--- a/CMakeLists.txt
10+++ b/CMakeLists.txt
11@@ -399,7 +399,7 @@ set_package_properties(Qt5QuickWidgets PROPERTIES
12         PURPOSE "Optionally used for the touch gui for Krita")
13 endif()
14 
15-if (NOT WIN32 AND NOT APPLE)
16+if (NOT WIN32 AND NOT APPLE AND NOT HAIKU)
17 
18     find_package(Qt5 ${MIN_QT_VERSION} REQUIRED X11Extras)
19 
20diff --git a/krita/main.cc b/krita/main.cc
21index 5077343..fb0a157 100644
22--- a/krita/main.cc
23+++ b/krita/main.cc
24@@ -73,6 +73,12 @@
25 #include <QLibrary>
26 #endif
27 
28+#if defined Q_OS_HAIKU
29+#include <unistd.h>
30+#include <sys/types.h>
31+#include <signal.h>
32+#endif
33+
34 #if defined HAVE_KCRASH
35 #include <kcrash.h>
36 #elif defined USE_DRMINGW
37@@ -251,7 +257,7 @@ extern "C" int main(int argc, char **argv)
38     }
39 
40 
41-#ifdef Q_OS_LINUX
42+#if defined(Q_OS_LINUX)
43     {
44         QByteArray originalXdgDataDirs = qgetenv("XDG_DATA_DIRS");
45         if (originalXdgDataDirs.isEmpty()) {
46@@ -260,6 +266,9 @@ extern "C" int main(int argc, char **argv)
47         }
48         qputenv("XDG_DATA_DIRS", QFile::encodeName(root + "share") + ":" + originalXdgDataDirs);
49     }
50+#elif defined(Q_OS_HAIKU)
51+	qputenv("KRITA_PLUGIN_PATH", QFile::encodeName(root + "lib"));
52+    qputenv("XDG_DATA_DIRS", QFile::encodeName(root + "share") + ":" + qgetenv("XDG_DATA_DIRS"));
53 #else
54     qputenv("XDG_DATA_DIRS", QFile::encodeName(root + "share"));
55 #endif
56@@ -538,6 +547,8 @@ extern "C" int main(int argc, char **argv)
57     if (logUsage) {
58         KisUsageLogger::close();
59     }
60-
61+#if defined Q_OS_HAIKU
62+	kill(::getpid(), SIGKILL);
63+#endif
64     return state;
65 }
66diff --git a/libs/image/kis_image_config.cpp b/libs/image/kis_image_config.cpp
67index ab4550d..979a5f1 100644
68--- a/libs/image/kis_image_config.cpp
69+++ b/libs/image/kis_image_config.cpp
70@@ -396,6 +396,8 @@ void KisImageConfig::setLazyFrameCreationEnabled(bool value)
71 #elif defined Q_OS_MACOS
72 #include <sys/types.h>
73 #include <sys/sysctl.h>
74+#elif defined Q_OS_HAIKU
75+#include <OS.h>
76 #endif
77 
78 int KisImageConfig::totalRAM()
79@@ -424,6 +426,13 @@ int KisImageConfig::totalRAM()
80     if(!error) {
81         totalMemory = physmem >> 20;
82     }
83+#elif defined Q_OS_HAIKU
84+	system_info info;
85+	error = get_system_info(&info) == B_OK?0:1;
86+	if (!error) {
87+		uint64_t size = (info.max_pages * B_PAGE_SIZE);
88+    	totalMemory = size >> 20;
89+	}
90 #elif defined Q_OS_WIN
91     MEMORYSTATUSEX status;
92     status.dwLength = sizeof(status);
93diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt
94index 6915acb..ff598ed 100644
95--- a/libs/ui/CMakeLists.txt
96+++ b/libs/ui/CMakeLists.txt
97@@ -568,7 +568,7 @@ if (HAVE_QT_MULTIMEDIA)
98     target_link_libraries(kritaui Qt5::Multimedia)
99 endif()
100 
101-if (NOT WIN32 AND NOT APPLE)
102+if (NOT WIN32 AND NOT APPLE AND NOT HAIKU)
103   target_link_libraries(kritaui ${X11_X11_LIB}
104                                 ${X11_Xinput_LIB})
105 endif()
106@@ -578,11 +578,17 @@ if(APPLE)
107     target_link_libraries(kritaui ${APPKIT_LIBRARY})
108 endif ()
109 
110+if(HAIKU)
111+    target_link_libraries(kritaui network)
112+    target_link_libraries(kritaui expat)
113+    target_link_libraries(kritaui iconv)
114+    target_link_libraries(kritaui intl)
115+endif ()
116 
117 target_link_libraries(kritaui ${OPENEXR_LIBRARIES})
118 
119 # Add VSync disable workaround
120-if(NOT WIN32 AND NOT APPLE)
121+if(NOT WIN32 AND NOT APPLE AND NOT HAIKU)
122     target_link_libraries(kritaui ${CMAKE_DL_LIBS} Qt5::X11Extras)
123 endif()
124 
125diff --git a/libs/ui/widgets/kis_floating_message.cpp b/libs/ui/widgets/kis_floating_message.cpp
126index 86e248c..f1b55b0 100644
127--- a/libs/ui/widgets/kis_floating_message.cpp
128+++ b/libs/ui/widgets/kis_floating_message.cpp
129@@ -129,6 +129,7 @@ KisFloatingMessage::KisFloatingMessage(const QString &message, QWidget *parent,
130     , m_priority(priority)
131     , m_alignment(alignment)
132 {
133+#ifndef Q_OS_HAIKU
134     m_icon = KisIconUtils::loadIcon("krita").pixmap(256, 256).toImage();
135 
136     setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip);
137@@ -139,6 +140,7 @@ KisFloatingMessage::KisFloatingMessage(const QString &message, QWidget *parent,
138 
139     m_timer.setSingleShot( true );
140     connect(&m_timer, SIGNAL(timeout()), SLOT(startFade()));
141+#endif
142 }
143 
144 void KisFloatingMessage::tryOverrideMessage(const QString message,
145@@ -160,12 +162,13 @@ void KisFloatingMessage::tryOverrideMessage(const QString message,
146 
147 void KisFloatingMessage::showMessage()
148 {
149-
150+#ifndef Q_OS_HAIKU
151     setGeometry(determineMetrics(fontMetrics().width('x')));
152     setWindowOpacity(OSD_WINDOW_OPACITY);
153 
154     QWidget::setVisible(true);
155     m_timer.start(m_timeout);
156+#endif
157 }
158 
159 void KisFloatingMessage::setShowOverParent(bool show)
160diff --git a/libs/widgetutils/KoResourcePaths.cpp b/libs/widgetutils/KoResourcePaths.cpp
161index ab83086..e40c143 100644
162--- a/libs/widgetutils/KoResourcePaths.cpp
163+++ b/libs/widgetutils/KoResourcePaths.cpp
164@@ -127,6 +127,8 @@ QString getInstallationPrefix() {
165     appdir.setPath(correctedPath);
166     appdir.cdUp();
167     return appdir.canonicalPath();
168+    #elif defined(Q_OS_HAIKU)
169+		return qApp->applicationDirPath() + "/";
170 #else
171     return qApp->applicationDirPath() + "/../";
172 #endif
173diff --git a/libs/widgetutils/kis_icon_utils.cpp b/libs/widgetutils/kis_icon_utils.cpp
174index 408174f..7be9ee8 100644
175--- a/libs/widgetutils/kis_icon_utils.cpp
176+++ b/libs/widgetutils/kis_icon_utils.cpp
177@@ -29,8 +29,10 @@
178 
179 #include <KoIcon.h>
180 #if QT_VERSION >= 0x050900
181+#if !defined(Q_OS_HAIKU)
182 #define CACHE_ICONS
183 #endif
184+#endif
185 
186 namespace KisIconUtils
187 {
188diff --git a/plugins/dockers/CMakeLists.txt b/plugins/dockers/CMakeLists.txt
189index 6952b67..58ecaae 100644
190--- a/plugins/dockers/CMakeLists.txt
191+++ b/plugins/dockers/CMakeLists.txt
192@@ -14,7 +14,7 @@ add_subdirectory(compositiondocker)
193 add_subdirectory(patterndocker)
194 add_subdirectory(griddocker)
195 add_subdirectory(arrangedocker)
196-if(HAVE_OCIO)
197+if(HAVE_OCIO AND NOT HAIKU)
198     add_subdirectory(lut)
199 endif()
200 add_subdirectory(overview)
201-- 
2022.23.0
203
204