Mercurial > emacs
comparison src/w32fns.c @ 86065:2557aa084b57
(Fw32_registered_hot_keys): Don't return the nil values corresponding
to deleted entries; they are an implementation detail.
(gray_bitmap_width, gray_bitmap_height, gray_bitmap_bits): Remove variables.
(w32_pass_extra_mouse_buttons_to_system, w32_strict_fontnames,
w32_pass_multimedia_buttons_to_system, w32_strict_painting,
Vw32_charset_info_alist, w32_to_x_color, w32_init_class, w32_createscrollbar,
w32_createwindow, my_post_msg, w32_get_modifiers, w32_grabbed_keys,
cancel_all_deferred_msgs): Make static.
(syms_of_w32fns) <w32-pass-multimedia-buttons-to-system>: Fix typo in docstring.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Wed, 14 Nov 2007 15:33:31 +0000 |
parents | 06d410ca9dce |
children | e1989ca5c28e |
comparison
equal
deleted
inserted
replaced
86064:31d99cc7cfc9 | 86065:2557aa084b57 |
---|---|
75 | 75 |
76 /* The gray bitmap `bitmaps/gray'. This is done because w32term.c uses | 76 /* The gray bitmap `bitmaps/gray'. This is done because w32term.c uses |
77 it, and including `bitmaps/gray' more than once is a problem when | 77 it, and including `bitmaps/gray' more than once is a problem when |
78 config.h defines `static' as an empty replacement string. */ | 78 config.h defines `static' as an empty replacement string. */ |
79 | 79 |
80 int gray_bitmap_width = gray_width; | |
81 int gray_bitmap_height = gray_height; | |
82 unsigned char *gray_bitmap_bits = gray_bits; | |
83 | |
84 /* The colormap for converting color names to RGB values */ | 80 /* The colormap for converting color names to RGB values */ |
85 Lisp_Object Vw32_color_map; | 81 Lisp_Object Vw32_color_map; |
86 | 82 |
87 /* Non nil if alt key presses are passed on to Windows. */ | 83 /* Non nil if alt key presses are passed on to Windows. */ |
88 Lisp_Object Vw32_pass_alt_to_system; | 84 Lisp_Object Vw32_pass_alt_to_system; |
141 /* Minimum interval between mouse movement (and scroll bar drag) | 137 /* Minimum interval between mouse movement (and scroll bar drag) |
142 events that are passed on to the event loop. */ | 138 events that are passed on to the event loop. */ |
143 int w32_mouse_move_interval; | 139 int w32_mouse_move_interval; |
144 | 140 |
145 /* Flag to indicate if XBUTTON events should be passed on to Windows. */ | 141 /* Flag to indicate if XBUTTON events should be passed on to Windows. */ |
146 int w32_pass_extra_mouse_buttons_to_system; | 142 static int w32_pass_extra_mouse_buttons_to_system; |
147 | 143 |
148 /* Flag to indicate if media keys should be passed on to Windows. */ | 144 /* Flag to indicate if media keys should be passed on to Windows. */ |
149 int w32_pass_multimedia_buttons_to_system; | 145 static int w32_pass_multimedia_buttons_to_system; |
150 | 146 |
151 /* Non nil if no window manager is in use. */ | 147 /* Non nil if no window manager is in use. */ |
152 Lisp_Object Vx_no_window_manager; | 148 Lisp_Object Vx_no_window_manager; |
153 | 149 |
154 /* Non-zero means we're allowed to display a hourglass pointer. */ | 150 /* Non-zero means we're allowed to display a hourglass pointer. */ |
183 | 179 |
184 /* Alist of bdf fonts and the files that define them. */ | 180 /* Alist of bdf fonts and the files that define them. */ |
185 Lisp_Object Vw32_bdf_filename_alist; | 181 Lisp_Object Vw32_bdf_filename_alist; |
186 | 182 |
187 /* A flag to control whether fonts are matched strictly or not. */ | 183 /* A flag to control whether fonts are matched strictly or not. */ |
188 int w32_strict_fontnames; | 184 static int w32_strict_fontnames; |
189 | 185 |
190 /* A flag to control whether we should only repaint if GetUpdateRect | 186 /* A flag to control whether we should only repaint if GetUpdateRect |
191 indicates there is an update region. */ | 187 indicates there is an update region. */ |
192 int w32_strict_painting; | 188 static int w32_strict_painting; |
193 | 189 |
194 /* Associative list linking character set strings to Windows codepages. */ | 190 /* Associative list linking character set strings to Windows codepages. */ |
195 Lisp_Object Vw32_charset_info_alist; | 191 static Lisp_Object Vw32_charset_info_alist; |
196 | 192 |
197 /* VIETNAMESE_CHARSET is not defined in some versions of MSVC. */ | 193 /* VIETNAMESE_CHARSET is not defined in some versions of MSVC. */ |
198 #ifndef VIETNAMESE_CHARSET | 194 #ifndef VIETNAMESE_CHARSET |
199 #define VIETNAMESE_CHARSET 163 | 195 #define VIETNAMESE_CHARSET 163 |
200 #endif | 196 #endif |
476 CHECK_NUMBER (red); | 472 CHECK_NUMBER (red); |
477 CHECK_NUMBER (green); | 473 CHECK_NUMBER (green); |
478 CHECK_NUMBER (blue); | 474 CHECK_NUMBER (blue); |
479 CHECK_STRING (name); | 475 CHECK_STRING (name); |
480 | 476 |
481 XSETINT (rgb, RGB(XUINT (red), XUINT (green), XUINT (blue))); | 477 XSETINT (rgb, RGB (XUINT (red), XUINT (green), XUINT (blue))); |
482 | 478 |
483 BLOCK_INPUT; | 479 BLOCK_INPUT; |
484 | 480 |
485 /* replace existing entry in w32-color-map or add new entry. */ | 481 /* replace existing entry in w32-color-map or add new entry. */ |
486 entry = Fassoc (name, Vw32_color_map); | 482 entry = Fassoc (name, Vw32_color_map); |
819 UNBLOCK_INPUT; | 815 UNBLOCK_INPUT; |
820 | 816 |
821 return (cmap); | 817 return (cmap); |
822 } | 818 } |
823 | 819 |
824 Lisp_Object | 820 static Lisp_Object |
825 w32_to_x_color (rgb) | 821 w32_to_x_color (rgb) |
826 Lisp_Object rgb; | 822 Lisp_Object rgb; |
827 { | 823 { |
828 Lisp_Object color; | 824 Lisp_Object color; |
829 | 825 |
936 /* Could be an old-style RGB Device specification. */ | 932 /* Could be an old-style RGB Device specification. */ |
937 char *color; | 933 char *color; |
938 int size; | 934 int size; |
939 color = colorname + 1; | 935 color = colorname + 1; |
940 | 936 |
941 size = strlen(color); | 937 size = strlen (color); |
942 if (size == 3 || size == 6 || size == 9 || size == 12) | 938 if (size == 3 || size == 6 || size == 9 || size == 12) |
943 { | 939 { |
944 UINT colorval; | 940 UINT colorval; |
945 int i, pos; | 941 int i, pos; |
946 pos = 0; | 942 pos = 0; |
954 unsigned long value; | 950 unsigned long value; |
955 | 951 |
956 /* The check for 'x' in the following conditional takes into | 952 /* The check for 'x' in the following conditional takes into |
957 account the fact that strtol allows a "0x" in front of | 953 account the fact that strtol allows a "0x" in front of |
958 our numbers, and we don't. */ | 954 our numbers, and we don't. */ |
959 if (!isxdigit(color[0]) || color[1] == 'x') | 955 if (!isxdigit (color[0]) || color[1] == 'x') |
960 break; | 956 break; |
961 t = color[size]; | 957 t = color[size]; |
962 color[size] = '\0'; | 958 color[size] = '\0'; |
963 value = strtoul(color, &end, 16); | 959 value = strtoul (color, &end, 16); |
964 color[size] = t; | 960 color[size] = t; |
965 if (errno == ERANGE || end - color != size) | 961 if (errno == ERANGE || end - color != size) |
966 break; | 962 break; |
967 switch (size) | 963 switch (size) |
968 { | 964 { |
988 } | 984 } |
989 color = end; | 985 color = end; |
990 } | 986 } |
991 } | 987 } |
992 } | 988 } |
993 else if (strnicmp(colorname, "rgb:", 4) == 0) | 989 else if (strnicmp (colorname, "rgb:", 4) == 0) |
994 { | 990 { |
995 char *color; | 991 char *color; |
996 UINT colorval; | 992 UINT colorval; |
997 int i, pos; | 993 int i, pos; |
998 pos = 0; | 994 pos = 0; |
1005 unsigned long value; | 1001 unsigned long value; |
1006 | 1002 |
1007 /* The check for 'x' in the following conditional takes into | 1003 /* The check for 'x' in the following conditional takes into |
1008 account the fact that strtol allows a "0x" in front of | 1004 account the fact that strtol allows a "0x" in front of |
1009 our numbers, and we don't. */ | 1005 our numbers, and we don't. */ |
1010 if (!isxdigit(color[0]) || color[1] == 'x') | 1006 if (!isxdigit (color[0]) || color[1] == 'x') |
1011 break; | 1007 break; |
1012 value = strtoul(color, &end, 16); | 1008 value = strtoul (color, &end, 16); |
1013 if (errno == ERANGE) | 1009 if (errno == ERANGE) |
1014 break; | 1010 break; |
1015 switch (end - color) | 1011 switch (end - color) |
1016 { | 1012 { |
1017 case 1: | 1013 case 1: |
1043 if (*end != '/') | 1039 if (*end != '/') |
1044 break; | 1040 break; |
1045 color = end + 1; | 1041 color = end + 1; |
1046 } | 1042 } |
1047 } | 1043 } |
1048 else if (strnicmp(colorname, "rgbi:", 5) == 0) | 1044 else if (strnicmp (colorname, "rgbi:", 5) == 0) |
1049 { | 1045 { |
1050 /* This is an RGB Intensity specification. */ | 1046 /* This is an RGB Intensity specification. */ |
1051 char *color; | 1047 char *color; |
1052 UINT colorval; | 1048 UINT colorval; |
1053 int i, pos; | 1049 int i, pos; |
1059 { | 1055 { |
1060 char *end; | 1056 char *end; |
1061 double value; | 1057 double value; |
1062 UINT val; | 1058 UINT val; |
1063 | 1059 |
1064 value = strtod(color, &end); | 1060 value = strtod (color, &end); |
1065 if (errno == ERANGE) | 1061 if (errno == ERANGE) |
1066 break; | 1062 break; |
1067 if (value < 0.0 || value > 1.0) | 1063 if (value < 0.0 || value > 1.0) |
1068 break; | 1064 break; |
1069 val = (UINT)(0x100 * value); | 1065 val = (UINT)(0x100 * value); |
1557 | 1553 |
1558 update_face_from_frame_parameter (f, Qmouse_color, arg); | 1554 update_face_from_frame_parameter (f, Qmouse_color, arg); |
1559 #endif /* TODO */ | 1555 #endif /* TODO */ |
1560 } | 1556 } |
1561 | 1557 |
1562 /* Defined in w32term.c. */ | |
1563 void | 1558 void |
1564 x_set_cursor_color (f, arg, oldval) | 1559 x_set_cursor_color (f, arg, oldval) |
1565 struct frame *f; | 1560 struct frame *f; |
1566 Lisp_Object arg, oldval; | 1561 Lisp_Object arg, oldval; |
1567 { | 1562 { |
1909 { | 1904 { |
1910 if (STRING_MULTIBYTE (name)) | 1905 if (STRING_MULTIBYTE (name)) |
1911 name = ENCODE_SYSTEM (name); | 1906 name = ENCODE_SYSTEM (name); |
1912 | 1907 |
1913 BLOCK_INPUT; | 1908 BLOCK_INPUT; |
1914 SetWindowText(FRAME_W32_WINDOW (f), SDATA (name)); | 1909 SetWindowText (FRAME_W32_WINDOW (f), SDATA (name)); |
1915 UNBLOCK_INPUT; | 1910 UNBLOCK_INPUT; |
1916 } | 1911 } |
1917 } | 1912 } |
1918 | 1913 |
1919 /* This function should be called when the user's lisp code has | 1914 /* This function should be called when the user's lisp code has |
1961 { | 1956 { |
1962 if (STRING_MULTIBYTE (name)) | 1957 if (STRING_MULTIBYTE (name)) |
1963 name = ENCODE_SYSTEM (name); | 1958 name = ENCODE_SYSTEM (name); |
1964 | 1959 |
1965 BLOCK_INPUT; | 1960 BLOCK_INPUT; |
1966 SetWindowText(FRAME_W32_WINDOW (f), SDATA (name)); | 1961 SetWindowText (FRAME_W32_WINDOW (f), SDATA (name)); |
1967 UNBLOCK_INPUT; | 1962 UNBLOCK_INPUT; |
1968 } | 1963 } |
1969 } | 1964 } |
1970 | 1965 |
1971 | 1966 |
2008 | 2003 |
2009 Cursor | 2004 Cursor |
2010 w32_load_cursor (LPCTSTR name) | 2005 w32_load_cursor (LPCTSTR name) |
2011 { | 2006 { |
2012 /* Try first to load cursor from application resource. */ | 2007 /* Try first to load cursor from application resource. */ |
2013 Cursor cursor = LoadImage ((HINSTANCE) GetModuleHandle(NULL), | 2008 Cursor cursor = LoadImage ((HINSTANCE) GetModuleHandle (NULL), |
2014 name, IMAGE_CURSOR, 0, 0, | 2009 name, IMAGE_CURSOR, 0, 0, |
2015 LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED); | 2010 LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED); |
2016 if (!cursor) | 2011 if (!cursor) |
2017 { | 2012 { |
2018 /* Then try to load a shared predefined cursor. */ | 2013 /* Then try to load a shared predefined cursor. */ |
2022 return cursor; | 2017 return cursor; |
2023 } | 2018 } |
2024 | 2019 |
2025 extern LRESULT CALLBACK w32_wnd_proc (); | 2020 extern LRESULT CALLBACK w32_wnd_proc (); |
2026 | 2021 |
2027 BOOL | 2022 static BOOL |
2028 w32_init_class (hinst) | 2023 w32_init_class (hinst) |
2029 HINSTANCE hinst; | 2024 HINSTANCE hinst; |
2030 { | 2025 { |
2031 WNDCLASS wc; | 2026 WNDCLASS wc; |
2032 | 2027 |
2042 wc.lpszClassName = EMACS_CLASS; | 2037 wc.lpszClassName = EMACS_CLASS; |
2043 | 2038 |
2044 return (RegisterClass (&wc)); | 2039 return (RegisterClass (&wc)); |
2045 } | 2040 } |
2046 | 2041 |
2047 HWND | 2042 static HWND |
2048 w32_createscrollbar (f, bar) | 2043 w32_createscrollbar (f, bar) |
2049 struct frame *f; | 2044 struct frame *f; |
2050 struct scroll_bar * bar; | 2045 struct scroll_bar * bar; |
2051 { | 2046 { |
2052 return (CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE, | 2047 return (CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE, |
2053 /* Position and size of scroll bar. */ | 2048 /* Position and size of scroll bar. */ |
2054 XINT(bar->left) + VERTICAL_SCROLL_BAR_WIDTH_TRIM, | 2049 XINT (bar->left) + VERTICAL_SCROLL_BAR_WIDTH_TRIM, |
2055 XINT(bar->top), | 2050 XINT (bar->top), |
2056 XINT(bar->width) - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, | 2051 XINT (bar->width) - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, |
2057 XINT(bar->height), | 2052 XINT (bar->height), |
2058 FRAME_W32_WINDOW (f), | 2053 FRAME_W32_WINDOW (f), |
2059 NULL, | 2054 NULL, |
2060 hinst, | 2055 hinst, |
2061 NULL)); | 2056 NULL)); |
2062 } | 2057 } |
2063 | 2058 |
2064 void | 2059 static void |
2065 w32_createwindow (f) | 2060 w32_createwindow (f) |
2066 struct frame *f; | 2061 struct frame *f; |
2067 { | 2062 { |
2068 HWND hwnd; | 2063 HWND hwnd; |
2069 RECT rect; | 2064 RECT rect; |
2129 f->left_pos = rect.left; | 2124 f->left_pos = rect.left; |
2130 f->top_pos = rect.top; | 2125 f->top_pos = rect.top; |
2131 } | 2126 } |
2132 } | 2127 } |
2133 | 2128 |
2134 void | 2129 static void |
2135 my_post_msg (wmsg, hwnd, msg, wParam, lParam) | 2130 my_post_msg (wmsg, hwnd, msg, wParam, lParam) |
2136 W32Msg * wmsg; | 2131 W32Msg * wmsg; |
2137 HWND hwnd; | 2132 HWND hwnd; |
2138 UINT msg; | 2133 UINT msg; |
2139 WPARAM wParam; | 2134 WPARAM wParam; |
2361 | 2356 |
2362 /* Don't generate any modifier if not explicitly requested. */ | 2357 /* Don't generate any modifier if not explicitly requested. */ |
2363 return 0; | 2358 return 0; |
2364 } | 2359 } |
2365 | 2360 |
2366 unsigned int | 2361 static unsigned int |
2367 w32_get_modifiers () | 2362 w32_get_modifiers () |
2368 { | 2363 { |
2369 return ((modifier_set (VK_SHIFT) ? shift_modifier : 0) | | 2364 return ((modifier_set (VK_SHIFT) ? shift_modifier : 0) | |
2370 (modifier_set (VK_CONTROL) ? ctrl_modifier : 0) | | 2365 (modifier_set (VK_CONTROL) ? ctrl_modifier : 0) | |
2371 (modifier_set (VK_LWIN) ? w32_key_to_modifier (VK_LWIN) : 0) | | 2366 (modifier_set (VK_LWIN) ? w32_key_to_modifier (VK_LWIN) : 0) | |
2432 | 2427 |
2433 return virt_key; | 2428 return virt_key; |
2434 } | 2429 } |
2435 | 2430 |
2436 /* List of special key combinations which w32 would normally capture, | 2431 /* List of special key combinations which w32 would normally capture, |
2437 but emacs should grab instead. Not directly visible to lisp, to | 2432 but Emacs should grab instead. Not directly visible to lisp, to |
2438 simplify synchronization. Each item is an integer encoding a virtual | 2433 simplify synchronization. Each item is an integer encoding a virtual |
2439 key code and modifier combination to capture. */ | 2434 key code and modifier combination to capture. */ |
2440 Lisp_Object w32_grabbed_keys; | 2435 static Lisp_Object w32_grabbed_keys; |
2441 | 2436 |
2442 #define HOTKEY(vk,mods) make_number (((vk) & 255) | ((mods) << 8)) | 2437 #define HOTKEY(vk, mods) make_number (((vk) & 255) | ((mods) << 8)) |
2443 #define HOTKEY_ID(k) (XFASTINT (k) & 0xbfff) | 2438 #define HOTKEY_ID(k) (XFASTINT (k) & 0xbfff) |
2444 #define HOTKEY_VK_CODE(k) (XFASTINT (k) & 255) | 2439 #define HOTKEY_VK_CODE(k) (XFASTINT (k) & 255) |
2445 #define HOTKEY_MODIFIERS(k) (XFASTINT (k) >> 8) | 2440 #define HOTKEY_MODIFIERS(k) (XFASTINT (k) >> 8) |
2446 | 2441 |
2447 #define RAW_HOTKEY_ID(k) ((k) & 0xbfff) | 2442 #define RAW_HOTKEY_ID(k) ((k) & 0xbfff) |
2664 complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result) | 2659 complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result) |
2665 { | 2660 { |
2666 deferred_msg * msg_buf = find_deferred_msg (hwnd, msg); | 2661 deferred_msg * msg_buf = find_deferred_msg (hwnd, msg); |
2667 | 2662 |
2668 if (msg_buf == NULL) | 2663 if (msg_buf == NULL) |
2669 /* Message may have been cancelled, so don't abort(). */ | 2664 /* Message may have been cancelled, so don't abort. */ |
2670 return; | 2665 return; |
2671 | 2666 |
2672 msg_buf->result = result; | 2667 msg_buf->result = result; |
2673 msg_buf->completed = 1; | 2668 msg_buf->completed = 1; |
2674 | 2669 |
2675 /* Ensure input thread is woken so it notices the completion. */ | 2670 /* Ensure input thread is woken so it notices the completion. */ |
2676 PostThreadMessage (dwWindowsThreadId, WM_NULL, 0, 0); | 2671 PostThreadMessage (dwWindowsThreadId, WM_NULL, 0, 0); |
2677 } | 2672 } |
2678 | 2673 |
2679 void | 2674 static void |
2680 cancel_all_deferred_msgs () | 2675 cancel_all_deferred_msgs () |
2681 { | 2676 { |
2682 deferred_msg * item; | 2677 deferred_msg * item; |
2683 | 2678 |
2684 /* Don't actually need synchronization for read access, since | 2679 /* Don't actually need synchronization for read access, since |
2752 | 2747 |
2753 wmsg.dwModifiers = modifiers; | 2748 wmsg.dwModifiers = modifiers; |
2754 | 2749 |
2755 /* Detect quit_char and set quit-flag directly. Note that we | 2750 /* Detect quit_char and set quit-flag directly. Note that we |
2756 still need to post a message to ensure the main thread will be | 2751 still need to post a message to ensure the main thread will be |
2757 woken up if blocked in sys_select(), but we do NOT want to post | 2752 woken up if blocked in sys_select, but we do NOT want to post |
2758 the quit_char message itself (because it will usually be as if | 2753 the quit_char message itself (because it will usually be as if |
2759 the user had typed quit_char twice). Instead, we post a dummy | 2754 the user had typed quit_char twice). Instead, we post a dummy |
2760 message that has no particular effect. */ | 2755 message that has no particular effect. */ |
2761 { | 2756 { |
2762 int c = wParam; | 2757 int c = wParam; |
2907 return 0; | 2902 return 0; |
2908 } | 2903 } |
2909 | 2904 |
2910 /* If GetUpdateRect returns 0 (meaning there is no update | 2905 /* If GetUpdateRect returns 0 (meaning there is no update |
2911 region), assume the whole window needs to be repainted. */ | 2906 region), assume the whole window needs to be repainted. */ |
2912 GetClientRect(hwnd, &wmsg.rect); | 2907 GetClientRect (hwnd, &wmsg.rect); |
2913 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); | 2908 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); |
2914 return 0; | 2909 return 0; |
2915 } | 2910 } |
2916 | 2911 |
2917 case WM_INPUTLANGCHANGE: | 2912 case WM_INPUTLANGCHANGE: |
3701 DWORD line_height; | 3696 DWORD line_height; |
3702 DWORD internal_border; | 3697 DWORD internal_border; |
3703 DWORD scrollbar_extra; | 3698 DWORD scrollbar_extra; |
3704 RECT wr; | 3699 RECT wr; |
3705 | 3700 |
3706 wp.length = sizeof(wp); | 3701 wp.length = sizeof (wp); |
3707 GetWindowRect (hwnd, &wr); | 3702 GetWindowRect (hwnd, &wr); |
3708 | 3703 |
3709 enter_crit (); | 3704 enter_crit (); |
3710 | 3705 |
3711 font_width = GetWindowLong (hwnd, WND_FONTWIDTH_INDEX); | 3706 font_width = GetWindowLong (hwnd, WND_FONTWIDTH_INDEX); |
4496 return Qnil; | 4491 return Qnil; |
4497 } | 4492 } |
4498 | 4493 |
4499 | 4494 |
4500 /* Return the charset portion of a font name. */ | 4495 /* Return the charset portion of a font name. */ |
4501 char * xlfd_charset_of_font (char * fontname) | 4496 char * |
4497 xlfd_charset_of_font (char * fontname) | |
4502 { | 4498 { |
4503 char *charset, *encoding; | 4499 char *charset, *encoding; |
4504 | 4500 |
4505 encoding = strrchr(fontname, '-'); | 4501 encoding = strrchr (fontname, '-'); |
4506 if (!encoding || encoding == fontname) | 4502 if (!encoding || encoding == fontname) |
4507 return NULL; | 4503 return NULL; |
4508 | 4504 |
4509 for (charset = encoding - 1; charset >= fontname; charset--) | 4505 for (charset = encoding - 1; charset >= fontname; charset--) |
4510 if (*charset == '-') | 4506 if (*charset == '-') |
4511 break; | 4507 break; |
4512 | 4508 |
4513 if (charset == fontname || strcmp(charset, "-*-*") == 0) | 4509 if (charset == fontname || strcmp (charset, "-*-*") == 0) |
4514 return NULL; | 4510 return NULL; |
4515 | 4511 |
4516 return charset + 1; | 4512 return charset + 1; |
4517 } | 4513 } |
4518 | 4514 |
4522 static BOOL w32_to_x_font (LOGFONT * lplf, char * lpxstr, int len, | 4518 static BOOL w32_to_x_font (LOGFONT * lplf, char * lpxstr, int len, |
4523 char * charset); | 4519 char * charset); |
4524 static BOOL x_to_w32_font (char *lpxstr, LOGFONT *lplogfont); | 4520 static BOOL x_to_w32_font (char *lpxstr, LOGFONT *lplogfont); |
4525 | 4521 |
4526 static struct font_info * | 4522 static struct font_info * |
4527 w32_load_system_font (f,fontname,size) | 4523 w32_load_system_font (f, fontname, size) |
4528 struct frame *f; | 4524 struct frame *f; |
4529 char * fontname; | 4525 char * fontname; |
4530 int size; | 4526 int size; |
4531 { | 4527 { |
4532 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); | 4528 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); |
4625 don't report themselves as double byte fonts, when | 4621 don't report themselves as double byte fonts, when |
4626 patently they are. So instead of trusting | 4622 patently they are. So instead of trusting |
4627 GetFontLanguageInfo, we check the properties of the | 4623 GetFontLanguageInfo, we check the properties of the |
4628 codepage directly, since that is ultimately what we are | 4624 codepage directly, since that is ultimately what we are |
4629 working from anyway. */ | 4625 working from anyway. */ |
4630 /* font->double_byte_p = GetFontLanguageInfo(hdc) & GCP_DBCS; */ | 4626 /* font->double_byte_p = GetFontLanguageInfo (hdc) & GCP_DBCS; */ |
4631 CPINFO cpi = {0}; | 4627 CPINFO cpi = {0}; |
4632 GetCPInfo (codepage, &cpi); | 4628 GetCPInfo (codepage, &cpi); |
4633 font->double_byte_p = cpi.MaxCharSize > 1; | 4629 font->double_byte_p = cpi.MaxCharSize > 1; |
4634 } | 4630 } |
4635 | 4631 |
4761 | 4757 |
4762 /* Load font named FONTNAME of size SIZE for frame F, and return a | 4758 /* Load font named FONTNAME of size SIZE for frame F, and return a |
4763 pointer to the structure font_info while allocating it dynamically. | 4759 pointer to the structure font_info while allocating it dynamically. |
4764 If loading fails, return NULL. */ | 4760 If loading fails, return NULL. */ |
4765 struct font_info * | 4761 struct font_info * |
4766 w32_load_font (f,fontname,size) | 4762 w32_load_font (f, fontname, size) |
4767 struct frame *f; | 4763 struct frame *f; |
4768 char * fontname; | 4764 char * fontname; |
4769 int size; | 4765 int size; |
4770 { | 4766 { |
4771 Lisp_Object bdf_fonts; | 4767 Lisp_Object bdf_fonts; |
4772 struct font_info *retval = NULL; | 4768 struct font_info *retval = NULL; |
4773 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); | 4769 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); |
4774 | 4770 |
4800 } | 4796 } |
4801 | 4797 |
4802 if (retval) | 4798 if (retval) |
4803 return retval; | 4799 return retval; |
4804 | 4800 |
4805 return w32_load_system_font(f, fontname, size); | 4801 return w32_load_system_font (f, fontname, size); |
4806 } | 4802 } |
4807 | 4803 |
4808 | 4804 |
4809 void | 4805 void |
4810 w32_unload_font (dpyinfo, font) | 4806 w32_unload_font (dpyinfo, font) |
4814 if (font) | 4810 if (font) |
4815 { | 4811 { |
4816 if (font->per_char) xfree (font->per_char); | 4812 if (font->per_char) xfree (font->per_char); |
4817 if (font->bdf) w32_free_bdf_font (font->bdf); | 4813 if (font->bdf) w32_free_bdf_font (font->bdf); |
4818 | 4814 |
4819 if (font->hfont) DeleteObject(font->hfont); | 4815 if (font->hfont) DeleteObject (font->hfont); |
4820 xfree (font); | 4816 xfree (font); |
4821 } | 4817 } |
4822 } | 4818 } |
4823 | 4819 |
4824 /* The font conversion stuff between x and w32 */ | 4820 /* The font conversion stuff between x and w32 */ |
4848 x_to_w32_weight (lpw) | 4844 x_to_w32_weight (lpw) |
4849 char * lpw; | 4845 char * lpw; |
4850 { | 4846 { |
4851 if (!lpw) return (FW_DONTCARE); | 4847 if (!lpw) return (FW_DONTCARE); |
4852 | 4848 |
4853 if (stricmp (lpw,"heavy") == 0) return FW_HEAVY; | 4849 if (stricmp (lpw, "heavy") == 0) return FW_HEAVY; |
4854 else if (stricmp (lpw,"extrabold") == 0) return FW_EXTRABOLD; | 4850 else if (stricmp (lpw, "extrabold") == 0) return FW_EXTRABOLD; |
4855 else if (stricmp (lpw,"bold") == 0) return FW_BOLD; | 4851 else if (stricmp (lpw, "bold") == 0) return FW_BOLD; |
4856 else if (stricmp (lpw,"demibold") == 0) return FW_SEMIBOLD; | 4852 else if (stricmp (lpw, "demibold") == 0) return FW_SEMIBOLD; |
4857 else if (stricmp (lpw,"semibold") == 0) return FW_SEMIBOLD; | 4853 else if (stricmp (lpw, "semibold") == 0) return FW_SEMIBOLD; |
4858 else if (stricmp (lpw,"medium") == 0) return FW_MEDIUM; | 4854 else if (stricmp (lpw, "medium") == 0) return FW_MEDIUM; |
4859 else if (stricmp (lpw,"normal") == 0) return FW_NORMAL; | 4855 else if (stricmp (lpw, "normal") == 0) return FW_NORMAL; |
4860 else if (stricmp (lpw,"light") == 0) return FW_LIGHT; | 4856 else if (stricmp (lpw, "light") == 0) return FW_LIGHT; |
4861 else if (stricmp (lpw,"extralight") == 0) return FW_EXTRALIGHT; | 4857 else if (stricmp (lpw, "extralight") == 0) return FW_EXTRALIGHT; |
4862 else if (stricmp (lpw,"thin") == 0) return FW_THIN; | 4858 else if (stricmp (lpw, "thin") == 0) return FW_THIN; |
4863 else | 4859 else |
4864 return FW_DONTCARE; | 4860 return FW_DONTCARE; |
4865 } | 4861 } |
4866 | 4862 |
4867 | 4863 |
4903 | 4899 |
4904 /* Look through w32-charset-info-alist for the character set. | 4900 /* Look through w32-charset-info-alist for the character set. |
4905 Format of each entry is | 4901 Format of each entry is |
4906 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). | 4902 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). |
4907 */ | 4903 */ |
4908 this_entry = Fassoc (build_string(charset), Vw32_charset_info_alist); | 4904 this_entry = Fassoc (build_string (charset), Vw32_charset_info_alist); |
4909 | 4905 |
4910 if (NILP(this_entry)) | 4906 if (NILP (this_entry)) |
4911 { | 4907 { |
4912 /* At startup, we want iso8859-1 fonts to come up properly. */ | 4908 /* At startup, we want iso8859-1 fonts to come up properly. */ |
4913 if (stricmp(charset, "iso8859-1") == 0) | 4909 if (stricmp (charset, "iso8859-1") == 0) |
4914 return ANSI_CHARSET; | 4910 return ANSI_CHARSET; |
4915 else | 4911 else |
4916 return DEFAULT_CHARSET; | 4912 return DEFAULT_CHARSET; |
4917 } | 4913 } |
4918 | 4914 |
4976 switch (fncharset) | 4972 switch (fncharset) |
4977 { | 4973 { |
4978 case ANSI_CHARSET: | 4974 case ANSI_CHARSET: |
4979 /* Handle startup case of w32-charset-info-alist not | 4975 /* Handle startup case of w32-charset-info-alist not |
4980 being set up yet. */ | 4976 being set up yet. */ |
4981 if (NILP(Vw32_charset_info_alist)) | 4977 if (NILP (Vw32_charset_info_alist)) |
4982 return "iso8859-1"; | 4978 return "iso8859-1"; |
4983 charset_type = Qw32_charset_ansi; | 4979 charset_type = Qw32_charset_ansi; |
4984 break; | 4980 break; |
4985 case DEFAULT_CHARSET: | 4981 case DEFAULT_CHARSET: |
4986 charset_type = Qw32_charset_default; | 4982 charset_type = Qw32_charset_default; |
5115 { | 5111 { |
5116 sprintf (buf, "*-#%u", fncharset); | 5112 sprintf (buf, "*-#%u", fncharset); |
5117 return buf; | 5113 return buf; |
5118 } | 5114 } |
5119 | 5115 |
5120 strncpy(buf, best_match, 31); | 5116 strncpy (buf, best_match, 31); |
5121 buf[31] = '\0'; | 5117 buf[31] = '\0'; |
5122 return buf; | 5118 return buf; |
5123 } | 5119 } |
5124 } | 5120 } |
5125 | 5121 |
5136 switch (fncharset) | 5132 switch (fncharset) |
5137 { | 5133 { |
5138 case ANSI_CHARSET: | 5134 case ANSI_CHARSET: |
5139 /* Handle startup case of w32-charset-info-alist not | 5135 /* Handle startup case of w32-charset-info-alist not |
5140 being set up yet. */ | 5136 being set up yet. */ |
5141 if (NILP(Vw32_charset_info_alist)) | 5137 if (NILP (Vw32_charset_info_alist)) |
5142 return Fcons (build_string ("iso8859-1"), Qnil); | 5138 return Fcons (build_string ("iso8859-1"), Qnil); |
5143 | 5139 |
5144 charset_type = Qw32_charset_ansi; | 5140 charset_type = Qw32_charset_ansi; |
5145 break; | 5141 break; |
5146 case DEFAULT_CHARSET: | 5142 case DEFAULT_CHARSET: |
5296 if (end > charset && *(end-1) == '-') | 5292 if (end > charset && *(end-1) == '-') |
5297 end--; | 5293 end--; |
5298 *end = '\0'; | 5294 *end = '\0'; |
5299 } | 5295 } |
5300 | 5296 |
5301 entry = Fassoc (build_string(charset), Vw32_charset_info_alist); | 5297 entry = Fassoc (build_string (charset), Vw32_charset_info_alist); |
5302 if (NILP (entry)) | 5298 if (NILP (entry)) |
5303 return CP_UNKNOWN; | 5299 return CP_UNKNOWN; |
5304 | 5300 |
5305 codepage = Fcdr (Fcdr (entry)); | 5301 codepage = Fcdr (Fcdr (entry)); |
5306 | 5302 |
5353 /* We explicitely disable composition handling because selection | 5349 /* We explicitely disable composition handling because selection |
5354 data should not contain any composition sequence. */ | 5350 data should not contain any composition sequence. */ |
5355 coding.composing = COMPOSITION_DISABLED; | 5351 coding.composing = COMPOSITION_DISABLED; |
5356 bufsz = decoding_buffer_size (&coding, LF_FACESIZE); | 5352 bufsz = decoding_buffer_size (&coding, LF_FACESIZE); |
5357 | 5353 |
5358 fontname = alloca(sizeof(*fontname) * bufsz); | 5354 fontname = alloca (sizeof (*fontname) * bufsz); |
5359 decode_coding (&coding, lplogfont->lfFaceName, fontname, | 5355 decode_coding (&coding, lplogfont->lfFaceName, fontname, |
5360 strlen(lplogfont->lfFaceName), bufsz - 1); | 5356 strlen (lplogfont->lfFaceName), bufsz - 1); |
5361 *(fontname + coding.produced) = '\0'; | 5357 *(fontname + coding.produced) = '\0'; |
5362 | 5358 |
5363 /* Replace dashes with underscores so the dashes are not | 5359 /* Replace dashes with underscores so the dashes are not |
5364 misinterpreted. */ | 5360 misinterpreted. */ |
5365 fontname_dash = fontname; | 5361 fontname_dash = fontname; |
5566 | 5562 |
5567 if (fields == EOF) return (FALSE); | 5563 if (fields == EOF) return (FALSE); |
5568 | 5564 |
5569 if (fields > 0) | 5565 if (fields > 0) |
5570 { | 5566 { |
5571 strncpy (lplogfont->lfFaceName,name, LF_FACESIZE); | 5567 strncpy (lplogfont->lfFaceName, name, LF_FACESIZE); |
5572 lplogfont->lfFaceName[LF_FACESIZE-1] = 0; | 5568 lplogfont->lfFaceName[LF_FACESIZE-1] = 0; |
5573 } | 5569 } |
5574 else | 5570 else |
5575 { | 5571 { |
5576 lplogfont->lfFaceName[0] = 0; | 5572 lplogfont->lfFaceName[0] = 0; |
5765 if (font_height && pattern_height && (font_height != pattern_height)) | 5761 if (font_height && pattern_height && (font_height != pattern_height)) |
5766 return FALSE; | 5762 return FALSE; |
5767 } | 5763 } |
5768 | 5764 |
5769 return (fast_string_match_ignore_case (build_string (regex), | 5765 return (fast_string_match_ignore_case (build_string (regex), |
5770 build_string(font_name_copy)) >= 0); | 5766 build_string (font_name_copy)) >= 0); |
5771 } | 5767 } |
5772 | 5768 |
5773 /* Callback functions, and a structure holding info they need, for | 5769 /* Callback functions, and a structure holding info they need, for |
5774 listing system fonts on W32. We need one set of functions to do the | 5770 listing system fonts on W32. We need one set of functions to do the |
5775 job properly, but these don't work on NT 3.51 and earlier, so we | 5771 job properly, but these don't work on NT 3.51 and earlier, so we |
6000 } | 5996 } |
6001 | 5997 |
6002 /* Interface to fontset handler. (adapted from mw32font.c in Meadow | 5998 /* Interface to fontset handler. (adapted from mw32font.c in Meadow |
6003 and xterm.c in Emacs 20.3) */ | 5999 and xterm.c in Emacs 20.3) */ |
6004 | 6000 |
6005 static Lisp_Object w32_list_bdf_fonts (Lisp_Object pattern, int max_names) | 6001 static Lisp_Object |
6002 w32_list_bdf_fonts (Lisp_Object pattern, int max_names) | |
6006 { | 6003 { |
6007 char *fontname, *ptnstr; | 6004 char *fontname, *ptnstr; |
6008 Lisp_Object list, tem, newlist = Qnil; | 6005 Lisp_Object list, tem, newlist = Qnil; |
6009 int n_fonts = 0; | 6006 int n_fonts = 0; |
6010 | 6007 |
6071 /* Avoid expensive EnumFontFamilies functions if we are not | 6068 /* Avoid expensive EnumFontFamilies functions if we are not |
6072 going to be able to output one of these anyway. */ | 6069 going to be able to output one of these anyway. */ |
6073 codepage = w32_codepage_for_font (SDATA (tpat)); | 6070 codepage = w32_codepage_for_font (SDATA (tpat)); |
6074 if (codepage != CP_8BIT && codepage != CP_UNICODE | 6071 if (codepage != CP_8BIT && codepage != CP_UNICODE |
6075 && codepage != CP_DEFAULT && codepage != CP_UNKNOWN | 6072 && codepage != CP_DEFAULT && codepage != CP_UNKNOWN |
6076 && !IsValidCodePage(codepage)) | 6073 && !IsValidCodePage (codepage)) |
6077 continue; | 6074 continue; |
6078 | 6075 |
6079 /* See if we cached the result for this particular query. | 6076 /* See if we cached the result for this particular query. |
6080 The cache is an alist of the form: | 6077 The cache is an alist of the form: |
6081 ((PATTERN (FONTNAME . WIDTH) ...) ...) | 6078 ((PATTERN (FONTNAME . WIDTH) ...) ...) |
6182 XSETCDR (tem, make_number (FONT_WIDTH (&thisinfo))); | 6179 XSETCDR (tem, make_number (FONT_WIDTH (&thisinfo))); |
6183 else | 6180 else |
6184 XSETCDR (tem, make_number (0)); | 6181 XSETCDR (tem, make_number (0)); |
6185 SelectObject (hdc, oldobj); | 6182 SelectObject (hdc, oldobj); |
6186 ReleaseDC (dpyinfo->root_window, hdc); | 6183 ReleaseDC (dpyinfo->root_window, hdc); |
6187 DeleteObject(thisinfo.hfont); | 6184 DeleteObject (thisinfo.hfont); |
6188 UNBLOCK_INPUT; | 6185 UNBLOCK_INPUT; |
6189 } | 6186 } |
6190 found_size = XINT (XCDR (tem)); | 6187 found_size = XINT (XCDR (tem)); |
6191 if (found_size == size) | 6188 if (found_size == size) |
6192 { | 6189 { |
6231 if (n_fonts < maxnames || maxnames < 0) | 6228 if (n_fonts < maxnames || maxnames < 0) |
6232 { | 6229 { |
6233 Lisp_Object combined[2]; | 6230 Lisp_Object combined[2]; |
6234 combined[0] = w32_list_bdf_fonts (pattern, maxnames - n_fonts); | 6231 combined[0] = w32_list_bdf_fonts (pattern, maxnames - n_fonts); |
6235 combined[1] = newlist; | 6232 combined[1] = newlist; |
6236 newlist = Fnconc(2, combined); | 6233 newlist = Fnconc (2, combined); |
6237 } | 6234 } |
6238 | 6235 |
6239 return newlist; | 6236 return newlist; |
6240 } | 6237 } |
6241 | 6238 |
6258 | 6255 |
6259 pfi = FRAME_W32_FONT_TABLE (f); | 6256 pfi = FRAME_W32_FONT_TABLE (f); |
6260 | 6257 |
6261 for (i = 0; i < one_w32_display_info.n_fonts ;i++, pfi++) | 6258 for (i = 0; i < one_w32_display_info.n_fonts ;i++, pfi++) |
6262 { | 6259 { |
6263 if (stricmp(pfi->name, fontname) == 0) return pfi; | 6260 if (stricmp (pfi->name, fontname) == 0) return pfi; |
6264 } | 6261 } |
6265 | 6262 |
6266 return NULL; | 6263 return NULL; |
6267 } | 6264 } |
6268 | 6265 |
6295 fontp->font_encoder = ccl; | 6292 fontp->font_encoder = ccl; |
6296 } | 6293 } |
6297 } | 6294 } |
6298 | 6295 |
6299 /* directory-files from dired.c. */ | 6296 /* directory-files from dired.c. */ |
6300 Lisp_Object Fdirectory_files P_((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)); | 6297 Lisp_Object Fdirectory_files P_ ((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)); |
6301 | 6298 |
6302 | 6299 |
6303 /* Find BDF files in a specified directory. (use GCPRO when calling, | 6300 /* Find BDF files in a specified directory. (use GCPRO when calling, |
6304 as this calls lisp to get a directory listing). */ | 6301 as this calls lisp to get a directory listing). */ |
6305 static Lisp_Object | 6302 static Lisp_Object |
6306 w32_find_bdf_fonts_in_dir (Lisp_Object directory) | 6303 w32_find_bdf_fonts_in_dir (Lisp_Object directory) |
6307 { | 6304 { |
6308 Lisp_Object filelist, list = Qnil; | 6305 Lisp_Object filelist, list = Qnil; |
6309 char fontname[100]; | 6306 char fontname[100]; |
6310 | 6307 |
6311 if (!STRINGP(directory)) | 6308 if (!STRINGP (directory)) |
6312 return Qnil; | 6309 return Qnil; |
6313 | 6310 |
6314 filelist = Fdirectory_files (directory, Qt, | 6311 filelist = Fdirectory_files (directory, Qt, |
6315 build_string (".*\\.[bB][dD][fF]"), Qt); | 6312 build_string (".*\\.[bB][dD][fF]"), Qt); |
6316 | 6313 |
6317 for ( ; CONSP(filelist); filelist = XCDR (filelist)) | 6314 for ( ; CONSP (filelist); filelist = XCDR (filelist)) |
6318 { | 6315 { |
6319 Lisp_Object filename = XCAR (filelist); | 6316 Lisp_Object filename = XCAR (filelist); |
6320 if (w32_BDF_to_x_font (SDATA (filename), fontname, 100)) | 6317 if (w32_BDF_to_x_font (SDATA (filename), fontname, 100)) |
6321 store_in_alist (&list, build_string (fontname), filename); | 6318 store_in_alist (&list, build_string (fontname), filename); |
6322 } | 6319 } |
6342 { | 6339 { |
6343 Lisp_Object pair[2]; | 6340 Lisp_Object pair[2]; |
6344 pair[0] = list; | 6341 pair[0] = list; |
6345 pair[1] = Qnil; | 6342 pair[1] = Qnil; |
6346 GCPRO2 (directory, list); | 6343 GCPRO2 (directory, list); |
6347 pair[1] = w32_find_bdf_fonts_in_dir( XCAR (directory) ); | 6344 pair[1] = w32_find_bdf_fonts_in_dir ( XCAR (directory) ); |
6348 list = Fnconc( 2, pair ); | 6345 list = Fnconc ( 2, pair ); |
6349 UNGCPRO; | 6346 UNGCPRO; |
6350 } | 6347 } |
6351 return list; | 6348 return list; |
6352 } | 6349 } |
6353 | 6350 |
6482 cap = GetDeviceCaps (hdc, NUMCOLORS); | 6479 cap = GetDeviceCaps (hdc, NUMCOLORS); |
6483 | 6480 |
6484 /* We force 24+ bit depths to 24-bit, both to prevent an overflow | 6481 /* We force 24+ bit depths to 24-bit, both to prevent an overflow |
6485 and because probably is more meaningful on Windows anyway */ | 6482 and because probably is more meaningful on Windows anyway */ |
6486 if (cap < 0) | 6483 if (cap < 0) |
6487 cap = 1 << min(dpyinfo->n_planes * dpyinfo->n_cbits, 24); | 6484 cap = 1 << min (dpyinfo->n_planes * dpyinfo->n_cbits, 24); |
6488 | 6485 |
6489 ReleaseDC (dpyinfo->root_window, hdc); | 6486 ReleaseDC (dpyinfo->root_window, hdc); |
6490 | 6487 |
6491 return make_number (cap); | 6488 return make_number (cap); |
6492 } | 6489 } |
6745 HOME directory, then in Emacs etc dir for a file called rgb.txt. */ | 6742 HOME directory, then in Emacs etc dir for a file called rgb.txt. */ |
6746 { | 6743 { |
6747 Lisp_Object color_file; | 6744 Lisp_Object color_file; |
6748 struct gcpro gcpro1; | 6745 struct gcpro gcpro1; |
6749 | 6746 |
6750 color_file = build_string("~/rgb.txt"); | 6747 color_file = build_string ("~/rgb.txt"); |
6751 | 6748 |
6752 GCPRO1 (color_file); | 6749 GCPRO1 (color_file); |
6753 | 6750 |
6754 if (NILP (Ffile_readable_p (color_file))) | 6751 if (NILP (Ffile_readable_p (color_file))) |
6755 color_file = | 6752 color_file = |
7983 /* "Directories" selected - strip dummy file name. */ | 7980 /* "Directories" selected - strip dummy file name. */ |
7984 char * last = strrchr (filename, '/'); | 7981 char * last = strrchr (filename, '/'); |
7985 *last = '\0'; | 7982 *last = '\0'; |
7986 } | 7983 } |
7987 | 7984 |
7988 file = DECODE_FILE(build_string (filename)); | 7985 file = DECODE_FILE (build_string (filename)); |
7989 } | 7986 } |
7990 /* User cancelled the dialog without making a selection. */ | 7987 /* User cancelled the dialog without making a selection. */ |
7991 else if (!CommDlgExtendedError ()) | 7988 else if (!CommDlgExtendedError ()) |
7992 file = Qnil; | 7989 file = Qnil; |
7993 /* An error occurred, fallback on reading from the mini-buffer. */ | 7990 /* An error occurred, fallback on reading from the mini-buffer. */ |
8309 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY, | 8306 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY, |
8310 (WPARAM) XINT (XCAR (item)), (LPARAM) item.i)) | 8307 (WPARAM) XINT (XCAR (item)), (LPARAM) item.i)) |
8311 #else | 8308 #else |
8312 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY, | 8309 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY, |
8313 (WPARAM) XINT (XCAR (item)), (LPARAM) item)) | 8310 (WPARAM) XINT (XCAR (item)), (LPARAM) item)) |
8314 | |
8315 #endif | 8311 #endif |
8316 { | 8312 { |
8317 MSG msg; | 8313 MSG msg; |
8318 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); | 8314 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); |
8319 } | 8315 } |
8325 DEFUN ("w32-registered-hot-keys", Fw32_registered_hot_keys, | 8321 DEFUN ("w32-registered-hot-keys", Fw32_registered_hot_keys, |
8326 Sw32_registered_hot_keys, 0, 0, 0, | 8322 Sw32_registered_hot_keys, 0, 0, 0, |
8327 doc: /* Return list of registered hot-key IDs. */) | 8323 doc: /* Return list of registered hot-key IDs. */) |
8328 () | 8324 () |
8329 { | 8325 { |
8330 return Fcopy_sequence (w32_grabbed_keys); | 8326 return Fdelq (Qnil, Fcopy_sequence (w32_grabbed_keys)); |
8331 } | 8327 } |
8332 | 8328 |
8333 DEFUN ("w32-reconstruct-hot-key", Fw32_reconstruct_hot_key, | 8329 DEFUN ("w32-reconstruct-hot-key", Fw32_reconstruct_hot_key, |
8334 Sw32_reconstruct_hot_key, 1, 1, 0, | 8330 Sw32_reconstruct_hot_key, 1, 1, 0, |
8335 doc: /* Convert hot-key ID to a lisp key combination. | 8331 doc: /* Convert hot-key ID to a lisp key combination. |
8488 use signed ones instead. */ | 8484 use signed ones instead. */ |
8489 LARGE_INTEGER availbytes; | 8485 LARGE_INTEGER availbytes; |
8490 LARGE_INTEGER freebytes; | 8486 LARGE_INTEGER freebytes; |
8491 LARGE_INTEGER totalbytes; | 8487 LARGE_INTEGER totalbytes; |
8492 | 8488 |
8493 if (pfn_GetDiskFreeSpaceEx(rootname, | 8489 if (pfn_GetDiskFreeSpaceEx (rootname, |
8494 (ULARGE_INTEGER *)&availbytes, | 8490 (ULARGE_INTEGER *)&availbytes, |
8495 (ULARGE_INTEGER *)&totalbytes, | 8491 (ULARGE_INTEGER *)&totalbytes, |
8496 (ULARGE_INTEGER *)&freebytes)) | 8492 (ULARGE_INTEGER *)&freebytes)) |
8497 value = list3 (make_float ((double) totalbytes.QuadPart), | 8493 value = list3 (make_float ((double) totalbytes.QuadPart), |
8498 make_float ((double) freebytes.QuadPart), | 8494 make_float ((double) freebytes.QuadPart), |
8499 make_float ((double) availbytes.QuadPart)); | 8495 make_float ((double) availbytes.QuadPart)); |
8500 } | 8496 } |
8501 else | 8497 else |
8503 DWORD sectors_per_cluster; | 8499 DWORD sectors_per_cluster; |
8504 DWORD bytes_per_sector; | 8500 DWORD bytes_per_sector; |
8505 DWORD free_clusters; | 8501 DWORD free_clusters; |
8506 DWORD total_clusters; | 8502 DWORD total_clusters; |
8507 | 8503 |
8508 if (GetDiskFreeSpace(rootname, | 8504 if (GetDiskFreeSpace (rootname, |
8509 §ors_per_cluster, | 8505 §ors_per_cluster, |
8510 &bytes_per_sector, | 8506 &bytes_per_sector, |
8511 &free_clusters, | 8507 &free_clusters, |
8512 &total_clusters)) | 8508 &total_clusters)) |
8513 value = list3 (make_float ((double) total_clusters | 8509 value = list3 (make_float ((double) total_clusters |
8514 * sectors_per_cluster * bytes_per_sector), | 8510 * sectors_per_cluster * bytes_per_sector), |
8515 make_float ((double) free_clusters | 8511 make_float ((double) free_clusters |
8516 * sectors_per_cluster * bytes_per_sector), | 8512 * sectors_per_cluster * bytes_per_sector), |
8517 make_float ((double) free_clusters | 8513 make_float ((double) free_clusters |
8553 if (!ppi2) | 8549 if (!ppi2) |
8554 { | 8550 { |
8555 ClosePrinter (hPrn); | 8551 ClosePrinter (hPrn); |
8556 return Qnil; | 8552 return Qnil; |
8557 } | 8553 } |
8558 /* Call GetPrinter() again with big enouth memory block */ | 8554 /* Call GetPrinter again with big enouth memory block */ |
8559 err = GetPrinter (hPrn, 2, (LPBYTE)ppi2, dwNeeded, &dwReturned); | 8555 err = GetPrinter (hPrn, 2, (LPBYTE)ppi2, dwNeeded, &dwReturned); |
8560 ClosePrinter (hPrn); | 8556 ClosePrinter (hPrn); |
8561 if (!err) | 8557 if (!err) |
8562 { | 8558 { |
8563 xfree(ppi2); | 8559 xfree (ppi2); |
8564 return Qnil; | 8560 return Qnil; |
8565 } | 8561 } |
8566 | 8562 |
8567 if (ppi2) | 8563 if (ppi2) |
8568 { | 8564 { |
8569 if (ppi2->Attributes & PRINTER_ATTRIBUTE_SHARED && ppi2->pServerName) | 8565 if (ppi2->Attributes & PRINTER_ATTRIBUTE_SHARED && ppi2->pServerName) |
8570 { | 8566 { |
8571 /* a remote printer */ | 8567 /* a remote printer */ |
8572 if (*ppi2->pServerName == '\\') | 8568 if (*ppi2->pServerName == '\\') |
8573 _snprintf(pname_buf, sizeof (pname_buf), "%s\\%s", ppi2->pServerName, | 8569 _snprintf (pname_buf, sizeof (pname_buf), "%s\\%s", ppi2->pServerName, |
8574 ppi2->pShareName); | 8570 ppi2->pShareName); |
8575 else | 8571 else |
8576 _snprintf(pname_buf, sizeof (pname_buf), "\\\\%s\\%s", ppi2->pServerName, | 8572 _snprintf (pname_buf, sizeof (pname_buf), "\\\\%s\\%s", ppi2->pServerName, |
8577 ppi2->pShareName); | 8573 ppi2->pShareName); |
8578 pname_buf[sizeof (pname_buf) - 1] = '\0'; | 8574 pname_buf[sizeof (pname_buf) - 1] = '\0'; |
8579 } | 8575 } |
8580 else | 8576 else |
8581 { | 8577 { |
8582 /* a local printer */ | 8578 /* a local printer */ |
8583 strncpy(pname_buf, ppi2->pPortName, sizeof (pname_buf)); | 8579 strncpy (pname_buf, ppi2->pPortName, sizeof (pname_buf)); |
8584 pname_buf[sizeof (pname_buf) - 1] = '\0'; | 8580 pname_buf[sizeof (pname_buf) - 1] = '\0'; |
8585 /* `pPortName' can include several ports, delimited by ','. | 8581 /* `pPortName' can include several ports, delimited by ','. |
8586 * we only use the first one. */ | 8582 * we only use the first one. */ |
8587 strtok(pname_buf, ","); | 8583 strtok (pname_buf, ","); |
8588 } | 8584 } |
8589 xfree(ppi2); | 8585 xfree (ppi2); |
8590 } | 8586 } |
8591 | 8587 |
8592 return build_string (pname_buf); | 8588 return build_string (pname_buf); |
8593 } | 8589 } |
8594 | 8590 |
8823 | 8819 |
8824 DEFVAR_BOOL ("w32-pass-multimedia-buttons-to-system", | 8820 DEFVAR_BOOL ("w32-pass-multimedia-buttons-to-system", |
8825 &w32_pass_multimedia_buttons_to_system, | 8821 &w32_pass_multimedia_buttons_to_system, |
8826 doc: /* If non-nil, media buttons are passed to Windows. | 8822 doc: /* If non-nil, media buttons are passed to Windows. |
8827 Some modern keyboards contain buttons for controlling media players, web | 8823 Some modern keyboards contain buttons for controlling media players, web |
8828 browsers and other applications. Generally these buttons are handled on a | 8824 browsers and other applications. Generally these buttons are handled on a |
8829 system wide basis, but by setting this to nil they are made available | 8825 system wide basis, but by setting this to nil they are made available |
8830 to Emacs for binding. Depending on your keyboard, additional keys that | 8826 to Emacs for binding. Depending on your keyboard, additional keys that |
8831 may be available are: | 8827 may be available are: |
8832 | 8828 |
8833 browser-back, browser-forward, browser-refresh, browser-stop, | 8829 browser-back, browser-forward, browser-refresh, browser-stop, |
8839 media-next, media-previous, media-stop, media-play-pause, media-select, | 8835 media-next, media-previous, media-stop, media-play-pause, media-select, |
8840 media-play, media-pause, media-record, media-fast-forward, media-rewind, | 8836 media-play, media-pause, media-record, media-fast-forward, media-rewind, |
8841 media-channel-up, media-channel-down, | 8837 media-channel-up, media-channel-down, |
8842 volume-mute, volume-up, volume-down, | 8838 volume-mute, volume-up, volume-down, |
8843 mic-volume-mute, mic-volume-down, mic-volume-up, mic-toggle, | 8839 mic-volume-mute, mic-volume-down, mic-volume-up, mic-toggle, |
8844 bass-down, bass-boost, bass-up, treble-down, treble-up | 8840 bass-down, bass-boost, bass-up, treble-down, treble-up */); |
8845 */); | |
8846 w32_pass_multimedia_buttons_to_system = 1; | 8841 w32_pass_multimedia_buttons_to_system = 1; |
8847 | 8842 |
8848 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape, | 8843 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape, |
8849 doc: /* The shape of the pointer when over text. | 8844 doc: /* The shape of the pointer when over text. |
8850 Changing the value does not affect existing frames | 8845 Changing the value does not affect existing frames |
8869 doc: /* *Seconds to wait before displaying an hourglass pointer. | 8864 doc: /* *Seconds to wait before displaying an hourglass pointer. |
8870 Value must be an integer or float. */); | 8865 Value must be an integer or float. */); |
8871 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY); | 8866 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY); |
8872 | 8867 |
8873 DEFVAR_LISP ("x-sensitive-text-pointer-shape", | 8868 DEFVAR_LISP ("x-sensitive-text-pointer-shape", |
8874 &Vx_sensitive_text_pointer_shape, | 8869 &Vx_sensitive_text_pointer_shape, |
8875 doc: /* The shape of the pointer when over mouse-sensitive text. | 8870 doc: /* The shape of the pointer when over mouse-sensitive text. |
8876 This variable takes effect when you create a new frame | 8871 This variable takes effect when you create a new frame |
8877 or when you set the mouse color. */); | 8872 or when you set the mouse color. */); |
8878 Vx_sensitive_text_pointer_shape = Qnil; | 8873 Vx_sensitive_text_pointer_shape = Qnil; |
8879 | 8874 |
8880 DEFVAR_LISP ("x-window-horizontal-drag-cursor", | 8875 DEFVAR_LISP ("x-window-horizontal-drag-cursor", |
8881 &Vx_window_horizontal_drag_shape, | 8876 &Vx_window_horizontal_drag_shape, |
8882 doc: /* Pointer shape to use for indicating a window can be dragged horizontally. | 8877 doc: /* Pointer shape to use for indicating a window can be dragged horizontally. |
8883 This variable takes effect when you create a new frame | 8878 This variable takes effect when you create a new frame |
8884 or when you set the mouse color. */); | 8879 or when you set the mouse color. */); |
8885 Vx_window_horizontal_drag_shape = Qnil; | 8880 Vx_window_horizontal_drag_shape = Qnil; |
8886 | 8881 |
9127 } | 9122 } |
9128 | 9123 |
9129 #undef abort | 9124 #undef abort |
9130 | 9125 |
9131 void | 9126 void |
9132 w32_abort() | 9127 w32_abort () |
9133 { | 9128 { |
9134 int button; | 9129 int button; |
9135 button = MessageBox (NULL, | 9130 button = MessageBox (NULL, |
9136 "A fatal error has occurred!\n\n" | 9131 "A fatal error has occurred!\n\n" |
9137 "Would you like to attach a debugger?\n\n" | 9132 "Would you like to attach a debugger?\n\n" |
9155 } | 9150 } |
9156 } | 9151 } |
9157 | 9152 |
9158 /* For convenience when debugging. */ | 9153 /* For convenience when debugging. */ |
9159 int | 9154 int |
9160 w32_last_error() | 9155 w32_last_error () |
9161 { | 9156 { |
9162 return GetLastError (); | 9157 return GetLastError (); |
9163 } | 9158 } |
9164 | 9159 |
9165 /* arch-tag: 707589ab-b9be-4638-8cdd-74629cc9b446 | 9160 /* arch-tag: 707589ab-b9be-4638-8cdd-74629cc9b446 |