diff options
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/src/term.c b/src/term.c index b8e972043a4..f23963cc39c 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -427,7 +427,7 @@ int term_gpm = 0; | |||
| 427 | static int mouse_face_beg_row, mouse_face_beg_col; | 427 | static int mouse_face_beg_row, mouse_face_beg_col; |
| 428 | static int mouse_face_end_row, mouse_face_end_col; | 428 | static int mouse_face_end_row, mouse_face_end_col; |
| 429 | static int mouse_face_past_end; | 429 | static int mouse_face_past_end; |
| 430 | static Lisp_Object mouse_face_window; | 430 | static Lisp_Object Qmouse_face_window; |
| 431 | static int mouse_face_face_id; | 431 | static int mouse_face_face_id; |
| 432 | 432 | ||
| 433 | /* FRAME and X, Y position of mouse when last checked for | 433 | /* FRAME and X, Y position of mouse when last checked for |
| @@ -2494,10 +2494,23 @@ set_tty_color_mode (f, val) | |||
| 2494 | ***********************************************************************/ | 2494 | ***********************************************************************/ |
| 2495 | 2495 | ||
| 2496 | #ifdef HAVE_GPM | 2496 | #ifdef HAVE_GPM |
| 2497 | void term_mouse_moveto (int x, int y) | ||
| 2498 | { | ||
| 2499 | const char *name; | ||
| 2500 | int fd; | ||
| 2501 | name = (const char *) ttyname (0); | ||
| 2502 | fd = open (name, O_WRONLY); | ||
| 2503 | /* TODO: how to set mouse position? | ||
| 2504 | SOME_FUNCTION (x, y, fd); */ | ||
| 2505 | close (fd); | ||
| 2506 | last_mouse_x = x; | ||
| 2507 | last_mouse_y = y; | ||
| 2508 | } | ||
| 2509 | |||
| 2497 | static void | 2510 | static void |
| 2498 | term_show_mouse_face (enum draw_glyphs_face draw) | 2511 | term_show_mouse_face (enum draw_glyphs_face draw) |
| 2499 | { | 2512 | { |
| 2500 | struct window *w = XWINDOW (mouse_face_window); | 2513 | struct window *w = XWINDOW (Qmouse_face_window); |
| 2501 | int save_x, save_y; | 2514 | int save_x, save_y; |
| 2502 | int i, j; | 2515 | int i, j; |
| 2503 | 2516 | ||
| @@ -2573,12 +2586,12 @@ term_show_mouse_face (enum draw_glyphs_face draw) | |||
| 2573 | static void | 2586 | static void |
| 2574 | term_clear_mouse_face () | 2587 | term_clear_mouse_face () |
| 2575 | { | 2588 | { |
| 2576 | if (!NILP (mouse_face_window)) | 2589 | if (!NILP (Qmouse_face_window)) |
| 2577 | term_show_mouse_face (DRAW_NORMAL_TEXT); | 2590 | term_show_mouse_face (DRAW_NORMAL_TEXT); |
| 2578 | 2591 | ||
| 2579 | mouse_face_beg_row = mouse_face_beg_col = -1; | 2592 | mouse_face_beg_row = mouse_face_beg_col = -1; |
| 2580 | mouse_face_end_row = mouse_face_end_col = -1; | 2593 | mouse_face_end_row = mouse_face_end_col = -1; |
| 2581 | mouse_face_window = Qnil; | 2594 | Qmouse_face_window = Qnil; |
| 2582 | } | 2595 | } |
| 2583 | 2596 | ||
| 2584 | /* Find the glyph matrix position of buffer position POS in window W. | 2597 | /* Find the glyph matrix position of buffer position POS in window W. |
| @@ -2679,7 +2692,7 @@ term_mouse_highlight (struct frame *f, int x, int y) | |||
| 2679 | if (!WINDOWP (window)) | 2692 | if (!WINDOWP (window)) |
| 2680 | return; | 2693 | return; |
| 2681 | 2694 | ||
| 2682 | if (!EQ (window, mouse_face_window)) | 2695 | if (!EQ (window, Qmouse_face_window)) |
| 2683 | term_clear_mouse_face (); | 2696 | term_clear_mouse_face (); |
| 2684 | 2697 | ||
| 2685 | w = XWINDOW (window); | 2698 | w = XWINDOW (window); |
| @@ -2737,7 +2750,7 @@ term_mouse_highlight (struct frame *f, int x, int y) | |||
| 2737 | { | 2750 | { |
| 2738 | extern Lisp_Object Qmouse_face; | 2751 | extern Lisp_Object Qmouse_face; |
| 2739 | Lisp_Object mouse_face, overlay, position, *overlay_vec; | 2752 | Lisp_Object mouse_face, overlay, position, *overlay_vec; |
| 2740 | int noverlays, obegv, ozv;; | 2753 | int noverlays, obegv, ozv; |
| 2741 | struct buffer *obuf; | 2754 | struct buffer *obuf; |
| 2742 | 2755 | ||
| 2743 | /* If we get an out-of-range value, return now; avoid an error. */ | 2756 | /* If we get an out-of-range value, return now; avoid an error. */ |
| @@ -2762,7 +2775,7 @@ term_mouse_highlight (struct frame *f, int x, int y) | |||
| 2762 | noverlays = sort_overlays (overlay_vec, noverlays, w); | 2775 | noverlays = sort_overlays (overlay_vec, noverlays, w); |
| 2763 | 2776 | ||
| 2764 | /* Check mouse-face highlighting. */ | 2777 | /* Check mouse-face highlighting. */ |
| 2765 | if (!(EQ (window, mouse_face_window) | 2778 | if (!(EQ (window, Qmouse_face_window) |
| 2766 | && y >= mouse_face_beg_row | 2779 | && y >= mouse_face_beg_row |
| 2767 | && y <= mouse_face_end_row | 2780 | && y <= mouse_face_end_row |
| 2768 | && (y > mouse_face_beg_row | 2781 | && (y > mouse_face_beg_row |
| @@ -2812,7 +2825,7 @@ term_mouse_highlight (struct frame *f, int x, int y) | |||
| 2812 | = !fast_find_position (w, XFASTINT (after), | 2825 | = !fast_find_position (w, XFASTINT (after), |
| 2813 | &mouse_face_end_col, | 2826 | &mouse_face_end_col, |
| 2814 | &mouse_face_end_row); | 2827 | &mouse_face_end_row); |
| 2815 | mouse_face_window = window; | 2828 | Qmouse_face_window = window; |
| 2816 | 2829 | ||
| 2817 | mouse_face_face_id | 2830 | mouse_face_face_id |
| 2818 | = face_at_buffer_position (w, pos, 0, 0, | 2831 | = face_at_buffer_position (w, pos, 0, 0, |
| @@ -2847,7 +2860,7 @@ term_mouse_highlight (struct frame *f, int x, int y) | |||
| 2847 | = !fast_find_position (w, XFASTINT (after), | 2860 | = !fast_find_position (w, XFASTINT (after), |
| 2848 | &mouse_face_end_col, | 2861 | &mouse_face_end_col, |
| 2849 | &mouse_face_end_row); | 2862 | &mouse_face_end_row); |
| 2850 | mouse_face_window = window; | 2863 | Qmouse_face_window = window; |
| 2851 | 2864 | ||
| 2852 | mouse_face_face_id | 2865 | mouse_face_face_id |
| 2853 | = face_at_buffer_position (w, pos, 0, 0, | 2866 | = face_at_buffer_position (w, pos, 0, 0, |
| @@ -2934,33 +2947,31 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) | |||
| 2934 | Set *time to the time the mouse was at the returned position. | 2947 | Set *time to the time the mouse was at the returned position. |
| 2935 | 2948 | ||
| 2936 | This should clear mouse_moved until the next motion | 2949 | This should clear mouse_moved until the next motion |
| 2937 | event arrives. | 2950 | event arrives. */ |
| 2938 | |||
| 2939 | NOT CURRENTLY INVOKED: see mouse_position_hook below. */ | ||
| 2940 | static void | 2951 | static void |
| 2941 | term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, | 2952 | term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, |
| 2942 | enum scroll_bar_part *part, Lisp_Object *x, | 2953 | enum scroll_bar_part *part, Lisp_Object *x, |
| 2943 | Lisp_Object *y, unsigned long *time) | 2954 | Lisp_Object *y, unsigned long *time) |
| 2944 | { | 2955 | { |
| 2945 | Gpm_Event event; | ||
| 2946 | struct timeval now; | 2956 | struct timeval now; |
| 2947 | int i; | 2957 | Lisp_Object frame, window; |
| 2948 | 2958 | struct window *w; | |
| 2949 | BLOCK_INPUT; | ||
| 2950 | 2959 | ||
| 2951 | *fp = SELECTED_FRAME (); | 2960 | *fp = SELECTED_FRAME (); |
| 2961 | (*fp)->mouse_moved = 0; | ||
| 2952 | 2962 | ||
| 2953 | *bar_window = Qnil; | 2963 | *bar_window = Qnil; |
| 2954 | *part = 0; | 2964 | *part = 0; |
| 2955 | 2965 | ||
| 2956 | i = Gpm_GetSnapshot (&event); | 2966 | XSETINT (*x, last_mouse_x); |
| 2967 | XSETINT (*y, last_mouse_y); | ||
| 2968 | XSETFRAME (frame, *fp); | ||
| 2969 | window = Fwindow_at (*x, *y, frame); | ||
| 2957 | 2970 | ||
| 2958 | XSETINT (*x, event.x); | 2971 | XSETINT (*x, last_mouse_x - WINDOW_LEFT_EDGE_COL (XWINDOW (window))); |
| 2959 | XSETINT (*y, event.y); | 2972 | XSETINT (*y, last_mouse_y - WINDOW_TOP_EDGE_LINE (XWINDOW (window))); |
| 2960 | gettimeofday(&now, 0); | 2973 | gettimeofday(&now, 0); |
| 2961 | *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); | 2974 | *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); |
| 2962 | |||
| 2963 | UNBLOCK_INPUT; | ||
| 2964 | } | 2975 | } |
| 2965 | 2976 | ||
| 2966 | /* Prepare a mouse-event in *RESULT for placement in the input queue. | 2977 | /* Prepare a mouse-event in *RESULT for placement in the input queue. |
| @@ -3059,7 +3070,7 @@ handle_one_term_event (Gpm_Event *event, struct input_event* hold_quit) | |||
| 3059 | name = (const char *) ttyname (0); | 3070 | name = (const char *) ttyname (0); |
| 3060 | fd = open (name, O_WRONLY); | 3071 | fd = open (name, O_WRONLY); |
| 3061 | ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1); | 3072 | ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1); |
| 3062 | close(fd); | 3073 | close (fd); |
| 3063 | 3074 | ||
| 3064 | term_mouse_movement (f, event); | 3075 | term_mouse_movement (f, event); |
| 3065 | 3076 | ||
| @@ -3074,7 +3085,6 @@ handle_one_term_event (Gpm_Event *event, struct input_event* hold_quit) | |||
| 3074 | else { | 3085 | else { |
| 3075 | f->mouse_moved = 0; | 3086 | f->mouse_moved = 0; |
| 3076 | term_mouse_click (&ie, event, f); | 3087 | term_mouse_click (&ie, event, f); |
| 3077 | //kbd_buffer_store_event_hold (&ie, hold_quit); | ||
| 3078 | } | 3088 | } |
| 3079 | 3089 | ||
| 3080 | done: | 3090 | done: |
| @@ -3159,11 +3169,8 @@ term_init (terminal_type) | |||
| 3159 | encode_terminal_dst_size = 0; | 3169 | encode_terminal_dst_size = 0; |
| 3160 | 3170 | ||
| 3161 | #ifdef HAVE_GPM | 3171 | #ifdef HAVE_GPM |
| 3162 | /* TODO: Can't get Gpm_Snapshot in term_mouse_position to work: test with | 3172 | mouse_position_hook = term_mouse_position; |
| 3163 | (mouse-position). Also set-mouse-position won't work as is. */ | 3173 | Qmouse_face_window = Qnil; |
| 3164 | /* mouse_position_hook = term_mouse_position; */ | ||
| 3165 | |||
| 3166 | mouse_face_window = Qnil; | ||
| 3167 | #endif | 3174 | #endif |
| 3168 | 3175 | ||
| 3169 | #ifdef WINDOWSNT | 3176 | #ifdef WINDOWSNT |
| @@ -3616,6 +3623,8 @@ bigger, or it may make it blink, or it may do nothing at all. */); | |||
| 3616 | #ifdef HAVE_GPM | 3623 | #ifdef HAVE_GPM |
| 3617 | defsubr (&Sterm_open_connection); | 3624 | defsubr (&Sterm_open_connection); |
| 3618 | defsubr (&Sterm_close_connection); | 3625 | defsubr (&Sterm_close_connection); |
| 3626 | |||
| 3627 | staticpro (&Qmouse_face_window); | ||
| 3619 | #endif /* HAVE_GPM */ | 3628 | #endif /* HAVE_GPM */ |
| 3620 | 3629 | ||
| 3621 | fullscreen_hook = NULL; | 3630 | fullscreen_hook = NULL; |