diff options
| author | Po Lu | 2021-12-28 14:05:32 +0800 |
|---|---|---|
| committer | Po Lu | 2021-12-28 14:07:49 +0800 |
| commit | 208ae993bac6f011f178befbeeb8104c0f63499f (patch) | |
| tree | 6eaf957703601d346bac51a2c92a3633a86dee24 /src | |
| parent | 036e88ce2f35b805f37e5f3b4948c7d8e7355b2c (diff) | |
| download | emacs-208ae993bac6f011f178befbeeb8104c0f63499f.tar.gz emacs-208ae993bac6f011f178befbeeb8104c0f63499f.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.m | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index 591e28f20b9..f79e271a989 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -6821,6 +6821,42 @@ not_in_argv (NSString *arg) | |||
| 6821 | [self mouseMoved: e]; | 6821 | [self mouseMoved: e]; |
| 6822 | } | 6822 | } |
| 6823 | 6823 | ||
| 6824 | #ifdef NS_IMPL_COCOA | ||
| 6825 | - (void) magnifyWithEvent: (NSEvent *) event | ||
| 6826 | { | ||
| 6827 | NSPoint pt = [self convertPoint: [event locationInWindow] fromView: nil]; | ||
| 6828 | static CGFloat last_scale; | ||
| 6829 | |||
| 6830 | NSTRACE ("[EmacsView magnifyWithEvent]"); | ||
| 6831 | if (emacs_event) | ||
| 6832 | { | ||
| 6833 | emacs_event->kind = PINCH_EVENT; | ||
| 6834 | emacs_event->modifiers = EV_MODIFIERS (event); | ||
| 6835 | XSETINT (emacs_event->x, lrint (pt.x)); | ||
| 6836 | XSETINT (emacs_event->y, lrint (pt.y)); | ||
| 6837 | XSETFRAME (emacs_event->frame_or_window, emacsframe); | ||
| 6838 | |||
| 6839 | if ([event phase] == NSEventPhaseBegan) | ||
| 6840 | { | ||
| 6841 | last_scale = 1.0 + [event magnification]; | ||
| 6842 | emacs_event->arg = list4 (make_float (0.0), | ||
| 6843 | make_float (0.0), | ||
| 6844 | make_float (last_scale), | ||
| 6845 | make_float (0.0)); | ||
| 6846 | } | ||
| 6847 | else | ||
| 6848 | /* Report a tiny change so that Lisp code doesn't think this | ||
| 6849 | is the beginning of an event sequence. This is the best we | ||
| 6850 | can do because NS doesn't report pinch events in as much | ||
| 6851 | detail as XInput 2 or GTK+ do. */ | ||
| 6852 | emacs_event->arg = list4 (make_float (0.01), | ||
| 6853 | make_float (0.0), | ||
| 6854 | make_float (last_scale += [event magnification]), | ||
| 6855 | make_float (0.0)); | ||
| 6856 | EV_TRAILER (event); | ||
| 6857 | } | ||
| 6858 | } | ||
| 6859 | #endif | ||
| 6824 | 6860 | ||
| 6825 | - (BOOL)windowShouldClose: (id)sender | 6861 | - (BOOL)windowShouldClose: (id)sender |
| 6826 | { | 6862 | { |