comparison src/xterm.c @ 111413:d53ee71e7e89

Unify mouse-highlight code for all GUI and TTY sessions. term.c: Remove static mouse_face_* variables. All users changed. (term_show_mouse_face, term_clear_mouse_face) (fast_find_position, term_mouse_highlight): Functions deleted. (tty_draw_row_with_mouse_face): New function. (term_mouse_movement): Call note_mouse_highlight instead of term_mouse_highlight. nsterm.m (ns_update_window_begin, ns_update_window_end) (ns_update_end, x_destroy_window, ns_frame_up_to_date) (ns_dumpglyphs_box_or_relief, ns_maybe_dumpglyphs_background) (ns_dumpglyphs_image, ns_dumpglyphs_stretch) (ns_initialize_display_info, keyDown, mouseMoved, mouseExited): Replace Display_Info with Mouse_HLInfo everywhere where mouse_face_* members were accessed for mouse highlight purposes. xterm.c (x_update_window_begin, x_update_window_end) (x_update_end, XTframe_up_to_date, x_set_mouse_face_gc) (handle_one_xevent, x_free_frame_resources, x_term_init): Replace Display_Info with Mouse_HLInfo everywhere where mouse_face_* members were accessed for mouse highlight purposes. w32term.c (x_update_window_begin, x_update_window_end) (x_update_end, w32_read_socket, x_free_frame_resources) (w32_initialize_display_info): Replace Display_Info with Mouse_HLInfo everywhere where mouse_face_* members were accessed for mouse highlight purposes. xdisp.c (show_mouse_face, note_mode_line_or_margin_highlight) (note_mouse_highlight) [HAVE_WINDOW_SYSTEM]: Don't run GUI code unless the frame is on a window-system. (get_tool_bar_item, handle_tool_bar_click) (note_tool_bar_highlight, draw_glyphs, erase_phys_cursor) (show_mouse_face, clear_mouse_face, coords_in_mouse_face_p) (note_mode_line_or_margin_highlight, note_mouse_highlight) (x_clear_window_mouse_face, cancel_mouse_face, expose_frame): Replace Display_Info with Mouse_HLInfo everywhere where mouse_face_* members were accessed for mouse highlight purposes. (coords_in_mouse_face_p): Move prototype out of the HAVE_WINDOW_SYSTEM conditional. (x_y_to_hpos_vpos, frame_to_window_pixel_xy): Move out of the HAVE_WINDOW_SYSTEM block. (try_window_id) [HAVE_GPM || MSDOS]: Call x_clear_window_mouse_face. (draw_row_with_mouse_face): Implementation for HAVE_WINDOW_SYSTEM systems. Call tty_draw_row_with_mouse_face for TTY systems. (show_mouse_face): Call draw_row_with_mouse_face, instead of calling draw_glyphs directly. (show_mouse_face, clear_mouse_face, coords_in_mouse_face_p) (cursor_in_mouse_face_p, rows_from_pos_range) (mouse_face_from_buffer_pos, mouse_face_from_string_pos) (note_mode_line_or_margin_highlight, note_mouse_highlight) (x_clear_window_mouse_face, cancel_mouse_face): Move out of the HAVE_WINDOW_SYSTEM block. Ifdef away window-system specific fragments. (note_mouse_highlight): Call popup_activated for MSDOS as well. Clear mouse highlight if pointer is over glyphs whose OBJECT is an integer. (mouse_face_from_buffer_pos): Add parentheses around && within ||. (x_consider_frame_title, tool_bar_lines_needed): Move prototypes to HAVE_WINDOW_SYSTEM-only part. (get_window_cursor_type): Move inside a HAVE_WINDOW_SYSTEM-only part. Remove "#ifdef HAVE_WINDOW_SYSTEM" from body of function. (null_glyph_slice): Move declaration into HAVE_WINDOW_SYSTEM-only part. dispnew.c (mirror_make_current): Set Y coordinate of the mode-line and header-line rows. (init_display): Setup initial frame's output_data for text terminal frames. xmenu.c (popup_activated): Don't define on MSDOS, which now has its own definition on msdos.c. msdos.c (show_mouse_face, clear_mouse_face) (fast_find_position, IT_note_mode_line_highlight) (IT_note_mouse_highlight): Functions deleted. (IT_frame_up_to_date, dos_rawgetc): Call note_mouse_highlight instead of IT_note_mouse_highlight. (draw_row_with_mouse_face, popup_activated): New functions. (dos_set_window_size, draw_row_with_mouse_face, IT_update_begin) (IT_update_end, IT_frame_up_to_date, internal_terminal_init) (dos_rawgetc): Replace Display_Info with Mouse_HLInfo everywhere where mouse_face_* members were accessed for mouse highlight purposes. msdos.h (initialize_msdos_display): Add prototype. frame.h (MOUSE_HL_INFO): New macro. lisp.h (Mouse_HLInfo): New data type. xterm.h (struct x_display_info): w32term.h (struct w32_display_info): nsterm.h (struct ns_display_info): termchar.h (struct tty_display_info): Use it instead of mouse_face_* members. dispextern.h (show_mouse_face, clear_mouse_face): Update type of 1st argument. (frame_to_window_pixel_xy, note_mouse_highlight) (x_clear_window_mouse_face, cancel_mouse_face, clear_mouse_face) (show_mouse_face, cursor_in_mouse_face_p): Move prototypes out of HAVE_WINDOW_SYSTEM conditional. (draw_row_with_mouse_face): Declare prototype. (tty_draw_row_with_mouse_face): Declare prototype.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 06 Nov 2010 10:28:31 +0200
parents 707be8bc83af f79bd5f589f7
children 132f2dfd549f
comparison
equal deleted inserted replaced
111412:cc7702f421a0 111413:d53ee71e7e89
546 546
547 static void 547 static void
548 x_update_window_begin (struct window *w) 548 x_update_window_begin (struct window *w)
549 { 549 {
550 struct frame *f = XFRAME (WINDOW_FRAME (w)); 550 struct frame *f = XFRAME (WINDOW_FRAME (w));
551 struct x_display_info *display_info = FRAME_X_DISPLAY_INFO (f); 551 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
552 552
553 updated_window = w; 553 updated_window = w;
554 set_output_cursor (&w->cursor); 554 set_output_cursor (&w->cursor);
555 555
556 BLOCK_INPUT; 556 BLOCK_INPUT;
557 557
558 if (f == display_info->mouse_face_mouse_frame) 558 if (f == hlinfo->mouse_face_mouse_frame)
559 { 559 {
560 /* Don't do highlighting for mouse motion during the update. */ 560 /* Don't do highlighting for mouse motion during the update. */
561 display_info->mouse_face_defer = 1; 561 hlinfo->mouse_face_defer = 1;
562 562
563 /* If F needs to be redrawn, simply forget about any prior mouse 563 /* If F needs to be redrawn, simply forget about any prior mouse
564 highlighting. */ 564 highlighting. */
565 if (FRAME_GARBAGED_P (f)) 565 if (FRAME_GARBAGED_P (f))
566 display_info->mouse_face_window = Qnil; 566 hlinfo->mouse_face_window = Qnil;
567 } 567 }
568 568
569 UNBLOCK_INPUT; 569 UNBLOCK_INPUT;
570 } 570 }
571 571
601 here. */ 601 here. */
602 602
603 static void 603 static void
604 x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritten_p) 604 x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritten_p)
605 { 605 {
606 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame)); 606 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
607 607
608 if (!w->pseudo_window_p) 608 if (!w->pseudo_window_p)
609 { 609 {
610 BLOCK_INPUT; 610 BLOCK_INPUT;
611 611
622 622
623 /* If a row with mouse-face was overwritten, arrange for 623 /* If a row with mouse-face was overwritten, arrange for
624 XTframe_up_to_date to redisplay the mouse highlight. */ 624 XTframe_up_to_date to redisplay the mouse highlight. */
625 if (mouse_face_overwritten_p) 625 if (mouse_face_overwritten_p)
626 { 626 {
627 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 627 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
628 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 628 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
629 dpyinfo->mouse_face_window = Qnil; 629 hlinfo->mouse_face_window = Qnil;
630 } 630 }
631 631
632 updated_window = NULL; 632 updated_window = NULL;
633 } 633 }
634 634
638 638
639 static void 639 static void
640 x_update_end (struct frame *f) 640 x_update_end (struct frame *f)
641 { 641 {
642 /* Mouse highlight may be displayed again. */ 642 /* Mouse highlight may be displayed again. */
643 FRAME_X_DISPLAY_INFO (f)->mouse_face_defer = 0; 643 MOUSE_HL_INFO (f)->mouse_face_defer = 0;
644 644
645 #ifndef XFlush 645 #ifndef XFlush
646 BLOCK_INPUT; 646 BLOCK_INPUT;
647 XFlush (FRAME_X_DISPLAY (f)); 647 XFlush (FRAME_X_DISPLAY (f));
648 UNBLOCK_INPUT; 648 UNBLOCK_INPUT;
657 static void 657 static void
658 XTframe_up_to_date (struct frame *f) 658 XTframe_up_to_date (struct frame *f)
659 { 659 {
660 if (FRAME_X_P (f)) 660 if (FRAME_X_P (f))
661 { 661 {
662 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 662 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
663 663
664 if (dpyinfo->mouse_face_deferred_gc 664 if (hlinfo->mouse_face_deferred_gc
665 || f == dpyinfo->mouse_face_mouse_frame) 665 || f == hlinfo->mouse_face_mouse_frame)
666 { 666 {
667 BLOCK_INPUT; 667 BLOCK_INPUT;
668 if (dpyinfo->mouse_face_mouse_frame) 668 if (hlinfo->mouse_face_mouse_frame)
669 note_mouse_highlight (dpyinfo->mouse_face_mouse_frame, 669 note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
670 dpyinfo->mouse_face_mouse_x, 670 hlinfo->mouse_face_mouse_x,
671 dpyinfo->mouse_face_mouse_y); 671 hlinfo->mouse_face_mouse_y);
672 dpyinfo->mouse_face_deferred_gc = 0; 672 hlinfo->mouse_face_deferred_gc = 0;
673 UNBLOCK_INPUT; 673 UNBLOCK_INPUT;
674 } 674 }
675 } 675 }
676 } 676 }
677 677
968 { 968 {
969 int face_id; 969 int face_id;
970 struct face *face; 970 struct face *face;
971 971
972 /* What face has to be used last for the mouse face? */ 972 /* What face has to be used last for the mouse face? */
973 face_id = FRAME_X_DISPLAY_INFO (s->f)->mouse_face_face_id; 973 face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
974 face = FACE_FROM_ID (s->f, face_id); 974 face = FACE_FROM_ID (s->f, face_id);
975 if (face == NULL) 975 if (face == NULL)
976 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 976 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
977 977
978 if (s->first_glyph->type == CHAR_GLYPH) 978 if (s->first_glyph->type == CHAR_GLYPH)
5786 int do_help = 0; 5786 int do_help = 0;
5787 int nbytes = 0; 5787 int nbytes = 0;
5788 struct frame *f = NULL; 5788 struct frame *f = NULL;
5789 struct coding_system coding; 5789 struct coding_system coding;
5790 XEvent event = *eventp; 5790 XEvent event = *eventp;
5791 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
5791 5792
5792 *finish = X_EVENT_NORMAL; 5793 *finish = X_EVENT_NORMAL;
5793 5794
5794 EVENT_INIT (inev.ie); 5795 EVENT_INIT (inev.ie);
5795 inev.ie.kind = NO_EVENT; 5796 inev.ie.kind = NO_EVENT;
6235 6236
6236 f = x_any_window_to_frame (dpyinfo, event.xkey.window); 6237 f = x_any_window_to_frame (dpyinfo, event.xkey.window);
6237 6238
6238 /* If mouse-highlight is an integer, input clears out 6239 /* If mouse-highlight is an integer, input clears out
6239 mouse highlighting. */ 6240 mouse highlighting. */
6240 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) 6241 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
6241 && (f == 0 6242 && (f == 0
6242 || !EQ (f->tool_bar_window, dpyinfo->mouse_face_window))) 6243 || !EQ (f->tool_bar_window, hlinfo->mouse_face_window)))
6243 { 6244 {
6244 clear_mouse_face (dpyinfo); 6245 clear_mouse_face (hlinfo);
6245 dpyinfo->mouse_face_hidden = 1; 6246 hlinfo->mouse_face_hidden = 1;
6246 } 6247 }
6247 6248
6248 #if defined USE_MOTIF && defined USE_TOOLKIT_SCROLL_BARS 6249 #if defined USE_MOTIF && defined USE_TOOLKIT_SCROLL_BARS
6249 if (f == 0) 6250 if (f == 0)
6250 { 6251 {
6597 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6598 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6598 6599
6599 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window); 6600 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window);
6600 if (f) 6601 if (f)
6601 { 6602 {
6602 if (f == dpyinfo->mouse_face_mouse_frame) 6603 if (f == hlinfo->mouse_face_mouse_frame)
6603 { 6604 {
6604 /* If we move outside the frame, then we're 6605 /* If we move outside the frame, then we're
6605 certainly no longer on any text in the frame. */ 6606 certainly no longer on any text in the frame. */
6606 clear_mouse_face (dpyinfo); 6607 clear_mouse_face (hlinfo);
6607 dpyinfo->mouse_face_mouse_frame = 0; 6608 hlinfo->mouse_face_mouse_frame = 0;
6608 } 6609 }
6609 6610
6610 /* Generate a nil HELP_EVENT to cancel a help-echo. 6611 /* Generate a nil HELP_EVENT to cancel a help-echo.
6611 Do it only if there's something to cancel. 6612 Do it only if there's something to cancel.
6612 Otherwise, the startup message is cleared when 6613 Otherwise, the startup message is cleared when
6635 && FRAME_LIVE_P (last_mouse_frame)) 6636 && FRAME_LIVE_P (last_mouse_frame))
6636 f = last_mouse_frame; 6637 f = last_mouse_frame;
6637 else 6638 else
6638 f = x_window_to_frame (dpyinfo, event.xmotion.window); 6639 f = x_window_to_frame (dpyinfo, event.xmotion.window);
6639 6640
6640 if (dpyinfo->mouse_face_hidden) 6641 if (hlinfo->mouse_face_hidden)
6641 { 6642 {
6642 dpyinfo->mouse_face_hidden = 0; 6643 hlinfo->mouse_face_hidden = 0;
6643 clear_mouse_face (dpyinfo); 6644 clear_mouse_face (hlinfo);
6644 } 6645 }
6645 6646
6646 #ifdef USE_GTK 6647 #ifdef USE_GTK
6647 if (f && xg_event_is_for_scrollbar (f, &event)) 6648 if (f && xg_event_is_for_scrollbar (f, &event))
6648 f = 0; 6649 f = 0;
6693 x_scroll_bar_note_movement (bar, &event); 6694 x_scroll_bar_note_movement (bar, &event);
6694 #endif /* USE_TOOLKIT_SCROLL_BARS */ 6695 #endif /* USE_TOOLKIT_SCROLL_BARS */
6695 6696
6696 /* If we move outside the frame, then we're 6697 /* If we move outside the frame, then we're
6697 certainly no longer on any text in the frame. */ 6698 certainly no longer on any text in the frame. */
6698 clear_mouse_face (dpyinfo); 6699 clear_mouse_face (hlinfo);
6699 } 6700 }
6700 6701
6701 /* If the contents of the global variable help_echo_string 6702 /* If the contents of the global variable help_echo_string
6702 has changed, generate a HELP_EVENT. */ 6703 has changed, generate a HELP_EVENT. */
6703 if (!NILP (help_echo_string) 6704 if (!NILP (help_echo_string)
9383 x_free_frame_resources (struct frame *f) 9384 x_free_frame_resources (struct frame *f)
9384 { 9385 {
9385 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 9386 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
9386 Lisp_Object bar; 9387 Lisp_Object bar;
9387 struct scroll_bar *b; 9388 struct scroll_bar *b;
9389 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
9388 9390
9389 BLOCK_INPUT; 9391 BLOCK_INPUT;
9390 9392
9391 /* If a display connection is dead, don't try sending more 9393 /* If a display connection is dead, don't try sending more
9392 commands to the X server. */ 9394 commands to the X server. */
9476 if (f == dpyinfo->x_focus_event_frame) 9478 if (f == dpyinfo->x_focus_event_frame)
9477 dpyinfo->x_focus_event_frame = 0; 9479 dpyinfo->x_focus_event_frame = 0;
9478 if (f == dpyinfo->x_highlight_frame) 9480 if (f == dpyinfo->x_highlight_frame)
9479 dpyinfo->x_highlight_frame = 0; 9481 dpyinfo->x_highlight_frame = 0;
9480 9482
9481 if (f == dpyinfo->mouse_face_mouse_frame) 9483 if (f == hlinfo->mouse_face_mouse_frame)
9482 { 9484 {
9483 dpyinfo->mouse_face_beg_row 9485 hlinfo->mouse_face_beg_row
9484 = dpyinfo->mouse_face_beg_col = -1; 9486 = hlinfo->mouse_face_beg_col = -1;
9485 dpyinfo->mouse_face_end_row 9487 hlinfo->mouse_face_end_row
9486 = dpyinfo->mouse_face_end_col = -1; 9488 = hlinfo->mouse_face_end_col = -1;
9487 dpyinfo->mouse_face_window = Qnil; 9489 hlinfo->mouse_face_window = Qnil;
9488 dpyinfo->mouse_face_deferred_gc = 0; 9490 hlinfo->mouse_face_deferred_gc = 0;
9489 dpyinfo->mouse_face_mouse_frame = 0; 9491 hlinfo->mouse_face_mouse_frame = 0;
9490 } 9492 }
9491 9493
9492 UNBLOCK_INPUT; 9494 UNBLOCK_INPUT;
9493 } 9495 }
9494 9496
9861 int connection; 9863 int connection;
9862 Display *dpy; 9864 Display *dpy;
9863 struct terminal *terminal; 9865 struct terminal *terminal;
9864 struct x_display_info *dpyinfo; 9866 struct x_display_info *dpyinfo;
9865 XrmDatabase xrdb; 9867 XrmDatabase xrdb;
9868 Mouse_HLInfo *hlinfo;
9866 9869
9867 BLOCK_INPUT; 9870 BLOCK_INPUT;
9868 9871
9869 if (!x_initialized) 9872 if (!x_initialized)
9870 { 9873 {
9991 9994
9992 /* We have definitely succeeded. Record the new connection. */ 9995 /* We have definitely succeeded. Record the new connection. */
9993 9996
9994 dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info)); 9997 dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info));
9995 memset (dpyinfo, 0, sizeof *dpyinfo); 9998 memset (dpyinfo, 0, sizeof *dpyinfo);
9999 hlinfo = &dpyinfo->mouse_highlight;
9996 10000
9997 terminal = x_create_terminal (dpyinfo); 10001 terminal = x_create_terminal (dpyinfo);
9998 10002
9999 { 10003 {
10000 struct x_display_info *share; 10004 struct x_display_info *share;
10113 dpyinfo->n_fonts = 0; 10117 dpyinfo->n_fonts = 0;
10114 dpyinfo->bitmaps = 0; 10118 dpyinfo->bitmaps = 0;
10115 dpyinfo->bitmaps_size = 0; 10119 dpyinfo->bitmaps_size = 0;
10116 dpyinfo->bitmaps_last = 0; 10120 dpyinfo->bitmaps_last = 0;
10117 dpyinfo->scratch_cursor_gc = 0; 10121 dpyinfo->scratch_cursor_gc = 0;
10118 dpyinfo->mouse_face_mouse_frame = 0; 10122 hlinfo->mouse_face_mouse_frame = 0;
10119 dpyinfo->mouse_face_deferred_gc = 0; 10123 hlinfo->mouse_face_deferred_gc = 0;
10120 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 10124 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
10121 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 10125 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
10122 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; 10126 hlinfo->mouse_face_face_id = DEFAULT_FACE_ID;
10123 dpyinfo->mouse_face_window = Qnil; 10127 hlinfo->mouse_face_window = Qnil;
10124 dpyinfo->mouse_face_overlay = Qnil; 10128 hlinfo->mouse_face_overlay = Qnil;
10125 dpyinfo->mouse_face_mouse_x = dpyinfo->mouse_face_mouse_y = 0; 10129 hlinfo->mouse_face_mouse_x = hlinfo->mouse_face_mouse_y = 0;
10126 dpyinfo->mouse_face_defer = 0; 10130 hlinfo->mouse_face_defer = 0;
10127 dpyinfo->mouse_face_hidden = 0; 10131 hlinfo->mouse_face_hidden = 0;
10128 dpyinfo->x_focus_frame = 0; 10132 dpyinfo->x_focus_frame = 0;
10129 dpyinfo->x_focus_event_frame = 0; 10133 dpyinfo->x_focus_event_frame = 0;
10130 dpyinfo->x_highlight_frame = 0; 10134 dpyinfo->x_highlight_frame = 0;
10131 dpyinfo->wm_type = X_WMTYPE_UNKNOWN; 10135 dpyinfo->wm_type = X_WMTYPE_UNKNOWN;
10132 10136