diff options
| author | Jan Djärv | 2009-07-03 11:07:02 +0000 |
|---|---|---|
| committer | Jan Djärv | 2009-07-03 11:07:02 +0000 |
| commit | e044e4fcd50c4db40c9efb40dd395bace59f287b (patch) | |
| tree | b5bae9d80138aba8501ad0d4cbb56cce5492dd09 /src | |
| parent | 2e9b968b289df9e1237d21253c8057789fb33808 (diff) | |
| download | emacs-e044e4fcd50c4db40c9efb40dd395bace59f287b.tar.gz emacs-e044e4fcd50c4db40c9efb40dd395bace59f287b.zip | |
* xterm.h (struct x_display_info): Add invisible_cursor.
(struct x_output): Add current_cursor.
* xterm.c (XTtoggle_invisible_pointer): New function.
(x_define_frame_cursor): Don't define cursor if invisible or the
same as before. Set current_cursor.
(x_create_terminal): Set toggle_invisible_pointer_hook.
* xfns.c (make_invisible_cursor): New function.
(x_set_mouse_color): Call make_invisible_cursor.
Set current_cursor.
(x_window): Set current_cursor.
* termhooks.h (struct terminal): Add toggle_invisible_pointer_hook.
* keyboard.c (command_loop_1): Call frame_make_pointer_invisible after
inserting a character.
(read_avail_input): Call frame_make_pointer_visible.
* frame.c (Vmake_pointer_invisible): New variable.
(frame_make_pointer_invisible, frame_make_pointer_visible): New
functions.
(syms_of_frame): DEFVAR make-pointer-invisible, initialize to Qt.
* frame.h: Declare frame_make_pointer_invisible and
frame_make_pointer_visible.
(struct frame): Add pointer_invisible.
* cus-start.el (all): Added make-pointer-invisible.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 30 | ||||
| -rw-r--r-- | src/frame.c | 39 | ||||
| -rw-r--r-- | src/frame.h | 7 | ||||
| -rw-r--r-- | src/keyboard.c | 4 | ||||
| -rw-r--r-- | src/termhooks.h | 1 | ||||
| -rw-r--r-- | src/xfns.c | 39 | ||||
| -rw-r--r-- | src/xterm.c | 27 | ||||
| -rw-r--r-- | src/xterm.h | 4 |
8 files changed, 145 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 52764078844..5f852a75496 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,33 @@ | |||
| 1 | 2009-07-03 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * xterm.h (struct x_display_info): Add invisible_cursor. | ||
| 4 | (struct x_output): Add current_cursor. | ||
| 5 | |||
| 6 | * xterm.c (XTtoggle_invisible_pointer): New function. | ||
| 7 | (x_define_frame_cursor): Don't define cursor if invisible or the | ||
| 8 | same as before. Set current_cursor. | ||
| 9 | (x_create_terminal): Set toggle_invisible_pointer_hook. | ||
| 10 | |||
| 11 | * xfns.c (make_invisible_cursor): New function. | ||
| 12 | (x_set_mouse_color): Call make_invisible_cursor. | ||
| 13 | Set current_cursor. | ||
| 14 | (x_window): Set current_cursor. | ||
| 15 | |||
| 16 | * termhooks.h (struct terminal): Add toggle_invisible_pointer_hook. | ||
| 17 | |||
| 18 | * keyboard.c (command_loop_1): Call frame_make_pointer_invisible after | ||
| 19 | inserting a character. | ||
| 20 | (read_avail_input): Call frame_make_pointer_visible. | ||
| 21 | |||
| 22 | * frame.c (Vmake_pointer_invisible): New variable. | ||
| 23 | (frame_make_pointer_invisible, frame_make_pointer_visible): New | ||
| 24 | functions. | ||
| 25 | (syms_of_frame): DEFVAR make-pointer-invisible, initialize to Qt. | ||
| 26 | |||
| 27 | * frame.h: Declare frame_make_pointer_invisible and | ||
| 28 | frame_make_pointer_visible. | ||
| 29 | (struct frame): Add pointer_invisible. | ||
| 30 | |||
| 1 | 2009-07-02 Jan Djärv <jan.h.d@swipnet.se> | 31 | 2009-07-02 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 32 | ||
| 3 | * gtkutil.c (xg_frame_set_char_size): Do set width/height if the | 33 | * gtkutil.c (xg_frame_set_char_size): Do set width/height if the |
diff --git a/src/frame.c b/src/frame.c index 506a4225a93..fa50d8752df 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -52,6 +52,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 52 | #endif | 52 | #endif |
| 53 | 53 | ||
| 54 | 54 | ||
| 55 | /* If we shall make pointer invisible when typing or not. */ | ||
| 56 | Lisp_Object Vmake_pointer_invisible; | ||
| 57 | |||
| 55 | #ifdef HAVE_WINDOW_SYSTEM | 58 | #ifdef HAVE_WINDOW_SYSTEM |
| 56 | 59 | ||
| 57 | /* The name we're using in resource queries. Most often "emacs". */ | 60 | /* The name we're using in resource queries. Most often "emacs". */ |
| @@ -4350,6 +4353,37 @@ x_figure_window_size (f, parms, toolbar_p) | |||
| 4350 | 4353 | ||
| 4351 | #endif /* HAVE_WINDOW_SYSTEM */ | 4354 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 4352 | 4355 | ||
| 4356 | void | ||
| 4357 | frame_make_pointer_invisible () | ||
| 4358 | { | ||
| 4359 | if (! NILP (Vmake_pointer_invisible)) | ||
| 4360 | { | ||
| 4361 | struct frame *f = SELECTED_FRAME (); | ||
| 4362 | if (f && !f->pointer_invisible | ||
| 4363 | && FRAME_TERMINAL (f)->toggle_invisible_pointer_hook) | ||
| 4364 | { | ||
| 4365 | f->mouse_moved = 0; | ||
| 4366 | FRAME_TERMINAL (f)->toggle_invisible_pointer_hook (f, 1); | ||
| 4367 | f->pointer_invisible = 1; | ||
| 4368 | } | ||
| 4369 | } | ||
| 4370 | } | ||
| 4371 | |||
| 4372 | void | ||
| 4373 | frame_make_pointer_visible () | ||
| 4374 | { | ||
| 4375 | /* We don't check Vmake_pointer_invisible here in case the | ||
| 4376 | pointer was invisible when Vmake_pointer_invisible was set to nil. */ | ||
| 4377 | |||
| 4378 | struct frame *f = SELECTED_FRAME (); | ||
| 4379 | if (f && f->pointer_invisible && f->mouse_moved | ||
| 4380 | && FRAME_TERMINAL (f)->toggle_invisible_pointer_hook) | ||
| 4381 | { | ||
| 4382 | FRAME_TERMINAL (f)->toggle_invisible_pointer_hook (f, 0); | ||
| 4383 | f->pointer_invisible = 0; | ||
| 4384 | } | ||
| 4385 | } | ||
| 4386 | |||
| 4353 | 4387 | ||
| 4354 | 4388 | ||
| 4355 | /*********************************************************************** | 4389 | /*********************************************************************** |
| @@ -4552,6 +4586,11 @@ is over the clickable text. However, the mouse shape still indicates | |||
| 4552 | when the mouse is over clickable text. */); | 4586 | when the mouse is over clickable text. */); |
| 4553 | Vmouse_highlight = Qt; | 4587 | Vmouse_highlight = Qt; |
| 4554 | 4588 | ||
| 4589 | DEFVAR_LISP ("make-pointer-invisible", &Vmake_pointer_invisible, | ||
| 4590 | doc: /* If non-nil, make pointer invisible while typing. | ||
| 4591 | The pointer becomes visible again when the mouse is moved. */); | ||
| 4592 | Vmake_pointer_invisible = Qt; | ||
| 4593 | |||
| 4555 | DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions, | 4594 | DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions, |
| 4556 | doc: /* Functions to be run before deleting a frame. | 4595 | doc: /* Functions to be run before deleting a frame. |
| 4557 | The functions are run with one arg, the frame to be deleted. | 4596 | The functions are run with one arg, the frame to be deleted. |
diff --git a/src/frame.h b/src/frame.h index 205141ec830..9fc326b6f1a 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -440,6 +440,9 @@ struct frame | |||
| 440 | since the last time we checked. */ | 440 | since the last time we checked. */ |
| 441 | unsigned char mouse_moved :1; | 441 | unsigned char mouse_moved :1; |
| 442 | 442 | ||
| 443 | /* Nonzero means that the pointer is invisible. */ | ||
| 444 | unsigned char pointer_invisible :1; | ||
| 445 | |||
| 443 | /* If can_have_scroll_bars is non-zero, this is non-zero if we should | 446 | /* If can_have_scroll_bars is non-zero, this is non-zero if we should |
| 444 | actually display them on this frame. */ | 447 | actually display them on this frame. */ |
| 445 | enum vertical_scroll_bar_type vertical_scroll_bar_type; | 448 | enum vertical_scroll_bar_type vertical_scroll_bar_type; |
| @@ -830,6 +833,8 @@ extern struct frame *make_frame_without_minibuffer P_ ((Lisp_Object, | |||
| 830 | Lisp_Object)); | 833 | Lisp_Object)); |
| 831 | #endif /* HAVE_WINDOW_SYSTEM */ | 834 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 832 | extern int other_visible_frames P_ ((struct frame *)); | 835 | extern int other_visible_frames P_ ((struct frame *)); |
| 836 | extern void frame_make_pointer_invisible P_ ((void)); | ||
| 837 | extern void frame_make_pointer_visible P_ ((void)); | ||
| 833 | 838 | ||
| 834 | extern Lisp_Object Vframe_list; | 839 | extern Lisp_Object Vframe_list; |
| 835 | extern Lisp_Object Vdefault_frame_alist; | 840 | extern Lisp_Object Vdefault_frame_alist; |
| @@ -1110,7 +1115,7 @@ extern Lisp_Object Vframe_alpha_lower_limit; | |||
| 1110 | extern void x_set_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 1115 | extern void x_set_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 1111 | 1116 | ||
| 1112 | extern void validate_x_resource_name P_ ((void)); | 1117 | extern void validate_x_resource_name P_ ((void)); |
| 1113 | 1118 | ||
| 1114 | extern Lisp_Object display_x_get_resource (Display_Info *, | 1119 | extern Lisp_Object display_x_get_resource (Display_Info *, |
| 1115 | Lisp_Object attribute, | 1120 | Lisp_Object attribute, |
| 1116 | Lisp_Object class, | 1121 | Lisp_Object class, |
diff --git a/src/keyboard.c b/src/keyboard.c index 55862e1da33..b8714a393ec 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1867,6 +1867,8 @@ command_loop_1 () | |||
| 1867 | if (value == 2) | 1867 | if (value == 2) |
| 1868 | nonundocount = 0; | 1868 | nonundocount = 0; |
| 1869 | 1869 | ||
| 1870 | frame_make_pointer_invisible (); | ||
| 1871 | |||
| 1870 | if (! NILP (Vpost_command_hook)) | 1872 | if (! NILP (Vpost_command_hook)) |
| 1871 | /* Put this before calling adjust_point_for_property | 1873 | /* Put this before calling adjust_point_for_property |
| 1872 | so it will only get called once in any case. */ | 1874 | so it will only get called once in any case. */ |
| @@ -7134,6 +7136,8 @@ read_avail_input (expected) | |||
| 7134 | if (err && !nread) | 7136 | if (err && !nread) |
| 7135 | nread = -1; | 7137 | nread = -1; |
| 7136 | 7138 | ||
| 7139 | frame_make_pointer_visible (); | ||
| 7140 | |||
| 7137 | return nread; | 7141 | return nread; |
| 7138 | } | 7142 | } |
| 7139 | 7143 | ||
diff --git a/src/termhooks.h b/src/termhooks.h index 33d89674273..bd9b4ec4575 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -427,6 +427,7 @@ struct terminal | |||
| 427 | void (*delete_glyphs_hook) P_ ((struct frame *, int)); | 427 | void (*delete_glyphs_hook) P_ ((struct frame *, int)); |
| 428 | 428 | ||
| 429 | void (*ring_bell_hook) P_ ((struct frame *f)); | 429 | void (*ring_bell_hook) P_ ((struct frame *f)); |
| 430 | void (*toggle_invisible_pointer_hook) P_ ((struct frame *f, int invisible)); | ||
| 430 | 431 | ||
| 431 | void (*reset_terminal_modes_hook) P_ ((struct terminal *)); | 432 | void (*reset_terminal_modes_hook) P_ ((struct terminal *)); |
| 432 | void (*set_terminal_modes_hook) P_ ((struct terminal *)); | 433 | void (*set_terminal_modes_hook) P_ ((struct terminal *)); |
diff --git a/src/xfns.c b/src/xfns.c index 9036ff171fa..237b1c911ee 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -941,6 +941,35 @@ x_set_background_color (f, arg, oldval) | |||
| 941 | } | 941 | } |
| 942 | } | 942 | } |
| 943 | 943 | ||
| 944 | static Cursor | ||
| 945 | make_invisible_cursor (f) | ||
| 946 | struct frame *f; | ||
| 947 | { | ||
| 948 | Display *dpy = FRAME_X_DISPLAY (f); | ||
| 949 | static char const no_data[] = { 0 }; | ||
| 950 | Pixmap pix; | ||
| 951 | XColor col; | ||
| 952 | Cursor c; | ||
| 953 | |||
| 954 | x_catch_errors (dpy); | ||
| 955 | pix = XCreateBitmapFromData (dpy, FRAME_X_DISPLAY_INFO (f)->root_window, | ||
| 956 | no_data, 1, 1); | ||
| 957 | if (! x_had_errors_p (dpy) && pix != None) | ||
| 958 | { | ||
| 959 | col.pixel = 0; | ||
| 960 | col.red = col.green = col.blue = 0; | ||
| 961 | col.flags = DoRed | DoGreen | DoBlue; | ||
| 962 | c = XCreatePixmapCursor (dpy, pix, pix, &col, &col, 0, 0); | ||
| 963 | if (x_had_errors_p (dpy) || c == None) | ||
| 964 | c = 0; | ||
| 965 | XFreePixmap (dpy, pix); | ||
| 966 | } | ||
| 967 | |||
| 968 | x_uncatch_errors (); | ||
| 969 | |||
| 970 | return c; | ||
| 971 | } | ||
| 972 | |||
| 944 | void | 973 | void |
| 945 | x_set_mouse_color (f, arg, oldval) | 974 | x_set_mouse_color (f, arg, oldval) |
| 946 | struct frame *f; | 975 | struct frame *f; |
| @@ -1046,8 +1075,12 @@ x_set_mouse_color (f, arg, oldval) | |||
| 1046 | } | 1075 | } |
| 1047 | 1076 | ||
| 1048 | if (FRAME_X_WINDOW (f) != 0) | 1077 | if (FRAME_X_WINDOW (f) != 0) |
| 1049 | XDefineCursor (dpy, FRAME_X_WINDOW (f), cursor); | 1078 | XDefineCursor (dpy, FRAME_X_WINDOW (f), |
| 1079 | f->output_data.x->current_cursor = cursor); | ||
| 1050 | 1080 | ||
| 1081 | if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor == 0) | ||
| 1082 | FRAME_X_DISPLAY_INFO (f)->invisible_cursor = make_invisible_cursor (f); | ||
| 1083 | |||
| 1051 | if (cursor != x->text_cursor | 1084 | if (cursor != x->text_cursor |
| 1052 | && x->text_cursor != 0) | 1085 | && x->text_cursor != 0) |
| 1053 | XFreeCursor (dpy, x->text_cursor); | 1086 | XFreeCursor (dpy, x->text_cursor); |
| @@ -2671,7 +2704,7 @@ x_window (f, window_prompting, minibuffer_only) | |||
| 2671 | } | 2704 | } |
| 2672 | 2705 | ||
| 2673 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | 2706 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), |
| 2674 | f->output_data.x->text_cursor); | 2707 | f->output.x->current_cursor = f->output_data.x->text_cursor); |
| 2675 | 2708 | ||
| 2676 | UNBLOCK_INPUT; | 2709 | UNBLOCK_INPUT; |
| 2677 | 2710 | ||
| @@ -2816,7 +2849,7 @@ x_window (f) | |||
| 2816 | } | 2849 | } |
| 2817 | 2850 | ||
| 2818 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | 2851 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), |
| 2819 | f->output_data.x->text_cursor); | 2852 | f->output.x->current_cursor = f->output_data.x->text_cursor); |
| 2820 | 2853 | ||
| 2821 | UNBLOCK_INPUT; | 2854 | UNBLOCK_INPUT; |
| 2822 | 2855 | ||
diff --git a/src/xterm.c b/src/xterm.c index 77dc48f9a64..c034faaec2e 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -3128,6 +3128,25 @@ XTflash (f) | |||
| 3128 | #endif /* defined (HAVE_TIMEVAL) && defined (HAVE_SELECT) */ | 3128 | #endif /* defined (HAVE_TIMEVAL) && defined (HAVE_SELECT) */ |
| 3129 | 3129 | ||
| 3130 | 3130 | ||
| 3131 | static void | ||
| 3132 | XTtoggle_invisible_pointer (f, invisible) | ||
| 3133 | FRAME_PTR f; | ||
| 3134 | int invisible; | ||
| 3135 | { | ||
| 3136 | BLOCK_INPUT; | ||
| 3137 | if (invisible) | ||
| 3138 | { | ||
| 3139 | if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor != 0) | ||
| 3140 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 3141 | FRAME_X_DISPLAY_INFO (f)->invisible_cursor); | ||
| 3142 | } | ||
| 3143 | else | ||
| 3144 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 3145 | f->output_data.x->current_cursor); | ||
| 3146 | UNBLOCK_INPUT; | ||
| 3147 | } | ||
| 3148 | |||
| 3149 | |||
| 3131 | /* Make audible bell. */ | 3150 | /* Make audible bell. */ |
| 3132 | 3151 | ||
| 3133 | void | 3152 | void |
| @@ -4568,7 +4587,7 @@ x_create_toolkit_scroll_bar (f, bar) | |||
| 4568 | /* Set the cursor to an arrow. I didn't find a resource to do that. | 4587 | /* Set the cursor to an arrow. I didn't find a resource to do that. |
| 4569 | And I'm wondering why it hasn't an arrow cursor by default. */ | 4588 | And I'm wondering why it hasn't an arrow cursor by default. */ |
| 4570 | XDefineCursor (XtDisplay (widget), XtWindow (widget), | 4589 | XDefineCursor (XtDisplay (widget), XtWindow (widget), |
| 4571 | f->output_data.x->nontext_cursor); | 4590 | f->output_data.x->nontext_cursor); |
| 4572 | 4591 | ||
| 4573 | #else /* !USE_MOTIF i.e. use Xaw */ | 4592 | #else /* !USE_MOTIF i.e. use Xaw */ |
| 4574 | 4593 | ||
| @@ -7344,7 +7363,10 @@ x_define_frame_cursor (f, cursor) | |||
| 7344 | struct frame *f; | 7363 | struct frame *f; |
| 7345 | Cursor cursor; | 7364 | Cursor cursor; |
| 7346 | { | 7365 | { |
| 7347 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor); | 7366 | if (!f->pointer_invisible |
| 7367 | && f->output_data.x->current_cursor != cursor) | ||
| 7368 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor); | ||
| 7369 | f->output_data.x->current_cursor = cursor; | ||
| 7348 | } | 7370 | } |
| 7349 | 7371 | ||
| 7350 | 7372 | ||
| @@ -10657,6 +10679,7 @@ x_create_terminal (struct x_display_info *dpyinfo) | |||
| 10657 | terminal->ins_del_lines_hook = x_ins_del_lines; | 10679 | terminal->ins_del_lines_hook = x_ins_del_lines; |
| 10658 | terminal->delete_glyphs_hook = x_delete_glyphs; | 10680 | terminal->delete_glyphs_hook = x_delete_glyphs; |
| 10659 | terminal->ring_bell_hook = XTring_bell; | 10681 | terminal->ring_bell_hook = XTring_bell; |
| 10682 | terminal->toggle_invisible_pointer_hook = XTtoggle_invisible_pointer; | ||
| 10660 | terminal->reset_terminal_modes_hook = XTreset_terminal_modes; | 10683 | terminal->reset_terminal_modes_hook = XTreset_terminal_modes; |
| 10661 | terminal->set_terminal_modes_hook = XTset_terminal_modes; | 10684 | terminal->set_terminal_modes_hook = XTset_terminal_modes; |
| 10662 | terminal->update_begin_hook = x_update_begin; | 10685 | terminal->update_begin_hook = x_update_begin; |
diff --git a/src/xterm.h b/src/xterm.h index 3c738861af4..0ab19fdd8dc 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -166,6 +166,9 @@ struct x_display_info | |||
| 166 | /* The cursor to use for vertical scroll bars. */ | 166 | /* The cursor to use for vertical scroll bars. */ |
| 167 | Cursor vertical_scroll_bar_cursor; | 167 | Cursor vertical_scroll_bar_cursor; |
| 168 | 168 | ||
| 169 | /* The invisible cursor used for pointer blanking. */ | ||
| 170 | Cursor invisible_cursor; | ||
| 171 | |||
| 169 | #ifdef USE_GTK | 172 | #ifdef USE_GTK |
| 170 | /* The GDK cursor for scroll bars and popup menus. */ | 173 | /* The GDK cursor for scroll bars and popup menus. */ |
| 171 | GdkCursor *xg_cursor; | 174 | GdkCursor *xg_cursor; |
| @@ -522,6 +525,7 @@ struct x_output | |||
| 522 | Cursor hand_cursor; | 525 | Cursor hand_cursor; |
| 523 | Cursor hourglass_cursor; | 526 | Cursor hourglass_cursor; |
| 524 | Cursor horizontal_drag_cursor; | 527 | Cursor horizontal_drag_cursor; |
| 528 | Cursor current_cursor; | ||
| 525 | 529 | ||
| 526 | /* Window whose cursor is hourglass_cursor. This window is temporarily | 530 | /* Window whose cursor is hourglass_cursor. This window is temporarily |
| 527 | mapped to display an hourglass cursor. */ | 531 | mapped to display an hourglass cursor. */ |