comparison src/w32fns.c @ 24670:045e247575d9

[andrewi] (w32_list_bdf_fonts): Initialize n_fonts. (Fw32_shell_execute): New function; used to support browse-url. (syms_of_w32fns): Register it. (w32_load_system_font): Force max width to be average char width for fixed-pitch fonts, to avoid unnecessary redisplay slowdown. (x_to_w32_charset): Define VIETNAMESE_CHARSET if not already defined. (syms_of_w32fns): Set Vw32_phantom_key_code to 255. [jasonr] (w32_wnd_proc) [WM_PAINT]: Use rectangle from GetUpdateRect rather than BeginPaint. (w32_wnd_proc): Attach to current foreground thread when grabbing focus; necessary on NT 5.0. (w32_wnd_proc) [W32_DEBUG_DISPLAY]: Add output for debugging display messages. (w32_to_x_charset): Put wildcard last in unknown charsets to avoid false matching.
author Andrew Innes <andrewi@gnu.org>
date Sun, 02 May 1999 10:23:06 +0000
parents 0e5c5bd9b99d
children 556285c0e5c4
comparison
equal deleted inserted replaced
24669:66df82aa955e 24670:045e247575d9
3717 frames to be redrawn if needed. */ 3717 frames to be redrawn if needed. */
3718 release_frame_dc (f, get_frame_dc (f)); 3718 release_frame_dc (f, get_frame_dc (f));
3719 } 3719 }
3720 return 0; 3720 return 0;
3721 case WM_PAINT: 3721 case WM_PAINT:
3722 { 3722 {
3723 PAINTSTRUCT paintStruct; 3723 PAINTSTRUCT paintStruct;
3724 3724 RECT update_rect;
3725 enter_crit (); 3725
3726 BeginPaint (hwnd, &paintStruct); 3726 /* MSDN Docs say not to call BeginPaint if GetUpdateRect
3727 wmsg.rect = paintStruct.rcPaint; 3727 fails. Apparently this can happen under some
3728 EndPaint (hwnd, &paintStruct); 3728 circumstances. */
3729 leave_crit (); 3729 if (GetUpdateRect (hwnd, &update_rect, FALSE))
3730 3730 {
3731 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 3731 enter_crit ();
3732 3732 BeginPaint (hwnd, &paintStruct);
3733 return (0); 3733
3734 /* The rectangles returned by GetUpdateRect and BeginPaint
3735 do not always match. GetUpdateRect seems to be the
3736 more reliable of the two. */
3737 wmsg.rect = update_rect;
3738
3739 #if defined (W32_DEBUG_DISPLAY)
3740 DebPrint (("WM_PAINT: painting %d,%d-%d,%d\n", wmsg.rect.left,
3741 wmsg.rect.top, wmsg.rect.right, wmsg.rect.bottom));
3742 DebPrint (("WM_PAINT: update region is %d,%d-%d,%d\n",
3743 update_rect.left, update_rect.top,
3744 update_rect.right, update_rect.bottom));
3745 #endif
3746 EndPaint (hwnd, &paintStruct);
3747 leave_crit ();
3748
3749 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
3750
3751 return 0;
3752 }
3753 return 1;
3734 } 3754 }
3735 3755
3736 case WM_INPUTLANGCHANGE: 3756 case WM_INPUTLANGCHANGE:
3737 /* Inform lisp thread of keyboard layout changes. */ 3757 /* Inform lisp thread of keyboard layout changes. */
3738 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 3758 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4958 struct font_info *w32_load_bdf_font (struct frame *f, char *fontname, 4978 struct font_info *w32_load_bdf_font (struct frame *f, char *fontname,
4959 int size, char* filename); 4979 int size, char* filename);
4960 4980
4961 struct font_info * 4981 struct font_info *
4962 w32_load_system_font (f,fontname,size) 4982 w32_load_system_font (f,fontname,size)
4963 struct frame *f; 4983 struct frame *f;
4964 char * fontname; 4984 char * fontname;
4965 int size; 4985 int size;
4966 { 4986 {
4967 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); 4987 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
4968 Lisp_Object font_names; 4988 Lisp_Object font_names;
4969 4989
4970 /* Get a list of all the fonts that match this name. Once we 4990 /* Get a list of all the fonts that match this name. Once we
5044 hdc = GetDC (dpyinfo->root_window); 5064 hdc = GetDC (dpyinfo->root_window);
5045 oldobj = SelectObject (hdc, font->hfont); 5065 oldobj = SelectObject (hdc, font->hfont);
5046 ok = GetTextMetrics (hdc, &font->tm); 5066 ok = GetTextMetrics (hdc, &font->tm);
5047 SelectObject (hdc, oldobj); 5067 SelectObject (hdc, oldobj);
5048 ReleaseDC (dpyinfo->root_window, hdc); 5068 ReleaseDC (dpyinfo->root_window, hdc);
5069
5070 /* [andrewi, 25-Apr-99] A number of fixed pitch fonts,
5071 eg. Courier New and perhaps others, report a max width which
5072 is larger than the average character width, at least on some
5073 NT systems (I don't understand why - my best guess is that it
5074 results from installing the CJK language packs for NT4).
5075 Unfortunately, this forces the redisplay code in dumpglyphs
5076 to draw text character by character.
5077
5078 I don't like this hack, but it seems better to force the max
5079 width to match the average width if the font is marked as
5080 fixed pitch, for the sake of redisplay performance. */
5081
5082 if ((font->tm.tmPitchAndFamily & TMPF_FIXED_PITCH) == 0)
5083 font->tm.tmMaxCharWidth = font->tm.tmAveCharWidth;
5049 } 5084 }
5050 5085
5051 UNBLOCK_INPUT; 5086 UNBLOCK_INPUT;
5052 5087
5053 if (!ok) 5088 if (!ok)
5797 5832
5798 Lisp_Object w32_list_bdf_fonts (Lisp_Object pattern, int max_names) 5833 Lisp_Object w32_list_bdf_fonts (Lisp_Object pattern, int max_names)
5799 { 5834 {
5800 char *fontname, *ptnstr; 5835 char *fontname, *ptnstr;
5801 Lisp_Object list, tem, newlist = Qnil; 5836 Lisp_Object list, tem, newlist = Qnil;
5802 int n_fonts; 5837 int n_fonts = 0;
5803 5838
5804 list = Vw32_bdf_filename_alist; 5839 list = Vw32_bdf_filename_alist;
5805 ptnstr = XSTRING (pattern)->data; 5840 ptnstr = XSTRING (pattern)->data;
5806 5841
5807 for ( ; CONSP (list); list = XCONS (list)->cdr) 5842 for ( ; CONSP (list); list = XCONS (list)->cdr)
6953 CHECK_NUMBER (command, 0); 6988 CHECK_NUMBER (command, 0);
6954 6989
6955 SendMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, XINT (command), 0); 6990 SendMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, XINT (command), 0);
6956 6991
6957 return Qnil; 6992 return Qnil;
6993 }
6994
6995 DEFUN ("w32-shell-execute", Fw32_shell_execute, Sw32_shell_execute, 2, 4, 0,
6996 "Get Windows to perform OPERATION on DOCUMENT.\n\
6997 This is a wrapper around the ShellExecute system function, which\n\
6998 invokes the application registered to handle OPERATION for DOCUMENT.\n\
6999 OPERATION is typically \"open\", \"print\" or \"explore\", and DOCUMENT\n\
7000 is typically the name of a document file or URL, but can also be a\n\
7001 program executable to run or a directory to open in the Windows Explorer.\n\
7002 \n\
7003 If DOCUMENT is a program executable, PARAMETERS can be a list of command\n\
7004 line parameters, but otherwise should be nil.\n\
7005 \n\
7006 SHOW-FLAG can be used to control whether the invoked application is hidden\n\
7007 or minimized. If SHOw-FLAG is nil, the application is displayed normally,\n\
7008 otherwise it is an integer representing a ShowWindow flag:\n\
7009 \n\
7010 0 - start hidden\n\
7011 1 - start normally\n\
7012 3 - start maximized\n\
7013 6 - start minimized")
7014 (operation, document, parameters, show_flag)
7015 Lisp_Object operation, document, parameters, show_flag;
7016 {
7017 Lisp_Object current_dir;
7018
7019 CHECK_STRING (operation, 0);
7020 CHECK_STRING (document, 0);
7021
7022 /* Encode filename and current directory. */
7023 current_dir = ENCODE_FILE (current_buffer->directory);
7024 document = ENCODE_FILE (document);
7025 if ((int) ShellExecute (NULL,
7026 XSTRING (operation)->data,
7027 XSTRING (document)->data,
7028 (STRINGP (parameters) ?
7029 XSTRING (parameters)->data : NULL),
7030 XSTRING (current_dir)->data,
7031 (INTEGERP (show_flag) ?
7032 XINT (show_flag) : SW_SHOWDEFAULT))
7033 > 32)
7034 return Qt;
7035 error ("ShellExecute failed");
6958 } 7036 }
6959 7037
6960 /* Lookup virtual keycode from string representing the name of a 7038 /* Lookup virtual keycode from string representing the name of a
6961 non-ascii keystroke into the corresponding virtual key, using 7039 non-ascii keystroke into the corresponding virtual key, using
6962 lispy_function_keys. */ 7040 lispy_function_keys. */
7499 defsubr (&Sw32_select_font); 7577 defsubr (&Sw32_select_font);
7500 defsubr (&Sw32_define_rgb_color); 7578 defsubr (&Sw32_define_rgb_color);
7501 defsubr (&Sw32_default_color_map); 7579 defsubr (&Sw32_default_color_map);
7502 defsubr (&Sw32_load_color_file); 7580 defsubr (&Sw32_load_color_file);
7503 defsubr (&Sw32_send_sys_command); 7581 defsubr (&Sw32_send_sys_command);
7582 defsubr (&Sw32_shell_execute);
7504 defsubr (&Sw32_register_hot_key); 7583 defsubr (&Sw32_register_hot_key);
7505 defsubr (&Sw32_unregister_hot_key); 7584 defsubr (&Sw32_unregister_hot_key);
7506 defsubr (&Sw32_registered_hot_keys); 7585 defsubr (&Sw32_registered_hot_keys);
7507 defsubr (&Sw32_reconstruct_hot_key); 7586 defsubr (&Sw32_reconstruct_hot_key);
7508 defsubr (&Sw32_toggle_lock_key); 7587 defsubr (&Sw32_toggle_lock_key);