]> git.eshelyaron.com Git - emacs.git/commitdiff
Display the OSK after touch screen drag-to-select
authorPo Lu <luangruo@yahoo.com>
Fri, 1 Sep 2023 06:50:28 +0000 (14:50 +0800)
committerPo Lu <luangruo@yahoo.com>
Fri, 1 Sep 2023 06:50:49 +0000 (14:50 +0800)
* lisp/touch-screen.el (touch-screen-handle-point-up) <drag>:
New case.  Activate the on screen keyboard should the window
where the first touch screen event landed have selected a
writable buffer in which the region is active.

lisp/touch-screen.el

index 577c993efcfea33b7419a108fe1db996f11973c5..7c9a68306ad72ded959047d2e3a3ebbfcbc08e77 100644 (file)
@@ -1034,6 +1034,10 @@ If the fourth element of `touch-screen-current-tool' is
 original position of the tool to display its bound keymap as a
 menu.
 
+If the fourth element of `touch-screen-current-tool' is `drag',
+the region is active, and the tool's initial window's selected
+buffer isn't read-only, display the on screen keyboard.
+
 If the command being executed is listed in
 `touch-screen-set-point-commands' also display the on-screen
 keyboard if the current buffer and the character at the new point
@@ -1064,8 +1068,8 @@ is not read-only."
                                  posn))
                     ;; Look for the command bound to this event.
                     (command (key-binding (if prefix
-                                                 (vector prefix
-                                                         (car event))
+                                              (vector prefix
+                                                      (car event))
                                             (vector (car event)))
                                           t nil posn)))
                (deactivate-mark)
@@ -1154,7 +1158,25 @@ is not read-only."
            ;; took place.
            (throw 'input-event
                   (list 'down-mouse-1
-                        (nth 4 touch-screen-current-tool)))))))
+                        (nth 4 touch-screen-current-tool))))
+          ((eq what 'drag)
+           ;; Display the on screen keyboard if the region is now
+           ;; active.  Check this within the window where the tool was
+           ;; first place.
+           (setq window (nth 1 touch-screen-current-tool))
+           (when window
+             (with-selected-window window
+               (when (and (region-active-p)
+                          (not buffer-read-only))
+                 ;; Once the on-screen keyboard has been opened, add
+                 ;; `touch-screen-window-selection-changed' as a window
+                 ;; selection change function This then prevents it from
+                 ;; being hidden after exiting the minibuffer.
+                 (progn
+                   (add-hook 'window-selection-change-functions
+                             #'touch-screen-window-selection-changed)
+                   (frame-toggle-on-screen-keyboard (selected-frame)
+                                                    nil)))))))))
 
 (defun touch-screen-handle-touch (event prefix &optional interactive)
   "Handle a single touch EVENT, and perform associated actions.