summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2018-03-18 13:44:37 +0000
committerMatthias Melcher <fltk@matthiasm.com>2018-03-18 13:44:37 +0000
commit5900d824e93be44a852741ca093d88023e2a516a (patch)
tree1441a0d02e432f046ba0cd83cbc1ef64badf8a61
parent7ff40388cbf2b4f1441efbc3b30f35017cab9304 (diff)
Android: Fixed bug when deleting complex clipping areas
Tested FLTK schemes - nice! Fixed crashbug in timer Fixed crashbug in mouse handler git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12771 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--ide/AndroidStudio3/README.md19
-rw-r--r--ide/AndroidStudio3/app/build.gradle2
-rw-r--r--ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx1
-rw-r--r--src/drivers/Android/Fl_Android_Graphics_Clipping.cxx19
-rw-r--r--src/drivers/Android/Fl_Android_Graphics_Font.H3
-rw-r--r--src/drivers/Android/Fl_Android_Graphics_Font.cxx4
-rw-r--r--src/drivers/Android/Fl_Android_Screen_Driver.cxx30
7 files changed, 56 insertions, 22 deletions
diff --git a/ide/AndroidStudio3/README.md b/ide/AndroidStudio3/README.md
index 73bbbc4e9..3c27f64ea 100644
--- a/ide/AndroidStudio3/README.md
+++ b/ide/AndroidStudio3/README.md
@@ -1,12 +1,15 @@
Hello Android
=============
+
Hello Android is an FLTK sample app that derives from the Android Studio sample
project Native Plasma. This sample uses Android Studio 3 and CMake.
+
Pre-requisites
--------------
- Android Studio 3.0+ with [NDK](https://developer.android.com/ndk/) bundle.
+
Getting Started
---------------
1. [Download Android Studio](http://developer.android.com/sdk/index.html)
@@ -15,16 +18,32 @@ Getting Started
1. Open the AndroidStudio project by loading the HelloAndroid directory.
1. Click *Run/Run 'app'*.
+
Micrososft Windows Users
------------------------
The file 'gradlew.zip' must be unzipped before you can use AndroidStudio. It contains the required file 'gradlew.bat'. This was neccessary because some svn setups block anything that looks like an executable file, including files that end in .bat .
+
Support
-------
If you've found an error in these samples, please [file an issue](http://www.fltk.org/str.php). Patches are encouraged, and may be submitted via the same FLTK Bug & Feature system.
Please visit the FLTK [Forum](http://www.fltk.org/newsgroups.php) for additional help.
+
License
-------
FLTK is provided under the terms of the [GNU Library Public License, Version 2 with exceptions](http://www.fltk.org/COPYING.php) that allow for static linking.
+
+
+Android Shell
+-------------
+> am start -n org.fltk.android_hello/android.app.NativeActivity
+> am force-stop org.fltk.android_hello
+
+> stop
+> setprop libc.debug.malloc 10
+> // setprop libc.debug.malloc.program org.fltk.android_hello
+> setprop libc.debug.malloc.options "guard fill"
+> start
+
diff --git a/ide/AndroidStudio3/app/build.gradle b/ide/AndroidStudio3/app/build.gradle
index dbe9d3dc9..fefeafe85 100644
--- a/ide/AndroidStudio3/app/build.gradle
+++ b/ide/AndroidStudio3/app/build.gradle
@@ -11,8 +11,6 @@ apply plugin: 'com.android.application'
buildTypes {
release {
minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'),
- 'proguard-rules.pro'
}
}
externalNativeBuild {
diff --git a/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx b/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx
index 6fc009043..6be53dd75 100644
--- a/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx
+++ b/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx
@@ -55,6 +55,7 @@ void hello_cb(void*)
int main(int argc, char **argv)
{
+ Fl::scheme("gleam");
win1 = new Fl_Window(20+50, 10, 200, 200, "back");
win1->color(FL_RED);
win1->box(FL_DOWN_BOX);
diff --git a/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx b/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx
index 5050a5082..1ea7cdb08 100644
--- a/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx
+++ b/src/drivers/Android/Fl_Android_Graphics_Clipping.cxx
@@ -172,6 +172,7 @@ int Fl_Rect_Region::intersect_with(const Fl_Rect_Region &r)
*/
void Fl_Rect_Region::add_to_bbox(const Fl_Rect_Region &r)
{
+ if (is_empty()) return;
if (r.pLeft<pLeft) pLeft = r.pLeft;
if (r.pTop<pTop) pTop = r.pTop;
if (r.pRight>pRight) pRight = r.pRight;
@@ -212,8 +213,14 @@ Fl_Complex_Region::Fl_Complex_Region(const Fl_Rect_Region &r) :
*/
Fl_Complex_Region::~Fl_Complex_Region()
{
- delete pSubregion; // recursively delete all subregions
- delete pNext; // recursively delete all following regions
+ // Do NOT delete the chain in pNext! The caller has to that job.
+ // A top-level coplex region has pNext always set to NULL, and it does
+ // delete all subregions chained via the subregion pNext.
+ while (pSubregion) {
+ Fl_Complex_Region *rgn = pSubregion;
+ pSubregion = rgn->pNext;
+ delete rgn;
+ }
}
/**
@@ -354,7 +361,15 @@ void Fl_Complex_Region::compress()
if (!pSubregion) return;
// remove all empty regions, because the really don't add anything (literally)
+ print("Compress");
Fl_Complex_Region *rgn = pSubregion;
+ while (rgn && rgn->is_empty()) {
+ pSubregion = rgn->next();
+ delete rgn;
+ rgn = pSubregion;
+ }
+
+
#if 0
// FIXME: remove emty rectangles and lift single rectangles
// TODO: merging rectangles may take much too much time with little benefit
diff --git a/src/drivers/Android/Fl_Android_Graphics_Font.H b/src/drivers/Android/Fl_Android_Graphics_Font.H
index 789651dc6..e53a9cc05 100644
--- a/src/drivers/Android/Fl_Android_Graphics_Font.H
+++ b/src/drivers/Android/Fl_Android_Graphics_Font.H
@@ -76,10 +76,11 @@ public:
*/
class Fl_Android_Font_Descriptor : public Fl_Font_Descriptor
{
+ typedef std::map<uint32_t, Fl_Android_Bytemap*> BytemapTable;
private:
Fl_Android_Font_Source *pFontSource;
Fl_Font pFontIndex;
- std::map<uint32_t, Fl_Android_Bytemap*> pBytemapTable;
+ BytemapTable pBytemapTable;
public:
Fl_Android_Font_Descriptor(const char *fname, Fl_Android_Font_Source *fsrc, Fl_Font fnum, Fl_Fontsize size);
diff --git a/src/drivers/Android/Fl_Android_Graphics_Font.cxx b/src/drivers/Android/Fl_Android_Graphics_Font.cxx
index 7f17e8911..55136e73e 100644
--- a/src/drivers/Android/Fl_Android_Graphics_Font.cxx
+++ b/src/drivers/Android/Fl_Android_Graphics_Font.cxx
@@ -341,7 +341,9 @@ Fl_Android_Font_Descriptor::~Fl_Android_Font_Descriptor()
*/
float Fl_Android_Font_Descriptor::get_advance(uint32_t c)
{
- // TODO: should we use the cahced value in the Bytemap?
+ // TODO: should we use the cached value in the Bytemap?
+ // Yes, we should, because if FLTK requests the width of a character, it is
+ // more than likely to render that character soon after.
return pFontSource->get_advance(c, size);
}
diff --git a/src/drivers/Android/Fl_Android_Screen_Driver.cxx b/src/drivers/Android/Fl_Android_Screen_Driver.cxx
index 1db417f4d..e9458c9c7 100644
--- a/src/drivers/Android/Fl_Android_Screen_Driver.cxx
+++ b/src/drivers/Android/Fl_Android_Screen_Driver.cxx
@@ -127,12 +127,17 @@ int Fl_Android_Screen_Driver::handle_mouse_event(AInputEvent *event)
ANativeWindow_getHeight(Fl_Android_Application::native_window()));
// FIXME: find the window in which the event happened
- Fl_Window *win = Fl::first_window();
- while (win) {
- if (ex>=win->x() && ex<win->x()+win->w() && ey>=win->y() && ey<win->y()+win->h())
- break;
- win = Fl::next_window(win);
+ Fl_Window *win = Fl::grab();
+ if (!win) {
+ win = Fl::first_window();
+ while (win) {
+ if (ex >= win->x() && ex < win->x() + win->w() && ey >= win->y() &&
+ ey < win->y() + win->h())
+ break;
+ win = Fl::next_window(win);
+ }
}
+ if (!win) return 0;
if (win) {
Fl::e_x = ex-win->x();
@@ -146,7 +151,7 @@ int Fl_Android_Screen_Driver::handle_mouse_event(AInputEvent *event)
Fl::e_keysym = FL_Button + 1;
if (AMotionEvent_getAction(event) == AMOTION_EVENT_ACTION_DOWN) {
Fl::e_is_click = 1;
- Fl::handle(FL_PUSH, win);
+ if (win) Fl::handle(FL_PUSH, win); // do NOT send a push event into the "Desktop"
Fl_Android_Application::log_i("Mouse push %d at %d, %d", Fl::event_button(), Fl::event_x(), Fl::event_y());
} else if (AMotionEvent_getAction(event) == AMOTION_EVENT_ACTION_MOVE) {
Fl::handle(FL_DRAG, win);
@@ -194,14 +199,6 @@ int Fl_Android_Screen_Driver::handle_queued_events(double time_to_wait)
}
-// TODO: we need a timout: nsecs_t systemTime(int clock = SYSTEM_TIME_MONOTONIC);
-// static inline nsecs_t seconds_to_nanoseconds(nsecs_t secs) return secs*1000000000;
-// int timer_create(clockid_t __clock, struct sigevent* __event, timer_t* __timer_ptr);
-// int timer_delete(timer_t __timer);
-// int timer_settime(timer_t __timer, int __flags, const struct itimerspec* __new_value, struct itimerspec* __old_value);
-// int timer_gettime(timer_t __timer, struct itimerspec* __ts);
-// int timer_getoverrun(timer_t __timer);
-
double Fl_Android_Screen_Driver::wait(double time_to_wait)
{
Fl::run_checks();
@@ -719,6 +716,7 @@ struct TimerData
void *data;
bool used;
bool triggered;
+ struct itimerspec timeout;
};
static TimerData* timerData = 0L;
static int NTimerData = 0;
@@ -816,11 +814,11 @@ void Fl_Android_Screen_Driver::repeat_timeout(double time, Fl_Timeout_Handler cb
}
double ff;
- struct itimerspec timeout = {
+ t.timeout = {
{ 0, 0 },
{ (time_t)floor(time), (long)(modf(time, &ff)*1000000000) }
};
- ret = timer_settime(t.handle, 0, &timeout, 0L);
+ ret = timer_settime(t.handle, 0, &t.timeout, 0L);
if (ret==-1) {
Fl_Android_Application::log_e("Can't launch timer: %s", strerror(errno));
return;