[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [qtcurve] /: enable building and use on Mac OS X
From:       René J.V. Bertin <rjvbertin () gmail ! com>
Date:       2014-09-30 20:01:15
Message-ID: E1XZ3bn-0004DG-R7 () scm ! kde ! org
[Download RAW message or body]

Git commit 6b9c0eb7c61a3d90942a82eca5e751296f4741ec by René J.V. Bertin.
Committed on 30/09/2014 at 18:54.
Pushed by rjvbb into branch 'master'.

enable building and use on Mac OS X

REVIEW:120437

M  +5    -0    CMakeLists.txt
M  +59   -0    gtk2/common/config_file.c
M  +0    -1    gtk2/style/CMakeLists.txt
M  +59   -0    gtk2/style/qt_settings.c
M  +0    -1    lib/cairo/CMakeLists.txt
M  +5    -1    lib/utils/CMakeLists.txt
M  +6    -0    lib/utils/color.h
M  +16   -0    lib/utils/map.c
M  +4    -0    lib/utils/process.c
M  +30   -0    lib/utils/timer.c
M  +0    -1    qt4/config/CMakeLists.txt
M  +4    -0    qt4/config/exportthemedialog.cpp
M  +4    -0    qt4/config/exportthemedialog.h
M  +0    -1    qt4/kwin/CMakeLists.txt
M  +0    -1    qt4/kwinconfig/CMakeLists.txt
M  +0    -1    qt4/style/CMakeLists.txt
M  +17   -1    qt4/style/qtcurve.cpp
M  +6    -0    qt4/style/qtcurve_plugin.cpp
M  +2    -0    qt5/CMakeLists.txt
M  +0    -1    qt5/style/CMakeLists.txt

http://commits.kde.org/qtcurve/6b9c0eb7c61a3d90942a82eca5e751296f4741ec

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f76fd1b..ff2573f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -136,11 +136,16 @@ cmake_c_fix_include_path(lib/cairo qtcurve-cairo)
 cmake_c_add_flags(CMAKE_C_FLAGS -Wall -Wextra -std=gnu99)
 # Register storage class is deprecated in C++11 but is still used in Qt.
 # Use compiler option to suppress the warning in clang++.
+if(NOT APPLE)
 # -std=c++0x is deprecated but gcc < 4.7 do not recognise c++11 ....
 cmake_c_add_flags(CMAKE_CXX_FLAGS -Wall -Wextra
   -Wno-deprecated-register -std=c++0x)
 cmake_c_add_flags(CMAKE_SHARED_LINKER_FLAGS -Wl,--as-needed -Wl,--no-undefined)
 cmake_c_add_flags(CMAKE_MODULE_LINKER_FLAGS -Wl,--as-needed -Wl,--no-undefined)
+else()
+cmake_c_add_flags(CMAKE_CXX_FLAGS -Wall -Wextra
+  -Wno-deprecated-register -std=c++11)
+endif(NOT APPLE)
 add_definitions("-D_GNU_SOURCE -pthread")
 
 if(NOT DEFINED LIB_INSTALL_DIR)
diff --git a/gtk2/common/config_file.c b/gtk2/common/config_file.c
index d732ca9..ac900d5 100644
--- a/gtk2/common/config_file.c
+++ b/gtk2/common/config_file.c
@@ -31,6 +31,65 @@
 #define OLD_CONFIG_FILE           "qtcurvestylerc"
 #define VERSION_KEY               "version"
 
+#if defined(__MACH__) || defined(__APPLE__)
+/* This code is public domain -- Will Hartung 4/9/09 */
+// http://stackoverflow.com/questions/735126/are-there-alternate-implementations-of-gnu-getline-interface
 +#include <stdio.h>
+#include <stdlib.h>
+
+static size_t getline(char **lineptr, size_t *n, FILE *stream) {
+    char *bufptr = NULL;
+    char *p = bufptr;
+    size_t size;
+    int c;
+
+    if (lineptr == NULL) {
+        return -1;
+    }
+    if (stream == NULL) {
+        return -1;
+    }
+    if (n == NULL) {
+        return -1;
+    }
+    bufptr = *lineptr;
+    size = *n;
+
+    c = fgetc(stream);
+    if (c == EOF) {
+        return -1;
+    }
+    if (bufptr == NULL) {
+        bufptr = malloc(128);
+        if (bufptr == NULL) {
+            return -1;
+        }
+        size = 128;
+    }
+    p = bufptr;
+    while(c != EOF) {
+        if ((p - bufptr) > (size - 1)) {
+            size = size + 128;
+            bufptr = realloc(bufptr, size);
+            if (bufptr == NULL) {
+                return -1;
+            }
+        }
+        *p++ = c;
+        if (c == '\n') {
+            break;
+        }
+        c = fgetc(stream);
+    }
+
+    *p++ = '\0';
+    *lineptr = bufptr;
+    *n = size;
+
+    return p - bufptr - 1;
+}
+#endif
+
 static const char*
 determineFileName(const char *file)
 {
diff --git a/gtk2/style/CMakeLists.txt b/gtk2/style/CMakeLists.txt
index 01e8891..dd88541 100644
--- a/gtk2/style/CMakeLists.txt
+++ b/gtk2/style/CMakeLists.txt
@@ -72,7 +72,6 @@ set(qtcurve_SRCS ${qtcurve_SRCS} ${qtcurve_style_common_SRCS})
 add_library(qtcurve-gtk2 MODULE ${qtcurve_SRCS})
 
 set_target_properties(qtcurve-gtk2 PROPERTIES
-  LINK_FLAGS "-Wl,--no-undefined"
   LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
   OUTPUT_NAME "qtcurve")
 add_dependencies(qtcurve-gtk2 qtc_gtk2_check_on_hdr qtc_gtk2_check_x_on_hdr
diff --git a/gtk2/style/qt_settings.c b/gtk2/style/qt_settings.c
index f5a5c98..e4671eb 100644
--- a/gtk2/style/qt_settings.c
+++ b/gtk2/style/qt_settings.c
@@ -49,6 +49,65 @@ Options opts;
 #define qtc_gtkrc_printf(args...)                       \
     gtk_rc_parse_string(QTC_LOCAL_BUFF_PRINTF(args))
 
+    #if defined(__MACH__) || defined(__APPLE__)
+/* This code is public domain -- Will Hartung 4/9/09 */
+// http://stackoverflow.com/questions/735126/are-there-alternate-implementations-of-gnu-getline-interface
 +#include <stdio.h>
+#include <stdlib.h>
+
+static size_t getline(char **lineptr, size_t *n, FILE *stream) {
+    char *bufptr = NULL;
+    char *p = bufptr;
+    size_t size;
+    int c;
+
+    if (lineptr == NULL) {
+        return -1;
+    }
+    if (stream == NULL) {
+        return -1;
+    }
+    if (n == NULL) {
+        return -1;
+    }
+    bufptr = *lineptr;
+    size = *n;
+
+    c = fgetc(stream);
+    if (c == EOF) {
+        return -1;
+    }
+    if (bufptr == NULL) {
+        bufptr = malloc(128);
+        if (bufptr == NULL) {
+            return -1;
+        }
+        size = 128;
+    }
+    p = bufptr;
+    while(c != EOF) {
+        if ((p - bufptr) > (size - 1)) {
+            size = size + 128;
+            bufptr = realloc(bufptr, size);
+            if (bufptr == NULL) {
+                return -1;
+            }
+        }
+        *p++ = c;
+        if (c == '\n') {
+            break;
+        }
+        c = fgetc(stream);
+    }
+
+    *p++ = '\0';
+    *lineptr = bufptr;
+    *n = size;
+
+    return p - bufptr - 1;
+}
+#endif
+
 static char*
 getKdeHome()
 {
diff --git a/lib/cairo/CMakeLists.txt b/lib/cairo/CMakeLists.txt
index c66c63c..3363e46 100644
--- a/lib/cairo/CMakeLists.txt
+++ b/lib/cairo/CMakeLists.txt
@@ -22,6 +22,5 @@ set_target_properties(qtcurve-cairo PROPERTIES
   VERSION 0.1
   SOVERSION 0
   COMPILE_FLAGS "-fvisibility=hidden"
-  LINK_FLAGS "-Wl,--no-undefined"
   LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
 install(TARGETS qtcurve-cairo LIBRARY DESTINATION "${LIB_INSTALL_DIR}")
diff --git a/lib/utils/CMakeLists.txt b/lib/utils/CMakeLists.txt
index 15757ed..630e493 100644
--- a/lib/utils/CMakeLists.txt
+++ b/lib/utils/CMakeLists.txt
@@ -12,8 +12,13 @@ set(qtcurve_utils_SRCS
   x11utils.c
   x11helpers.c
   x11wrap.c)
+if(APPLE)
+set(qtcurve_utils_LINKS
+  ${LIBEXECINFO_LIBRARIES} pthread)
+else()
 set(qtcurve_utils_LINKS
   m rt dl ${LIBEXECINFO_LIBRARIES} pthread)
+endif(APPLE)
 
 include_directories("${CMAKE_CURRENT_BINARY_DIR}")
 
@@ -34,7 +39,6 @@ set_target_properties(qtcurve-utils PROPERTIES
   VERSION 1.0
   SOVERSION 1
   COMPILE_FLAGS "-fvisibility=hidden"
-  LINK_FLAGS "-Wl,--no-undefined"
   LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
 install(TARGETS qtcurve-utils LIBRARY
   DESTINATION "${LIB_INSTALL_DIR}")
diff --git a/lib/utils/color.h b/lib/utils/color.h
index 2c7081f..b8aae3c 100644
--- a/lib/utils/color.h
+++ b/lib/utils/color.h
@@ -25,6 +25,12 @@
 
 #include "utils.h"
 #include "options.h"
+#ifdef Q_OS_MAC
+#include <math.h>
+#if QT_VERSION >= 0x050000
+#define isnan(x)  std::isnan(x)
+#endif //QT_VERSION
+#endif // Q_OS_MAC
 
 QTC_BEGIN_DECLS
 
diff --git a/lib/utils/map.c b/lib/utils/map.c
index a829e9e..136a7d7 100644
--- a/lib/utils/map.c
+++ b/lib/utils/map.c
@@ -21,6 +21,16 @@
 
 #include "map.h"
 
+#if defined(__MACH__) || defined(__APPLE__)
+qtcStrMapItemCompare(void *_map, const void *_left, const void *_right)
+{
+    const char **left = (const char**)_left;
+    const char **right = (const char**)_right;
+    QtcStrMap *map = (QtcStrMap*)_map;
+    return (map->case_sensitive ? strcmp(*left, *right) :
+                strcasecmp(*left, *right));
+}
+#else
 static int
 qtcStrMapItemCompare(const void *_left, const void *_right, void *_map)
 {
@@ -30,13 +40,19 @@ qtcStrMapItemCompare(const void *_left, const void *_right, void \
*_map)  return (map->case_sensitive ? strcmp(*left, *right) :
             strcasecmp(*left, *right));
 }
+#endif
 
 QTC_EXPORT void
 qtcStrMapInit(QtcStrMap *map)
 {
     QTC_RET_IF_FAIL(map && !map->inited && map->items && map->size && map->num);
+#if defined(__MACH__) || defined(__APPLE__)
+    qsort_r(map->items, map->num, map->size,
+            map, qtcStrMapItemCompare);
+#else
     qsort_r(map->items, map->num, map->size,
             qtcStrMapItemCompare, map);
+#endif
     map->inited = true;
 }
 
diff --git a/lib/utils/process.c b/lib/utils/process.c
index f2490ef..b5d7a73 100644
--- a/lib/utils/process.c
+++ b/lib/utils/process.c
@@ -23,7 +23,11 @@
 #include "fd_utils.h"
 #include "timer.h"
 #include <unistd.h>
+#if !defined(__APPLE__) && !defined(__MACH__)
 #include <wait.h>
+#else
+#include <signal.h>
+#endif //__APPLE__
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <fcntl.h>
diff --git a/lib/utils/timer.c b/lib/utils/timer.c
index 879451e..51393fd 100644
--- a/lib/utils/timer.c
+++ b/lib/utils/timer.c
@@ -25,6 +25,35 @@
 #include <time.h>
 #include <pthread.h>
 
+#if defined(__APPLE__) || defined(__MACH__)
+
+#include <mach/mach.h>
+#include <mach/mach_time.h>
+#include <mach/mach_init.h>
+#include <sys/sysctl.h>
+
+static mach_timebase_info_data_t sTimebaseInfo;
+static double calibrator= 0;
+
+// #include <stdio.h>
+__attribute__((constructor)) static void init_HRTime()
+{
+    if( !calibrator ){
+        mach_timebase_info(&sTimebaseInfo);
+        /* go from absolute time units to nanoseconds: */
+        calibrator= ((double)sTimebaseInfo.numer / (double)sTimebaseInfo.denom);
+//         fprintf( stderr, "init_HRTime(): calibrator=%g\n", calibrator );
+    }
+}
+
+QTC_EXPORT uint64_t qtcGetTime()
+{
+    return (uint64_t) mach_absolute_time() * calibrator;
+}
+
+#else
+// other = Linux ...
+
 #ifdef CLOCK_THREAD_CPUTIME_ID
 #  define CLOCK_ID CLOCK_THREAD_CPUTIME_ID
 #else
@@ -38,6 +67,7 @@ qtcGetTime()
     clock_gettime(CLOCK_ID, &time_spec);
     return ((uint64_t)time_spec.tv_sec) * 1000000000 + time_spec.tv_nsec;
 }
+#endif // __APPLE__
 
 QTC_EXPORT uint64_t
 qtcGetElapse(uint64_t prev)
diff --git a/qt4/config/CMakeLists.txt b/qt4/config/CMakeLists.txt
index 15454e6..3b65e09 100644
--- a/qt4/config/CMakeLists.txt
+++ b/qt4/config/CMakeLists.txt
@@ -50,7 +50,6 @@ kde4_add_ui_files(kstyle_qtcurve_config_PART_SRCS
 kde4_add_plugin(kstyle_qtcurve_config_kde4
   ${kstyle_qtcurve_config_PART_SRCS})
 set_target_properties(kstyle_qtcurve_config_kde4 PROPERTIES
-  LINK_FLAGS "-Wl,--no-undefined"
   LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
   OUTPUT_NAME "kstyle_qtcurve_config")
 target_link_libraries(kstyle_qtcurve_config_kde4
diff --git a/qt4/config/exportthemedialog.cpp b/qt4/config/exportthemedialog.cpp
index f39b86d..1ffbc12 100644
--- a/qt4/config/exportthemedialog.cpp
+++ b/qt4/config/exportthemedialog.cpp
@@ -29,7 +29,11 @@
 #include <QDir>
 #include <QGridLayout>
 #include <QLabel>
+#ifdef Q_OS_MAC
+#include "common/config_file.h"
+#else
 #include "config_file.h"
+#endif //Q_OS_MAC
 
 CExportThemeDialog::CExportThemeDialog(QWidget *parent)
                   : KDialog(parent)
diff --git a/qt4/config/exportthemedialog.h b/qt4/config/exportthemedialog.h
index 42590ec..093b8fd 100644
--- a/qt4/config/exportthemedialog.h
+++ b/qt4/config/exportthemedialog.h
@@ -24,7 +24,11 @@
 #define __EXPORT_THEME_DIALOG_H__
 
 #include <kdialog.h>
+#ifdef Q_OS_MAC
+#include "common/common.h"
+#else
 #include "common.h"
+#endif //Q_OS_MAC
 
 class KUrlRequester;
 class QLineEdit;
diff --git a/qt4/kwin/CMakeLists.txt b/qt4/kwin/CMakeLists.txt
index 654604b..52c7c03 100644
--- a/qt4/kwin/CMakeLists.txt
+++ b/qt4/kwin/CMakeLists.txt
@@ -33,7 +33,6 @@ include_directories(
   ${QT_QTCORE_INCLUDE_DIR})
 kde4_add_plugin(kwin3_qtcurve_kde4 ${kwin3_qtcurve_PART_SRCS})
 set_target_properties(kwin3_qtcurve_kde4 PROPERTIES
-  LINK_FLAGS "-Wl,--no-undefined"
   LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
   OUTPUT_NAME "kwin3_qtcurve")
 target_link_libraries(kwin3_qtcurve_kde4 kdecorations
diff --git a/qt4/kwinconfig/CMakeLists.txt b/qt4/kwinconfig/CMakeLists.txt
index cbd8b62..1de6dc2 100644
--- a/qt4/kwinconfig/CMakeLists.txt
+++ b/qt4/kwinconfig/CMakeLists.txt
@@ -21,7 +21,6 @@ kde4_add_ui_files(kwin_qtcurve_config_PART_SRCS
   ${kwin_qtcurve_config_PART_UIS})
 kde4_add_plugin(kwin_qtcurve_config_kde4 ${kwin_qtcurve_config_PART_SRCS})
 set_target_properties(kwin_qtcurve_config_kde4 PROPERTIES
-  LINK_FLAGS "-Wl,--no-undefined"
   LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
   OUTPUT_NAME "kwin_qtcurve_config")
 include_directories("${CMAKE_CURRENT_BINARY_DIR}")
diff --git a/qt4/style/CMakeLists.txt b/qt4/style/CMakeLists.txt
index f38d029..ffd67a7 100644
--- a/qt4/style/CMakeLists.txt
+++ b/qt4/style/CMakeLists.txt
@@ -56,7 +56,6 @@ qt4_wrap_cpp(qtcurve_MOC_SRCS ${qtcurve_MOC_HDRS})
 add_library(qtcurve-qt4 MODULE ${qtcurve_SRCS} ${qtcurve_MOC_SRCS})
 add_dependencies(qtcurve-qt4 qtc_qt4_check_on_hdr qtc_qt4_check_x_on_hdr)
 set_target_properties(qtcurve-qt4 PROPERTIES
-  LINK_FLAGS "-Wl,--no-undefined"
   LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
   OUTPUT_NAME "qtcurve"
   PREFIX "")
diff --git a/qt4/style/qtcurve.cpp b/qt4/style/qtcurve.cpp
index 7346c2f..0f71830 100644
--- a/qt4/style/qtcurve.cpp
+++ b/qt4/style/qtcurve.cpp
@@ -72,7 +72,9 @@
 #include "macmenu.h"
 #include "shadowhelper.h"
 #include <sys/time.h>
+#ifdef Q_WS_X11
 #include <qtcurve-utils/x11qtc.h>
+#endif
 
 #include <QDebug>
 
@@ -576,22 +578,32 @@ static const QLatin1String \
constDwtFloat("qt_dockwidget_floatbutton");  void
 setOpacityProp(QWidget *w, unsigned short opacity)
 {
+#ifdef Q_WS_X11
     if (WId wid = qtcGetWid(w->window())) {
         qtcX11SetOpacity(wid, opacity);
     }
+#else
+    Q_UNUSED(w);
+    Q_UNUSED(opacity);
+#endif
 }
 
 void
 setBgndProp(QWidget *w, EAppearance app, bool haveBgndImage)
 {
+#ifdef Q_WS_X11
     if (WId wid = qtcGetWid(w->window())) {
         uint32_t prop =
             (((qtcIsFlatBgnd(app) ? (haveBgndImage ? APPEARANCE_RAISED :
                                      APPEARANCE_FLAT) : app) & 0xFF) |
              (w->palette().background().color().rgb() & 0x00FFFFFF) << 8);
-
         qtcX11SetBgnd(wid, prop);
     }
+#else
+    Q_UNUSED(w);
+    Q_UNUSED(app);
+    Q_UNUSED(haveBgndImage);
+#endif
 }
 
 void
@@ -603,7 +615,9 @@ setSbProp(QWidget *w)
 
         if (!prop.isValid() || !prop.toBool()) {
             w->setProperty(constStatusBarProperty, true);
+#ifdef Q_WS_X11
             qtcX11SetStatusBar(wid);
+#endif
         }
     }
 }
@@ -13362,9 +13376,11 @@ void Style::emitMenuSize(QWidget *w, unsigned short size, \
bool force)  
         if (oldSize != size) {
             w->setProperty(constMenuSizeProperty, size);
+#ifdef Q_WS_X11
             qtcX11SetMenubarSize(wid, size);
             getKWinDBus()->call(QDBus::NoBlock, "menuBarSize",
                                 (unsigned int)wid, (int)size);
+#endif
         }
     }
 }
diff --git a/qt4/style/qtcurve_plugin.cpp b/qt4/style/qtcurve_plugin.cpp
index f390da4..8339536 100644
--- a/qt4/style/qtcurve_plugin.cpp
+++ b/qt4/style/qtcurve_plugin.cpp
@@ -31,9 +31,15 @@
 #  include <QX11Info>
 #endif
 
+#include <QTypeInfo>
+#include <QFileInfo>
+
 namespace QtCurve {
 
 #ifdef QTC_QT4_STYLE_SUPPORT
+
+#include <QDir>
+
 static void
 getStyles(const QString &dir, const char *sub, QSet<QString> &styles)
 {
diff --git a/qt5/CMakeLists.txt b/qt5/CMakeLists.txt
index 1d0359e..226210d 100644
--- a/qt5/CMakeLists.txt
+++ b/qt5/CMakeLists.txt
@@ -13,7 +13,9 @@ if(ENABLE_QT5)
     set(QTC_QT5_DEFS ${QTC_QT5_DEFS} ${${QtModule}_DEFINITIONS})
     set(QTC_QT5_INCLUDES ${QTC_QT5_INCLUDES} ${${QtModule}_INCLUDE_DIRS})
   endforeach()
+if(NOT APPLE)
   set(QTC_QT5_OPT_MODULES Qt5X11Extras)
+endif(NOT APPLE)
   foreach(QtModule ${QTC_QT5_OPT_MODULES})
     find_package(${QtModule})
     if(${QtModule}_FOUND)
diff --git a/qt5/style/CMakeLists.txt b/qt5/style/CMakeLists.txt
index b6cb222..9dc5410 100644
--- a/qt5/style/CMakeLists.txt
+++ b/qt5/style/CMakeLists.txt
@@ -56,7 +56,6 @@ include_directories(
 qt5_wrap_cpp(qtcurve_MOC_SRCS ${qtcurve_MOC_HDRS})
 add_library(qtcurve-qt5 MODULE ${qtcurve_SRCS} ${qtcurve_MOC_SRCS})
 set_target_properties(qtcurve-qt5 PROPERTIES
-  LINK_FLAGS "-Wl,--no-undefined"
   OUTPUT_NAME "qtcurve"
   LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
   PREFIX "")


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic