On Android, FLTK's locking mechanisms don't work correctly, neither for enabling the global lock (via Fl::lock) or thru the Fl::awake(void *) messages (pipes). The Fl_lock.cxx file has the locking functions in an Android ifdef and remain to be implemented. I was able to get things working by subclassing the Fl_Android_System_Driver from the Fl_Posix_System_Driver instead of the Fl_System_Driver. I had to copy some implementation of the other posix systems (X11 namely for locking) since Android also uses pthreads.
diff -- git a/ src/ CMakeLists.txt b/ src/ CMakeLists.txt
index d5eee5dc8..96108dad5 100644
--- a/ src/ CMakeLists.txt
+++ b/ src/ CMakeLists.txt
@@ - 300 ,6 + 300 ,7 @@ elseif (ANDROID)
set (DRIVER_FILES
drivers/ Android/ Fl_Android_Application.cxx
+ drivers/ Posix/ Fl_Posix_System_Driver.cxx
drivers/ Android/ Fl_Android_System_Driver.cxx
drivers/ Android/ Fl_Android_Screen_Driver.cxx
drivers/ Android/ Fl_Android_Screen_Keyboard.cxx
@@ - 311 ,6 + 312 ,7 @@ elseif (ANDROID)
)
set (DRIVER_HEADER_FILES
drivers/ Android/ Fl_Android_Application.H
+ drivers/ Posix/ Fl_Posix_System_Driver.H
drivers/ Android/ Fl_Android_System_Driver.H
drivers/ Android/ Fl_Android_Screen_Driver.H
drivers/ Android/ Fl_Android_Window_Driver.H
diff -- git a/ src/ Fl_lock.cxx b/ src/ Fl_lock.cxx
index a98be46ec..07999a0a0 100644
--- a/ src/ Fl_lock.cxx
+++ b/ src/ Fl_lock.cxx
@@ - 418 ,29 + 418 ,29 @@ void unlock_ring () {}
// TODO: can these functions be moved to the system drivers?
- #ifdef __ANDROID__
-
- static void unlock_ring ()
- {
- // TODO: implement me
- }
-
- static void lock_ring ()
- {
- // TODO: implement me
- }
-
- static void unlock_function ()
- {
- // TODO: implement me
- }
-
- static void lock_function ()
- {
- // TODO: implement me
- }
-
- #endif // __ANDROID__
+ //#ifdef __ANDROID__
+ //
+ //static void unlock_ring()
+ //{
+ // // TODO: implement me
+ //}
+ //
+ //static void lock_ring()
+ //{
+ // // TODO: implement me
+ //}
+ //
+ //static void unlock_function()
+ //{
+ // // TODO: implement me
+ //}
+ //
+ //static void lock_function()
+ //{
+ // // TODO: implement me
+ //}
+ //
+ //#endif // __ANDROID__
diff -- git a/ src/ config_lib.h b/ src/ config_lib.h
index bbcfb75f5..aa16cd48b 100644
--- a/ src/ config_lib.h
+++ b/ src/ config_lib.h
@@ - 78 ,7 + 78 ,7 @@
# define FL_CFG_SYS_POSIX
#elif defined (_WIN32)
# define FL_CFG_SYS_WIN32
- #elif defined (USE_X11) /* X11 */
+ #elif defined (USE_X11) || defined (__ANDROID__) /* X11 */
# define FL_CFG_SYS_POSIX
#endif
diff -- git a/ src/ drivers/ Android/ Fl_Android_System_Driver.H b/ src/ drivers/ Android/ Fl_Android_System_Driver.H
index 5e6dafb1e..786ce58fd 100644
--- a/ src/ drivers/ Android/ Fl_Android_System_Driver.H
+++ b/ src/ drivers/ Android/ Fl_Android_System_Driver.H
@@ - 25 ,6 + 25 ,7 @@
#include < string.h>
#include < FL/ fl_string.h>
#include "../../Fl_System_Driver.H"
+ #include "../Posix/Fl_Posix_System_Driver.H"
#include < stdarg.h>
/*
@@ -38,7 +39,7 @@
- multithreading
*/
- class Fl_Android_System_Driver : public Fl_System_Driver
+ class Fl_Android_System_Driver : public Fl_Posix_System_Driver
{
#if 0
public:
@@ - 124 ,7 + 125 ,7 @@ public:
virtual void remove_fd (int);
virtual void gettime (time_t * sec, int * usec);
#endif
- virtual char * strdup (const char * s) {return :: strdup (s);}
+ // virtual char *strdup(const char *s) {return ::strdup(s);}
};
#endif // FL_ANDROID_SYSTEM_DRIVER_H
The above diff works for multithreading, for Fl::awake I just use a std::queue, std::unique_lock and a mutex,
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub , or unsubscribe .
[ Direct Link to Message ]