diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2018-03-18 13:44:37 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2018-03-18 13:44:37 +0000 |
| commit | 5900d824e93be44a852741ca093d88023e2a516a (patch) | |
| tree | 1441a0d02e432f046ba0cd83cbc1ef64badf8a61 /src/drivers/Android | |
| parent | 7ff40388cbf2b4f1441efbc3b30f35017cab9304 (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
Diffstat (limited to 'src/drivers/Android')
| -rw-r--r-- | src/drivers/Android/Fl_Android_Graphics_Clipping.cxx | 19 | ||||
| -rw-r--r-- | src/drivers/Android/Fl_Android_Graphics_Font.H | 3 | ||||
| -rw-r--r-- | src/drivers/Android/Fl_Android_Graphics_Font.cxx | 4 | ||||
| -rw-r--r-- | src/drivers/Android/Fl_Android_Screen_Driver.cxx | 30 |
4 files changed, 36 insertions, 20 deletions
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; |
