From 422c5899f0b2dbd077b22de65f091b32a60f5d0b Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 24 Apr 2024 11:42:48 +0800 Subject: [PATCH] Miscellaneous fixes for Android port * lisp/touch-screen.el (touch-screen-hold, touch-screen-drag): Clear deactivate-mark if the mark is activated to prevent undue deactivation after completion. * lisp/wid-edit.el (widget-field, widget-single-line-field): Insert specifications suitable for monochrome displays. * src/androidfns.c (Fxw_display_color_p, Fx_display_grayscale_p): Report color and/or grayscale properly. * src/image.c (image_create_bitmap_from_file) [HAVE_ANDROID]: If a file with no extension cannot be located, append .xbm and retry. (cherry picked from commit d3d1be8ae56efe29e4a721c5dd4e1fa973cf9d5a) --- lisp/touch-screen.el | 11 ++++++++--- lisp/wid-edit.el | 15 ++++++++++++++- src/androidfns.c | 11 +++++++++-- src/image.c | 15 +++++++++++---- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/lisp/touch-screen.el b/lisp/touch-screen.el index 037386112d3..52a36712c44 100644 --- a/lisp/touch-screen.el +++ b/lisp/touch-screen.el @@ -351,7 +351,8 @@ word around EVENT; otherwise, set point to the location of EVENT." touch-screen-word-select-bounds nil) (push-mark point) (goto-char point) - (activate-mark)) + (activate-mark) + (setq deactivate-mark nil)) ;; Start word selection by trying to obtain the position ;; around point. (let ((word-start nil) @@ -381,7 +382,8 @@ word around EVENT; otherwise, set point to the location of EVENT." touch-screen-word-select-initial-word nil) (push-mark point) (goto-char point) - (activate-mark)) + (activate-mark) + (setq deactivate-mark nil)) ;; Otherwise, select the word. Move point to either the ;; end or the start of the word, depending on which is ;; closer to EVENT. @@ -420,10 +422,12 @@ word around EVENT; otherwise, set point to the location of EVENT." (progn (push-mark word-start) (activate-mark) + (setq deactivate-mark nil) (goto-char word-end)) (progn (push-mark word-end) (activate-mark) + (setq deactivate-mark nil) (goto-char word-start))) ;; Record the bounds of the selected word. (setq touch-screen-word-select-bounds @@ -837,7 +841,8 @@ area." ;; Display a preview of the line now around ;; point if requested by the user. (when touch-screen-preview-select - (touch-screen-preview-select)))))))))))))) + (touch-screen-preview-select))))))))))) + (setq deactivate-mark nil)))) (defun touch-screen-restart-drag (event) "Restart dragging to select text. diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index dc481d4d0a5..2d82fbe7c89 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -141,12 +141,21 @@ This exists as a variable so it can be set locally in certain buffers.") :background "dim gray" :box (:line-width (1 . -1) :color "gray46") :extend t) + ;; Monochrome displays. + (((background light)) + :background "white" + :box (:line-width (1 . -1) :color "black") + :extend t) + (((background dark)) + :background "black" + :box (:line-width (1 . -1) :color "white") + :extend t) (t :slant italic :extend t)) "Face used for editable fields." :group 'widget-faces - :version "28.1") + :version "30.1") (defface widget-single-line-field '((((type tty)) :background "green3" @@ -157,6 +166,10 @@ This exists as a variable so it can be set locally in certain buffers.") (((class grayscale color) (background dark)) :background "dim gray") + ;; Monochrome displays. + (((background light)) + :stipple "gray3" + :extend t) (t :slant italic)) "Face used for editable fields spanning only a single line." diff --git a/src/androidfns.c b/src/androidfns.c index b6df7ae0677..df425e5779e 100644 --- a/src/androidfns.c +++ b/src/androidfns.c @@ -1202,7 +1202,10 @@ DEFUN ("xw-display-color-p", Fxw_display_color_p, doc: /* SKIP: real doc in xfns.c. */) (Lisp_Object terminal) { - return Qt; + struct android_display_info *dpyinfo; + + dpyinfo = check_android_display_info (terminal); + return dpyinfo->n_planes > 8 ? Qt : Qnil; } DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, @@ -1210,7 +1213,11 @@ DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, doc: /* SKIP: real doc in xfns.c. */) (Lisp_Object terminal) { - return Qnil; + struct android_display_info *dpyinfo; + + dpyinfo = check_android_display_info (terminal); + return (dpyinfo->n_planes > 1 && dpyinfo->n_planes <= 8 + ? Qt : Qnil); } DEFUN ("x-display-pixel-width", Fx_display_pixel_width, diff --git a/src/image.c b/src/image.c index d1faadee968..74249b8d465 100644 --- a/src/image.c +++ b/src/image.c @@ -957,10 +957,17 @@ image_create_bitmap_from_file (struct frame *f, Lisp_Object file) } } - /* Search bitmap-file-path for the file, if appropriate. */ - if (openp (Vx_bitmap_file_path, file, Qnil, &found, - make_fixnum (R_OK), false, false, NULL) - < 0) + /* Search bitmap-file-path for the file, if appropriate. If no file + extension or directory is specified and no file by this name + exists, append the extension ".xbm" and retry. */ + if ((openp (Vx_bitmap_file_path, file, Qnil, &found, + make_fixnum (R_OK), false, false, NULL) < 0) + && (NILP (Fequal (Ffile_name_nondirectory (file), file)) + || strrchr (SSDATA (file), '.') + || (openp (Vx_bitmap_file_path, + CALLN (Fconcat, file, build_string (".xbm")), + Qnil, &found, make_fixnum (R_OK), false, false, + NULL) < 0))) return -1; if (!STRINGP (image_find_image_fd (file, &fd)) -- 2.39.5