[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 208ae993ba: Add support for pinch events to NS
From: |
Po Lu |
Subject: |
master 208ae993ba: Add support for pinch events to NS |
Date: |
Tue, 28 Dec 2021 01:08:05 -0500 (EST) |
branch: master
commit 208ae993bac6f011f178befbeeb8104c0f63499f
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Add support for pinch events to NS
* lisp/face-remap.el (text-scale-pinch): Remove mistaken
assumption that angle is always 1.0 at the beginning of
a sequence.
* src/nsterm.c (- magnifyWithEvent): New function.
---
lisp/face-remap.el | 3 +--
src/nsterm.m | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/lisp/face-remap.el b/lisp/face-remap.el
index 67123ac7f8..3440f4c941 100644
--- a/lisp/face-remap.el
+++ b/lisp/face-remap.el
@@ -417,8 +417,7 @@ a top-level keymap, `text-scale-increase' or
(with-selected-window window
(when (and (zerop dx)
(zerop dy)
- (zerop angle)
- (equal scale 1.0))
+ (zerop angle))
(setq text-scale--pinch-start-scale
(if text-scale-mode text-scale-mode-amount 0)))
(text-scale-set
diff --git a/src/nsterm.m b/src/nsterm.m
index 591e28f20b..f79e271a98 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6821,6 +6821,42 @@ not_in_argv (NSString *arg)
[self mouseMoved: e];
}
+#ifdef NS_IMPL_COCOA
+- (void) magnifyWithEvent: (NSEvent *) event
+{
+ NSPoint pt = [self convertPoint: [event locationInWindow] fromView: nil];
+ static CGFloat last_scale;
+
+ NSTRACE ("[EmacsView magnifyWithEvent]");
+ if (emacs_event)
+ {
+ emacs_event->kind = PINCH_EVENT;
+ emacs_event->modifiers = EV_MODIFIERS (event);
+ XSETINT (emacs_event->x, lrint (pt.x));
+ XSETINT (emacs_event->y, lrint (pt.y));
+ XSETFRAME (emacs_event->frame_or_window, emacsframe);
+
+ if ([event phase] == NSEventPhaseBegan)
+ {
+ last_scale = 1.0 + [event magnification];
+ emacs_event->arg = list4 (make_float (0.0),
+ make_float (0.0),
+ make_float (last_scale),
+ make_float (0.0));
+ }
+ else
+ /* Report a tiny change so that Lisp code doesn't think this
+ is the beginning of an event sequence. This is the best we
+ can do because NS doesn't report pinch events in as much
+ detail as XInput 2 or GTK+ do. */
+ emacs_event->arg = list4 (make_float (0.01),
+ make_float (0.0),
+ make_float (last_scale += [event
magnification]),
+ make_float (0.0));
+ EV_TRAILER (event);
+ }
+}
+#endif
- (BOOL)windowShouldClose: (id)sender
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 208ae993ba: Add support for pinch events to NS,
Po Lu <=