mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-04 17:55:36 +08:00
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:
@@ -128,8 +128,8 @@ public class TermuxFloatView extends LinearLayout {
|
||||
if (isInLongPressState) return true;
|
||||
|
||||
getLocationOnScreen(location);
|
||||
int x = layoutParams.x; // location[0];
|
||||
int y = layoutParams.y; // location[1];
|
||||
int x = location[0];
|
||||
int y = location[1];
|
||||
float touchX = event.getRawX();
|
||||
float touchY = event.getRawY();
|
||||
boolean clickedInside = (touchX >= x) && (touchX <= (x + layoutParams.width)) && (touchY >= y) && (touchY <= (y + layoutParams.height));
|
||||
|
@@ -37,8 +37,9 @@ public class TermuxFloatViewClient implements TerminalViewClient {
|
||||
@Override
|
||||
public boolean onLongPress(MotionEvent event) {
|
||||
view.updateLongPressMode(true);
|
||||
view.initialX = view.layoutParams.x;
|
||||
view.initialY = view.layoutParams.y;
|
||||
view.getLocationOnScreen(view.location);
|
||||
view.initialX = view.location[0];
|
||||
view.initialY = view.location[1];
|
||||
view.initialTouchX = event.getRawX();
|
||||
view.initialTouchY = event.getRawY();
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user