Add window and input management signals for Android
[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         bool starting_up;
24         Mutex startup_mutex;
25
26 public:
27         MainThread(ANativeActivity *);
28
29         bool is_starting_up() const { return starting_up; }
30         void wait_for_app_created();
31         void resume_startup();
32
33 private:
34         virtual void main();
35
36         static void app_created(void *);
37         static void native_window_created(ANativeActivity *, ANativeWindow *);
38         static void native_window_resized(ANativeActivity *, ANativeWindow *);
39         static void native_window_destroyed(ANativeActivity *, ANativeWindow *);
40         static void input_queue_created(ANativeActivity *, AInputQueue *);
41         static void input_queue_destroyed(ANativeActivity *, AInputQueue *);
42 };
43
44 } // namespace Android
45 } // namespace Msp
46
47 #endif