Use getLocationOnScreen() to calculate position

This avoids problem when the window has been prevented from scrolling
outside of the screen, or when the touch keyboard has made it move.
This commit is contained in:
Fredrik Fornwall
2017-04-02 14:46:47 +02:00
parent 19f838e3d1
commit eefd504f08
2 changed files with 5 additions and 4 deletions

View File

@@ -128,8 +128,8 @@ public class TermuxFloatView extends LinearLayout {
if (isInLongPressState) return true; if (isInLongPressState) return true;
getLocationOnScreen(location); getLocationOnScreen(location);
int x = layoutParams.x; // location[0]; int x = location[0];
int y = layoutParams.y; // location[1]; int y = location[1];
float touchX = event.getRawX(); float touchX = event.getRawX();
float touchY = event.getRawY(); float touchY = event.getRawY();
boolean clickedInside = (touchX >= x) && (touchX <= (x + layoutParams.width)) && (touchY >= y) && (touchY <= (y + layoutParams.height)); boolean clickedInside = (touchX >= x) && (touchX <= (x + layoutParams.width)) && (touchY >= y) && (touchY <= (y + layoutParams.height));

View File

@@ -37,8 +37,9 @@ public class TermuxFloatViewClient implements TerminalViewClient {
@Override @Override
public boolean onLongPress(MotionEvent event) { public boolean onLongPress(MotionEvent event) {
view.updateLongPressMode(true); view.updateLongPressMode(true);
view.initialX = view.layoutParams.x; view.getLocationOnScreen(view.location);
view.initialY = view.layoutParams.y; view.initialX = view.location[0];
view.initialY = view.location[1];
view.initialTouchX = event.getRawX(); view.initialTouchX = event.getRawX();
view.initialTouchY = event.getRawY(); view.initialTouchY = event.getRawY();
return true; return true;