aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeoff Voelker1996-01-25 03:13:39 +0000
committerGeoff Voelker1996-01-25 03:13:39 +0000
commit3c190163d271e86a274d97c20bd6e6f88b18a08a (patch)
tree512e1e9e3be5a8a3f2490e9c9e2fd5f043c1e195
parentdd118a073d7800973c5a7e3e74e541c6dc626392 (diff)
downloademacs-3c190163d271e86a274d97c20bd6e6f88b18a08a.tar.gz
emacs-3c190163d271e86a274d97c20bd6e6f88b18a08a.zip
backout 1996-01-21T00:22:24Z!voelker@cs.washington.edu
-rw-r--r--src/w32fns.c737
-rw-r--r--src/w32reg.c2
-rw-r--r--src/w32term.h52
3 files changed, 218 insertions, 573 deletions
diff --git a/src/w32fns.c b/src/w32fns.c
index 4e1092c6924..11aaf43dd01 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -45,13 +45,6 @@ extern struct scroll_bar *x_window_to_scroll_bar ();
45/* The colormap for converting color names to RGB values */ 45/* The colormap for converting color names to RGB values */
46Lisp_Object Vwin32_color_map; 46Lisp_Object Vwin32_color_map;
47 47
48/* Switch to control whether we inhibit requests for italicised fonts (which
49 are synthesized, look ugly, and are trashed by cursor movement under NT). */
50Lisp_Object Vwin32_enable_italics;
51
52/* Enable palette management. */
53Lisp_Object Vwin32_enable_palette;
54
55/* The name we're using in resource queries. */ 48/* The name we're using in resource queries. */
56Lisp_Object Vx_resource_name; 49Lisp_Object Vx_resource_name;
57 50
@@ -618,7 +611,7 @@ x_set_frame_parameters (f, alist)
618 if (NATNUMP (param_index) 611 if (NATNUMP (param_index)
619 && (XFASTINT (param_index) 612 && (XFASTINT (param_index)
620 < sizeof (x_frame_parms)/sizeof (x_frame_parms[0]))) 613 < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))
621 (*x_frame_parms[XINT (param_index)].setter) (f, val, old_value); 614 (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);
622 } 615 }
623 } 616 }
624 617
@@ -762,16 +755,18 @@ x_real_positions (f, xptr, yptr)
762 int *xptr, *yptr; 755 int *xptr, *yptr;
763{ 756{
764 POINT pt; 757 POINT pt;
765 RECT rect; 758
759 {
760 RECT rect;
766 761
767 GetClientRect (FRAME_WIN32_WINDOW (f), &rect); 762 GetClientRect(FRAME_WIN32_WINDOW(f), &rect);
768 AdjustWindowRect (&rect, f->output_data.win32->dwStyle, 763 AdjustWindowRect(&rect, f->output_data.win32->dwStyle, FRAME_EXTERNAL_MENU_BAR(f));
769 FRAME_EXTERNAL_MENU_BAR (f));
770 764
771 pt.x = rect.left; 765 pt.x = rect.left;
772 pt.y = rect.top; 766 pt.y = rect.top;
767 }
773 768
774 ClientToScreen (FRAME_WIN32_WINDOW (f), &pt); 769 ClientToScreen (FRAME_WIN32_WINDOW(f), &pt);
775 770
776 *xptr = pt.x; 771 *xptr = pt.x;
777 *yptr = pt.y; 772 *yptr = pt.y;
@@ -821,91 +816,25 @@ x_report_frame_params (f, alistptr)
821} 816}
822 817
823 818
824DEFUN ("win32-define-rgb-color", Fwin32_define_rgb_color, Swin32_define_rgb_color, 4, 4, 0, 819#if 0
825 "Convert RGB numbers to a windows color reference and associate with\n\ 820DEFUN ("win32-rgb", Fwin32_rgb, Swin32_rgb, 3, 3, 0,
826NAME (a string). This adds or updates a named color to win32-color-map,\n\ 821 "Convert RGB numbers to a windows color reference.")
827making it available for use. The original entry's RGB ref is returned,\n\ 822 (red, green, blue)
828or nil if the entry is new.") 823 Lisp_Object red, green, blue;
829 (red, green, blue, name)
830 Lisp_Object red, green, blue, name;
831{ 824{
832 Lisp_Object rgb; 825 Lisp_Object rgb;
833 Lisp_Object oldrgb = Qnil;
834 Lisp_Object entry;
835 826
836 CHECK_NUMBER (red, 0); 827 CHECK_NUMBER (red, 0);
837 CHECK_NUMBER (green, 0); 828 CHECK_NUMBER (green, 0);
838 CHECK_NUMBER (blue, 0); 829 CHECK_NUMBER (blue, 0);
839 CHECK_STRING (name, 0);
840 830
841 XSET (rgb, Lisp_Int, RGB (XUINT (red), XUINT (green), XUINT (blue))); 831 XSET (rgb, Lisp_Int, RGB(XUINT(red), XUINT(green), XUINT(blue)));
842
843 BLOCK_INPUT;
844
845 /* replace existing entry in win32-color-map or add new entry. */
846 entry = Fassoc (name, Vwin32_color_map);
847 if (NILP (entry))
848 {
849 entry = Fcons (name, rgb);
850 Vwin32_color_map = Fcons (entry, Vwin32_color_map);
851 }
852 else
853 {
854 oldrgb = Fcdr (entry);
855 Fsetcdr (entry, rgb);
856 }
857
858 UNBLOCK_INPUT;
859 832
860 return (oldrgb); 833 return (rgb);
861} 834}
862 835
863DEFUN ("win32-load-color-file", Fwin32_load_color_file, Swin32_load_color_file, 1, 1, 0,
864 "Create an alist of color entries from an external file (ie. rgb.txt).\n\
865Assign this value to win32-color-map to replace the existing color map.\n\
866The file should define one named RGB color per line like so:\
867 R G B name\n\
868where R,G,B are numbers between 0 and 255 and name is an arbitrary string.")
869 (filename)
870 Lisp_Object filename;
871{
872 FILE *fp;
873 Lisp_Object cmap = Qnil;
874 Lisp_Object abspath;
875
876 CHECK_STRING (filename, 0);
877 abspath = Fexpand_file_name (filename, Qnil);
878
879 fp = fopen (XSTRING (filename)->data, "rt");
880 if (fp)
881 {
882 char buf[512];
883 int red, green, blue;
884 int num;
885
886 BLOCK_INPUT;
887
888 while (fgets (buf, sizeof (buf), fp) != NULL)
889 {
890 if (sscanf (buf, "%u %u %u %n]", &red, &green, &blue, &num) == 3)
891 {
892 char *name = buf + num;
893 num = strlen (name) - 1;
894 if (name[num] == '\n')
895 name[num] = 0;
896 cmap = Fcons (Fcons (build_string (name),
897 make_number (RGB (red, green, blue))),
898 cmap);
899 }
900 }
901 fclose (fp);
902
903 UNBLOCK_INPUT;
904 }
905
906 return cmap;
907}
908 836
837#else
909/* The default colors for the win32 color map */ 838/* The default colors for the win32 color map */
910typedef struct colormap_t 839typedef struct colormap_t
911{ 840{
@@ -1179,6 +1108,7 @@ DEFUN ("win32-default-color-map", Fwin32_default_color_map, Swin32_default_color
1179 1108
1180 return (cmap); 1109 return (cmap);
1181} 1110}
1111#endif
1182 1112
1183Lisp_Object 1113Lisp_Object
1184win32_to_x_color (rgb) 1114win32_to_x_color (rgb)
@@ -1231,121 +1161,6 @@ x_to_win32_color (colorname)
1231 return ret; 1161 return ret;
1232} 1162}
1233 1163
1234
1235void
1236win32_regenerate_palette (FRAME_PTR f)
1237{
1238 struct win32_palette_entry * pList;
1239 LOGPALETTE * p_palette;
1240 HPALETTE h_new_palette;
1241 int i;
1242
1243 /* don't bother trying to create palette if not supported */
1244 if (! FRAME_WIN32_DISPLAY_INFO (f)->has_palette)
1245 return;
1246
1247 p_palette = (LOGPALETTE *)
1248 xmalloc (sizeof (LOGPALETTE) +
1249 FRAME_WIN32_DISPLAY_INFO (f)->n_colors_in_use * sizeof (PALETTEENTRY));
1250 p_palette->palVersion = 0x300;
1251 p_palette->palNumEntries = FRAME_WIN32_DISPLAY_INFO (f)->n_colors_in_use;
1252
1253 pList = FRAME_WIN32_DISPLAY_INFO (f)->p_colors_in_use;
1254 for (i = 0; i < FRAME_WIN32_DISPLAY_INFO (f)->n_colors_in_use;
1255 i++, pList = pList->next)
1256 p_palette->palPalEntry[i] = pList->entry;
1257
1258 h_new_palette = CreatePalette ((LPLOGPALETTE) p_palette);
1259
1260 enter_crit (CRIT_GDI);
1261
1262 if (FRAME_WIN32_DISPLAY_INFO (f)->h_palette)
1263 DeleteObject (FRAME_WIN32_DISPLAY_INFO (f)->h_palette);
1264 FRAME_WIN32_DISPLAY_INFO (f)->h_palette = h_new_palette;
1265
1266 /* Realize display palette and garbage all frames. */
1267 ReleaseFrameDC (f, GetFrameDC (f));
1268
1269 leave_crit (CRIT_GDI);
1270
1271 xfree (p_palette);
1272}
1273
1274#define WIN32_COLOR(pe) RGB (pe.peRed, pe.peGreen, pe.peBlue)
1275#define SET_WIN32_COLOR(pe, color) \
1276 do { \
1277 pe.peRed = GetRValue (color); \
1278 pe.peGreen = GetGValue (color); \
1279 pe.peBlue = GetBValue (color); \
1280 pe.peFlags = 0; \
1281 } while (0)
1282
1283#if 0
1284/* Keep these around in case we ever want to track color usage. */
1285void
1286win32_map_color (FRAME_PTR f, COLORREF color)
1287{
1288 struct win32_palette_entry * pList = FRAME_WIN32_DISPLAY_INFO (f)->p_colors_in_use;
1289
1290 if (NILP (Vwin32_enable_palette))
1291 return;
1292
1293 /* check if color is already mapped */
1294 while (pList)
1295 {
1296 if (WIN32_COLOR (pList->entry) == color)
1297 {
1298 ++pList->refcount;
1299 return;
1300 }
1301 pList = pList->next;
1302 }
1303
1304 /* not already mapped, so add to list and recreate Windows palette */
1305 pList = (struct win32_palette_entry *) xmalloc (sizeof (struct win32_palette_entry));
1306 SET_WIN32_COLOR (pList->entry, color);
1307 pList->refcount = 1;
1308 pList->next = FRAME_WIN32_DISPLAY_INFO (f)->p_colors_in_use;
1309 FRAME_WIN32_DISPLAY_INFO (f)->p_colors_in_use = pList;
1310 FRAME_WIN32_DISPLAY_INFO (f)->n_colors_in_use++;
1311
1312 /* set flag that palette must be regenerated */
1313 FRAME_WIN32_DISPLAY_INFO (f)->regen_palette = TRUE;
1314}
1315
1316void
1317win32_unmap_color (FRAME_PTR f, COLORREF color)
1318{
1319 struct win32_palette_entry * pList = FRAME_WIN32_DISPLAY_INFO (f)->p_colors_in_use;
1320 struct win32_palette_entry **ppPrev = &FRAME_WIN32_DISPLAY_INFO (f)->p_colors_in_use;
1321
1322 if (NILP (Vwin32_enable_palette))
1323 return;
1324
1325 /* check if color is already mapped */
1326 while (pList)
1327 {
1328 if (WIN32_COLOR (pList->entry) == color)
1329 {
1330 if (--pList->refcount == 0)
1331 {
1332 *ppPrev = pList->next;
1333 xfree (pList);
1334 FRAME_WIN32_DISPLAY_INFO (f)->n_colors_in_use--;
1335 break;
1336 }
1337 else
1338 return;
1339 }
1340 ppPrev = &pList->next;
1341 pList = pList->next;
1342 }
1343
1344 /* set flag that palette must be regenerated */
1345 FRAME_WIN32_DISPLAY_INFO (f)->regen_palette = TRUE;
1346}
1347#endif
1348
1349/* Decide if color named COLOR is valid for the display associated with 1164/* Decide if color named COLOR is valid for the display associated with
1350 the selected frame; if so, return the rgb values in COLOR_DEF. 1165 the selected frame; if so, return the rgb values in COLOR_DEF.
1351 If ALLOC is nonzero, allocate a new colormap cell. */ 1166 If ALLOC is nonzero, allocate a new colormap cell. */
@@ -1358,49 +1173,18 @@ defined_color (f, color, color_def, alloc)
1358 int alloc; 1173 int alloc;
1359{ 1174{
1360 register Lisp_Object tem; 1175 register Lisp_Object tem;
1361 1176
1362 tem = x_to_win32_color (color); 1177 tem = x_to_win32_color (color);
1363 1178
1364 if (!NILP (tem)) 1179 if (!NILP (tem))
1365 { 1180 {
1366 if (!NILP (Vwin32_enable_palette)) 1181 *color_def = XUINT (tem);
1367 {
1368 struct win32_palette_entry * pEntry =
1369 FRAME_WIN32_DISPLAY_INFO (f)->p_colors_in_use;
1370 struct win32_palette_entry ** ppLast =
1371 &FRAME_WIN32_DISPLAY_INFO (f)->p_colors_in_use;
1372
1373 /* check if color is already mapped */
1374 while (pEntry)
1375 {
1376 if (WIN32_COLOR (pEntry->entry) == XUINT(tem))
1377 break;
1378 ppLast = &pEntry->next;
1379 pEntry = pEntry->next;
1380 }
1381
1382 if (pEntry == NULL && alloc)
1383 {
1384 /* not already mapped, so add to list */
1385 pEntry = (struct win32_palette_entry *)
1386 xmalloc (sizeof (struct win32_palette_entry));
1387 SET_WIN32_COLOR (pEntry->entry, XUINT(tem));
1388 pEntry->next = NULL;
1389 *ppLast = pEntry;
1390 FRAME_WIN32_DISPLAY_INFO (f)->n_colors_in_use++;
1391
1392 /* set flag that palette must be regenerated */
1393 FRAME_WIN32_DISPLAY_INFO (f)->regen_palette = TRUE;
1394 }
1395 }
1396 /* whether or not frame can display arbitrary RGB colors, force
1397 COLORREF value to snap to nearest color in system palette by
1398 simulating the PALETTE_RGB macro. */
1399 *color_def = XUINT (tem) | 0x2000000;
1400 return 1; 1182 return 1;
1401 } 1183 }
1402 else 1184 else
1403 return 0; 1185 {
1186 return 0;
1187 }
1404} 1188}
1405 1189
1406/* Given a string ARG naming a color, compute a pixel value from it 1190/* Given a string ARG naming a color, compute a pixel value from it
@@ -2539,7 +2323,7 @@ win32_init_class (hinst)
2539{ 2323{
2540 WNDCLASS wc; 2324 WNDCLASS wc;
2541 2325
2542 wc.style = CS_HREDRAW | CS_VREDRAW; 2326 wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
2543 wc.lpfnWndProc = (WNDPROC) win32_wnd_proc; 2327 wc.lpfnWndProc = (WNDPROC) win32_wnd_proc;
2544 wc.cbClsExtra = 0; 2328 wc.cbClsExtra = 0;
2545 wc.cbWndExtra = WND_EXTRA_BYTES; 2329 wc.cbWndExtra = WND_EXTRA_BYTES;
@@ -2643,6 +2427,26 @@ win_msg_worker (dw)
2643 return (0); 2427 return (0);
2644} 2428}
2645 2429
2430HDC
2431map_mode (hdc)
2432 HDC hdc;
2433{
2434 if (hdc)
2435 {
2436#if 0
2437 /* Make mapping mode be in 1/20 of point */
2438
2439 SetMapMode (hdc, MM_ANISOTROPIC);
2440 SetWindowExtEx (hdc, 1440, 1440, NULL);
2441 SetViewportExtEx (hdc,
2442 GetDeviceCaps (hdc, LOGPIXELSX),
2443 GetDeviceCaps (hdc, LOGPIXELSY),
2444 NULL);
2445#endif
2446 }
2447 return (hdc);
2448}
2449
2646/* Convert between the modifier bits Win32 uses and the modifier bits 2450/* Convert between the modifier bits Win32 uses and the modifier bits
2647 Emacs uses. */ 2451 Emacs uses. */
2648unsigned int 2452unsigned int
@@ -2689,33 +2493,50 @@ win32_wnd_proc (hwnd, msg, wParam, lParam)
2689 switch (msg) 2493 switch (msg)
2690 { 2494 {
2691 case WM_ERASEBKGND: 2495 case WM_ERASEBKGND:
2692 enter_crit (CRIT_GDI);
2693 GetUpdateRect (hwnd, &wmsg.rect, FALSE);
2694 leave_crit (CRIT_GDI);
2695 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
2696 return 1;
2697 case WM_PALETTECHANGED:
2698 /* ignore our own changes */
2699 if ((HWND)wParam != hwnd)
2700 { 2496 {
2701 /* simply notify main thread it may need to update frames */ 2497 HBRUSH hb;
2702 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 2498 HANDLE oldobj;
2499 RECT rect;
2500
2501 GetClientRect (hwnd, &rect);
2502
2503 hb = CreateSolidBrush (GetWindowLong (hwnd, WND_BACKGROUND_INDEX));
2504
2505 oldobj = SelectObject ((HDC)wParam, hb);
2506
2507 FillRect((HDC)wParam, &rect, hb);
2508
2509 SelectObject((HDC)wParam, oldobj);
2510
2511 DeleteObject (hb);
2512
2513 return (0);
2703 } 2514 }
2704 return 0;
2705 case WM_PAINT: 2515 case WM_PAINT:
2706 { 2516 {
2707 PAINTSTRUCT paintStruct; 2517 PAINTSTRUCT paintStruct;
2708 2518
2709 enter_crit (CRIT_GDI);
2710 BeginPaint (hwnd, &paintStruct); 2519 BeginPaint (hwnd, &paintStruct);
2711 wmsg.rect = paintStruct.rcPaint; 2520 wmsg.rect = paintStruct.rcPaint;
2712 EndPaint (hwnd, &paintStruct); 2521 EndPaint (hwnd, &paintStruct);
2713 leave_crit (CRIT_GDI); 2522
2714
2715 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 2523 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
2716 2524
2717 return (0); 2525 return (0);
2718 } 2526 }
2527
2528 case WM_CREATE:
2529 {
2530 HDC hdc = my_get_dc (hwnd);
2531
2532 /* Make mapping mode be in 1/20 of point */
2533
2534 map_mode (hdc);
2535
2536 ReleaseDC (hwnd, hdc);
2537 }
2538
2539 return (0);
2719 case WM_KEYDOWN: 2540 case WM_KEYDOWN:
2720 case WM_SYSKEYDOWN: 2541 case WM_SYSKEYDOWN:
2721#if 0 2542#if 0
@@ -2740,7 +2561,7 @@ win32_wnd_proc (hwnd, msg, wParam, lParam)
2740 || wParam == VK_SHIFT 2561 || wParam == VK_SHIFT
2741 || wParam == VK_CONTROL 2562 || wParam == VK_CONTROL
2742 || wParam == VK_CAPITAL) 2563 || wParam == VK_CAPITAL)
2743 goto dflt; 2564 break;
2744 2565
2745 /* Anything we do not have a name for needs to be translated or 2566 /* Anything we do not have a name for needs to be translated or
2746 returned as ascii keystroke. */ 2567 returned as ascii keystroke. */
@@ -2803,8 +2624,7 @@ win32_wnd_proc (hwnd, msg, wParam, lParam)
2803 { 2624 {
2804 WINDOWPLACEMENT wp; 2625 WINDOWPLACEMENT wp;
2805 LPWINDOWPOS lppos = (WINDOWPOS *) lParam; 2626 LPWINDOWPOS lppos = (WINDOWPOS *) lParam;
2806 2627
2807 wp.length = sizeof (wp);
2808 GetWindowPlacement (hwnd, &wp); 2628 GetWindowPlacement (hwnd, &wp);
2809 2629
2810 if (wp.showCmd != SW_SHOWMINIMIZED && ! (lppos->flags & SWP_NOSIZE)) 2630 if (wp.showCmd != SW_SHOWMINIMIZED && ! (lppos->flags & SWP_NOSIZE))
@@ -2818,12 +2638,12 @@ win32_wnd_proc (hwnd, msg, wParam, lParam)
2818 2638
2819 GetWindowRect (hwnd, &wr); 2639 GetWindowRect (hwnd, &wr);
2820 2640
2821 enter_crit (CRIT_MSG); 2641 enter_crit ();
2822 2642
2823 dwXUnits = GetWindowLong (hwnd, WND_X_UNITS_INDEX); 2643 dwXUnits = GetWindowLong (hwnd, WND_X_UNITS_INDEX);
2824 dwYUnits = GetWindowLong (hwnd, WND_Y_UNITS_INDEX); 2644 dwYUnits = GetWindowLong (hwnd, WND_Y_UNITS_INDEX);
2825 2645
2826 leave_crit (CRIT_MSG); 2646 leave_crit ();
2827 2647
2828 memset (&rect, 0, sizeof (rect)); 2648 memset (&rect, 0, sizeof (rect));
2829 AdjustWindowRect (&rect, GetWindowLong (hwnd, GWL_STYLE), 2649 AdjustWindowRect (&rect, GetWindowLong (hwnd, GWL_STYLE),
@@ -3109,7 +2929,7 @@ This function is an internal primitive--use `make-frame' instead.")
3109 font = x_new_font (f, "-*-system-medium-r-normal-*-*-200-*-*-c-120-*-*"); 2929 font = x_new_font (f, "-*-system-medium-r-normal-*-*-200-*-*-c-120-*-*");
3110#endif 2930#endif
3111 if (! STRINGP (font)) 2931 if (! STRINGP (font))
3112 font = x_new_font (f, "-*-Fixedsys-*-r-*-*-12-90-*-*-c-*-*-*"); 2932 font = x_new_font (f, "-*-terminal-medium-r-normal-*-*-180-*-*-c-120-*-*");
3113 UNBLOCK_INPUT; 2933 UNBLOCK_INPUT;
3114 if (! STRINGP (font)) 2934 if (! STRINGP (font))
3115 font = build_string ("-*-system"); 2935 font = build_string ("-*-system");
@@ -3297,50 +3117,54 @@ DEFUN ("unfocus-frame", Funfocus_frame, Sunfocus_frame, 0, 0, 0,
3297 return Qnil; 3117 return Qnil;
3298} 3118}
3299 3119
3300XFontStruct * 3120XFontStruct
3301win32_load_font (dpyinfo,name) 3121*win32_load_font (dpyinfo,name)
3302 struct win32_display_info *dpyinfo; 3122struct win32_display_info *dpyinfo;
3303 char *name; 3123char * name;
3304{ 3124{
3305 XFontStruct * font = NULL; 3125 XFontStruct * font = NULL;
3306 BOOL ok; 3126 BOOL ok;
3307 LOGFONT lf; 3127
3308 3128 {
3309 if (!name || !x_to_win32_font (name, &lf)) 3129 LOGFONT lf;
3310 return (NULL); 3130
3311 3131 if (!name || !x_to_win32_font(name, &lf))
3312 font = (XFontStruct *) xmalloc (sizeof (XFontStruct)); 3132 return (NULL);
3313 if (!font) return (NULL); 3133
3314 3134 font = (XFontStruct *) xmalloc (sizeof (XFontStruct));
3315 BLOCK_INPUT; 3135
3316 3136 if (!font) return (NULL);
3317 font->hfont = CreateFontIndirect (&lf); 3137
3318 3138 BLOCK_INPUT;
3319 if (font->hfont == NULL) 3139
3320 { 3140 font->hfont = CreateFontIndirect(&lf);
3321 ok = FALSE;
3322 }
3323 else
3324 {
3325 HDC hdc;
3326 HANDLE oldobj;
3327
3328 hdc = GetDC (dpyinfo->root_window);
3329
3330 oldobj = SelectObject (hdc, font->hfont);
3331
3332 ok = GetTextMetrics (hdc, &font->tm);
3333
3334 SelectObject (hdc, oldobj);
3335
3336 ReleaseDC (dpyinfo->root_window, hdc);
3337 } 3141 }
3142
3143 if (font->hfont == NULL)
3144 {
3145 ok = FALSE;
3146 }
3147 else
3148 {
3149 HDC hdc;
3150 HANDLE oldobj;
3338 3151
3152 hdc = my_get_dc (dpyinfo->root_window);
3153
3154 oldobj = SelectObject (hdc, font->hfont);
3155
3156 ok = GetTextMetrics (hdc, &font->tm);
3157
3158 SelectObject (hdc, oldobj);
3159
3160 ReleaseDC (dpyinfo->root_window, hdc);
3161 }
3162
3339 UNBLOCK_INPUT; 3163 UNBLOCK_INPUT;
3340 3164
3341 if (ok) return (font); 3165 if (ok) return (font);
3342 3166
3343 win32_unload_font (dpyinfo, font); 3167 win32_unload_font(dpyinfo, font);
3344 return (NULL); 3168 return (NULL);
3345} 3169}
3346 3170
@@ -3351,7 +3175,7 @@ win32_unload_font (dpyinfo, font)
3351{ 3175{
3352 if (font) 3176 if (font)
3353 { 3177 {
3354 if (font->hfont) DeleteObject (font->hfont); 3178 if (font->hfont) DeleteObject(font->hfont);
3355 xfree (font); 3179 xfree (font);
3356 } 3180 }
3357} 3181}
@@ -3436,11 +3260,7 @@ x_to_win32_weight (lpw)
3436{ 3260{
3437 if (!lpw) return (FW_DONTCARE); 3261 if (!lpw) return (FW_DONTCARE);
3438 3262
3439 if (stricmp (lpw, "heavy") == 0) 3263 if (stricmp (lpw, "bold") == 0)
3440 return (FW_HEAVY);
3441 else if (stricmp (lpw, "extrabold") == 0)
3442 return (FW_EXTRABOLD);
3443 else if (stricmp (lpw, "bold") == 0)
3444 return (FW_BOLD); 3264 return (FW_BOLD);
3445 else if (stricmp (lpw, "demibold") == 0) 3265 else if (stricmp (lpw, "demibold") == 0)
3446 return (FW_SEMIBOLD); 3266 return (FW_SEMIBOLD);
@@ -3448,81 +3268,22 @@ x_to_win32_weight (lpw)
3448 return (FW_MEDIUM); 3268 return (FW_MEDIUM);
3449 else if (stricmp (lpw, "normal") == 0) 3269 else if (stricmp (lpw, "normal") == 0)
3450 return (FW_NORMAL); 3270 return (FW_NORMAL);
3451 else if (stricmp (lpw, "light") == 0)
3452 return (FW_LIGHT);
3453 else if (stricmp (lpw, "extralight") == 0)
3454 return (FW_EXTRALIGHT);
3455 else if (stricmp (lpw, "thin") == 0)
3456 return (FW_THIN);
3457 else 3271 else
3458 return (FW_DONTCARE); 3272 return (FW_DONTCARE);
3459} 3273}
3460 3274
3461
3462char * 3275char *
3463win32_to_x_weight (fnweight) 3276win32_to_x_weight (fnweight)
3464 int fnweight; 3277 int fnweight;
3465{ 3278{
3466 if (fnweight >= FW_HEAVY) 3279 if (fnweight >= FW_BOLD)
3467 return "heavy"; 3280 return ("bold");
3468 else if (fnweight >= FW_EXTRABOLD) 3281 else if (fnweight >= FW_SEMIBOLD)
3469 return "extrabold"; 3282 return ("demibold");
3470 else if (fnweight >= FW_BOLD) 3283 else if (fnweight >= FW_MEDIUM)
3471 return "bold"; 3284 return ("medium");
3472 else if (fnweight >= FW_SEMIBOLD) 3285 else
3473 return "semibold"; 3286 return ("normal");
3474 else if (fnweight >= FW_MEDIUM)
3475 return "medium";
3476 else if (fnweight >= FW_NORMAL)
3477 return "normal";
3478 else if (fnweight >= FW_LIGHT)
3479 return "light";
3480 else if (fnweight >= FW_EXTRALIGHT)
3481 return "extralight";
3482 else if (fnweight >= FW_THIN)
3483 return "thin";
3484 else
3485 return "*";
3486}
3487
3488LONG
3489x_to_win32_charset (lpcs)
3490 char * lpcs;
3491{
3492 if (!lpcs) return (0);
3493
3494 if (stricmp (lpcs, "ansi") == 0)
3495 return (ANSI_CHARSET);
3496 else if (stricmp (lpcs, "iso8859-1") == 0)
3497 return (ANSI_CHARSET);
3498 else if (stricmp (lpcs, "iso8859") == 0)
3499 return (ANSI_CHARSET);
3500 else if (stricmp (lpcs, "oem") == 0)
3501 return (OEM_CHARSET);
3502#ifdef UNICODE_CHARSET
3503 else if (stricmp (lpcs, "unicode") == 0)
3504 return (UNICODE_CHARSET);
3505 else if (stricmp (lpcs, "iso10646") == 0)
3506 return (UNICODE_CHARSET);
3507#endif
3508 else
3509 return (0);
3510}
3511
3512char *
3513win32_to_x_charset (fncharset)
3514 int fncharset;
3515{
3516 switch (fncharset)
3517 {
3518 case ANSI_CHARSET: return "ansi";
3519 case OEM_CHARSET: return "oem";
3520 case SYMBOL_CHARSET: return "symbol";
3521#ifdef UNICODE_CHARSET
3522 case UNICODE_CHARSET: return "unicode";
3523#endif
3524 }
3525 return "*";
3526} 3287}
3527 3288
3528BOOL 3289BOOL
@@ -3533,25 +3294,29 @@ win32_to_x_font (lplogfont, lpxstr, len)
3533{ 3294{
3534 if (!lpxstr) return (FALSE); 3295 if (!lpxstr) return (FALSE);
3535 3296
3536 if (lplogfont) 3297 if (lplogfont)
3537 { 3298 {
3299 int height = (lplogfont->lfHeight * 1440)
3300 / one_win32_display_info.height_in;
3301 int width = (lplogfont->lfWidth * 1440)
3302 / one_win32_display_info.width_in;
3303
3304 height = abs (height);
3538 _snprintf (lpxstr, len - 1, 3305 _snprintf (lpxstr, len - 1,
3539 "-*-%s-%s-%c-*-*-%d-%d-*-*-%c-%d-*-%s-", 3306 "-*-%s-%s-%c-%s-%s-*-%d-*-*-%c-%d-*-*-",
3540 lplogfont->lfFaceName, 3307 lplogfont->lfFaceName,
3541 win32_to_x_weight (lplogfont->lfWeight), 3308 win32_to_x_weight (lplogfont->lfWeight),
3542 lplogfont->lfItalic ? 'i' : 'r', 3309 lplogfont->lfItalic ? 'i' : 'r',
3543 abs (lplogfont->lfHeight), 3310 "*", "*",
3544 (abs (lplogfont->lfHeight) * 720) / one_win32_display_info.height_in, 3311 height,
3545 ((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH) ? 'p' : 'c', 3312 ((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH) ? 'p' : 'c',
3546 lplogfont->lfWidth * 10, 3313 width);
3547 win32_to_x_charset (lplogfont->lfCharSet) 3314 }
3548 ); 3315 else
3549 }
3550 else
3551 { 3316 {
3552 strncpy (lpxstr, "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-", len - 1); 3317 strncpy (lpxstr, "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-", len - 1);
3553 } 3318 }
3554 3319
3555 lpxstr[len - 1] = 0; /* just to be sure */ 3320 lpxstr[len - 1] = 0; /* just to be sure */
3556 return (TRUE); 3321 return (TRUE);
3557} 3322}
@@ -3565,119 +3330,56 @@ x_to_win32_font (lpxstr, lplogfont)
3565 3330
3566 memset (lplogfont, 0, sizeof (*lplogfont)); 3331 memset (lplogfont, 0, sizeof (*lplogfont));
3567 3332
3333 lplogfont->lfCharSet = OEM_CHARSET;
3568 lplogfont->lfOutPrecision = OUT_DEFAULT_PRECIS; 3334 lplogfont->lfOutPrecision = OUT_DEFAULT_PRECIS;
3569 lplogfont->lfClipPrecision = CLIP_DEFAULT_PRECIS; 3335 lplogfont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
3570 lplogfont->lfQuality = DEFAULT_QUALITY; 3336 lplogfont->lfQuality = DEFAULT_QUALITY;
3571 3337
3572 if (!lpxstr) 3338 if (lpxstr && *lpxstr == '-') lpxstr++;
3573 return FALSE;
3574
3575 /* Provide a simple escape mechanism for specifying Windows font names
3576 * directly -- if font spec does not beginning with '-', assume this
3577 * format:
3578 * "<font name>[:height in pixels[:width in pixels[:weight]]]"
3579 */
3580 3339
3581 if (*lpxstr == '-') 3340 {
3582 { 3341 int fields;
3583 int fields; 3342 char name[50], weight[20], slant, pitch, height[10], width[10];
3584 char name[50], weight[20], slant, pitch, pixels[10], height[10], width[10], remainder[20]; 3343
3585 char * encoding; 3344 fields = (lpxstr
3586 3345 ? sscanf (lpxstr,
3587 fields = sscanf (lpxstr, 3346 "%*[^-]-%[^-]-%[^-]-%c-%*[^-]-%*[^-]-%*[^-]-%[^-]-%*[^-]-%*[^-]-%c-%[^-]",
3588 "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%*[^-]-%c-%9[^-]-%19s", 3347 name, weight, &slant, height, &pitch, width)
3589 name, weight, &slant, pixels, height, &pitch, width, remainder); 3348 : 0);
3590 3349
3591 if (fields == EOF) return (FALSE); 3350 if (fields == EOF) return (FALSE);
3592 3351
3593 if (fields > 0 && name[0] != '*') 3352 if (fields > 0 && name[0] != '*')
3594 {
3595 strncpy (lplogfont->lfFaceName,name, LF_FACESIZE);
3596 lplogfont->lfFaceName[LF_FACESIZE-1] = 0;
3597 }
3598 else
3599 lplogfont->lfFaceName[0] = 0;
3600
3601 fields--;
3602
3603 lplogfont->lfWeight = x_to_win32_weight((fields > 0 ? weight : ""));
3604
3605 fields--;
3606
3607 if (!NILP (Vwin32_enable_italics))
3608 lplogfont->lfItalic = (fields > 0 && slant == 'i');
3609
3610 fields--;
3611
3612 if (fields > 0 && pixels[0] != '*')
3613 lplogfont->lfHeight = atoi (pixels);
3614
3615 fields--;
3616
3617 if (fields > 0 && lplogfont->lfHeight == 0 && height[0] != '*')
3618 lplogfont->lfHeight = (atoi (height)
3619 * one_win32_display_info.height_in) / 720;
3620
3621 fields--;
3622
3623 lplogfont->lfPitchAndFamily =
3624 (fields > 0 && pitch == 'p') ? VARIABLE_PITCH : FIXED_PITCH;
3625
3626 fields--;
3627
3628 if (fields > 0 && width[0] != '*')
3629 lplogfont->lfWidth = atoi (width) / 10;
3630
3631 fields--;
3632
3633 /* Not all font specs include the registry field, so we allow for an
3634 optional registry field before the encoding when parsing
3635 remainder. Also we strip the trailing '-' if present. */
3636 { 3353 {
3637 int len = strlen (remainder); 3354 strncpy (lplogfont->lfFaceName, name, LF_FACESIZE);
3638 if (len > 0 && remainder[len-1] == '-') 3355 }
3639 remainder[len-1] = 0; 3356 else
3357 {
3358 lplogfont->lfFaceName[0] = 0;
3640 } 3359 }
3641 encoding = remainder; 3360
3642 if (strncmp (encoding, "*-", 2) == 0) 3361 fields--;
3643 encoding += 2; 3362
3644 lplogfont->lfCharSet = x_to_win32_charset (fields > 0 ? encoding : ""); 3363 lplogfont->lfWeight = x_to_win32_weight((fields > 0 ? weight : ""));
3645 } 3364
3646 else 3365 fields--;
3647 { 3366
3648 int fields; 3367 lplogfont->lfItalic = (fields > 0 && slant == 'i');
3649 char name[100], height[10], width[10], weight[20]; 3368
3650 3369 fields--;
3651 fields = sscanf (lpxstr, 3370
3652 "%99[^:]:%9[^:]:%9[^:]:%19s", 3371 if (fields > 0 && height[0] != '*')
3653 name, height, width, weight); 3372 lplogfont->lfHeight = (atoi (height) * one_win32_display_info.height_in) / 1440;
3654 3373
3655 if (fields == EOF) return (FALSE); 3374 fields--;
3656 3375
3657 if (fields > 0) 3376 lplogfont->lfPitchAndFamily = (fields > 0 && pitch == 'p') ? VARIABLE_PITCH : FIXED_PITCH;
3658 { 3377
3659 strncpy (lplogfont->lfFaceName,name, LF_FACESIZE); 3378 fields--;
3660 lplogfont->lfFaceName[LF_FACESIZE-1] = 0; 3379
3661 } 3380 if (fields > 0 && width[0] != '*')
3662 else 3381 lplogfont->lfWidth = (atoi (width) * one_win32_display_info.width_in) / 1440;
3663 { 3382 }
3664 lplogfont->lfFaceName[0] = 0;
3665 }
3666
3667 fields--;
3668
3669 if (fields > 0)
3670 lplogfont->lfHeight = atoi (height);
3671
3672 fields--;
3673
3674 if (fields > 0)
3675 lplogfont->lfWidth = atoi (width);
3676
3677 fields--;
3678
3679 lplogfont->lfWeight = x_to_win32_weight ((fields > 0 ? weight : ""));
3680 }
3681 3383
3682 return (TRUE); 3384 return (TRUE);
3683} 3385}
@@ -3871,7 +3573,7 @@ even if they match PATTERN and FACE.")
3871 ef.numFonts = 0; 3573 ef.numFonts = 0;
3872 3574
3873 { 3575 {
3874 ef.hdc = GetDC (FRAME_WIN32_WINDOW (f)); 3576 ef.hdc = my_get_dc (FRAME_WIN32_WINDOW (f));
3875 3577
3876 EnumFontFamilies (ef.hdc, NULL, (FONTENUMPROC) enum_font_cb1, (LPARAM)&ef); 3578 EnumFontFamilies (ef.hdc, NULL, (FONTENUMPROC) enum_font_cb1, (LPARAM)&ef);
3877 3579
@@ -4057,11 +3759,9 @@ If omitted or nil, that stands for the selected frame's display.")
4057 HDC hdc; 3759 HDC hdc;
4058 int cap; 3760 int cap;
4059 3761
4060 hdc = GetDC (dpyinfo->root_window); 3762 hdc = my_get_dc (dpyinfo->root_window);
4061 if (dpyinfo->has_palette) 3763
4062 cap = GetDeviceCaps (hdc, SIZEPALETTE); 3764 cap = GetDeviceCaps (hdc,NUMCOLORS);
4063 else
4064 cap = GetDeviceCaps (hdc, NUMCOLORS);
4065 3765
4066 ReleaseDC (dpyinfo->root_window, hdc); 3766 ReleaseDC (dpyinfo->root_window, hdc);
4067 3767
@@ -4140,8 +3840,10 @@ If omitted or nil, that stands for the selected frame's display.")
4140 HDC hdc; 3840 HDC hdc;
4141 int cap; 3841 int cap;
4142 3842
4143 hdc = GetDC (dpyinfo->root_window); 3843 hdc = my_get_dc (dpyinfo->root_window);
3844
4144 cap = GetDeviceCaps (hdc, VERTSIZE); 3845 cap = GetDeviceCaps (hdc, VERTSIZE);
3846
4145 ReleaseDC (dpyinfo->root_window, hdc); 3847 ReleaseDC (dpyinfo->root_window, hdc);
4146 3848
4147 return make_number (cap); 3849 return make_number (cap);
@@ -4160,8 +3862,10 @@ If omitted or nil, that stands for the selected frame's display.")
4160 HDC hdc; 3862 HDC hdc;
4161 int cap; 3863 int cap;
4162 3864
4163 hdc = GetDC (dpyinfo->root_window); 3865 hdc = my_get_dc (dpyinfo->root_window);
3866
4164 cap = GetDeviceCaps (hdc, HORZSIZE); 3867 cap = GetDeviceCaps (hdc, HORZSIZE);
3868
4165 ReleaseDC (dpyinfo->root_window, hdc); 3869 ReleaseDC (dpyinfo->root_window, hdc);
4166 3870
4167 return make_number (cap); 3871 return make_number (cap);
@@ -4310,22 +4014,12 @@ terminate Emacs if we can't open the connection.")
4310 unsigned int n_planes; 4014 unsigned int n_planes;
4311 unsigned char *xrm_option; 4015 unsigned char *xrm_option;
4312 struct win32_display_info *dpyinfo; 4016 struct win32_display_info *dpyinfo;
4313 Lisp_Object color_file = Qnil;
4314 4017
4315 CHECK_STRING (display, 0); 4018 CHECK_STRING (display, 0);
4316 if (! NILP (xrm_string)) 4019 if (! NILP (xrm_string))
4317 CHECK_STRING (xrm_string, 1); 4020 CHECK_STRING (xrm_string, 1);
4318 4021
4319 /* Allow color mapping to be defined externally; first look in user's 4022 Vwin32_color_map = Fwin32_default_color_map ();
4320 HOME directory, then in Emacs etc dir for a file called rgb.txt. */
4321 color_file = build_string ("~/rgb.txt");
4322 if (NILP (color_file) || NILP (Ffile_readable_p (color_file)))
4323 color_file = concat2 (Vdoc_directory, build_string ("rgb.txt"));
4324
4325 Vwin32_color_map = Fwin32_load_color_file (color_file);
4326
4327 if (NILP (Vwin32_color_map))
4328 Vwin32_color_map = Fwin32_default_color_map ();
4329 4023
4330 if (! NILP (xrm_string)) 4024 if (! NILP (xrm_string))
4331 xrm_option = (unsigned char *) XSTRING (xrm_string)->data; 4025 xrm_option = (unsigned char *) XSTRING (xrm_string)->data;
@@ -4345,7 +4039,8 @@ terminate Emacs if we can't open the connection.")
4345 if (dpyinfo == 0) 4039 if (dpyinfo == 0)
4346 { 4040 {
4347 if (!NILP (must_succeed)) 4041 if (!NILP (must_succeed))
4348 fatal ("Cannot connect to server %s.\n", XSTRING (display)->data); 4042 fatal ("Cannot connect to server %s.\n",
4043 XSTRING (display)->data);
4349 else 4044 else
4350 error ("Cannot connect to server %s", XSTRING (display)->data); 4045 error ("Cannot connect to server %s", XSTRING (display)->data);
4351 } 4046 }
@@ -4436,7 +4131,7 @@ DEFUN ("win32-select-font", Fwin32_select_font, Swin32_select_font, 0, 1, 0,
4436 cf.lpLogFont = &lf; 4131 cf.lpLogFont = &lf;
4437 4132
4438 if (!ChooseFont (&cf) || !win32_to_x_font (&lf, buf, 100)) 4133 if (!ChooseFont (&cf) || !win32_to_x_font (&lf, buf, 100))
4439 return Qnil; 4134 return Qnil;
4440 4135
4441 return build_string (buf); 4136 return build_string (buf);
4442} 4137}
@@ -4524,14 +4219,6 @@ syms_of_win32fns ()
4524 "A array of color name mappings for windows."); 4219 "A array of color name mappings for windows.");
4525 Vwin32_color_map = Qnil; 4220 Vwin32_color_map = Qnil;
4526 4221
4527 DEFVAR_LISP ("win32-enable-italics", &Vwin32_enable_italics,
4528 "Non-nil enables selection of artificially italicized fonts.");
4529 Vwin32_enable_italics = Qnil;
4530
4531 DEFVAR_LISP ("win32-enable-palette", &Vwin32_enable_palette,
4532 "Non-nil enables Windows palette management to map colors exactly.");
4533 Vwin32_enable_palette = Qt;
4534
4535 init_x_parm_symbols (); 4222 init_x_parm_symbols ();
4536 4223
4537 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path, 4224 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path,
@@ -4607,8 +4294,6 @@ unless you set it to something else.");
4607 /* Win32 specific functions */ 4294 /* Win32 specific functions */
4608 4295
4609 defsubr (&Swin32_select_font); 4296 defsubr (&Swin32_select_font);
4610 defsubr (&Swin32_define_rgb_color);
4611 defsubr (&Swin32_load_color_file);
4612} 4297}
4613 4298
4614#undef abort 4299#undef abort
@@ -4616,9 +4301,9 @@ unless you set it to something else.");
4616void 4301void
4617win32_abort() 4302win32_abort()
4618{ 4303{
4619 MessageBox (NULL, 4304 MessageBox (NULL,
4620 "A fatal error has occurred - aborting!", 4305 "A fatal error has occurred - aborting!",
4621 "Emacs Abort Dialog", 4306 "Emacs Abort Dialog",
4622 MB_OK | MB_ICONEXCLAMATION); 4307 MB_OK|MB_ICONEXCLAMATION);
4623 abort(); 4308 abort();
4624} 4309}
diff --git a/src/w32reg.c b/src/w32reg.c
index 9142fee5a40..dcb4ba29716 100644
--- a/src/w32reg.c
+++ b/src/w32reg.c
@@ -28,7 +28,7 @@ Boston, MA 02111-1307, USA. */
28#include <stdio.h> 28#include <stdio.h>
29#include <string.h> 29#include <string.h>
30 30
31#define REG_ROOT "Software\\GNU\\Emacs" 31#define REG_ROOT "SOFTWARE\\GNU\\Emacs\\"
32 32
33LPBYTE 33LPBYTE
34win32_get_string_resource (name, class, dwexptype) 34win32_get_string_resource (name, class, dwexptype)
diff --git a/src/w32term.h b/src/w32term.h
index 7bf953fd036..a5301896541 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -75,23 +75,6 @@ struct win32_bitmap_record
75 /* Record some info about this pixmap. */ 75 /* Record some info about this pixmap. */
76 int height, width, depth; 76 int height, width, depth;
77}; 77};
78
79/* Palette book-keeping stuff for mapping requested colors into the
80 system palette. Keep a ref-counted list of requested colors and
81 regenerate the app palette whenever the requested list changes. */
82
83extern Lisp_Object Vwin32_enable_palette;
84
85struct win32_palette_entry {
86 struct win32_palette_entry * next;
87 PALETTEENTRY entry;
88#if 0
89 unsigned refcount;
90#endif
91};
92
93extern void win32_regenerate_palette(struct frame *f);
94
95 78
96/* For each display (currently only one on win32), we have a structure that 79/* For each display (currently only one on win32), we have a structure that
97 records information about it. */ 80 records information about it. */
@@ -119,15 +102,6 @@ struct win32_display_info
119 /* The cursor to use for vertical scroll bars. */ 102 /* The cursor to use for vertical scroll bars. */
120 Cursor vertical_scroll_bar_cursor; 103 Cursor vertical_scroll_bar_cursor;
121 104
122 /* color palette information */
123 int has_palette;
124 struct win32_palette_entry * p_colors_in_use;
125 unsigned n_colors_in_use;
126 HPALETTE h_palette;
127
128 /* deferred action flags checked when starting frame update */
129 int regen_palette;
130
131 /* A table of all the fonts we have already loaded. */ 105 /* A table of all the fonts we have already loaded. */
132 struct font_info *font_table; 106 struct font_info *font_table;
133 107
@@ -213,9 +187,6 @@ extern struct win32_display_info *win32_term_init ();
213 187
214struct win32_output 188struct win32_output
215{ 189{
216 /* Original palette (used to deselect real palette after drawing) */
217 HPALETTE h_old_palette;
218
219 /* Position of the Win32 window (x and y offsets in root window). */ 190 /* Position of the Win32 window (x and y offsets in root window). */
220 int left_pos; 191 int left_pos;
221 int top_pos; 192 int top_pos;
@@ -577,6 +548,10 @@ win32_fill_area (f,hdc,f->output_data.win32->background_pixel,x,y,nx,ny)
577extern XFontStruct *win32_load_font (); 548extern XFontStruct *win32_load_font ();
578extern void win32_unload_font (); 549extern void win32_unload_font ();
579 550
551extern HDC map_mode();
552
553#define my_get_dc(hwnd) (map_mode (GetDC (hwnd)))
554
580#define WM_EMACS_START (WM_USER + 1) 555#define WM_EMACS_START (WM_USER + 1)
581#define WM_EMACS_KILL (WM_EMACS_START + 0x00) 556#define WM_EMACS_KILL (WM_EMACS_START + 0x00)
582#define WM_EMACS_CREATEWINDOW (WM_EMACS_START + 0x01) 557#define WM_EMACS_CREATEWINDOW (WM_EMACS_START + 0x01)
@@ -603,26 +578,11 @@ typedef struct Win32Msg {
603 RECT rect; 578 RECT rect;
604} Win32Msg; 579} Win32Msg;
605 580
606/* Identifiers for array of critical sections; we need one for
607 serializing access to hand-crafter message queue, and another
608 for preventing palette changes during GDI calls. */
609enum win32_critical_section {
610 CRIT_MSG, /* message queue */
611 CRIT_GDI, /* GDI calls */
612 CRIT_TOTAL /* num of critical sections */
613};
614
615extern CRITICAL_SECTION critsect[CRIT_TOTAL];
616
617extern void init_crit (); 581extern void init_crit ();
582extern void enter_crit ();
583extern void leave_crit ();
618extern void delete_crit (); 584extern void delete_crit ();
619 585
620#define enter_crit(index) EnterCriticalSection (&critsect[index])
621#define leave_crit(index) LeaveCriticalSection (&critsect[index])
622
623extern HDC GetFrameDC (struct frame * f);
624extern int ReleaseFrameDC (struct frame * f, HDC hDC);
625
626extern BOOL get_next_msg (); 586extern BOOL get_next_msg ();
627extern BOOL post_msg (); 587extern BOOL post_msg ();
628extern void wait_for_sync (); 588extern void wait_for_sync ();