]> git.tdb.fi Git - libs/core.git/blob - source/core/android/mainthread.h
Fix an infinite recursion bug
[libs/core.git] / source / core / android / mainthread.h
1 #ifndef MSP_CORE_ANDROID_MAINTHREAD_H_
2 #define MSP_CORE_ANDROID_MAINTHREAD_H_
3
4 #include <android/native_activity.h>
5 #include <sigc++/signal.h>
6 #include "mutex.h"
7 #include "thread.h"
8
9 namespace Msp {
10 namespace Android {
11
12 class MainThread: public Thread
13 {
14 public:
15         sigc::signal<void, ANativeWindow *> signal_native_window_created;
16         sigc::signal<void, ANativeWindow *> signal_native_window_resized;
17         sigc::signal<void, ANativeWindow *> signal_native_window_destroyed;
18         sigc::signal<void, AInputQueue *> signal_input_queue_created;
19         sigc::signal<void, AInputQueue *> signal_input_queue_destroyed;
20
21 private:
22         ANativeActivity *activity;
23         AAssetManager *asset_manager;
24         bool starting_up;
25         Mutex startup_mutex;
26
27 public:
28         MainThread(ANativeActivity *);
29
30         void attach_to_activity(ANativeActivity *);
31         bool is_starting_up() const { return starting_up; }
32         void wait_for_app_created();
33         void resume_startup();
34
35         AAssetManager *get_asset_manager() const { return asset_manager; }
36
37 private:
38         virtual void main();
39
40         static void app_created(void *);
41         static void activity_destroyed(ANativeActivity *);
42         static void native_window_created(ANativeActivity *, ANativeWindow *);
43         static void native_window_resized(ANativeActivity *, ANativeWindow *);
44         static void native_window_destroyed(ANativeActivity *, ANativeWindow *);
45         static void input_queue_created(ANativeActivity *, AInputQueue *);
46         static void input_queue_destroyed(ANativeActivity *, AInputQueue *);
47 };
48
49 } // namespace Android
50 } // namespace Msp
51
52 #endif