From 88ce4aec17dbf37de19060f03e543e7bf26fc1af Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 11 Mar 2018 22:00:59 +0000 Subject: Android: Made Fl_Rect virtual. Maybe a bad idea? Also, added rectangular clipping which works. Expanding now to a more complex clipping scheme to make multiple windows work. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12739 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/drivers/Android/Fl_Android_Screen_Driver.cxx | 34 +++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src/drivers/Android/Fl_Android_Screen_Driver.cxx') diff --git a/src/drivers/Android/Fl_Android_Screen_Driver.cxx b/src/drivers/Android/Fl_Android_Screen_Driver.cxx index 9c2d830fd..810ccedbf 100644 --- a/src/drivers/Android/Fl_Android_Screen_Driver.cxx +++ b/src/drivers/Android/Fl_Android_Screen_Driver.cxx @@ -116,22 +116,38 @@ 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 = (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())); + int ex = Fl::e_x_root = (int)(AMotionEvent_getX(event, 0) * 600 / + ANativeWindow_getWidth(Fl_Android_Application::native_window())); + int ey = Fl::e_y_root = (int)(AMotionEvent_getY(event, 0) * 800 / + 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() && exx()+win->w() && ey>=win->y() && eyy()+win->h()) + break; + win = Fl::next_window(win); + } + + if (win) { + Fl::e_x = ex-win->x(); + Fl::e_y = ey-win->y(); + } else { + Fl::e_x = ex; + Fl::e_y = ey; + } + Fl::e_state = FL_BUTTON1; Fl::e_keysym = FL_Button + 1; if (AMotionEvent_getAction(event) == AMOTION_EVENT_ACTION_DOWN) { Fl::e_is_click = 1; - Fl::handle(FL_PUSH, Fl::first_window()); - Fl_Android_Application::log_i("Mouse push %d at %d, %d", Fl::event_button(), Fl::event_x(), - Fl::event_y()); + Fl::handle(FL_PUSH, win); + 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, Fl::first_window()); + Fl::handle(FL_DRAG, win); } else if (AMotionEvent_getAction(event) == AMOTION_EVENT_ACTION_UP) { Fl::e_state = 0; - Fl::handle(FL_RELEASE, Fl::first_window()); + Fl::handle(FL_RELEASE, win); } return 1; } -- cgit v1.2.3