Android: specific event for Android. Use Fl::add_system_handler() and Fl::event(), for example: FL_ANDROID_EVENT_LOW_MEMORY

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12720 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2018-03-07 23:01:50 +00:00
parent 2e5b983f4b
commit 626ecbfca0
3 changed files with 44 additions and 1 deletions

View File

@ -406,6 +406,30 @@ 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 */

View File

@ -15,6 +15,7 @@
*
*/
#include <src/drivers/Android/Fl_Android_Application.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Enumerations.H>
@ -22,8 +23,15 @@
Fl_Window *win;
Fl_Button *btn;
int h(void*, void*)
{
Fl_Android_Application::log_w("App global even %p", Fl::event());
return 0;
}
int main(int argc, char **argv)
{
Fl::add_system_handler(h, 0);
win = new Fl_Window(10, 10, 600, 400, "Hallo");
btn = new Fl_Button(190, 200, 280, 35, "Hello, Android!");
btn->color(FL_LIGHT2);

View File

@ -59,11 +59,22 @@ Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver()
return new Fl_Android_Screen_Driver();
}
extern int fl_send_system_handlers(void *e);
int Fl_Android_Screen_Driver::handle_app_command()
{
// get the command
int8_t cmd = Fl_Android_Application::read_cmd();
// setup the Android glue and prepare all settings for calling into FLTK
Fl_Android_Application::pre_exec_cmd(cmd);
// TODO: call Fl::handle() with event parametrs set
// call all registered FLTK system handlers
Fl::e_number = ((uint32_t)cmd-APP_CMD_INPUT_CHANGED) + FL_ANDROID_EVENT_INPUT_CHANGED;
fl_send_system_handlers(0L);
// fixup and finalize application wide command handling
Fl_Android_Application::post_exec_cmd(cmd);
return 1;
}