summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-10-28 10:02:58 +0800
committerPo Lu <luangruo@yahoo.com>2023-10-28 10:19:41 +0800
commitf0d42c5e47eaba2c8ccee0a804965a2b71923d41 (patch)
treed49ef9b2e71da47ed4ca845ac341b95eed6ac739 /java
parenteb6708f0ac129f2faee31b1f5517641ffb38fcdf (diff)
downloademacs-f0d42c5e47eaba2c8ccee0a804965a2b71923d41.tar.gz
Minor adjustments to Android drag and drop and content URIs
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow) <dndXPosition, dndYPosition>: New fields initialized to -1. (onDragEvent): Remember the position of the previous event to avoid sending duplicates. * src/androidvfs.c (EMACS_PATH_MAX): New define. (android_saf_tree_rename, android_saf_tree_opendir) (android_name_file, android_fstatat, android_faccessat) (android_fchmodat, android_readlinkat): Use EMACS_PATH_MAX where SAF file names might be encountered.
Diffstat (limited to 'java')
-rw-r--r--java/org/gnu/emacs/EmacsWindow.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java
index 7662186a0eb..d7a37a8d57f 100644
--- a/java/org/gnu/emacs/EmacsWindow.java
+++ b/java/org/gnu/emacs/EmacsWindow.java
@@ -152,6 +152,10 @@ public final class EmacsWindow extends EmacsHandleObject
/* The position of this window relative to the root window. */
public int xPosition, yPosition;
+ /* The position of the last drag and drop event received; both
+ values are -1 if no drag and drop operation is under way. */
+ private int dndXPosition, dndYPosition;
+
public
EmacsWindow (short handle, final EmacsWindow parent, int x, int y,
int width, int height, boolean overrideRedirect)
@@ -202,6 +206,9 @@ public final class EmacsWindow extends EmacsHandleObject
return size () > 10;
}
};
+
+ dndXPosition = -1;
+ dndYPosition = -1;
}
public void
@@ -1617,11 +1624,26 @@ public final class EmacsWindow extends EmacsHandleObject
return true;
case DragEvent.ACTION_DRAG_LOCATION:
- /* Send this drag motion event to Emacs. */
- EmacsNative.sendDndDrag (handle, x, y);
+ /* Send this drag motion event to Emacs. Skip this when the
+ integer position hasn't changed, for Android sends events
+ even if the movement from the previous position of the drag
+ is less than 1 pixel on either axis. */
+
+ if (x != dndXPosition || y != dndYPosition)
+ {
+ EmacsNative.sendDndDrag (handle, x, y);
+ dndXPosition = x;
+ dndYPosition = y;
+ }
+
return true;
case DragEvent.ACTION_DROP:
+ /* Reset this view's record of the previous drag and drop
+ event's position. */
+ dndXPosition = -1;
+ dndYPosition = -1;
+
/* Judge whether this is plain text, or if it's a file URI for
which permissions must be requested. */
@@ -1706,8 +1728,13 @@ public final class EmacsWindow extends EmacsHandleObject
if (builder.length () > 0)
EmacsNative.sendDndUri (handle, x, y, builder.toString ());
-
return true;
+
+ default:
+ /* Reset this view's record of the previous drag and drop
+ event's position. */
+ dndXPosition = -1;
+ dndYPosition = -1;
}
return true;