aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChong Yidong2006-08-20 17:58:09 +0000
committerChong Yidong2006-08-20 17:58:09 +0000
commitc5b76d6cf7f35283aae93ef33b8dad1bdf13e085 (patch)
treed7c6ed11cfb85a0ad41946ccbd6936cd757007fe /src
parentc7e8d385a28e54d0caeef794c9ab50ff104d9c78 (diff)
downloademacs-c5b76d6cf7f35283aae93ef33b8dad1bdf13e085.tar.gz
emacs-c5b76d6cf7f35283aae93ef33b8dad1bdf13e085.zip
* keyboard.c (show_help_echo): Preserve mouse movement flag if
tracking mouse.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/keyboard.c144
2 files changed, 82 insertions, 67 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a820b51f77d..b7778885c13 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12006-08-20 Chong Yidong <cyd@stupidchicken.com>
2
3 * keyboard.c (show_help_echo): Preserve mouse movement flag if
4 tracking mouse.
5
12006-08-20 Richard Stallman <rms@gnu.org> 62006-08-20 Richard Stallman <rms@gnu.org>
2 7
3 * xfaces.c (load_pixmap): Add quotes in error message. 8 * xfaces.c (load_pixmap): Add quotes in error message.
diff --git a/src/keyboard.c b/src/keyboard.c
index 13ab5299982..e4c17d5d43f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1390,6 +1390,72 @@ DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0,
1390 return Qnil; 1390 return Qnil;
1391} 1391}
1392 1392
1393#ifdef HAVE_MOUSE
1394
1395/* Restore mouse tracking enablement. See Ftrack_mouse for the only use
1396 of this function. */
1397
1398static Lisp_Object
1399tracking_off (old_value)
1400 Lisp_Object old_value;
1401{
1402 do_mouse_tracking = old_value;
1403 if (NILP (old_value))
1404 {
1405 /* Redisplay may have been preempted because there was input
1406 available, and it assumes it will be called again after the
1407 input has been processed. If the only input available was
1408 the sort that we have just disabled, then we need to call
1409 redisplay. */
1410 if (!readable_events (READABLE_EVENTS_DO_TIMERS_NOW))
1411 {
1412 redisplay_preserve_echo_area (6);
1413 get_input_pending (&input_pending,
1414 READABLE_EVENTS_DO_TIMERS_NOW);
1415 }
1416 }
1417 return Qnil;
1418}
1419
1420DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0,
1421 doc: /* Evaluate BODY with mouse movement events enabled.
1422Within a `track-mouse' form, mouse motion generates input events that
1423you can read with `read-event'.
1424Normally, mouse motion is ignored.
1425usage: (track-mouse BODY ...) */)
1426 (args)
1427 Lisp_Object args;
1428{
1429 int count = SPECPDL_INDEX ();
1430 Lisp_Object val;
1431
1432 record_unwind_protect (tracking_off, do_mouse_tracking);
1433
1434 do_mouse_tracking = Qt;
1435
1436 val = Fprogn (args);
1437 return unbind_to (count, val);
1438}
1439
1440/* If mouse has moved on some frame, return one of those frames.
1441 Return 0 otherwise. */
1442
1443static FRAME_PTR
1444some_mouse_moved ()
1445{
1446 Lisp_Object tail, frame;
1447
1448 FOR_EACH_FRAME (tail, frame)
1449 {
1450 if (XFRAME (frame)->mouse_moved)
1451 return XFRAME (frame);
1452 }
1453
1454 return 0;
1455}
1456
1457#endif /* HAVE_MOUSE */
1458
1393/* This is the actual command reading loop, 1459/* This is the actual command reading loop,
1394 sans error-handling encapsulation. */ 1460 sans error-handling encapsulation. */
1395 1461
@@ -2310,7 +2376,17 @@ show_help_echo (help, window, object, pos, ok_to_overwrite_keystroke_echo)
2310 2376
2311#ifdef HAVE_MOUSE 2377#ifdef HAVE_MOUSE
2312 if (!noninteractive && STRINGP (help)) 2378 if (!noninteractive && STRINGP (help))
2313 help = call1 (Qmouse_fixup_help_message, help); 2379 {
2380 /* The mouse-fixup-help-message Lisp function can call
2381 mouse_position_hook, which resets the mouse_moved flags.
2382 This causes trouble if we are trying to read a mouse motion
2383 event (i.e., if we are inside a `track-mouse' form), so we
2384 restore the mouse_moved flag. */
2385 FRAME_PTR f = NILP (do_mouse_tracking) ? NULL : some_mouse_moved ();
2386 help = call1 (Qmouse_fixup_help_message, help);
2387 if (f)
2388 f->mouse_moved = 1;
2389 }
2314#endif 2390#endif
2315 2391
2316 if (STRINGP (help) || NILP (help)) 2392 if (STRINGP (help) || NILP (help))
@@ -3464,72 +3540,6 @@ restore_getcjmp (temp)
3464 bcopy (temp, getcjmp, sizeof getcjmp); 3540 bcopy (temp, getcjmp, sizeof getcjmp);
3465} 3541}
3466 3542
3467#ifdef HAVE_MOUSE
3468
3469/* Restore mouse tracking enablement. See Ftrack_mouse for the only use
3470 of this function. */
3471
3472static Lisp_Object
3473tracking_off (old_value)
3474 Lisp_Object old_value;
3475{
3476 do_mouse_tracking = old_value;
3477 if (NILP (old_value))
3478 {
3479 /* Redisplay may have been preempted because there was input
3480 available, and it assumes it will be called again after the
3481 input has been processed. If the only input available was
3482 the sort that we have just disabled, then we need to call
3483 redisplay. */
3484 if (!readable_events (READABLE_EVENTS_DO_TIMERS_NOW))
3485 {
3486 redisplay_preserve_echo_area (6);
3487 get_input_pending (&input_pending,
3488 READABLE_EVENTS_DO_TIMERS_NOW);
3489 }
3490 }
3491 return Qnil;
3492}
3493
3494DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0,
3495 doc: /* Evaluate BODY with mouse movement events enabled.
3496Within a `track-mouse' form, mouse motion generates input events that
3497you can read with `read-event'.
3498Normally, mouse motion is ignored.
3499usage: (track-mouse BODY ...) */)
3500 (args)
3501 Lisp_Object args;
3502{
3503 int count = SPECPDL_INDEX ();
3504 Lisp_Object val;
3505
3506 record_unwind_protect (tracking_off, do_mouse_tracking);
3507
3508 do_mouse_tracking = Qt;
3509
3510 val = Fprogn (args);
3511 return unbind_to (count, val);
3512}
3513
3514/* If mouse has moved on some frame, return one of those frames.
3515 Return 0 otherwise. */
3516
3517static FRAME_PTR
3518some_mouse_moved ()
3519{
3520 Lisp_Object tail, frame;
3521
3522 FOR_EACH_FRAME (tail, frame)
3523 {
3524 if (XFRAME (frame)->mouse_moved)
3525 return XFRAME (frame);
3526 }
3527
3528 return 0;
3529}
3530
3531#endif /* HAVE_MOUSE */
3532
3533/* Low level keyboard/mouse input. 3543/* Low level keyboard/mouse input.
3534 kbd_buffer_store_event places events in kbd_buffer, and 3544 kbd_buffer_store_event places events in kbd_buffer, and
3535 kbd_buffer_get_event retrieves them. */ 3545 kbd_buffer_get_event retrieves them. */