summaryrefslogtreecommitdiff
path: root/src/drivers/Android/Fl_Android_Screen_Driver.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2018-03-11 22:00:59 +0000
committerMatthias Melcher <fltk@matthiasm.com>2018-03-11 22:00:59 +0000
commit88ce4aec17dbf37de19060f03e543e7bf26fc1af (patch)
tree7f78eafdfdddeb7c84983fd488efbbb3d3363572 /src/drivers/Android/Fl_Android_Screen_Driver.cxx
parent0b1fd7ee3738e7121b35a5f7289c35c4a820e4a3 (diff)
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
Diffstat (limited to 'src/drivers/Android/Fl_Android_Screen_Driver.cxx')
-rw-r--r--src/drivers/Android/Fl_Android_Screen_Driver.cxx34
1 files changed, 25 insertions, 9 deletions
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() && ex<win->x()+win->w() && ey>=win->y() && ey<win->y()+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;
}