aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32fns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32fns.c')
-rw-r--r--src/w32fns.c74
1 files changed, 44 insertions, 30 deletions
diff --git a/src/w32fns.c b/src/w32fns.c
index f48e5764b4c..510d1e94f16 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1,6 +1,6 @@
1/* Graphical user interface functions for the Microsoft W32 API. 1/* Graphical user interface functions for the Microsoft W32 API.
2 2
3Copyright (C) 1989, 1992-2011 Free Software Foundation, Inc. 3Copyright (C) 1989, 1992-2012 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -140,8 +140,8 @@ struct MONITOR_INFO
140 DWORD dwFlags; 140 DWORD dwFlags;
141}; 141};
142 142
143/* Reportedly, VS 6 does not have this in its headers. */ 143/* Reportedly, MSVC does not have this in its headers. */
144#if defined (_MSC_VER) && _MSC_VER < 1300 144#ifdef _MSC_VER
145DECLARE_HANDLE(HMONITOR); 145DECLARE_HANDLE(HMONITOR);
146#endif 146#endif
147 147
@@ -635,9 +635,8 @@ colormap_t w32_color_map[] =
635 {"LightGreen" , PALETTERGB (144,238,144)}, 635 {"LightGreen" , PALETTERGB (144,238,144)},
636}; 636};
637 637
638DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map, 638static Lisp_Object
639 0, 0, 0, doc: /* Return the default color map. */) 639w32_default_color_map (void)
640 (void)
641{ 640{
642 int i; 641 int i;
643 colormap_t *pc = w32_color_map; 642 colormap_t *pc = w32_color_map;
@@ -658,6 +657,13 @@ DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map,
658 return (cmap); 657 return (cmap);
659} 658}
660 659
660DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map,
661 0, 0, 0, doc: /* Return the default color map. */)
662 (void)
663{
664 return w32_default_color_map ();
665}
666
661static Lisp_Object 667static Lisp_Object
662w32_color_map_lookup (char *colorname) 668w32_color_map_lookup (char *colorname)
663{ 669{
@@ -683,7 +689,6 @@ w32_color_map_lookup (char *colorname)
683 QUIT; 689 QUIT;
684 } 690 }
685 691
686
687 UNBLOCK_INPUT; 692 UNBLOCK_INPUT;
688 693
689 return ret; 694 return ret;
@@ -2083,7 +2088,7 @@ w32_key_to_modifier (int key)
2083 key_mapping = Qnil; 2088 key_mapping = Qnil;
2084 } 2089 }
2085 2090
2086 /* NB. This code runs in the input thread, asychronously to the lisp 2091 /* NB. This code runs in the input thread, asynchronously to the lisp
2087 thread, so we must be careful to ensure access to lisp data is 2092 thread, so we must be careful to ensure access to lisp data is
2088 thread-safe. The following code is safe because the modifier 2093 thread-safe. The following code is safe because the modifier
2089 variable values are updated atomically from lisp and symbols are 2094 variable values are updated atomically from lisp and symbols are
@@ -2257,7 +2262,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2257 some third party shell extensions can cause it to be used in 2262 some third party shell extensions can cause it to be used in
2258 system dialogs, which causes a crash if it is not initialized. 2263 system dialogs, which causes a crash if it is not initialized.
2259 This is a known bug in Windows, which was fixed long ago, but 2264 This is a known bug in Windows, which was fixed long ago, but
2260 the patch for XP is not publically available until XP SP3, 2265 the patch for XP is not publicly available until XP SP3,
2261 and older versions will never be patched. */ 2266 and older versions will never be patched. */
2262 CoInitialize (NULL); 2267 CoInitialize (NULL);
2263 w32_createwindow ((struct frame *) msg.wParam); 2268 w32_createwindow ((struct frame *) msg.wParam);
@@ -2412,7 +2417,7 @@ complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result)
2412 deferred_msg * msg_buf = find_deferred_msg (hwnd, msg); 2417 deferred_msg * msg_buf = find_deferred_msg (hwnd, msg);
2413 2418
2414 if (msg_buf == NULL) 2419 if (msg_buf == NULL)
2415 /* Message may have been cancelled, so don't abort. */ 2420 /* Message may have been canceled, so don't abort. */
2416 return; 2421 return;
2417 2422
2418 msg_buf->result = result; 2423 msg_buf->result = result;
@@ -2474,6 +2479,10 @@ signal_user_input (void)
2474 if (!NILP (Vthrow_on_input)) 2479 if (!NILP (Vthrow_on_input))
2475 { 2480 {
2476 Vquit_flag = Vthrow_on_input; 2481 Vquit_flag = Vthrow_on_input;
2482 /* Doing a QUIT from this thread is a bad idea, since this
2483 unwinds the stack of the Lisp thread, and the Windows runtime
2484 rightfully barfs. Disabled. */
2485#if 0
2477 /* If we're inside a function that wants immediate quits, 2486 /* If we're inside a function that wants immediate quits,
2478 do it now. */ 2487 do it now. */
2479 if (immediate_quit && NILP (Vinhibit_quit)) 2488 if (immediate_quit && NILP (Vinhibit_quit))
@@ -2481,6 +2490,7 @@ signal_user_input (void)
2481 immediate_quit = 0; 2490 immediate_quit = 0;
2482 QUIT; 2491 QUIT;
2483 } 2492 }
2493#endif
2484 } 2494 }
2485} 2495}
2486 2496
@@ -2533,7 +2543,7 @@ post_character_message (HWND hwnd, UINT msg,
2533 the lisp thread to respond. 2543 the lisp thread to respond.
2534 2544
2535 Note that we don't want to block the input thread waiting for 2545 Note that we don't want to block the input thread waiting for
2536 a reponse from the lisp thread (although that would at least 2546 a response from the lisp thread (although that would at least
2537 solve the deadlock problem above), because we want to be able 2547 solve the deadlock problem above), because we want to be able
2538 to receive C-g to interrupt the lisp thread. */ 2548 to receive C-g to interrupt the lisp thread. */
2539 cancel_all_deferred_msgs (); 2549 cancel_all_deferred_msgs ();
@@ -2875,7 +2885,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2875 key.dwControlKeyState = modifiers; 2885 key.dwControlKeyState = modifiers;
2876 2886
2877 add = w32_kbd_patch_key (&key); 2887 add = w32_kbd_patch_key (&key);
2878 /* 0 means an unrecognised keycode, negative means 2888 /* 0 means an unrecognized keycode, negative means
2879 dead key. Ignore both. */ 2889 dead key. Ignore both. */
2880 while (--add >= 0) 2890 while (--add >= 0)
2881 { 2891 {
@@ -2938,7 +2948,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2938 break; 2948 break;
2939 2949
2940 case WM_IME_CHAR: 2950 case WM_IME_CHAR:
2941 /* If we can't get the IME result as unicode, use default processing, 2951 /* If we can't get the IME result as Unicode, use default processing,
2942 which will at least allow characters decodable in the system locale 2952 which will at least allow characters decodable in the system locale
2943 get through. */ 2953 get through. */
2944 if (!get_composition_string_fn) 2954 if (!get_composition_string_fn)
@@ -3706,7 +3716,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3706 if (w32_system_caret_hwnd == NULL) 3716 if (w32_system_caret_hwnd == NULL)
3707 { 3717 {
3708 /* Use the default caret width, and avoid changing it 3718 /* Use the default caret width, and avoid changing it
3709 unneccesarily, as it confuses screen reader software. */ 3719 unnecessarily, as it confuses screen reader software. */
3710 w32_system_caret_hwnd = hwnd; 3720 w32_system_caret_hwnd = hwnd;
3711 CreateCaret (hwnd, NULL, 0, 3721 CreateCaret (hwnd, NULL, 0,
3712 w32_system_caret_height); 3722 w32_system_caret_height);
@@ -3744,7 +3754,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3744 flags |= TPM_RIGHTBUTTON; 3754 flags |= TPM_RIGHTBUTTON;
3745 3755
3746 /* Remember we did a SetCapture on the initial mouse down event, 3756 /* Remember we did a SetCapture on the initial mouse down event,
3747 so for safety, we make sure the capture is cancelled now. */ 3757 so for safety, we make sure the capture is canceled now. */
3748 ReleaseCapture (); 3758 ReleaseCapture ();
3749 button_state = 0; 3759 button_state = 0;
3750 3760
@@ -3972,7 +3982,7 @@ x_make_gc (struct frame *f)
3972 3982
3973 3983
3974/* Handler for signals raised during x_create_frame and 3984/* Handler for signals raised during x_create_frame and
3975 x_create_top_frame. FRAME is the frame which is partially 3985 x_create_tip_frame. FRAME is the frame which is partially
3976 constructed. */ 3986 constructed. */
3977 3987
3978static Lisp_Object 3988static Lisp_Object
@@ -3981,13 +3991,14 @@ unwind_create_frame (Lisp_Object frame)
3981 struct frame *f = XFRAME (frame); 3991 struct frame *f = XFRAME (frame);
3982 3992
3983 /* If frame is ``official'', nothing to do. */ 3993 /* If frame is ``official'', nothing to do. */
3984 if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame)) 3994 if (NILP (Fmemq (frame, Vframe_list)))
3985 { 3995 {
3986#if GLYPH_DEBUG 3996#if GLYPH_DEBUG
3987 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); 3997 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
3988#endif 3998#endif
3989 3999
3990 x_free_frame_resources (f); 4000 x_free_frame_resources (f);
4001 free_glyphs (f);
3991 4002
3992#if GLYPH_DEBUG 4003#if GLYPH_DEBUG
3993 /* Check that reference counts are indeed correct. */ 4004 /* Check that reference counts are indeed correct. */
@@ -4129,7 +4140,6 @@ This function is an internal primitive--use `make-frame' instead. */)
4129 FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL); 4140 FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL);
4130 4141
4131 f->terminal = dpyinfo->terminal; 4142 f->terminal = dpyinfo->terminal;
4132 f->terminal->reference_count++;
4133 4143
4134 f->output_method = output_w32; 4144 f->output_method = output_w32;
4135 f->output_data.w32 = 4145 f->output_data.w32 =
@@ -4148,7 +4158,8 @@ This function is an internal primitive--use `make-frame' instead. */)
4148 /* With FRAME_X_DISPLAY_INFO set up, this unwind-protect is safe. */ 4158 /* With FRAME_X_DISPLAY_INFO set up, this unwind-protect is safe. */
4149 record_unwind_protect (unwind_create_frame, frame); 4159 record_unwind_protect (unwind_create_frame, frame);
4150#if GLYPH_DEBUG 4160#if GLYPH_DEBUG
4151 image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; 4161 image_cache_refcount =
4162 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
4152 dpyinfo_refcount = dpyinfo->reference_count; 4163 dpyinfo_refcount = dpyinfo->reference_count;
4153#endif /* GLYPH_DEBUG */ 4164#endif /* GLYPH_DEBUG */
4154 4165
@@ -4281,6 +4292,7 @@ This function is an internal primitive--use `make-frame' instead. */)
4281 x_make_gc (f); 4292 x_make_gc (f);
4282 4293
4283 /* Now consider the frame official. */ 4294 /* Now consider the frame official. */
4295 f->terminal->reference_count++;
4284 FRAME_W32_DISPLAY_INFO (f)->reference_count++; 4296 FRAME_W32_DISPLAY_INFO (f)->reference_count++;
4285 Vframe_list = Fcons (frame, Vframe_list); 4297 Vframe_list = Fcons (frame, Vframe_list);
4286 4298
@@ -4768,7 +4780,7 @@ terminate Emacs if we can't open the connection.
4768 UNGCPRO; 4780 UNGCPRO;
4769 } 4781 }
4770 if (NILP (Vw32_color_map)) 4782 if (NILP (Vw32_color_map))
4771 Vw32_color_map = Fw32_default_color_map (); 4783 Vw32_color_map = w32_default_color_map ();
4772 4784
4773 /* Merge in system logical colors. */ 4785 /* Merge in system logical colors. */
4774 add_system_logical_colors_to_map (&Vw32_color_map); 4786 add_system_logical_colors_to_map (&Vw32_color_map);
@@ -4944,7 +4956,7 @@ If TYPE is nil or omitted, get the property as a string.
4944Otherwise TYPE is the name of the atom that denotes the type expected. 4956Otherwise TYPE is the name of the atom that denotes the type expected.
4945If SOURCE is non-nil, get the property on that window instead of from 4957If SOURCE is non-nil, get the property on that window instead of from
4946FRAME. The number 0 denotes the root window. 4958FRAME. The number 0 denotes the root window.
4947If DELETE_P is non-nil, delete the property after retreiving it. 4959If DELETE_P is non-nil, delete the property after retrieving it.
4948If VECTOR_RET_P is non-nil, don't return a string but a vector of values. 4960If VECTOR_RET_P is non-nil, don't return a string but a vector of values.
4949 4961
4950Value is nil if FRAME hasn't a property with name PROP or if PROP has 4962Value is nil if FRAME hasn't a property with name PROP or if PROP has
@@ -5004,7 +5016,8 @@ no value of TYPE (always string in the MS Windows case). */)
5004 cursor. Duplicated from xdisp.c, but cannot use the version there 5016 cursor. Duplicated from xdisp.c, but cannot use the version there
5005 due to lack of atimers on w32. */ 5017 due to lack of atimers on w32. */
5006#define DEFAULT_HOURGLASS_DELAY 1 5018#define DEFAULT_HOURGLASS_DELAY 1
5007/* Return non-zero if houglass timer has been started or hourglass is shown. */ 5019/* Return non-zero if hourglass timer has been started or hourglass is
5020 shown. */
5008/* PENDING: if W32 can use atimers (atimer.[hc]) then the common impl in 5021/* PENDING: if W32 can use atimers (atimer.[hc]) then the common impl in
5009 xdisp.c could be used. */ 5022 xdisp.c could be used. */
5010 5023
@@ -5223,7 +5236,6 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
5223 from this point on, x_destroy_window might screw up reference 5236 from this point on, x_destroy_window might screw up reference
5224 counts etc. */ 5237 counts etc. */
5225 f->terminal = dpyinfo->terminal; 5238 f->terminal = dpyinfo->terminal;
5226 f->terminal->reference_count++;
5227 f->output_method = output_w32; 5239 f->output_method = output_w32;
5228 f->output_data.w32 = 5240 f->output_data.w32 =
5229 (struct w32_output *) xmalloc (sizeof (struct w32_output)); 5241 (struct w32_output *) xmalloc (sizeof (struct w32_output));
@@ -5233,7 +5245,8 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
5233 f->icon_name = Qnil; 5245 f->icon_name = Qnil;
5234 5246
5235#if GLYPH_DEBUG 5247#if GLYPH_DEBUG
5236 image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; 5248 image_cache_refcount =
5249 FRAME_IMAGE_CACHE ? FRAME_IMAGE_CACHE (f)->refcount : 0;
5237 dpyinfo_refcount = dpyinfo->reference_count; 5250 dpyinfo_refcount = dpyinfo->reference_count;
5238#endif /* GLYPH_DEBUG */ 5251#endif /* GLYPH_DEBUG */
5239 FRAME_KBOARD (f) = kb; 5252 FRAME_KBOARD (f) = kb;
@@ -5374,15 +5387,16 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
5374 5387
5375 UNGCPRO; 5388 UNGCPRO;
5376 5389
5390 /* Now that the frame is official, it counts as a reference to
5391 its display. */
5392 FRAME_W32_DISPLAY_INFO (f)->reference_count++;
5393 f->terminal->reference_count++;
5394
5377 /* It is now ok to make the frame official even if we get an error 5395 /* It is now ok to make the frame official even if we get an error
5378 below. And the frame needs to be on Vframe_list or making it 5396 below. And the frame needs to be on Vframe_list or making it
5379 visible won't work. */ 5397 visible won't work. */
5380 Vframe_list = Fcons (frame, Vframe_list); 5398 Vframe_list = Fcons (frame, Vframe_list);
5381 5399
5382 /* Now that the frame is official, it counts as a reference to
5383 its display. */
5384 FRAME_W32_DISPLAY_INFO (f)->reference_count++;
5385
5386 /* Setting attributes of faces of the tooltip frame from resources 5400 /* Setting attributes of faces of the tooltip frame from resources
5387 and similar will increment face_change_count, which leads to the 5401 and similar will increment face_change_count, which leads to the
5388 clearing of all current matrices. Since this isn't necessary 5402 clearing of all current matrices. Since this isn't necessary
@@ -6023,7 +6037,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
6023 6037
6024 file = DECODE_FILE (build_string (filename)); 6038 file = DECODE_FILE (build_string (filename));
6025 } 6039 }
6026 /* User cancelled the dialog without making a selection. */ 6040 /* User canceled the dialog without making a selection. */
6027 else if (!CommDlgExtendedError ()) 6041 else if (!CommDlgExtendedError ())
6028 file = Qnil; 6042 file = Qnil;
6029 /* An error occurred, fallback on reading from the mini-buffer. */ 6043 /* An error occurred, fallback on reading from the mini-buffer. */
@@ -6701,7 +6715,7 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
6701 ClosePrinter (hPrn); 6715 ClosePrinter (hPrn);
6702 return Qnil; 6716 return Qnil;
6703 } 6717 }
6704 /* Call GetPrinter again with big enouth memory block */ 6718 /* Call GetPrinter again with big enough memory block. */
6705 err = GetPrinter (hPrn, 2, (LPBYTE)ppi2, dwNeeded, &dwReturned); 6719 err = GetPrinter (hPrn, 2, (LPBYTE)ppi2, dwNeeded, &dwReturned);
6706 ClosePrinter (hPrn); 6720 ClosePrinter (hPrn);
6707 if (!err) 6721 if (!err)