aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNick Roberts2007-05-30 05:19:55 +0000
committerNick Roberts2007-05-30 05:19:55 +0000
commit94da14a02dab82212794e779c2c601f001f116fa (patch)
tree897fc8d813a59cba2b4d0f0df6e41a32b71b5032 /src
parentb9695a7afbd87241a9e187cb6c06d253bbc9e1e3 (diff)
downloademacs-94da14a02dab82212794e779c2c601f001f116fa.tar.gz
emacs-94da14a02dab82212794e779c2c601f001f116fa.zip
(mouse_face_window): Rename...
(Qmouse_face_window): ...to this. (term_show_mouse_face, term_clear_mouse_face) (term_mouse_highlight): Use Qmouse_face_window. (term_mouse_moveto): New function. (term_mouse_position): Make it work. (syms_of_term): Uncomment assignment to mouse_position_hook. Staticpro Qmouse_face_window.
Diffstat (limited to 'src')
-rw-r--r--src/term.c63
1 files changed, 36 insertions, 27 deletions
diff --git a/src/term.c b/src/term.c
index e4a685fae2d..6a39544c00c 100644
--- a/src/term.c
+++ b/src/term.c
@@ -425,7 +425,7 @@ int term_gpm = 0;
425static int mouse_face_beg_row, mouse_face_beg_col; 425static int mouse_face_beg_row, mouse_face_beg_col;
426static int mouse_face_end_row, mouse_face_end_col; 426static int mouse_face_end_row, mouse_face_end_col;
427static int mouse_face_past_end; 427static int mouse_face_past_end;
428static Lisp_Object mouse_face_window; 428static Lisp_Object Qmouse_face_window;
429static int mouse_face_face_id; 429static int mouse_face_face_id;
430 430
431/* FRAME and X, Y position of mouse when last checked for 431/* FRAME and X, Y position of mouse when last checked for
@@ -2382,10 +2382,23 @@ set_tty_color_mode (f, val)
2382 ***********************************************************************/ 2382 ***********************************************************************/
2383 2383
2384#ifdef HAVE_GPM 2384#ifdef HAVE_GPM
2385void term_mouse_moveto (int x, int y)
2386{
2387 const char *name;
2388 int fd;
2389 name = (const char *) ttyname (0);
2390 fd = open (name, O_WRONLY);
2391 /* TODO: how to set mouse position?
2392 SOME_FUNCTION (x, y, fd); */
2393 close (fd);
2394 last_mouse_x = x;
2395 last_mouse_y = y;
2396}
2397
2385static void 2398static void
2386term_show_mouse_face (enum draw_glyphs_face draw) 2399term_show_mouse_face (enum draw_glyphs_face draw)
2387{ 2400{
2388 struct window *w = XWINDOW (mouse_face_window); 2401 struct window *w = XWINDOW (Qmouse_face_window);
2389 int save_x, save_y; 2402 int save_x, save_y;
2390 int i, j; 2403 int i, j;
2391 2404
@@ -2461,12 +2474,12 @@ term_show_mouse_face (enum draw_glyphs_face draw)
2461static void 2474static void
2462term_clear_mouse_face () 2475term_clear_mouse_face ()
2463{ 2476{
2464 if (!NILP (mouse_face_window)) 2477 if (!NILP (Qmouse_face_window))
2465 term_show_mouse_face (DRAW_NORMAL_TEXT); 2478 term_show_mouse_face (DRAW_NORMAL_TEXT);
2466 2479
2467 mouse_face_beg_row = mouse_face_beg_col = -1; 2480 mouse_face_beg_row = mouse_face_beg_col = -1;
2468 mouse_face_end_row = mouse_face_end_col = -1; 2481 mouse_face_end_row = mouse_face_end_col = -1;
2469 mouse_face_window = Qnil; 2482 Qmouse_face_window = Qnil;
2470} 2483}
2471 2484
2472/* Find the glyph matrix position of buffer position POS in window W. 2485/* Find the glyph matrix position of buffer position POS in window W.
@@ -2567,7 +2580,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2567 if (!WINDOWP (window)) 2580 if (!WINDOWP (window))
2568 return; 2581 return;
2569 2582
2570 if (!EQ (window, mouse_face_window)) 2583 if (!EQ (window, Qmouse_face_window))
2571 term_clear_mouse_face (); 2584 term_clear_mouse_face ();
2572 2585
2573 w = XWINDOW (window); 2586 w = XWINDOW (window);
@@ -2650,7 +2663,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2650 noverlays = sort_overlays (overlay_vec, noverlays, w); 2663 noverlays = sort_overlays (overlay_vec, noverlays, w);
2651 2664
2652 /* Check mouse-face highlighting. */ 2665 /* Check mouse-face highlighting. */
2653 if (!(EQ (window, mouse_face_window) 2666 if (!(EQ (window, Qmouse_face_window)
2654 && y >= mouse_face_beg_row 2667 && y >= mouse_face_beg_row
2655 && y <= mouse_face_end_row 2668 && y <= mouse_face_end_row
2656 && (y > mouse_face_beg_row 2669 && (y > mouse_face_beg_row
@@ -2700,7 +2713,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2700 = !fast_find_position (w, XFASTINT (after), 2713 = !fast_find_position (w, XFASTINT (after),
2701 &mouse_face_end_col, 2714 &mouse_face_end_col,
2702 &mouse_face_end_row); 2715 &mouse_face_end_row);
2703 mouse_face_window = window; 2716 Qmouse_face_window = window;
2704 2717
2705 mouse_face_face_id 2718 mouse_face_face_id
2706 = face_at_buffer_position (w, pos, 0, 0, 2719 = face_at_buffer_position (w, pos, 0, 0,
@@ -2735,7 +2748,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2735 = !fast_find_position (w, XFASTINT (after), 2748 = !fast_find_position (w, XFASTINT (after),
2736 &mouse_face_end_col, 2749 &mouse_face_end_col,
2737 &mouse_face_end_row); 2750 &mouse_face_end_row);
2738 mouse_face_window = window; 2751 Qmouse_face_window = window;
2739 2752
2740 mouse_face_face_id 2753 mouse_face_face_id
2741 = face_at_buffer_position (w, pos, 0, 0, 2754 = face_at_buffer_position (w, pos, 0, 0,
@@ -2822,33 +2835,31 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event)
2822 Set *time to the time the mouse was at the returned position. 2835 Set *time to the time the mouse was at the returned position.
2823 2836
2824 This should clear mouse_moved until the next motion 2837 This should clear mouse_moved until the next motion
2825 event arrives. 2838 event arrives. */
2826
2827 NOT CURRENTLY INVOKED: see mouse_position_hook below. */
2828static void 2839static void
2829term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, 2840term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
2830 enum scroll_bar_part *part, Lisp_Object *x, 2841 enum scroll_bar_part *part, Lisp_Object *x,
2831 Lisp_Object *y, unsigned long *time) 2842 Lisp_Object *y, unsigned long *time)
2832{ 2843{
2833 Gpm_Event event;
2834 struct timeval now; 2844 struct timeval now;
2835 int i; 2845 Lisp_Object frame, window;
2836 2846 struct window *w;
2837 BLOCK_INPUT;
2838 2847
2839 *fp = SELECTED_FRAME (); 2848 *fp = SELECTED_FRAME ();
2849 (*fp)->mouse_moved = 0;
2840 2850
2841 *bar_window = Qnil; 2851 *bar_window = Qnil;
2842 *part = 0; 2852 *part = 0;
2843 2853
2844 i = Gpm_GetSnapshot (&event); 2854 XSETINT (*x, last_mouse_x);
2855 XSETINT (*y, last_mouse_y);
2856 XSETFRAME (frame, *fp);
2857 window = Fwindow_at (*x, *y, frame);
2845 2858
2846 XSETINT (*x, event.x); 2859 XSETINT (*x, last_mouse_x - WINDOW_LEFT_EDGE_COL (XWINDOW (window)));
2847 XSETINT (*y, event.y); 2860 XSETINT (*y, last_mouse_y - WINDOW_TOP_EDGE_LINE (XWINDOW (window)));
2848 gettimeofday(&now, 0); 2861 gettimeofday(&now, 0);
2849 *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); 2862 *time = (now.tv_sec * 1000) + (now.tv_usec / 1000);
2850
2851 UNBLOCK_INPUT;
2852} 2863}
2853 2864
2854/* Prepare a mouse-event in *RESULT for placement in the input queue. 2865/* Prepare a mouse-event in *RESULT for placement in the input queue.
@@ -2947,7 +2958,7 @@ handle_one_term_event (Gpm_Event *event, struct input_event* hold_quit)
2947 name = (const char *) ttyname (0); 2958 name = (const char *) ttyname (0);
2948 fd = open (name, O_WRONLY); 2959 fd = open (name, O_WRONLY);
2949 ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1); 2960 ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1);
2950 close(fd); 2961 close (fd);
2951 2962
2952 term_mouse_movement (f, event); 2963 term_mouse_movement (f, event);
2953 2964
@@ -2962,7 +2973,6 @@ handle_one_term_event (Gpm_Event *event, struct input_event* hold_quit)
2962 else { 2973 else {
2963 f->mouse_moved = 0; 2974 f->mouse_moved = 0;
2964 term_mouse_click (&ie, event, f); 2975 term_mouse_click (&ie, event, f);
2965 //kbd_buffer_store_event_hold (&ie, hold_quit);
2966 } 2976 }
2967 2977
2968 done: 2978 done:
@@ -3046,11 +3056,8 @@ term_init (terminal_type)
3046 encode_terminal_bufsize = 0; 3056 encode_terminal_bufsize = 0;
3047 3057
3048#ifdef HAVE_GPM 3058#ifdef HAVE_GPM
3049 /* TODO: Can't get Gpm_Snapshot in term_mouse_position to work: test with 3059 mouse_position_hook = term_mouse_position;
3050 (mouse-position). Also set-mouse-position won't work as is. */ 3060 Qmouse_face_window = Qnil;
3051 /* mouse_position_hook = term_mouse_position; */
3052
3053 mouse_face_window = Qnil;
3054#endif 3061#endif
3055 3062
3056#ifdef WINDOWSNT 3063#ifdef WINDOWSNT
@@ -3503,6 +3510,8 @@ bigger, or it may make it blink, or it may do nothing at all. */);
3503#ifdef HAVE_GPM 3510#ifdef HAVE_GPM
3504 defsubr (&Sterm_open_connection); 3511 defsubr (&Sterm_open_connection);
3505 defsubr (&Sterm_close_connection); 3512 defsubr (&Sterm_close_connection);
3513
3514 staticpro (&Qmouse_face_window);
3506#endif /* HAVE_GPM */ 3515#endif /* HAVE_GPM */
3507 3516
3508 fullscreen_hook = NULL; 3517 fullscreen_hook = NULL;