aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2017-09-25 11:19:07 -0700
committerPaul Eggert2017-09-25 11:19:07 -0700
commitabcb2e62dae6aa26308f7ac9efc89247f89cbe65 (patch)
treefd2c052c3ec67555b0a92dc86da7ecba9b1ab3f6 /src
parent0bd61c212fe53fb843a10da9a2da88e110d3785a (diff)
parent49cd561dc62ea6b3fbedab7aef0f020733f4cf09 (diff)
downloademacs-abcb2e62dae6aa26308f7ac9efc89247f89cbe65.tar.gz
emacs-abcb2e62dae6aa26308f7ac9efc89247f89cbe65.zip
Merge from origin/emacs-26
49cd561dc6 * test/lisp/tramp-tests.el (tramp-test21-file-links): Spec... b719f6b20b Loosen strict parsing requirement for desktop files c7a0c13777 * lisp/xdg.el (xdg-thumb-uri): Fix doc string. dc6b3560e5 Fix documentation of `make-frame' and related variables an... 3d3778d82a Accept new `always' value for option `buffer-offer-save' 638f64c40a Improve new NS scrolling variable names d93301242f Document 'replace-buffer-contents' in the manual. 00e4e3e9d2 Fix undecorated frame resizing issues on NS (bug#28512) 820739bbb5 ; * doc/emacs/display.texi (Display Custom): Fix wording. f2b2201594 ; Spelling and URL fixes 0e143b1fc5 Documentation improvements for 'display-line-numbers' f656ccdb43 ; Fix typo d64da52d57 Fix last change in bat-mode.el 908af46abd Fix restoring in GUI sessions desktop saved in TTY sessions 51cbd85454 Improve syntax highlighting in bat-mode 0273916618 Document the 'list-FOO' convention d24ec58540 Expose viewing conditions in CAM02-UCS metric a81d5a3d3f Revert "Set frame size to actual requested size (bug#18215)" 0bf066d4b2 Add tests for Edebug 68baca3ee1 Catch more messages in ert-with-message-capture 28e0c410c9 ; * lisp/mouse.el (secondary-selection-exist-p): Doc fix. 31e1d9ef2f Support setting region from secondary selection and vice v... 047f02f00f Fix new copy-directory bug with empty dirs fbd15836af * doc/lispref/strings.texi (Formatting Strings): Improve i... f16a8d5dbd Fix 2 testsuite tests for MS-Windows 965cffd89c Rename timer-list to list-timers a5fec62b51 Provide native touchpad scrolling on macOS 7b3d1c6beb Fix MinGW64 build broken by recent MinGW64 import libraries c83d0c5fdf Fix crashes in 'move-point-visually' in minibuffer windows 7f3d5f929d * src/emacs.c (usage_message): Don't mention 'find-file'. 6845282200 Fix a minor inaccuracy in the Emacs manual 74d7bb9498 Fix errors in flyspell-post-command-hook 40fdbb01d0 Work on Tramp's file-truename 1a01423b3c Fix bug with make-directory on MS-Windows root 066efb8666 Fix log-view-diff-common when point is after last entry 3f006b56cd Adapt fileio-tests--symlink-failure to Cygwin ee512e9a82 Ignore buffers whose name begins with a space in save-some... 9e1b5bd92c Improve tramp-interrupt-process robustness 8d4223e61b Minor Tramp doc update 331d0e520f Fix gensym 466df76f7d Cleanup in files-tests.el 6359fe630a Remove old cl-assert calls in 'newline' 059184e645 Avoid crash with C-g C-g in GC 541006c536 Fix format-time-string %Z bug with negative tz 679e05eeb9 message-citation-line-format %Z is now tz name 4e8888d438 Use doc-view or pdf-tools on any window-system 5f28f0db73 Fix bug with min and max and NaNs 37b5e661d2 Fix recently-introduced copy-directory bug 6bbbc38b34 Merge from Gnulib 57249fb297 Fix compatibility problem in Tramp 411bec82c4 Avoid GCC 7 compilation warning in eval.c 34a6774daa ; Partially revert c3445aed5194
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in2
-rw-r--r--src/data.c12
-rw-r--r--src/editfns.c3
-rw-r--r--src/emacs.c8
-rw-r--r--src/eval.c2
-rw-r--r--src/keyboard.c5
-rw-r--r--src/lcms.c107
-rw-r--r--src/nsterm.m173
-rw-r--r--src/term.c12
-rw-r--r--src/termhooks.h4
-rw-r--r--src/xdisp.c4
11 files changed, 269 insertions, 63 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 0e55ad4bb29..9a8c9c85f04 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -280,7 +280,7 @@ GNU_OBJC_CFLAGS=$(patsubst -specs=%-hardened-cc1,,@GNU_OBJC_CFLAGS@)
280## w32xfns.o w32select.o image.o w32uniscribe.o if HAVE_W32, else 280## w32xfns.o w32select.o image.o w32uniscribe.o if HAVE_W32, else
281## empty. 281## empty.
282W32_OBJ=@W32_OBJ@ 282W32_OBJ=@W32_OBJ@
283## -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32 lusp10 -lcomctl32 283## -lkernel32 -luser32 -lusp10 -lgdi32 -lole32 -lcomdlg32 -lcomctl32
284## --lwinspool if HAVE_W32, else empty. 284## --lwinspool if HAVE_W32, else empty.
285W32_LIBS=@W32_LIBS@ 285W32_LIBS=@W32_LIBS@
286 286
diff --git a/src/data.c b/src/data.c
index 95bf06e5102..e070be6c208 100644
--- a/src/data.c
+++ b/src/data.c
@@ -3010,16 +3010,16 @@ static Lisp_Object
3010minmax_driver (ptrdiff_t nargs, Lisp_Object *args, 3010minmax_driver (ptrdiff_t nargs, Lisp_Object *args,
3011 enum Arith_Comparison comparison) 3011 enum Arith_Comparison comparison)
3012{ 3012{
3013 eassume (0 < nargs); 3013 Lisp_Object accum = args[0];
3014 Lisp_Object accum = args[0]; /* pacify GCC */ 3014 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (accum);
3015 for (ptrdiff_t argnum = 0; argnum < nargs; argnum++) 3015 for (ptrdiff_t argnum = 1; argnum < nargs; argnum++)
3016 { 3016 {
3017 Lisp_Object val = args[argnum]; 3017 Lisp_Object val = args[argnum];
3018 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val); 3018 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val);
3019 if (argnum == 0 || !NILP (arithcompare (val, accum, comparison))) 3019 if (!NILP (arithcompare (val, accum, comparison)))
3020 accum = val; 3020 accum = val;
3021 else if (FLOATP (accum) && isnan (XFLOAT_DATA (accum))) 3021 else if (FLOATP (val) && isnan (XFLOAT_DATA (val)))
3022 return accum; 3022 return val;
3023 } 3023 }
3024 return accum; 3024 return accum;
3025} 3025}
diff --git a/src/editfns.c b/src/editfns.c
index b03eb947dec..2f8b075817a 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -187,7 +187,8 @@ tzlookup (Lisp_Object zone, bool settz)
187 if (sec != 0) 187 if (sec != 0)
188 prec += 2, numzone = 100 * numzone + sec; 188 prec += 2, numzone = 100 * numzone + sec;
189 } 189 }
190 sprintf (tzbuf, tzbuf_format, prec, numzone, 190 sprintf (tzbuf, tzbuf_format, prec,
191 XINT (zone) < 0 ? -numzone : numzone,
191 &"-"[XINT (zone) < 0], hour, min, sec); 192 &"-"[XINT (zone) < 0], hour, min, sec);
192 zone_string = tzbuf; 193 zone_string = tzbuf;
193 } 194 }
diff --git a/src/emacs.c b/src/emacs.c
index 1ad8af70a74..0fe7d9113b4 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -252,7 +252,7 @@ Initialization options:\n\
252 "\ 252 "\
253Action options:\n\ 253Action options:\n\
254\n\ 254\n\
255FILE visit FILE using find-file\n\ 255FILE visit FILE\n\
256+LINE go to line LINE in next FILE\n\ 256+LINE go to line LINE in next FILE\n\
257+LINE:COLUMN go to line LINE, column COLUMN, in next FILE\n\ 257+LINE:COLUMN go to line LINE, column COLUMN, in next FILE\n\
258--directory, -L DIR prepend DIR to load-path (with :DIR, append DIR)\n\ 258--directory, -L DIR prepend DIR to load-path (with :DIR, append DIR)\n\
@@ -260,13 +260,13 @@ FILE visit FILE using find-file\n\
260--execute EXPR evaluate Emacs Lisp expression EXPR\n\ 260--execute EXPR evaluate Emacs Lisp expression EXPR\n\
261", 261",
262 "\ 262 "\
263--file FILE visit FILE using find-file\n\ 263--file FILE visit FILE\n\
264--find-file FILE visit FILE using find-file\n\ 264--find-file FILE visit FILE\n\
265--funcall, -f FUNC call Emacs Lisp function FUNC with no arguments\n\ 265--funcall, -f FUNC call Emacs Lisp function FUNC with no arguments\n\
266--insert FILE insert contents of FILE into current buffer\n\ 266--insert FILE insert contents of FILE into current buffer\n\
267--kill exit without asking for confirmation\n\ 267--kill exit without asking for confirmation\n\
268--load, -l FILE load Emacs Lisp FILE using the load function\n\ 268--load, -l FILE load Emacs Lisp FILE using the load function\n\
269--visit FILE visit FILE using find-file\n\ 269--visit FILE visit FILE\n\
270\n\ 270\n\
271", 271",
272 "\ 272 "\
diff --git a/src/eval.c b/src/eval.c
index 62e219631db..39d78364d5f 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1428,7 +1428,7 @@ push_handler (Lisp_Object tag_ch_val, enum handlertype handlertype)
1428struct handler * 1428struct handler *
1429push_handler_nosignal (Lisp_Object tag_ch_val, enum handlertype handlertype) 1429push_handler_nosignal (Lisp_Object tag_ch_val, enum handlertype handlertype)
1430{ 1430{
1431 struct handler *c = handlerlist->nextfree; 1431 struct handler *CACHEABLE c = handlerlist->nextfree;
1432 if (!c) 1432 if (!c)
1433 { 1433 {
1434 c = malloc (sizeof *c); 1434 c = malloc (sizeof *c);
diff --git a/src/keyboard.c b/src/keyboard.c
index 4db50be855c..e8701b88708 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5925,7 +5925,10 @@ make_lispy_event (struct input_event *event)
5925 ASIZE (wheel_syms)); 5925 ASIZE (wheel_syms));
5926 } 5926 }
5927 5927
5928 if (event->modifiers & (double_modifier | triple_modifier)) 5928 if (NUMBERP (event->arg))
5929 return list4 (head, position, make_number (double_click_count),
5930 event->arg);
5931 else if (event->modifiers & (double_modifier | triple_modifier))
5929 return list3 (head, position, make_number (double_click_count)); 5932 return list3 (head, position, make_number (double_click_count));
5930 else 5933 else
5931 return list2 (head, position); 5934 return list2 (head, position);
diff --git a/src/lcms.c b/src/lcms.c
index f543a030399..a5e527911ef 100644
--- a/src/lcms.c
+++ b/src/lcms.c
@@ -139,6 +139,26 @@ chroma, and hue, respectively. The parameters each default to 1. */)
139 return make_float (cmsCIE2000DeltaE (&Lab1, &Lab2, Kl, Kc, Kh)); 139 return make_float (cmsCIE2000DeltaE (&Lab1, &Lab2, Kl, Kc, Kh));
140} 140}
141 141
142static double
143deg2rad (double degrees)
144{
145 return M_PI * degrees / 180.0;
146}
147
148static cmsCIEXYZ illuminant_d65 = { .X = 95.0455, .Y = 100.0, .Z = 108.8753 };
149
150static void
151default_viewing_conditions (const cmsCIEXYZ *wp, cmsViewingConditions *vc)
152{
153 vc->whitePoint.X = wp->X;
154 vc->whitePoint.Y = wp->Y;
155 vc->whitePoint.Z = wp->Z;
156 vc->Yb = 20;
157 vc->La = 100;
158 vc->surround = AVG_SURROUND;
159 vc->D_value = 1.0;
160}
161
142/* FIXME: code duplication */ 162/* FIXME: code duplication */
143 163
144static bool 164static bool
@@ -160,11 +180,62 @@ parse_xyz_list (Lisp_Object xyz_list, cmsCIEXYZ *color)
160 return true; 180 return true;
161} 181}
162 182
163DEFUN ("lcms-cam02-ucs", Flcms_cam02_ucs, Slcms_cam02_ucs, 2, 3, 0, 183static bool
184parse_viewing_conditions (Lisp_Object view, const cmsCIEXYZ *wp,
185 cmsViewingConditions *vc)
186{
187#define PARSE_VIEW_CONDITION_FLOAT(field) \
188 if (CONSP (view) && NUMBERP (XCAR (view))) \
189 { \
190 vc->field = XFLOATINT (XCAR (view)); \
191 view = XCDR (view); \
192 } \
193 else \
194 return false;
195#define PARSE_VIEW_CONDITION_INT(field) \
196 if (CONSP (view) && NATNUMP (XCAR (view))) \
197 { \
198 CHECK_RANGED_INTEGER (XCAR (view), 1, 4); \
199 vc->field = XINT (XCAR (view)); \
200 view = XCDR (view); \
201 } \
202 else \
203 return false;
204
205 PARSE_VIEW_CONDITION_FLOAT (Yb);
206 PARSE_VIEW_CONDITION_FLOAT (La);
207 PARSE_VIEW_CONDITION_INT (surround);
208 PARSE_VIEW_CONDITION_FLOAT (D_value);
209
210 if (! NILP (view))
211 return false;
212
213 vc->whitePoint.X = wp->X;
214 vc->whitePoint.Y = wp->Y;
215 vc->whitePoint.Z = wp->Z;
216 return true;
217}
218
219/* References:
220 Li, Luo et al. "The CRI-CAM02UCS colour rendering index." COLOR research
221 and application, 37 No.3, 2012.
222 Luo et al. "Uniform colour spaces based on CIECAM02 colour appearance
223 model." COLOR research and application, 31 No.4, 2006. */
224
225DEFUN ("lcms-cam02-ucs", Flcms_cam02_ucs, Slcms_cam02_ucs, 2, 4, 0,
164 doc: /* Compute CAM02-UCS metric distance between COLOR1 and COLOR2. 226 doc: /* Compute CAM02-UCS metric distance between COLOR1 and COLOR2.
165Each color is a list of XYZ coordinates, with Y scaled about unity. 227Each color is a list of XYZ tristimulus values, with Y scaled about unity.
166Optional argument is the XYZ white point, which defaults to illuminant D65. */) 228Optional argument WHITEPOINT is the XYZ white point, which defaults to
167 (Lisp_Object color1, Lisp_Object color2, Lisp_Object whitepoint) 229illuminant D65.
230Optional argument VIEW is a list containing the viewing conditions, and
231is of the form (YB LA SURROUND DVALUE) where SURROUND corresponds to
232 1 AVG_SURROUND
233 2 DIM_SURROUND
234 3 DARK_SURROUND
235 4 CUTSHEET_SURROUND
236The default viewing conditions are (20 100 1 1). */)
237 (Lisp_Object color1, Lisp_Object color2, Lisp_Object whitepoint,
238 Lisp_Object view)
168{ 239{
169 cmsViewingConditions vc; 240 cmsViewingConditions vc;
170 cmsJCh jch1, jch2; 241 cmsJCh jch1, jch2;
@@ -188,17 +259,13 @@ Optional argument is the XYZ white point, which defaults to illuminant D65. */)
188 if (!(CONSP (color2) && parse_xyz_list (color2, &xyz2))) 259 if (!(CONSP (color2) && parse_xyz_list (color2, &xyz2)))
189 signal_error ("Invalid color", color2); 260 signal_error ("Invalid color", color2);
190 if (NILP (whitepoint)) 261 if (NILP (whitepoint))
191 parse_xyz_list (Vlcms_d65_xyz, &xyzw); 262 xyzw = illuminant_d65;
192 else if (!(CONSP (whitepoint) && parse_xyz_list (whitepoint, &xyzw))) 263 else if (!(CONSP (whitepoint) && parse_xyz_list (whitepoint, &xyzw)))
193 signal_error ("Invalid white point", whitepoint); 264 signal_error ("Invalid white point", whitepoint);
194 265 if (NILP (view))
195 vc.whitePoint.X = xyzw.X; 266 default_viewing_conditions (&xyzw, &vc);
196 vc.whitePoint.Y = xyzw.Y; 267 else if (!(CONSP (view) && parse_viewing_conditions (view, &xyzw, &vc)))
197 vc.whitePoint.Z = xyzw.Z; 268 signal_error ("Invalid view conditions", view);
198 vc.Yb = 20;
199 vc.La = 100;
200 vc.surround = AVG_SURROUND;
201 vc.D_value = 1.0;
202 269
203 h1 = cmsCIECAM02Init (0, &vc); 270 h1 = cmsCIECAM02Init (0, &vc);
204 h2 = cmsCIECAM02Init (0, &vc); 271 h2 = cmsCIECAM02Init (0, &vc);
@@ -227,10 +294,10 @@ Optional argument is the XYZ white point, which defaults to illuminant D65. */)
227 Mp2 = 43.86 * log (1.0 + 0.0228 * (jch2.C * sqrt (sqrt (FL)))); 294 Mp2 = 43.86 * log (1.0 + 0.0228 * (jch2.C * sqrt (sqrt (FL))));
228 Jp1 = 1.7 * jch1.J / (1.0 + (0.007 * jch1.J)); 295 Jp1 = 1.7 * jch1.J / (1.0 + (0.007 * jch1.J));
229 Jp2 = 1.7 * jch2.J / (1.0 + (0.007 * jch2.J)); 296 Jp2 = 1.7 * jch2.J / (1.0 + (0.007 * jch2.J));
230 ap1 = Mp1 * cos (jch1.h); 297 ap1 = Mp1 * cos (deg2rad (jch1.h));
231 ap2 = Mp2 * cos (jch2.h); 298 ap2 = Mp2 * cos (deg2rad (jch2.h));
232 bp1 = Mp1 * sin (jch1.h); 299 bp1 = Mp1 * sin (deg2rad (jch1.h));
233 bp2 = Mp2 * sin (jch2.h); 300 bp2 = Mp2 * sin (deg2rad (jch2.h));
234 301
235 return make_float (sqrt ((Jp2 - Jp1) * (Jp2 - Jp1) + 302 return make_float (sqrt ((Jp2 - Jp1) * (Jp2 - Jp1) +
236 (ap2 - ap1) * (ap2 - ap1) + 303 (ap2 - ap1) * (ap2 - ap1) +
@@ -291,12 +358,6 @@ DEFUN ("lcms2-available-p", Flcms2_available_p, Slcms2_available_p, 0, 0, 0,
291void 358void
292syms_of_lcms2 (void) 359syms_of_lcms2 (void)
293{ 360{
294 DEFVAR_LISP ("lcms-d65-xyz", Vlcms_d65_xyz,
295 doc: /* D65 illuminant as a CIE XYZ triple. */);
296 Vlcms_d65_xyz = list3 (make_float (0.950455),
297 make_float (1.0),
298 make_float (1.088753));
299
300 defsubr (&Slcms_cie_de2000); 361 defsubr (&Slcms_cie_de2000);
301 defsubr (&Slcms_cam02_ucs); 362 defsubr (&Slcms_cam02_ucs);
302 defsubr (&Slcms2_available_p); 363 defsubr (&Slcms2_available_p);
diff --git a/src/nsterm.m b/src/nsterm.m
index 27515335332..f0b6a70dae3 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1820,8 +1820,8 @@ x_set_window_size (struct frame *f,
1820 1820
1821 if (pixelwise) 1821 if (pixelwise)
1822 { 1822 {
1823 pixelwidth = width; 1823 pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
1824 pixelheight = height; 1824 pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, height);
1825 } 1825 }
1826 else 1826 else
1827 { 1827 {
@@ -6498,24 +6498,139 @@ not_in_argv (NSString *arg)
6498 6498
6499 if ([theEvent type] == NSEventTypeScrollWheel) 6499 if ([theEvent type] == NSEventTypeScrollWheel)
6500 { 6500 {
6501 CGFloat delta = [theEvent deltaY]; 6501#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
6502 /* Mac notebooks send wheel events w/delta =0 when trackpad scrolling */ 6502#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
6503 if (delta == 0) 6503 if ([theEvent respondsToSelector:@selector(hasPreciseScrollingDeltas)])
6504 { 6504 {
6505 delta = [theEvent deltaX]; 6505#endif
6506 if (delta == 0) 6506 /* If the input device is a touchpad or similar, use precise
6507 * scrolling deltas. These are measured in pixels, so we
6508 * have to add them up until they exceed one line height,
6509 * then we can send a scroll wheel event.
6510 *
6511 * If the device only has coarse scrolling deltas, like a
6512 * real mousewheel, the deltas represent a ratio of whole
6513 * lines, so round up the number of lines. This means we
6514 * always send one scroll event per click, but can still
6515 * scroll more than one line if the OS tells us to.
6516 */
6517 bool horizontal;
6518 int lines = 0;
6519 int scrollUp = NO;
6520
6521 /* FIXME: At the top or bottom of the buffer we should
6522 * ignore momentum-phase events. */
6523 if (! ns_use_mwheel_momentum
6524 && [theEvent momentumPhase] != NSEventPhaseNone)
6525 return;
6526
6527 if ([theEvent hasPreciseScrollingDeltas])
6507 { 6528 {
6508 NSTRACE_MSG ("deltaIsZero"); 6529 static int totalDeltaX, totalDeltaY;
6509 return; 6530 int lineHeight;
6531
6532 if (NUMBERP (ns_mwheel_line_height))
6533 lineHeight = XINT (ns_mwheel_line_height);
6534 else
6535 {
6536 /* FIXME: Use actual line height instead of the default. */
6537 lineHeight = default_line_pixel_height
6538 (XWINDOW (FRAME_SELECTED_WINDOW (emacsframe)));
6539 }
6540
6541 if ([theEvent phase] == NSEventPhaseBegan)
6542 {
6543 totalDeltaX = 0;
6544 totalDeltaY = 0;
6545 }
6546
6547 totalDeltaX += [theEvent scrollingDeltaX];
6548 totalDeltaY += [theEvent scrollingDeltaY];
6549
6550 /* Calculate the number of lines, if any, to scroll, and
6551 * reset the total delta for the direction we're NOT
6552 * scrolling so that small movements don't add up. */
6553 if (abs (totalDeltaX) > abs (totalDeltaY)
6554 && abs (totalDeltaX) > lineHeight)
6555 {
6556 horizontal = YES;
6557 scrollUp = totalDeltaX > 0;
6558
6559 lines = abs (totalDeltaX / lineHeight);
6560 totalDeltaX = totalDeltaX % lineHeight;
6561 totalDeltaY = 0;
6562 }
6563 else if (abs (totalDeltaY) >= abs (totalDeltaX)
6564 && abs (totalDeltaY) > lineHeight)
6565 {
6566 horizontal = NO;
6567 scrollUp = totalDeltaY > 0;
6568
6569 lines = abs (totalDeltaY / lineHeight);
6570 totalDeltaY = totalDeltaY % lineHeight;
6571 totalDeltaX = 0;
6572 }
6573
6574 if (lines > 1 && ! ns_use_mwheel_acceleration)
6575 lines = 1;
6510 } 6576 }
6511 emacs_event->kind = HORIZ_WHEEL_EVENT; 6577 else
6578 {
6579 CGFloat delta;
6580
6581 if ([theEvent scrollingDeltaY] == 0)
6582 {
6583 horizontal = YES;
6584 delta = [theEvent scrollingDeltaX];
6585 }
6586 else
6587 {
6588 horizontal = NO;
6589 delta = [theEvent scrollingDeltaY];
6590 }
6591
6592 lines = (ns_use_mwheel_acceleration)
6593 ? ceil (fabs (delta)) : 1;
6594
6595 scrollUp = delta > 0;
6596 }
6597
6598 if (lines == 0)
6599 return;
6600
6601 emacs_event->kind = horizontal ? HORIZ_WHEEL_EVENT : WHEEL_EVENT;
6602 emacs_event->arg = (make_number (lines));
6603
6604 emacs_event->code = 0;
6605 emacs_event->modifiers = EV_MODIFIERS (theEvent) |
6606 (scrollUp ? up_modifier : down_modifier);
6607#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
6512 } 6608 }
6513 else 6609 else
6514 emacs_event->kind = WHEEL_EVENT; 6610#endif
6611#endif /* defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 */
6612#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
6613 {
6614 CGFloat delta = [theEvent deltaY];
6615 /* Mac notebooks send wheel events w/delta =0 when trackpad scrolling */
6616 if (delta == 0)
6617 {
6618 delta = [theEvent deltaX];
6619 if (delta == 0)
6620 {
6621 NSTRACE_MSG ("deltaIsZero");
6622 return;
6623 }
6624 emacs_event->kind = HORIZ_WHEEL_EVENT;
6625 }
6626 else
6627 emacs_event->kind = WHEEL_EVENT;
6515 6628
6516 emacs_event->code = 0; 6629 emacs_event->code = 0;
6517 emacs_event->modifiers = EV_MODIFIERS (theEvent) | 6630 emacs_event->modifiers = EV_MODIFIERS (theEvent) |
6518 ((delta > 0) ? up_modifier : down_modifier); 6631 ((delta > 0) ? up_modifier : down_modifier);
6632 }
6633#endif
6519 } 6634 }
6520 else 6635 else
6521 { 6636 {
@@ -6524,9 +6639,11 @@ not_in_argv (NSString *arg)
6524 emacs_event->modifiers = EV_MODIFIERS (theEvent) 6639 emacs_event->modifiers = EV_MODIFIERS (theEvent)
6525 | EV_UDMODIFIERS (theEvent); 6640 | EV_UDMODIFIERS (theEvent);
6526 } 6641 }
6642
6527 XSETINT (emacs_event->x, lrint (p.x)); 6643 XSETINT (emacs_event->x, lrint (p.x));
6528 XSETINT (emacs_event->y, lrint (p.y)); 6644 XSETINT (emacs_event->y, lrint (p.y));
6529 EV_TRAILER (theEvent); 6645 EV_TRAILER (theEvent);
6646 return;
6530} 6647}
6531 6648
6532 6649
@@ -6707,9 +6824,10 @@ not_in_argv (NSString *arg)
6707 6824
6708 if (wait_for_tool_bar) 6825 if (wait_for_tool_bar)
6709 { 6826 {
6710 /* The toolbar height is always 0 in fullscreen, so don't wait 6827 /* The toolbar height is always 0 in fullscreen and undecorated
6711 for it to become available. */ 6828 frames, so don't wait for it to become available. */
6712 if (FRAME_TOOLBAR_HEIGHT (emacsframe) == 0 6829 if (FRAME_TOOLBAR_HEIGHT (emacsframe) == 0
6830 && FRAME_UNDECORATED (emacsframe) == false
6713 && ! [self isFullscreen]) 6831 && ! [self isFullscreen])
6714 { 6832 {
6715 NSTRACE_MSG ("Waiting for toolbar"); 6833 NSTRACE_MSG ("Waiting for toolbar");
@@ -7090,9 +7208,9 @@ not_in_argv (NSString *arg)
7090 7208
7091 win = [[EmacsWindow alloc] 7209 win = [[EmacsWindow alloc]
7092 initWithContentRect: r 7210 initWithContentRect: r
7093 styleMask: (FRAME_UNDECORATED (f) 7211 styleMask: ((FRAME_UNDECORATED (f)
7094 ? FRAME_UNDECORATED_FLAGS 7212 ? FRAME_UNDECORATED_FLAGS
7095 : FRAME_DECORATED_FLAGS 7213 : FRAME_DECORATED_FLAGS)
7096#ifdef NS_IMPL_COCOA 7214#ifdef NS_IMPL_COCOA
7097 | NSWindowStyleMaskResizable 7215 | NSWindowStyleMaskResizable
7098 | NSWindowStyleMaskMiniaturizable 7216 | NSWindowStyleMaskMiniaturizable
@@ -9166,6 +9284,23 @@ Note that this does not apply to images.
9166This variable is ignored on Mac OS X < 10.7 and GNUstep. */); 9284This variable is ignored on Mac OS X < 10.7 and GNUstep. */);
9167 ns_use_srgb_colorspace = YES; 9285 ns_use_srgb_colorspace = YES;
9168 9286
9287 DEFVAR_BOOL ("ns-use-mwheel-acceleration",
9288 ns_use_mwheel_acceleration,
9289 doc: /*Non-nil means use macOS's standard mouse wheel acceleration.
9290This variable is ignored on macOS < 10.7 and GNUstep. Default is t. */);
9291 ns_use_mwheel_acceleration = YES;
9292
9293 DEFVAR_LISP ("ns-mwheel-line-height", ns_mwheel_line_height,
9294 doc: /*The number of pixels touchpad scrolling considers one line.
9295Nil or a non-number means use the default frame line height.
9296This variable is ignored on macOS < 10.7 and GNUstep. Default is nil. */);
9297 ns_mwheel_line_height = Qnil;
9298
9299 DEFVAR_BOOL ("ns-use-mwheel-momentum", ns_use_mwheel_momentum,
9300 doc: /*Non-nil means mouse wheel scrolling uses momentum.
9301This variable is ignored on macOS < 10.7 and GNUstep. Default is t. */);
9302 ns_use_mwheel_momentum = YES;
9303
9169 /* TODO: move to common code */ 9304 /* TODO: move to common code */
9170 DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars, 9305 DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars,
9171 doc: /* Which toolkit scroll bars Emacs uses, if any. 9306 doc: /* Which toolkit scroll bars Emacs uses, if any.
diff --git a/src/term.c b/src/term.c
index a2ae8c2c6f0..065bce45d3c 100644
--- a/src/term.c
+++ b/src/term.c
@@ -155,12 +155,16 @@ tty_ring_bell (struct frame *f)
155static void 155static void
156tty_send_additional_strings (struct terminal *terminal, Lisp_Object sym) 156tty_send_additional_strings (struct terminal *terminal, Lisp_Object sym)
157{ 157{
158 Lisp_Object lisp_terminal; 158 /* Use only accessors like CDR_SAFE and assq_no_quit to avoid any
159 Lisp_Object extra_codes; 159 form of quitting or signaling an error, since this function can
160 run as part of the "emergency escape" procedure invoked in the
161 middle of GC, where quitting means crashing (Bug#17406). */
162 if (! terminal->name)
163 return;
160 struct tty_display_info *tty = terminal->display_info.tty; 164 struct tty_display_info *tty = terminal->display_info.tty;
161 165
162 XSETTERMINAL (lisp_terminal, terminal); 166 for (Lisp_Object extra_codes
163 for (extra_codes = Fterminal_parameter (lisp_terminal, sym); 167 = CDR_SAFE (assq_no_quit (sym, terminal->param_alist));
164 CONSP (extra_codes); 168 CONSP (extra_codes);
165 extra_codes = XCDR (extra_codes)) 169 extra_codes = XCDR (extra_codes))
166 { 170 {
diff --git a/src/termhooks.h b/src/termhooks.h
index 97c128ba4e2..b5171bf1229 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -116,7 +116,9 @@ enum event_kind
116 .frame_or_window gives the frame 116 .frame_or_window gives the frame
117 the wheel event occurred in. 117 the wheel event occurred in.
118 .timestamp gives a timestamp (in 118 .timestamp gives a timestamp (in
119 milliseconds) for the event. */ 119 milliseconds) for the event.
120 .arg may contain the number of
121 lines to scroll. */
120 HORIZ_WHEEL_EVENT, /* A wheel event generated by a second 122 HORIZ_WHEEL_EVENT, /* A wheel event generated by a second
121 horizontal wheel that is present on some 123 horizontal wheel that is present on some
122 mice. See WHEEL_EVENT. */ 124 mice. See WHEEL_EVENT. */
diff --git a/src/xdisp.c b/src/xdisp.c
index dc5dbb05762..141275f15a0 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22395,8 +22395,8 @@ Value is the new character position of point. */)
22395 row += dir; 22395 row += dir;
22396 else 22396 else
22397 row -= dir; 22397 row -= dir;
22398 if (row < MATRIX_FIRST_TEXT_ROW (w->current_matrix) 22398 if (!(MATRIX_FIRST_TEXT_ROW (w->current_matrix) <= row
22399 || row > MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w)) 22399 && row < MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w)))
22400 goto simulate_display; 22400 goto simulate_display;
22401 22401
22402 if (dir > 0) 22402 if (dir > 0)