summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Enumerations.H24
-rw-r--r--FL/android.H111
-rw-r--r--src/drivers/Android/Fl_Android_Application.H96
-rw-r--r--src/drivers/Android/Fl_Android_Application.cxx13
-rw-r--r--src/drivers/Android/Fl_Android_Screen_Driver.cxx8
5 files changed, 131 insertions, 121 deletions
diff --git a/FL/Enumerations.H b/FL/Enumerations.H
index d97298073..2a1908f8e 100644
--- a/FL/Enumerations.H
+++ b/FL/Enumerations.H
@@ -406,30 +406,6 @@ enum Fl_Event { // events
FL_ZOOM_GESTURE = 26
// DEV NOTE: Keep this list in sync with FL/names.h
-
-#ifdef __ANDROID__
- // These events are specific to the Android OS driver system. They can
- // be read by adding a callback via Fl::add_system_handler() and reading Fl::event()
- // Dont's change the order of these enums! See Fl_Android_Application.H .
- , FL_ANDROID_EVENTS = 0x00010000,
- FL_ANDROID_EVENT_INPUT_CHANGED,
- FL_ANDROID_EVENT_INIT_WINDOW,
- FL_ANDROID_EVENT_TERM_WINDOW,
- FL_ANDROID_EVENT_WINDOW_RESIZED,
- FL_ANDROID_EVENT_WINDOW_REDRAW_NEEDED,
- FL_ANDROID_EVENT_CONTENT_RECT_CHANGED,
- FL_ANDROID_EVENT_GAINED_FOCUS,
- FL_ANDROID_EVENT_LOST_FOCUS,
- FL_ANDROID_EVENT_CONFIG_CHANGED,
- FL_ANDROID_EVENT_LOW_MEMORY,
- FL_ANDROID_EVENT_START,
- FL_ANDROID_EVENT_RESUME,
- FL_ANDROID_EVENT_SAVE_STATE,
- FL_ANDROID_EVENT_PAUSE,
- FL_ANDROID_EVENT_STOP,
- FL_ANDROID_EVENT_DESTROY
-#endif
-
};
/** \name When Conditions */
diff --git a/FL/android.H b/FL/android.H
index 43ccc0554..c6da1e3c9 100644
--- a/FL/android.H
+++ b/FL/android.H
@@ -33,6 +33,117 @@ typedef void *Window; // used by fl_find(), fl_xid() and class Fl_X
*/
extern void *fl_gc;
+/**
+ * These events are specific to the Android OS driver system. They can
+ * be read by adding a callback via Fl::add_system_handler() and reading Fl::event()
+ * Dont's change the order of these enums! See Fl_Android_Application.H .
+ */
+enum Fl_Android_Platform_Event
+{
+ FL_ANDROID_EVENTS = 0x00010000,
+
+ /**
+ * Command from main thread: the AInputQueue has changed. Upon processing
+ * this command, android_app->inputQueue will be updated to the new queue
+ * (or NULL).
+ */
+ FL_ANDROID_EVENT_INPUT_CHANGED,
+
+ /**
+ * Command from main thread: a new ANativeWindow is ready for use. Upon
+ * receiving this command, android_app->window will contain the new window
+ * surface.
+ */
+ FL_ANDROID_EVENT_INIT_WINDOW,
+
+ /**
+ * Command from main thread: the existing ANativeWindow needs to be
+ * terminated. Upon receiving this command, android_app->window still
+ * contains the existing window; after calling android_app_exec_cmd
+ * it will be set to NULL.
+ */
+ FL_ANDROID_EVENT_TERM_WINDOW,
+
+ /**
+ * Command from main thread: the current ANativeWindow has been resized.
+ * Please redraw with its new size.
+ */
+ FL_ANDROID_EVENT_WINDOW_RESIZED,
+
+ /**
+ * Command from main thread: the system needs that the current ANativeWindow
+ * be redrawn. You should redraw the window before handing this to
+ * android_app_exec_cmd() in order to avoid transient drawing glitches.
+ */
+ FL_ANDROID_EVENT_WINDOW_REDRAW_NEEDED,
+
+ /**
+ * Command from main thread: the content area of the window has changed,
+ * such as from the soft input window being shown or hidden. You can
+ * find the new content rect in android_app::contentRect.
+ */
+ FL_ANDROID_EVENT_CONTENT_RECT_CHANGED,
+
+ /**
+ * Command from main thread: the app's activity window has gained
+ * input focus.
+ */
+ FL_ANDROID_EVENT_GAINED_FOCUS,
+
+ /**
+ * Command from main thread: the app's activity window has lost
+ * input focus.
+ */
+ FL_ANDROID_EVENT_LOST_FOCUS,
+
+ /**
+ * Command from main thread: the current device configuration has changed.
+ */
+ FL_ANDROID_EVENT_CONFIG_CHANGED,
+
+ /**
+ * Command from main thread: the system is running low on memory.
+ * Try to reduce your memory use.
+ */
+ FL_ANDROID_EVENT_LOW_MEMORY,
+
+ /**
+ * Command from main thread: the app's activity has been started.
+ */
+ FL_ANDROID_EVENT_START,
+
+ /**
+ * Command from main thread: the app's activity has been resumed.
+ */
+ FL_ANDROID_EVENT_RESUME,
+
+ /**
+ * Command from main thread: the app should generate a new saved state
+ * for itself, to restore from later if needed. If you have saved state,
+ * allocate it with malloc and place it in android_app.savedState with
+ * the size in android_app.savedStateSize. The will be freed for you
+ * later.
+ */
+ FL_ANDROID_EVENT_SAVE_STATE,
+
+ /**
+ * Command from main thread: the app's activity has been paused.
+ */
+ FL_ANDROID_EVENT_PAUSE,
+
+ /**
+ * Command from main thread: the app's activity has been stopped.
+ */
+ FL_ANDROID_EVENT_STOP,
+
+ /**
+ * Command from main thread: the app's activity is being destroyed,
+ * and waiting for the app thread to clean up and exit before proceeding.
+ */
+ FL_ANDROID_EVENT_DESTROY
+};
+
+
//
// End of "$Id$".
//
diff --git a/src/drivers/Android/Fl_Android_Application.H b/src/drivers/Android/Fl_Android_Application.H
index 69ba524c0..dbc0a4dd9 100644
--- a/src/drivers/Android/Fl_Android_Application.H
+++ b/src/drivers/Android/Fl_Android_Application.H
@@ -133,105 +133,25 @@ public:
LOOPER_ID_USER = 3,
};
+ /**
+ * @see android.H Fl_Android_Platform_Event
+ */
enum {
- /**
- * Command from main thread: the AInputQueue has changed. Upon processing
- * this command, android_app->inputQueue will be updated to the new queue
- * (or NULL).
- */
APP_CMD_INPUT_CHANGED,
-
- /**
- * Command from main thread: a new ANativeWindow is ready for use. Upon
- * receiving this command, android_app->window will contain the new window
- * surface.
- */
APP_CMD_INIT_WINDOW,
-
- /**
- * Command from main thread: the existing ANativeWindow needs to be
- * terminated. Upon receiving this command, android_app->window still
- * contains the existing window; after calling android_app_exec_cmd
- * it will be set to NULL.
- */
APP_CMD_TERM_WINDOW,
-
- /**
- * Command from main thread: the current ANativeWindow has been resized.
- * Please redraw with its new size.
- */
APP_CMD_WINDOW_RESIZED,
-
- /**
- * Command from main thread: the system needs that the current ANativeWindow
- * be redrawn. You should redraw the window before handing this to
- * android_app_exec_cmd() in order to avoid transient drawing glitches.
- */
APP_CMD_WINDOW_REDRAW_NEEDED,
-
- /**
- * Command from main thread: the content area of the window has changed,
- * such as from the soft input window being shown or hidden. You can
- * find the new content rect in android_app::contentRect.
- */
APP_CMD_CONTENT_RECT_CHANGED,
-
- /**
- * Command from main thread: the app's activity window has gained
- * input focus.
- */
APP_CMD_GAINED_FOCUS,
-
- /**
- * Command from main thread: the app's activity window has lost
- * input focus.
- */
APP_CMD_LOST_FOCUS,
-
- /**
- * Command from main thread: the current device configuration has changed.
- */
APP_CMD_CONFIG_CHANGED,
-
- /**
- * Command from main thread: the system is running low on memory.
- * Try to reduce your memory use.
- */
APP_CMD_LOW_MEMORY,
-
- /**
- * Command from main thread: the app's activity has been started.
- */
APP_CMD_START,
-
- /**
- * Command from main thread: the app's activity has been resumed.
- */
APP_CMD_RESUME,
-
- /**
- * Command from main thread: the app should generate a new saved state
- * for itself, to restore from later if needed. If you have saved state,
- * allocate it with malloc and place it in android_app.savedState with
- * the size in android_app.savedStateSize. The will be freed for you
- * later.
- */
APP_CMD_SAVE_STATE,
-
- /**
- * Command from main thread: the app's activity has been paused.
- */
APP_CMD_PAUSE,
-
- /**
- * Command from main thread: the app's activity has been stopped.
- */
APP_CMD_STOP,
-
- /**
- * Command from main thread: the app's activity is being destroyed,
- * and waiting for the app thread to clean up and exit before proceeding.
- */
APP_CMD_DESTROY,
};
@@ -264,8 +184,8 @@ public:
static inline ANativeWindow *native_window() { return pNativeWindow; }
static inline ANativeWindow_Buffer &graphics_buffer() { return pApplicationWindowBuffer; }
static int destroy_requested() { return pDestroyRequested; }
- static void set_on_app_cmd(void (*cmd)(int32_t cmd)) { pOnAppCmd = cmd; }
- static void set_on_input_event(int32_t (*cmd)(AInputEvent* event)) { pOnInputEvent = cmd; }
+ //static void set_on_app_cmd(void (*cmd)(int32_t cmd)) { pOnAppCmd = cmd; }
+ //static void set_on_input_event(int32_t (*cmd)(AInputEvent* event)) { pOnInputEvent = cmd; }
static bool copy_screen();
@@ -287,7 +207,7 @@ protected:
static void *pSavedState;
static size_t pSavedStateSize;
static ALooper *pMsgPipeLooper;
- static ALooper *pRedrawLooper;
+ //static ALooper *pRedrawLooper;
static AInputQueue *pInputQueue;
static ANativeWindow *pNativeWindow;
static ANativeWindow_Buffer pNativeWindowBuffer;
@@ -308,10 +228,10 @@ protected:
static int pRunning;
static int pStateSaved;
static int pDestroyed;
- static int pRedrawNeeded;
+ //static int pRedrawNeeded;
static AInputQueue* pPendingInputQueue;
static ANativeWindow* pPendingWindow;
- static ARect pPendingContentRect;
+ //static ARect pPendingContentRect;
};
diff --git a/src/drivers/Android/Fl_Android_Application.cxx b/src/drivers/Android/Fl_Android_Application.cxx
index 757f366da..7163fc559 100644
--- a/src/drivers/Android/Fl_Android_Application.cxx
+++ b/src/drivers/Android/Fl_Android_Application.cxx
@@ -62,9 +62,6 @@ size_t Fl_Android_Application::pSavedStateSize = 0;
// The ALooper associated with the app's thread.
ALooper* Fl_Android_Application::pMsgPipeLooper = 0;
-// The ALooper tht interrupts the main loop when FLTK requests a redraw.
-ALooper* Fl_Android_Application::pRedrawLooper = 0;
-
// When non-NULL, this is the input queue from which the app will
// receive user input events.
AInputQueue* Fl_Android_Application::pInputQueue = 0;
@@ -103,10 +100,10 @@ struct Fl_Android_Application::android_poll_source Fl_Android_Application::pInpu
int Fl_Android_Application::pRunning = 0;
int Fl_Android_Application::pStateSaved = 0;
int Fl_Android_Application::pDestroyed = 0;
-int Fl_Android_Application::pRedrawNeeded = 0;
+//int Fl_Android_Application::pRedrawNeeded = 0;
AInputQueue *Fl_Android_Application::pPendingInputQueue = 0;
ANativeWindow *Fl_Android_Application::pPendingWindow = 0;
-ARect Fl_Android_Application::pPendingContentRect = { 0 };
+//ARect Fl_Android_Application::pPendingContentRect = { 0 };
@@ -173,6 +170,8 @@ int8_t Fl_Android_Application::read_cmd()
case APP_CMD_SAVE_STATE:
free_saved_state();
break;
+ default:
+ break;
}
return cmd;
} else {
@@ -276,6 +275,10 @@ void Fl_Android_Application::pre_exec_cmd(int8_t cmd)
case APP_CMD_DESTROY:
LOGV("APP_CMD_DESTROY\n");
pDestroyRequested = 1;
+ // FIXME: see Fl::program_should_quit()
+ break;
+
+ default:
break;
}
}
diff --git a/src/drivers/Android/Fl_Android_Screen_Driver.cxx b/src/drivers/Android/Fl_Android_Screen_Driver.cxx
index f3e7ddc9c..9c2d830fd 100644
--- a/src/drivers/Android/Fl_Android_Screen_Driver.cxx
+++ b/src/drivers/Android/Fl_Android_Screen_Driver.cxx
@@ -116,10 +116,10 @@ int Fl_Android_Screen_Driver::handle_keyboard_event(AInputEvent *event)
int Fl_Android_Screen_Driver::handle_mouse_event(AInputEvent *event)
{
- Fl::e_x = Fl::e_x_root = AMotionEvent_getX(event, 0) * 600 /
- ANativeWindow_getWidth(Fl_Android_Application::native_window());
- Fl::e_y = Fl::e_y_root = AMotionEvent_getY(event, 0) * 800 /
- ANativeWindow_getHeight(Fl_Android_Application::native_window());
+ Fl::e_x = Fl::e_x_root = (int)(AMotionEvent_getX(event, 0) * 600 /
+ ANativeWindow_getWidth(Fl_Android_Application::native_window()));
+ Fl::e_y = Fl::e_y_root = (int)(AMotionEvent_getY(event, 0) * 800 /
+ ANativeWindow_getHeight(Fl_Android_Application::native_window()));
Fl::e_state = FL_BUTTON1;
Fl::e_keysym = FL_Button + 1;
if (AMotionEvent_getAction(event) == AMOTION_EVENT_ACTION_DOWN) {