diff options
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/src/term.c b/src/term.c index f23963cc39c..566b8b84915 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -430,11 +430,6 @@ static int mouse_face_past_end; | |||
| 430 | static Lisp_Object Qmouse_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 | ||
| 434 | highlighting. X and Y can be negative or out of range for the frame. */ | ||
| 435 | struct frame *mouse_face_mouse_frame; | ||
| 436 | int mouse_face_mouse_x, mouse_face_mouse_y; | ||
| 437 | |||
| 438 | static int pos_x, pos_y; | 433 | static int pos_x, pos_y; |
| 439 | static int last_mouse_x, last_mouse_y; | 434 | static int last_mouse_x, last_mouse_y; |
| 440 | #endif /* HAVE_GPM */ | 435 | #endif /* HAVE_GPM */ |
| @@ -2494,17 +2489,18 @@ set_tty_color_mode (f, val) | |||
| 2494 | ***********************************************************************/ | 2489 | ***********************************************************************/ |
| 2495 | 2490 | ||
| 2496 | #ifdef HAVE_GPM | 2491 | #ifdef HAVE_GPM |
| 2497 | void term_mouse_moveto (int x, int y) | 2492 | void |
| 2493 | term_mouse_moveto (int x, int y) | ||
| 2498 | { | 2494 | { |
| 2499 | const char *name; | 2495 | const char *name; |
| 2500 | int fd; | 2496 | int fd; |
| 2497 | /* TODO: how to set mouse position? | ||
| 2501 | name = (const char *) ttyname (0); | 2498 | name = (const char *) ttyname (0); |
| 2502 | fd = open (name, O_WRONLY); | 2499 | fd = open (name, O_WRONLY); |
| 2503 | /* TODO: how to set mouse position? | 2500 | SOME_FUNCTION (x, y, fd); |
| 2504 | SOME_FUNCTION (x, y, fd); */ | ||
| 2505 | close (fd); | 2501 | close (fd); |
| 2506 | last_mouse_x = x; | 2502 | last_mouse_x = x; |
| 2507 | last_mouse_y = y; | 2503 | last_mouse_y = y; */ |
| 2508 | } | 2504 | } |
| 2509 | 2505 | ||
| 2510 | static void | 2506 | static void |
| @@ -2681,10 +2677,6 @@ term_mouse_highlight (struct frame *f, int x, int y) | |||
| 2681 | || !f->glyphs_initialized_p) | 2677 | || !f->glyphs_initialized_p) |
| 2682 | return; | 2678 | return; |
| 2683 | 2679 | ||
| 2684 | mouse_face_mouse_x = x; | ||
| 2685 | mouse_face_mouse_y = y; | ||
| 2686 | mouse_face_mouse_frame = f; | ||
| 2687 | |||
| 2688 | /* Which window is that in? */ | 2680 | /* Which window is that in? */ |
| 2689 | window = window_from_coordinates (f, x, y, &part, &x, &y, 0); | 2681 | window = window_from_coordinates (f, x, y, &part, &x, &y, 0); |
| 2690 | 2682 | ||
| @@ -2926,7 +2918,7 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) | |||
| 2926 | if (event->x != last_mouse_x || event->y != last_mouse_y) | 2918 | if (event->x != last_mouse_x || event->y != last_mouse_y) |
| 2927 | { | 2919 | { |
| 2928 | frame->mouse_moved = 1; | 2920 | frame->mouse_moved = 1; |
| 2929 | term_mouse_highlight (frame, event->x - 1, event->y - 1); | 2921 | term_mouse_highlight (frame, event->x, event->y); |
| 2930 | /* Remember which glyph we're now on. */ | 2922 | /* Remember which glyph we're now on. */ |
| 2931 | last_mouse_x = event->x; | 2923 | last_mouse_x = event->x; |
| 2932 | last_mouse_y = event->y; | 2924 | last_mouse_y = event->y; |
| @@ -2946,7 +2938,7 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) | |||
| 2946 | 2938 | ||
| 2947 | Set *time to the time the mouse was at the returned position. | 2939 | Set *time to the time the mouse was at the returned position. |
| 2948 | 2940 | ||
| 2949 | This should clear mouse_moved until the next motion | 2941 | This clears mouse_moved until the next motion |
| 2950 | event arrives. */ | 2942 | event arrives. */ |
| 2951 | static void | 2943 | static void |
| 2952 | term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, | 2944 | term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, |
| @@ -2954,8 +2946,6 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, | |||
| 2954 | Lisp_Object *y, unsigned long *time) | 2946 | Lisp_Object *y, unsigned long *time) |
| 2955 | { | 2947 | { |
| 2956 | struct timeval now; | 2948 | struct timeval now; |
| 2957 | Lisp_Object frame, window; | ||
| 2958 | struct window *w; | ||
| 2959 | 2949 | ||
| 2960 | *fp = SELECTED_FRAME (); | 2950 | *fp = SELECTED_FRAME (); |
| 2961 | (*fp)->mouse_moved = 0; | 2951 | (*fp)->mouse_moved = 0; |
| @@ -2963,13 +2953,8 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, | |||
| 2963 | *bar_window = Qnil; | 2953 | *bar_window = Qnil; |
| 2964 | *part = 0; | 2954 | *part = 0; |
| 2965 | 2955 | ||
| 2966 | XSETINT (*x, last_mouse_x); | 2956 | XSETINT (*x, last_mouse_x); |
| 2967 | XSETINT (*y, last_mouse_y); | 2957 | XSETINT (*y, last_mouse_y); |
| 2968 | XSETFRAME (frame, *fp); | ||
| 2969 | window = Fwindow_at (*x, *y, frame); | ||
| 2970 | |||
| 2971 | XSETINT (*x, last_mouse_x - WINDOW_LEFT_EDGE_COL (XWINDOW (window))); | ||
| 2972 | XSETINT (*y, last_mouse_y - WINDOW_TOP_EDGE_LINE (XWINDOW (window))); | ||
| 2973 | gettimeofday(&now, 0); | 2958 | gettimeofday(&now, 0); |
| 2974 | *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); | 2959 | *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); |
| 2975 | } | 2960 | } |
| @@ -3016,7 +3001,7 @@ term_mouse_click (struct input_event *result, Gpm_Event *event, | |||
| 3016 | if (event->type & GPM_DRAG) | 3001 | if (event->type & GPM_DRAG) |
| 3017 | result->modifiers |= drag_modifier; | 3002 | result->modifiers |= drag_modifier; |
| 3018 | 3003 | ||
| 3019 | if (!(event->type & (GPM_MOVE|GPM_DRAG))) { | 3004 | if (!(event->type & (GPM_MOVE | GPM_DRAG))) { |
| 3020 | 3005 | ||
| 3021 | /* 1 << KG_SHIFT */ | 3006 | /* 1 << KG_SHIFT */ |
| 3022 | if (event->modifiers & (1 << 0)) | 3007 | if (event->modifiers & (1 << 0)) |
| @@ -3032,8 +3017,8 @@ term_mouse_click (struct input_event *result, Gpm_Event *event, | |||
| 3032 | result->modifiers |= meta_modifier; | 3017 | result->modifiers |= meta_modifier; |
| 3033 | } | 3018 | } |
| 3034 | 3019 | ||
| 3035 | XSETINT (result->x, event->x - 1); | 3020 | XSETINT (result->x, event->x); |
| 3036 | XSETINT (result->y, event->y - 1); | 3021 | XSETINT (result->y, event->y); |
| 3037 | XSETFRAME (result->frame_or_window, f); | 3022 | XSETFRAME (result->frame_or_window, f); |
| 3038 | result->arg = Qnil; | 3023 | result->arg = Qnil; |
| 3039 | return Qnil; | 3024 | return Qnil; |
| @@ -3052,7 +3037,7 @@ handle_one_term_event (Gpm_Event *event, struct input_event* hold_quit) | |||
| 3052 | ie.kind = NO_EVENT; | 3037 | ie.kind = NO_EVENT; |
| 3053 | ie.arg = Qnil; | 3038 | ie.arg = Qnil; |
| 3054 | 3039 | ||
| 3055 | if (event->type & GPM_MOVE) { | 3040 | if (event->type & (GPM_MOVE | GPM_DRAG)) { |
| 3056 | unsigned char buf[6 * sizeof (short)]; | 3041 | unsigned char buf[6 * sizeof (short)]; |
| 3057 | unsigned short *arg = (unsigned short *) buf + 1; | 3042 | unsigned short *arg = (unsigned short *) buf + 1; |
| 3058 | const char *name; | 3043 | const char *name; |
| @@ -3063,8 +3048,8 @@ handle_one_term_event (Gpm_Event *event, struct input_event* hold_quit) | |||
| 3063 | /* Display mouse pointer */ | 3048 | /* Display mouse pointer */ |
| 3064 | buf[sizeof(short) - 1] = 2; /* set selection */ | 3049 | buf[sizeof(short) - 1] = 2; /* set selection */ |
| 3065 | 3050 | ||
| 3066 | arg[0] = arg[2] = (unsigned short) event->x; | 3051 | arg[0] = arg[2] = (unsigned short) event->x + gpm_zerobased; |
| 3067 | arg[1] = arg[3] = (unsigned short) event->y; | 3052 | arg[1] = arg[3] = (unsigned short) event->y + gpm_zerobased; |
| 3068 | arg[4] = (unsigned short) 3; | 3053 | arg[4] = (unsigned short) 3; |
| 3069 | 3054 | ||
| 3070 | name = (const char *) ttyname (0); | 3055 | name = (const char *) ttyname (0); |
| @@ -3072,7 +3057,8 @@ handle_one_term_event (Gpm_Event *event, struct input_event* hold_quit) | |||
| 3072 | ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1); | 3057 | ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1); |
| 3073 | close (fd); | 3058 | close (fd); |
| 3074 | 3059 | ||
| 3075 | term_mouse_movement (f, event); | 3060 | if (!term_mouse_movement (f, event)) |
| 3061 | help_echo_string = previous_help_echo_string; | ||
| 3076 | 3062 | ||
| 3077 | /* If the contents of the global variable help_echo_string | 3063 | /* If the contents of the global variable help_echo_string |
| 3078 | has changed, generate a HELP_EVENT. */ | 3064 | has changed, generate a HELP_EVENT. */ |
| @@ -3123,6 +3109,7 @@ DEFUN ("term-open-connection", Fterm_open_connection, Sterm_open_connection, | |||
| 3123 | connection.defaultMask = ~GPM_HARD; | 3109 | connection.defaultMask = ~GPM_HARD; |
| 3124 | connection.maxMod = ~0; | 3110 | connection.maxMod = ~0; |
| 3125 | connection.minMod = 0; | 3111 | connection.minMod = 0; |
| 3112 | gpm_zerobased = 1; | ||
| 3126 | 3113 | ||
| 3127 | if (Gpm_Open (&connection, 0) < 0) | 3114 | if (Gpm_Open (&connection, 0) < 0) |
| 3128 | return Qnil; | 3115 | return Qnil; |