summaryrefslogtreecommitdiff
path: root/lisp/face-remap.el
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2021-12-26 13:47:23 +0800
committerPo Lu <luangruo@yahoo.com>2021-12-26 13:55:05 +0800
commit101bbd1392077e26e904c70fead7f7d7dce595f7 (patch)
tree1947fe12c50d8d53588b55329618ba1a1009c1db /lisp/face-remap.el
parent4e2058aec33db5097edd17da8fe08bea373fd8bc (diff)
downloademacs-101bbd1392077e26e904c70fead7f7d7dce595f7.tar.gz
emacs-101bbd1392077e26e904c70fead7f7d7dce595f7.tar.bz2
emacs-101bbd1392077e26e904c70fead7f7d7dce595f7.zip
Add support for pinch gestures to the XI2 build
* doc/lispref/commands.texi (Misc Events): Document new event type `pinch'. * etc/NEWS: Announce new event `pinch'. * etc/PROBLEMS: Document problems with mismatched libXi versions. * lisp/face-remap.el (text-scale--pinch-start-scale): New variable. (text-scale-pinch): New command. * src/keyboard.c (make_lispy_event): Handle PINCH_EVENTs. (syms_of_keyboard): New symbol `pinch'. * src/termhooks.h (enum event_kind): New enum `PINCH_EVENT'. * src/xfns.c (setup_xi_event_mask): Add pinch events to event mask if available. * src/xterm.c (handle_one_xevent): Handle pinch events.
Diffstat (limited to 'lisp/face-remap.el')
-rw-r--r--lisp/face-remap.el24
1 files changed, 24 insertions, 0 deletions
diff --git a/lisp/face-remap.el b/lisp/face-remap.el
index 50302b9682c..8507f7e8e36 100644
--- a/lisp/face-remap.el
+++ b/lisp/face-remap.el
@@ -390,6 +390,30 @@ a top-level keymap, `text-scale-increase' or
(lambda () (interactive) (text-scale-adjust (abs inc))))))
map))))) ;; )
+(defvar-local text-scale--pinch-start-scale 0
+ "The text scale at the start of a pinch sequence.")
+
+;;;###autoload (define-key global-map [pinch] 'text-scale-pinch)
+;;;###autoload
+(defun text-scale-pinch (event)
+ "Adjust the height of the default face by the scale in EVENT."
+ (interactive "e")
+ (let ((window (posn-window (nth 1 event)))
+ (scale (nth 4 event))
+ (dx (nth 2 event))
+ (dy (nth 3 event))
+ (angle (nth 5 event)))
+ (with-selected-window window
+ (when (and (zerop dx)
+ (zerop dy)
+ (zerop angle)
+ (equal scale 1.0))
+ (setq text-scale--pinch-start-scale
+ (if text-scale-mode text-scale-mode-amount 0)))
+ (text-scale-set
+ (+ text-scale--pinch-start-scale
+ (round (log scale text-scale-mode-step)))))))
+
;; ----------------------------------------------------------------
;; buffer-face-mode