aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.c
diff options
context:
space:
mode:
authorMiles Bader2007-05-30 14:44:47 +0000
committerMiles Bader2007-05-30 14:44:47 +0000
commit34c6724464237db4bfd5b3fa57e8b0f66a92f618 (patch)
treebbfe4aea433c943f0f6a67b3e49ee31647e12d92 /src/term.c
parent30790a37efea5c6fed87ee0dd0d54c31ac9eea11 (diff)
parent7a781a5480b9a1f55d28a76e1d1f89aaa2421f97 (diff)
downloademacs-34c6724464237db4bfd5b3fa57e8b0f66a92f618.tar.gz
emacs-34c6724464237db4bfd5b3fa57e8b0f66a92f618.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 771-780) - Update from CVS - Merge from emacs--rel--22 - Merge from emacs--rel--22, gnus--rel--5.10 - Fix tq.el edge case * emacs--rel--22 (patch 26-32) - Update from CVS - lisp/vc-hooks.el (vc-find-root): Fix file attribute test * gnus--rel--5.10 (patch 224-225) - Merge from emacs--devo--0, emacs--rel--22 - Update from CVS Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-18
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c65
1 files changed, 37 insertions, 28 deletions
diff --git a/src/term.c b/src/term.c
index 1d8e885ade9..f6b9306dc6b 100644
--- a/src/term.c
+++ b/src/term.c
@@ -205,7 +205,7 @@ int gpm_tty;
205static int mouse_face_beg_row, mouse_face_beg_col; 205static int mouse_face_beg_row, mouse_face_beg_col;
206static int mouse_face_end_row, mouse_face_end_col; 206static int mouse_face_end_row, mouse_face_end_col;
207static int mouse_face_past_end; 207static int mouse_face_past_end;
208static Lisp_Object mouse_face_window; 208static Lisp_Object Qmouse_face_window;
209static int mouse_face_face_id; 209static int mouse_face_face_id;
210 210
211/* FRAME and X, Y position of mouse when last checked for 211/* FRAME and X, Y position of mouse when last checked for
@@ -2344,10 +2344,23 @@ the currently selected frame. */)
2344 ***********************************************************************/ 2344 ***********************************************************************/
2345 2345
2346#ifdef HAVE_GPM 2346#ifdef HAVE_GPM
2347void term_mouse_moveto (int x, int y)
2348{
2349 const char *name;
2350 int fd;
2351 name = (const char *) ttyname (0);
2352 fd = open (name, O_WRONLY);
2353 /* TODO: how to set mouse position?
2354 SOME_FUNCTION (x, y, fd); */
2355 close (fd);
2356 last_mouse_x = x;
2357 last_mouse_y = y;
2358}
2359
2347static void 2360static void
2348term_show_mouse_face (enum draw_glyphs_face draw) 2361term_show_mouse_face (enum draw_glyphs_face draw)
2349{ 2362{
2350 struct window *w = XWINDOW (mouse_face_window); 2363 struct window *w = XWINDOW (Qmouse_face_window);
2351 int save_x, save_y; 2364 int save_x, save_y;
2352 int i, j; 2365 int i, j;
2353 2366
@@ -2426,12 +2439,12 @@ term_show_mouse_face (enum draw_glyphs_face draw)
2426static void 2439static void
2427term_clear_mouse_face () 2440term_clear_mouse_face ()
2428{ 2441{
2429 if (!NILP (mouse_face_window)) 2442 if (!NILP (Qmouse_face_window))
2430 term_show_mouse_face (DRAW_NORMAL_TEXT); 2443 term_show_mouse_face (DRAW_NORMAL_TEXT);
2431 2444
2432 mouse_face_beg_row = mouse_face_beg_col = -1; 2445 mouse_face_beg_row = mouse_face_beg_col = -1;
2433 mouse_face_end_row = mouse_face_end_col = -1; 2446 mouse_face_end_row = mouse_face_end_col = -1;
2434 mouse_face_window = Qnil; 2447 Qmouse_face_window = Qnil;
2435} 2448}
2436 2449
2437/* Find the glyph matrix position of buffer position POS in window W. 2450/* Find the glyph matrix position of buffer position POS in window W.
@@ -2532,7 +2545,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2532 if (!WINDOWP (window)) 2545 if (!WINDOWP (window))
2533 return; 2546 return;
2534 2547
2535 if (!EQ (window, mouse_face_window)) 2548 if (!EQ (window, Qmouse_face_window))
2536 term_clear_mouse_face (); 2549 term_clear_mouse_face ();
2537 2550
2538 w = XWINDOW (window); 2551 w = XWINDOW (window);
@@ -2590,7 +2603,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2590 { 2603 {
2591 extern Lisp_Object Qmouse_face; 2604 extern Lisp_Object Qmouse_face;
2592 Lisp_Object mouse_face, overlay, position, *overlay_vec; 2605 Lisp_Object mouse_face, overlay, position, *overlay_vec;
2593 int noverlays, obegv, ozv;; 2606 int noverlays, obegv, ozv;
2594 struct buffer *obuf; 2607 struct buffer *obuf;
2595 2608
2596 /* If we get an out-of-range value, return now; avoid an error. */ 2609 /* If we get an out-of-range value, return now; avoid an error. */
@@ -2615,7 +2628,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2615 noverlays = sort_overlays (overlay_vec, noverlays, w); 2628 noverlays = sort_overlays (overlay_vec, noverlays, w);
2616 2629
2617 /* Check mouse-face highlighting. */ 2630 /* Check mouse-face highlighting. */
2618 if (!(EQ (window, mouse_face_window) 2631 if (!(EQ (window, Qmouse_face_window)
2619 && y >= mouse_face_beg_row 2632 && y >= mouse_face_beg_row
2620 && y <= mouse_face_end_row 2633 && y <= mouse_face_end_row
2621 && (y > mouse_face_beg_row 2634 && (y > mouse_face_beg_row
@@ -2665,7 +2678,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2665 = !fast_find_position (w, XFASTINT (after), 2678 = !fast_find_position (w, XFASTINT (after),
2666 &mouse_face_end_col, 2679 &mouse_face_end_col,
2667 &mouse_face_end_row); 2680 &mouse_face_end_row);
2668 mouse_face_window = window; 2681 Qmouse_face_window = window;
2669 2682
2670 mouse_face_face_id 2683 mouse_face_face_id
2671 = face_at_buffer_position (w, pos, 0, 0, 2684 = face_at_buffer_position (w, pos, 0, 0,
@@ -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,
@@ -2787,33 +2800,31 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event)
2787 Set *time to the time the mouse was at the returned position. 2800 Set *time to the time the mouse was at the returned position.
2788 2801
2789 This should clear mouse_moved until the next motion 2802 This should clear mouse_moved until the next motion
2790 event arrives. 2803 event arrives. */
2791
2792 NOT CURRENTLY INVOKED: see mouse_position_hook below. */
2793static void 2804static void
2794term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, 2805term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
2795 enum scroll_bar_part *part, Lisp_Object *x, 2806 enum scroll_bar_part *part, Lisp_Object *x,
2796 Lisp_Object *y, unsigned long *time) 2807 Lisp_Object *y, unsigned long *time)
2797{ 2808{
2798 Gpm_Event event;
2799 struct timeval now; 2809 struct timeval now;
2800 int i; 2810 Lisp_Object frame, window;
2801 2811 struct window *w;
2802 BLOCK_INPUT;
2803 2812
2804 *fp = SELECTED_FRAME (); 2813 *fp = SELECTED_FRAME ();
2814 (*fp)->mouse_moved = 0;
2805 2815
2806 *bar_window = Qnil; 2816 *bar_window = Qnil;
2807 *part = 0; 2817 *part = 0;
2808 2818
2809 i = Gpm_GetSnapshot (&event); 2819 XSETINT (*x, last_mouse_x);
2820 XSETINT (*y, last_mouse_y);
2821 XSETFRAME (frame, *fp);
2822 window = Fwindow_at (*x, *y, frame);
2810 2823
2811 XSETINT (*x, event.x); 2824 XSETINT (*x, last_mouse_x - WINDOW_LEFT_EDGE_COL (XWINDOW (window)));
2812 XSETINT (*y, event.y); 2825 XSETINT (*y, last_mouse_y - WINDOW_TOP_EDGE_LINE (XWINDOW (window)));
2813 gettimeofday(&now, 0); 2826 gettimeofday(&now, 0);
2814 *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); 2827 *time = (now.tv_sec * 1000) + (now.tv_usec / 1000);
2815
2816 UNBLOCK_INPUT;
2817} 2828}
2818 2829
2819/* Prepare a mouse-event in *RESULT for placement in the input queue. 2830/* Prepare a mouse-event in *RESULT for placement in the input queue.
@@ -2912,7 +2923,7 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct in
2912 name = (const char *) ttyname (0); 2923 name = (const char *) ttyname (0);
2913 fd = open (name, O_WRONLY); 2924 fd = open (name, O_WRONLY);
2914 ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1); 2925 ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1);
2915 close(fd); 2926 close (fd);
2916 2927
2917 term_mouse_movement (f, event); 2928 term_mouse_movement (f, event);
2918 2929
@@ -2927,7 +2938,6 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct in
2927 else { 2938 else {
2928 f->mouse_moved = 0; 2939 f->mouse_moved = 0;
2929 term_mouse_click (&ie, event, f); 2940 term_mouse_click (&ie, event, f);
2930 //kbd_buffer_store_event_hold (&ie, hold_quit);
2931 } 2941 }
2932 2942
2933 done: 2943 done:
@@ -3259,11 +3269,8 @@ init_tty (char *name, char *terminal_type, int must_succeed)
3259 encode_terminal_bufsize = 0; 3269 encode_terminal_bufsize = 0;
3260 3270
3261#ifdef HAVE_GPM 3271#ifdef HAVE_GPM
3262 /* TODO: Can't get Gpm_Snapshot in term_mouse_position to work: test with 3272 mouse_position_hook = term_mouse_position;
3263 (mouse-position). Also set-mouse-position won't work as is. */ 3273 Qmouse_face_window = Qnil;
3264 /* mouse_position_hook = term_mouse_position; */
3265
3266 mouse_face_window = Qnil;
3267#endif 3274#endif
3268 3275
3269#ifdef WINDOWSNT 3276#ifdef WINDOWSNT
@@ -3899,6 +3906,8 @@ bigger, or it may make it blink, or it may do nothing at all. */);
3899#ifdef HAVE_GPM 3906#ifdef HAVE_GPM
3900 defsubr (&Sterm_open_connection); 3907 defsubr (&Sterm_open_connection);
3901 defsubr (&Sterm_close_connection); 3908 defsubr (&Sterm_close_connection);
3909
3910 staticpro (&Qmouse_face_window);
3902#endif /* HAVE_GPM */ 3911#endif /* HAVE_GPM */
3903} 3912}
3904 3913