X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/c71a0d48f3c880248a7f7f25e92ddbcbad5ef0e7..b6e64c4136905ab4f00194c360bd6cd3cd767b9c:/src/w32fns.c diff --git a/src/w32fns.c b/src/w32fns.c index bdf9dce941..96b3f69b72 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -140,8 +140,8 @@ struct MONITOR_INFO DWORD dwFlags; }; -/* Reportedly, VS 6 does not have this in its headers. */ -#if defined (_MSC_VER) && _MSC_VER < 1300 +/* Reportedly, MSVC does not have this in its headers. */ +#ifdef _MSC_VER DECLARE_HANDLE(HMONITOR); #endif @@ -184,7 +184,7 @@ unsigned int msh_mousewheel = 0; static unsigned menu_free_timer = 0; #if GLYPH_DEBUG -int image_cache_refcount, dpyinfo_refcount; +static int image_cache_refcount, dpyinfo_refcount; #endif static HWND w32_visible_system_caret_hwnd; @@ -635,9 +635,8 @@ colormap_t w32_color_map[] = {"LightGreen" , PALETTERGB (144,238,144)}, }; -DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map, - 0, 0, 0, doc: /* Return the default color map. */) - (void) +static Lisp_Object +w32_default_color_map (void) { int i; colormap_t *pc = w32_color_map; @@ -658,6 +657,13 @@ DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map, return (cmap); } +DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map, + 0, 0, 0, doc: /* Return the default color map. */) + (void) +{ + return w32_default_color_map (); +} + static Lisp_Object w32_color_map_lookup (char *colorname) { @@ -683,7 +689,6 @@ w32_color_map_lookup (char *colorname) QUIT; } - UNBLOCK_INPUT; return ret; @@ -1596,7 +1601,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) } FRAME_TOOL_BAR_LINES (f) = nlines; - change_window_heights (root_window, delta); + resize_frame_windows (f, FRAME_LINES (f), 0); adjust_glyphs (f); /* We also have to make sure that the internal border at the top of @@ -1631,6 +1636,9 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) if (WINDOWP (f->tool_bar_window)) clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix); } + + run_window_configuration_change_hook (f); + } @@ -2080,7 +2088,7 @@ w32_key_to_modifier (int key) key_mapping = Qnil; } - /* NB. This code runs in the input thread, asychronously to the lisp + /* NB. This code runs in the input thread, asynchronously to the lisp thread, so we must be careful to ensure access to lisp data is thread-safe. The following code is safe because the modifier variable values are updated atomically from lisp and symbols are @@ -2254,7 +2262,7 @@ w32_msg_pump (deferred_msg * msg_buf) some third party shell extensions can cause it to be used in system dialogs, which causes a crash if it is not initialized. This is a known bug in Windows, which was fixed long ago, but - the patch for XP is not publically available until XP SP3, + the patch for XP is not publicly available until XP SP3, and older versions will never be patched. */ CoInitialize (NULL); w32_createwindow ((struct frame *) msg.wParam); @@ -2872,7 +2880,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) key.dwControlKeyState = modifiers; add = w32_kbd_patch_key (&key); - /* 0 means an unrecognised keycode, negative means + /* 0 means an unrecognized keycode, negative means dead key. Ignore both. */ while (--add >= 0) { @@ -2935,7 +2943,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_IME_CHAR: - /* If we can't get the IME result as unicode, use default processing, + /* If we can't get the IME result as Unicode, use default processing, which will at least allow characters decodable in the system locale get through. */ if (!get_composition_string_fn) @@ -3270,7 +3278,8 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { /* Free memory used by owner-drawn and help-echo strings. */ w32_free_menu_strings (hwnd); - f->output_data.w32->menubar_active = 0; + if (f) + f->output_data.w32->menubar_active = 0; menubar_in_use = 0; } } @@ -3620,10 +3629,10 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (LOWORD (lParam) == HTCLIENT) { f = x_window_to_frame (dpyinfo, hwnd); - if (f->output_data.w32->hourglass_p && !menubar_in_use - && !current_popup_menu) + if (f && f->output_data.w32->hourglass_p + && !menubar_in_use && !current_popup_menu) SetCursor (f->output_data.w32->hourglass_cursor); - else + else if (f) SetCursor (f->output_data.w32->current_cursor); return 0; } @@ -3702,7 +3711,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (w32_system_caret_hwnd == NULL) { /* Use the default caret width, and avoid changing it - unneccesarily, as it confuses screen reader software. */ + unnecessarily, as it confuses screen reader software. */ w32_system_caret_hwnd = hwnd; CreateCaret (hwnd, NULL, 0, w32_system_caret_height); @@ -3968,7 +3977,7 @@ x_make_gc (struct frame *f) /* Handler for signals raised during x_create_frame and - x_create_top_frame. FRAME is the frame which is partially + x_create_tip_frame. FRAME is the frame which is partially constructed. */ static Lisp_Object @@ -3977,13 +3986,14 @@ unwind_create_frame (Lisp_Object frame) struct frame *f = XFRAME (frame); /* If frame is ``official'', nothing to do. */ - if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame)) + if (NILP (Fmemq (frame, Vframe_list))) { #if GLYPH_DEBUG struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); #endif x_free_frame_resources (f); + free_glyphs (f); #if GLYPH_DEBUG /* Check that reference counts are indeed correct. */ @@ -4125,7 +4135,6 @@ This function is an internal primitive--use `make-frame' instead. */) FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL); f->terminal = dpyinfo->terminal; - f->terminal->reference_count++; f->output_method = output_w32; f->output_data.w32 = @@ -4144,7 +4153,8 @@ This function is an internal primitive--use `make-frame' instead. */) /* With FRAME_X_DISPLAY_INFO set up, this unwind-protect is safe. */ record_unwind_protect (unwind_create_frame, frame); #if GLYPH_DEBUG - image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; + image_cache_refcount = + FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0; dpyinfo_refcount = dpyinfo->reference_count; #endif /* GLYPH_DEBUG */ @@ -4277,6 +4287,7 @@ This function is an internal primitive--use `make-frame' instead. */) x_make_gc (f); /* Now consider the frame official. */ + f->terminal->reference_count++; FRAME_W32_DISPLAY_INFO (f)->reference_count++; Vframe_list = Fcons (frame, Vframe_list); @@ -4764,7 +4775,7 @@ terminate Emacs if we can't open the connection. UNGCPRO; } if (NILP (Vw32_color_map)) - Vw32_color_map = Fw32_default_color_map (); + Vw32_color_map = w32_default_color_map (); /* Merge in system logical colors. */ add_system_logical_colors_to_map (&Vw32_color_map); @@ -5219,7 +5230,6 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, from this point on, x_destroy_window might screw up reference counts etc. */ f->terminal = dpyinfo->terminal; - f->terminal->reference_count++; f->output_method = output_w32; f->output_data.w32 = (struct w32_output *) xmalloc (sizeof (struct w32_output)); @@ -5229,7 +5239,8 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, f->icon_name = Qnil; #if GLYPH_DEBUG - image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; + image_cache_refcount = + FRAME_IMAGE_CACHE ? FRAME_IMAGE_CACHE (f)->refcount : 0; dpyinfo_refcount = dpyinfo->reference_count; #endif /* GLYPH_DEBUG */ FRAME_KBOARD (f) = kb; @@ -5370,15 +5381,16 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, UNGCPRO; + /* Now that the frame is official, it counts as a reference to + its display. */ + FRAME_W32_DISPLAY_INFO (f)->reference_count++; + f->terminal->reference_count++; + /* It is now ok to make the frame official even if we get an error below. And the frame needs to be on Vframe_list or making it visible won't work. */ Vframe_list = Fcons (frame, Vframe_list); - /* Now that the frame is official, it counts as a reference to - its display. */ - FRAME_W32_DISPLAY_INFO (f)->reference_count++; - /* Setting attributes of faces of the tooltip frame from resources and similar will increment face_change_count, which leads to the clearing of all current matrices. Since this isn't necessary @@ -5822,8 +5834,6 @@ Value is t if tooltip was open, nil otherwise. */) UNGCPRO; return unbind_to (count, deleted); } - - /*********************************************************************** File selection dialog @@ -6699,7 +6709,7 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name, ClosePrinter (hPrn); return Qnil; } - /* Call GetPrinter again with big enouth memory block */ + /* Call GetPrinter again with big enough memory block. */ err = GetPrinter (hPrn, 2, (LPBYTE)ppi2, dwNeeded, &dwReturned); ClosePrinter (hPrn); if (!err) @@ -6804,10 +6814,6 @@ syms_of_w32fns (void) DEFSYM (Qfont_param, "font-parameter"); /* This is the end of symbol initialization. */ - /* Text property `display' should be nonsticky by default. */ - Vtext_property_default_nonsticky - = Fcons (Fcons (Qdisplay, Qt), Vtext_property_default_nonsticky); - Fput (Qundefined_color, Qerror_conditions, pure_cons (Qundefined_color, pure_cons (Qerror, Qnil)));