From 673d17bf653f376cebf623006c363b9542d612c2 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Thu, 21 Apr 2016 15:40:38 +0300 Subject: [PATCH] Android MotionEvent handling - close #238 --- src/dlangui/platforms/android/androidapp.d | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/dlangui/platforms/android/androidapp.d b/src/dlangui/platforms/android/androidapp.d index 3e21cfaf..39fd2f18 100644 --- a/src/dlangui/platforms/android/androidapp.d +++ b/src/dlangui/platforms/android/androidapp.d @@ -45,11 +45,19 @@ class AndroidWindow : Window { override @property void windowIcon(DrawBufRef icon) { // not supported } + uint _lastRedrawEventCode; /// request window redraw override void invalidate() { + _platform.sendRedrawEvent(this, ++_lastRedrawEventCode); + } + + void processRedrawEvent(uint code) { + //if (code == _lastRedrawEventCode) + // redraw(); } /// close window override void close() { + _platform.closeWindow(this); } protected AndroidPlatform _platform; @@ -149,7 +157,8 @@ class AndroidWindow : Window { } return 1; } else if (et == AINPUT_EVENT_TYPE_KEY) { - return 1; + Log.d("AINPUT_EVENT_TYPE_KEY"); + return 0; } return 0; } @@ -276,6 +285,7 @@ class AndroidPlatform : Platform { return 0; } + /** * Tear down the EGL context currently associated with the display. */ @@ -389,6 +399,18 @@ class AndroidPlatform : Platform { } } + void sendRedrawEvent(AndroidWindow w, uint redrawEventCode) { + import core.stdc.stdio; + import core.sys.posix.unistd; + if (w && w is activeWindow) { + // request update + _appstate.redrawNeeded = true; + Log.d("sending APP_CMD_WINDOW_REDRAW_NEEDED"); + ubyte cmd = APP_CMD_WINDOW_REDRAW_NEEDED; + write(_appstate.msgwrite, &cmd, cmd.sizeof); + } + } + /** * create window * Args: