Mercurial > emacs
diff src/w32term.c @ 91041:bdb3fe0ba9fa
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 866-879)
- Merge multi-tty branch
- Update from CVS
- Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-257
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 11 Oct 2007 16:22:07 +0000 |
parents | d41ffb650865 5039706521c9 |
children | a0e466c4d599 |
line wrap: on
line diff
--- a/src/w32term.c Thu Oct 11 16:14:00 2007 +0000 +++ b/src/w32term.c Thu Oct 11 16:22:07 2007 +0000 @@ -64,8 +64,6 @@ #include "font.h" #endif /* USE_FONT_BACKEND */ -#define abs(x) ((x) < 0 ? -(x) : (x)) - /* Fringe bitmaps. */ @@ -265,9 +263,9 @@ int x_compute_min_glyph_bounds P_ ((struct frame *)); static void x_update_end P_ ((struct frame *)); static void w32_frame_up_to_date P_ ((struct frame *)); -static void w32_set_terminal_modes P_ ((void)); -static void w32_reset_terminal_modes P_ ((void)); -static void x_clear_frame P_ ((void)); +static void w32_set_terminal_modes P_ ((struct terminal *)); +static void w32_reset_terminal_modes P_ ((struct terminal *)); +static void x_clear_frame P_ ((struct frame *)); static void frame_highlight P_ ((struct frame *)); static void frame_unhighlight P_ ((struct frame *)); static void x_new_focus_frame P_ ((struct w32_display_info *, @@ -879,7 +877,7 @@ rarely happens). */ static void -w32_set_terminal_modes (void) +w32_set_terminal_modes (struct terminal *term) { } @@ -887,7 +885,7 @@ the W32 windows go away, and suspending requires no action. */ static void -w32_reset_terminal_modes (void) +w32_reset_terminal_modes (struct terminal *term) { } @@ -3016,7 +3014,7 @@ } else { - w32_fill_area (s->f, s->hdc, s->face->underline_color, s->x, + w32_fill_area (s->f, s->hdc, s->face->strike_through_color, s->x, s->y + dy, s->width, h); } } @@ -3109,16 +3107,10 @@ for X frames. */ static void -x_delete_glyphs (n) +x_delete_glyphs (f, n) + struct frame *f; register int n; { - struct frame *f; - - if (updating_frame) - f = updating_frame; - else - f = SELECTED_FRAME (); - if (! FRAME_W32_P (f)) return; @@ -3130,15 +3122,8 @@ frame. Otherwise clear the selected frame. */ static void -x_clear_frame () -{ - struct frame *f; - - if (updating_frame) - f = updating_frame; - else - f = SELECTED_FRAME (); - +x_clear_frame (struct frame *f) +{ if (! FRAME_W32_P (f)) return; @@ -3165,18 +3150,14 @@ /* Make audible bell. */ static void -w32_ring_bell (void) -{ - struct frame *f; - - f = SELECTED_FRAME (); - +w32_ring_bell (struct frame *f) +{ BLOCK_INPUT; if (FRAME_W32_P (f) && visible_bell) { int i; - HWND hwnd = FRAME_W32_WINDOW (SELECTED_FRAME ()); + HWND hwnd = FRAME_W32_WINDOW (f); for (i = 0; i < 5; i++) { @@ -3186,7 +3167,7 @@ FlashWindow (hwnd, FALSE); } else - w32_sys_ring_bell (); + w32_sys_ring_bell (f); UNBLOCK_INPUT; } @@ -3213,16 +3194,10 @@ lines or deleting -N lines at vertical position VPOS. */ static void -x_ins_del_lines (vpos, n) +x_ins_del_lines (f, vpos, n) + struct frame *f; int vpos, n; { - struct frame *f; - - if (updating_frame) - f = updating_frame; - else - f = SELECTED_FRAME (); - if (! FRAME_W32_P (f)) return; @@ -3627,7 +3602,8 @@ POINT p; int delta; - result->kind = WHEEL_EVENT; + result->kind = msg->msg.message == WM_MOUSEHWHEEL ? HORIZ_WHEEL_EVENT + : WHEEL_EVENT; result->code = 0; result->timestamp = msg->msg.time; @@ -4859,7 +4835,13 @@ only when it is active. */ if (WINDOWP(window) && !EQ (window, last_window) - && !EQ (window, selected_window)) + && !EQ (window, selected_window) + /* For click-to-focus window managers + create event iff we don't leave the + selected frame. */ + && (focus_follows_mouse + || (EQ (XWINDOW (window)->frame, + XWINDOW (selected_window)->frame)))) { inev.kind = SELECT_WINDOW_EVENT; inev.frame_or_window = window; @@ -4964,6 +4946,7 @@ } case WM_MOUSEWHEEL: + case WM_MOUSEHWHEEL: { if (dpyinfo->grabbed && last_mouse_frame && FRAME_LIVE_P (last_mouse_frame)) @@ -6478,8 +6461,8 @@ free_frame_menubar (f); - unload_color (f, f->output_data.x->foreground_pixel); - unload_color (f, f->output_data.x->background_pixel); + unload_color (f, FRAME_FOREGROUND_PIXEL (f)); + unload_color (f, FRAME_BACKGROUND_PIXEL (f)); unload_color (f, f->output_data.w32->cursor_pixel); unload_color (f, f->output_data.w32->cursor_foreground_pixel); unload_color (f, f->output_data.w32->border_pixel); @@ -6518,14 +6501,13 @@ /* Destroy the window of frame F. */ - +void x_destroy_window (f) struct frame *f; { struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); x_free_frame_resources (f); - dpyinfo->reference_count--; } @@ -6785,6 +6767,132 @@ return buffer; } +void +x_flush (struct frame * f) +{ /* Nothing to do */ } + + +extern frame_parm_handler w32_frame_parm_handlers[]; + +static struct redisplay_interface w32_redisplay_interface = +{ + w32_frame_parm_handlers, + x_produce_glyphs, + x_write_glyphs, + x_insert_glyphs, + x_clear_end_of_line, + x_scroll_run, + x_after_update_window_line, + x_update_window_begin, + x_update_window_end, + x_cursor_to, + x_flush, + 0, /* flush_display_optional */ + x_clear_window_mouse_face, + w32_get_glyph_overhangs, + x_fix_overlapping_area, + w32_draw_fringe_bitmap, + w32_define_fringe_bitmap, + w32_destroy_fringe_bitmap, + w32_per_char_metric, + w32_encode_char, + NULL, /* w32_compute_glyph_string_overhangs */ + x_draw_glyph_string, + w32_define_frame_cursor, + w32_clear_frame_area, + w32_draw_window_cursor, + w32_draw_vertical_window_border, + w32_shift_glyphs_for_insert +}; + +static void x_delete_terminal (struct terminal *term); + +static struct terminal * +w32_create_terminal (struct w32_display_info *dpyinfo) +{ + struct terminal *terminal; + + terminal = create_terminal (); + + terminal->type = output_w32; + terminal->display_info.w32 = dpyinfo; + dpyinfo->terminal = terminal; + + /* MSVC does not type K&R functions with no arguments correctly, and + so we must explicitly cast them. */ + terminal->clear_frame_hook = x_clear_frame; + terminal->ins_del_lines_hook = x_ins_del_lines; + terminal->delete_glyphs_hook = x_delete_glyphs; + terminal->ring_bell_hook = w32_ring_bell; + terminal->reset_terminal_modes_hook = w32_reset_terminal_modes; + terminal->set_terminal_modes_hook = w32_set_terminal_modes; + terminal->update_begin_hook = x_update_begin; + terminal->update_end_hook = x_update_end; + terminal->set_terminal_window_hook = w32_set_terminal_window; + terminal->read_socket_hook = w32_read_socket; + terminal->frame_up_to_date_hook = w32_frame_up_to_date; + terminal->mouse_position_hook = w32_mouse_position; + terminal->frame_rehighlight_hook = w32_frame_rehighlight; + terminal->frame_raise_lower_hook = w32_frame_raise_lower; + // terminal->fullscreen_hook = XTfullscreen_hook; + terminal->set_vertical_scroll_bar_hook = w32_set_vertical_scroll_bar; + terminal->condemn_scroll_bars_hook = w32_condemn_scroll_bars; + terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar; + terminal->judge_scroll_bars_hook = w32_judge_scroll_bars; + + terminal->delete_frame_hook = x_destroy_window; + terminal->delete_terminal_hook = x_delete_terminal; + + terminal->rif = &w32_redisplay_interface; + terminal->scroll_region_ok = 1; /* We'll scroll partial frames. */ + terminal->char_ins_del_ok = 1; + terminal->line_ins_del_ok = 1; /* We'll just blt 'em. */ + terminal->fast_clear_end_of_line = 1; /* X does this well. */ + terminal->memory_below_frame = 0; /* We don't remember what scrolls + off the bottom. */ + +#ifdef MULTI_KBOARD + /* We don't yet support separate terminals on W32, so don't try to share + keyboards between virtual terminals that are on the same physical + terminal like X does. */ + terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); + init_kboard (terminal->kboard); + terminal->kboard->next_kboard = all_kboards; + all_kboards = terminal->kboard; + /* Don't let the initial kboard remain current longer than necessary. + That would cause problems if a file loaded on startup tries to + prompt in the mini-buffer. */ + if (current_kboard == initial_kboard) + current_kboard = terminal->kboard; + terminal->kboard->reference_count++; +#endif + + return terminal; +} + +static void +x_delete_terminal (struct terminal *terminal) +{ + struct w32_display_info *dpyinfo = terminal->display_info.w32; + int i; + + /* Protect against recursive calls. Fdelete_frame in + delete_terminal calls us back when it deletes our last frame. */ + if (!terminal->name) + return; + + BLOCK_INPUT; + /* Free the fonts in the font table. */ + for (i = 0; i < dpyinfo->n_fonts; i++) + if (dpyinfo->font_table[i].name) + { + DeleteObject (((XFontStruct*)(dpyinfo->font_table[i].font))->hfont); + } + + x_delete_display (dpyinfo); + UNBLOCK_INPUT; +} + struct w32_display_info * w32_term_init (display_name, xrm_option, resource_name) Lisp_Object display_name; @@ -6792,6 +6900,7 @@ char *resource_name; { struct w32_display_info *dpyinfo; + struct terminal *terminal; HDC hdc; BLOCK_INPUT; @@ -6805,6 +6914,12 @@ w32_initialize_display_info (display_name); dpyinfo = &one_w32_display_info; + terminal = w32_create_terminal (dpyinfo); + + /* Set the name of the terminal. */ + terminal->name = (char *) xmalloc (SBYTES (display_name) + 1); + strncpy (terminal->name, SDATA (display_name), SBYTES (display_name)); + terminal->name[SBYTES (display_name)] = 0; dpyinfo->xrdb = xrm_option ? w32_make_rdb (xrm_option) : NULL; @@ -6834,6 +6949,9 @@ w32_defined_color (0, "black", &color, 1); } + /* Add the default keyboard. */ + add_keyboard_wait_descriptor (0); + /* Create Fringe Bitmaps and store them for later use. On W32, bitmaps are all unsigned short, as Windows requires @@ -6841,7 +6959,7 @@ horizontally reflected compared to how they appear on X, so we need to bitswap and convert to unsigned shorts before creating the bitmaps. */ - w32_init_fringe (); + w32_init_fringe (terminal->rif); #ifndef F_SETOWN_BUG #ifdef F_SETOWN @@ -6865,7 +6983,6 @@ } /* Get rid of display DPYINFO, assuming all frames are already gone. */ - void x_delete_display (dpyinfo) struct w32_display_info *dpyinfo; @@ -6916,73 +7033,9 @@ DWORD WINAPI w32_msg_worker (void * arg); -void -x_flush (struct frame * f) -{ /* Nothing to do */ } - -extern frame_parm_handler w32_frame_parm_handlers[]; - -static struct redisplay_interface w32_redisplay_interface = -{ - w32_frame_parm_handlers, - x_produce_glyphs, - x_write_glyphs, - x_insert_glyphs, - x_clear_end_of_line, - x_scroll_run, - x_after_update_window_line, - x_update_window_begin, - x_update_window_end, - x_cursor_to, - x_flush, - 0, /* flush_display_optional */ - x_clear_window_mouse_face, - w32_get_glyph_overhangs, - x_fix_overlapping_area, - w32_draw_fringe_bitmap, - w32_define_fringe_bitmap, - w32_destroy_fringe_bitmap, - w32_per_char_metric, - w32_encode_char, - NULL, /* w32_compute_glyph_string_overhangs */ - x_draw_glyph_string, - w32_define_frame_cursor, - w32_clear_frame_area, - w32_draw_window_cursor, - w32_draw_vertical_window_border, - w32_shift_glyphs_for_insert -}; - static void w32_initialize () { - rif = &w32_redisplay_interface; - - /* MSVC does not type K&R functions with no arguments correctly, and - so we must explicitly cast them. */ - clear_frame_hook = (void (*)(void)) x_clear_frame; - ring_bell_hook = (void (*)(void)) w32_ring_bell; - update_begin_hook = x_update_begin; - update_end_hook = x_update_end; - - read_socket_hook = w32_read_socket; - - frame_up_to_date_hook = w32_frame_up_to_date; - - mouse_position_hook = w32_mouse_position; - frame_rehighlight_hook = w32_frame_rehighlight; - frame_raise_lower_hook = w32_frame_raise_lower; - set_vertical_scroll_bar_hook = w32_set_vertical_scroll_bar; - condemn_scroll_bars_hook = w32_condemn_scroll_bars; - redeem_scroll_bar_hook = w32_redeem_scroll_bar; - judge_scroll_bars_hook = w32_judge_scroll_bars; - - scroll_region_ok = 1; /* we'll scroll partial frames */ - char_ins_del_ok = 1; - line_ins_del_ok = 1; /* we'll just blt 'em */ - fast_clear_end_of_line = 1; /* X does this well */ - memory_below_frame = 0; /* we don't remember what scrolls - off the bottom */ baud_rate = 19200; w32_system_caret_hwnd = NULL;