aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2007-09-28 19:47:02 +0000
committerStefan Monnier2007-09-28 19:47:02 +0000
commit6178ce5e8b701c44d7c31ed54fa8021f049784d1 (patch)
treea446b34b6fb649865a6dc3870c4c63ac29125ca1 /src
parent977ede64fee880cc025955e39ed1f055240abe50 (diff)
downloademacs-6178ce5e8b701c44d7c31ed54fa8021f049784d1.tar.gz
emacs-6178ce5e8b701c44d7c31ed54fa8021f049784d1.zip
(mouse_face_window): Rename from Qmouse_face_window. Update all users.
(handle_one_term_event): Use Gpm_DrawPointer. (Fgpm_mouse_start): Rename from Fterm_open_connection. Signal errors instead of returning nil. Always return nil. (Fgpm_mouse_stop): Rename from Fterm_close_connection. Make it a noop if gpm-mouse was not activated. (syms_of_term): Update names.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/term.c66
2 files changed, 38 insertions, 39 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e1408227092..f7698a2cfc3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
12007-09-28 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * term.c (mouse_face_window): Rename from Qmouse_face_window.
4 Update all users.
5 (handle_one_term_event): Use Gpm_DrawPointer.
6 (Fgpm_mouse_start): Rename from Fterm_open_connection.
7 Signal errors instead of returning nil. Always return nil.
8 (Fgpm_mouse_stop): Rename from Fterm_close_connection.
9 Make it a noop if gpm-mouse was not activated.
10 (syms_of_term): Update names.
11
12007-09-27 Stefan Monnier <monnier@iro.umontreal.ca> 122007-09-27 Stefan Monnier <monnier@iro.umontreal.ca>
2 13
3 * sysdep.c (narrow_foreground_group, widen_foreground_group): Static. 14 * sysdep.c (narrow_foreground_group, widen_foreground_group): Static.
diff --git a/src/term.c b/src/term.c
index 62f7a4da77e..6dbfb5daee8 100644
--- a/src/term.c
+++ b/src/term.c
@@ -202,7 +202,7 @@ struct tty_display_info *gpm_tty = NULL;
202static int mouse_face_beg_row, mouse_face_beg_col; 202static int mouse_face_beg_row, mouse_face_beg_col;
203static int mouse_face_end_row, mouse_face_end_col; 203static int mouse_face_end_row, mouse_face_end_col;
204static int mouse_face_past_end; 204static int mouse_face_past_end;
205static Lisp_Object Qmouse_face_window; 205static Lisp_Object mouse_face_window;
206static int mouse_face_face_id; 206static int mouse_face_face_id;
207 207
208static int pos_x, pos_y; 208static int pos_x, pos_y;
@@ -2360,7 +2360,7 @@ term_mouse_moveto (int x, int y)
2360static void 2360static void
2361term_show_mouse_face (enum draw_glyphs_face draw) 2361term_show_mouse_face (enum draw_glyphs_face draw)
2362{ 2362{
2363 struct window *w = XWINDOW (Qmouse_face_window); 2363 struct window *w = XWINDOW (mouse_face_window);
2364 int save_x, save_y; 2364 int save_x, save_y;
2365 int i; 2365 int i;
2366 2366
@@ -2439,12 +2439,12 @@ term_show_mouse_face (enum draw_glyphs_face draw)
2439static void 2439static void
2440term_clear_mouse_face () 2440term_clear_mouse_face ()
2441{ 2441{
2442 if (!NILP (Qmouse_face_window)) 2442 if (!NILP (mouse_face_window))
2443 term_show_mouse_face (DRAW_NORMAL_TEXT); 2443 term_show_mouse_face (DRAW_NORMAL_TEXT);
2444 2444
2445 mouse_face_beg_row = mouse_face_beg_col = -1; 2445 mouse_face_beg_row = mouse_face_beg_col = -1;
2446 mouse_face_end_row = mouse_face_end_col = -1; 2446 mouse_face_end_row = mouse_face_end_col = -1;
2447 Qmouse_face_window = Qnil; 2447 mouse_face_window = Qnil;
2448} 2448}
2449 2449
2450/* 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.
@@ -2541,7 +2541,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2541 if (!WINDOWP (window)) 2541 if (!WINDOWP (window))
2542 return; 2542 return;
2543 2543
2544 if (!EQ (window, Qmouse_face_window)) 2544 if (!EQ (window, mouse_face_window))
2545 term_clear_mouse_face (); 2545 term_clear_mouse_face ();
2546 2546
2547 w = XWINDOW (window); 2547 w = XWINDOW (window);
@@ -2624,7 +2624,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2624 noverlays = sort_overlays (overlay_vec, noverlays, w); 2624 noverlays = sort_overlays (overlay_vec, noverlays, w);
2625 2625
2626 /* Check mouse-face highlighting. */ 2626 /* Check mouse-face highlighting. */
2627 if (!(EQ (window, Qmouse_face_window) 2627 if (!(EQ (window, mouse_face_window)
2628 && y >= mouse_face_beg_row 2628 && y >= mouse_face_beg_row
2629 && y <= mouse_face_end_row 2629 && y <= mouse_face_end_row
2630 && (y > mouse_face_beg_row 2630 && (y > mouse_face_beg_row
@@ -2674,7 +2674,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2674 = !fast_find_position (w, XFASTINT (after), 2674 = !fast_find_position (w, XFASTINT (after),
2675 &mouse_face_end_col, 2675 &mouse_face_end_col,
2676 &mouse_face_end_row); 2676 &mouse_face_end_row);
2677 Qmouse_face_window = window; 2677 mouse_face_window = window;
2678 2678
2679 mouse_face_face_id 2679 mouse_face_face_id
2680 = face_at_buffer_position (w, pos, 0, 0, 2680 = face_at_buffer_position (w, pos, 0, 0,
@@ -2709,7 +2709,7 @@ term_mouse_highlight (struct frame *f, int x, int y)
2709 = !fast_find_position (w, XFASTINT (after), 2709 = !fast_find_position (w, XFASTINT (after),
2710 &mouse_face_end_col, 2710 &mouse_face_end_col,
2711 &mouse_face_end_row); 2711 &mouse_face_end_row);
2712 Qmouse_face_window = window; 2712 mouse_face_window = window;
2713 2713
2714 mouse_face_face_id 2714 mouse_face_face_id
2715 = face_at_buffer_position (w, pos, 0, 0, 2715 = face_at_buffer_position (w, pos, 0, 0,
@@ -2885,7 +2885,6 @@ int
2885handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct input_event* hold_quit) 2885handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct input_event* hold_quit)
2886{ 2886{
2887 struct frame *f = XFRAME (tty->top_frame); 2887 struct frame *f = XFRAME (tty->top_frame);
2888 int fd;
2889 struct input_event ie; 2888 struct input_event ie;
2890 int do_help = 0; 2889 int do_help = 0;
2891 int count = 0; 2890 int count = 0;
@@ -2895,24 +2894,10 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct in
2895 ie.arg = Qnil; 2894 ie.arg = Qnil;
2896 2895
2897 if (event->type & (GPM_MOVE | GPM_DRAG)) { 2896 if (event->type & (GPM_MOVE | GPM_DRAG)) {
2898 unsigned char buf[6 * sizeof (short)];
2899 unsigned short *arg = (unsigned short *) buf + 1;
2900 const char *name;
2901
2902 previous_help_echo_string = help_echo_string; 2897 previous_help_echo_string = help_echo_string;
2903 help_echo_string = Qnil; 2898 help_echo_string = Qnil;
2904 2899
2905 /* Display mouse pointer */ 2900 Gpm_DrawPointer (event->x, event->y, fileno (tty->output));
2906 buf[sizeof(short) - 1] = 2; /* set selection */
2907
2908 arg[0] = arg[2] = (unsigned short) event->x + gpm_zerobased;
2909 arg[1] = arg[3] = (unsigned short) event->y + gpm_zerobased;
2910 arg[4] = (unsigned short) 3;
2911
2912 name = ttyname (0);
2913 fd = open (name, O_WRONLY);
2914 ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1);
2915 close (fd);
2916 2901
2917 if (!term_mouse_movement (f, event)) 2902 if (!term_mouse_movement (f, event))
2918 help_echo_string = previous_help_echo_string; 2903 help_echo_string = previous_help_echo_string;
@@ -2955,10 +2940,10 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct in
2955 return count; 2940 return count;
2956} 2941}
2957 2942
2958DEFUN ("term-open-connection", Fterm_open_connection, Sterm_open_connection, 2943DEFUN ("gpm-mouse-start", Fgpm_mouse_start, Sgpm_mouse_start,
2959 0, 0, 0, 2944 0, 0, 0,
2960 doc: /* Open a connection to Gpm. 2945 doc: /* Open a connection to Gpm.
2961We only support Gpm on one tty at a time. */) 2946Gpm-mouse can only be activated for one tty at a time. */)
2962 () 2947 ()
2963{ 2948{
2964 struct frame *f = SELECTED_FRAME (); 2949 struct frame *f = SELECTED_FRAME ();
@@ -2967,8 +2952,10 @@ We only support Gpm on one tty at a time. */)
2967 ? (f)->terminal->display_info.tty : NULL); 2952 ? (f)->terminal->display_info.tty : NULL);
2968 Gpm_Connect connection; 2953 Gpm_Connect connection;
2969 2954
2970 if (gpm_tty || !tty) /* Already running, or not applicable. */ 2955 if (gpm_tty)
2971 return Qnil; 2956 error ("Gpm-mouse can only be activated for one tty at a time");
2957 if (!tty)
2958 error ("Gpm-mouse only works in the GNU/Linux console");
2972 2959
2973 connection.eventMask = ~0; 2960 connection.eventMask = ~0;
2974 connection.defaultMask = ~GPM_HARD; 2961 connection.defaultMask = ~GPM_HARD;
@@ -2977,7 +2964,7 @@ We only support Gpm on one tty at a time. */)
2977 gpm_zerobased = 1; 2964 gpm_zerobased = 1;
2978 2965
2979 if (Gpm_Open (&connection, 0) < 0) 2966 if (Gpm_Open (&connection, 0) < 0)
2980 return Qnil; 2967 error ("Gpm-mouse failed to connect to the gpm daemon");
2981 else 2968 else
2982 { 2969 {
2983 gpm_tty = tty; 2970 gpm_tty = tty;
@@ -2987,19 +2974,20 @@ We only support Gpm on one tty at a time. */)
2987 reset_sys_modes (tty); 2974 reset_sys_modes (tty);
2988 init_sys_modes (tty); 2975 init_sys_modes (tty);
2989 add_gpm_wait_descriptor (gpm_fd); 2976 add_gpm_wait_descriptor (gpm_fd);
2990 return Qt; 2977 return Qnil;
2991 } 2978 }
2992} 2979}
2993 2980
2994DEFUN ("term-close-connection", Fterm_close_connection, Sterm_close_connection, 2981DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop,
2995 0, 0, 0, 2982 0, 0, 0,
2996 doc: /* Close a connection to Gpm. */) 2983 doc: /* Close a connection to Gpm. */)
2997 () 2984 ()
2998{ 2985{
2999 delete_gpm_wait_descriptor (gpm_fd); 2986 if (gpm_fd >= 0)
3000 while (Gpm_Close()); /* close all the stack */ 2987 delete_gpm_wait_descriptor (gpm_fd);
3001 gpm_tty = NULL; 2988 while (Gpm_Close()); /* close all the stack */
3002 return Qnil; 2989 gpm_tty = NULL;
2990 return Qnil;
3003} 2991}
3004#endif /* HAVE_GPM */ 2992#endif /* HAVE_GPM */
3005 2993
@@ -3272,7 +3260,7 @@ init_tty (char *name, char *terminal_type, int must_succeed)
3272 3260
3273#ifdef HAVE_GPM 3261#ifdef HAVE_GPM
3274 terminal->mouse_position_hook = term_mouse_position; 3262 terminal->mouse_position_hook = term_mouse_position;
3275 Qmouse_face_window = Qnil; 3263 mouse_face_window = Qnil;
3276#endif 3264#endif
3277 3265
3278#ifdef WINDOWSNT 3266#ifdef WINDOWSNT
@@ -3904,10 +3892,10 @@ bigger, or it may make it blink, or it may do nothing at all. */);
3904 defsubr (&Ssuspend_tty); 3892 defsubr (&Ssuspend_tty);
3905 defsubr (&Sresume_tty); 3893 defsubr (&Sresume_tty);
3906#ifdef HAVE_GPM 3894#ifdef HAVE_GPM
3907 defsubr (&Sterm_open_connection); 3895 defsubr (&Sgpm_mouse_start);
3908 defsubr (&Sterm_close_connection); 3896 defsubr (&Sgpm_mouse_stop);
3909 3897
3910 staticpro (&Qmouse_face_window); 3898 staticpro (&mouse_face_window);
3911#endif /* HAVE_GPM */ 3899#endif /* HAVE_GPM */
3912} 3900}
3913 3901