1 /* Functions for the Win32 window system.
2 Copyright (C) 1989, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Added by Kevin Gallo */
32 #include "dispextern.h"
34 #include "blockinput.h"
37 #include "termhooks.h"
42 extern void free_frame_menubar ();
43 extern struct scroll_bar
*x_window_to_scroll_bar ();
46 /* The colormap for converting color names to RGB values */
47 Lisp_Object Vwin32_color_map
;
49 /* Non nil if alt key presses are passed on to Windows. */
50 Lisp_Object Vwin32_pass_alt_to_system
;
52 /* Non nil if alt key is translated to meta_modifier, nil if it is translated
54 Lisp_Object Vwin32_alt_is_meta
;
56 /* Non nil if left window, right window, and application key events
57 are passed on to Windows. */
58 Lisp_Object Vwin32_pass_optional_keys_to_system
;
60 /* Switch to control whether we inhibit requests for italicised fonts (which
61 are synthesized, look ugly, and are trashed by cursor movement under NT). */
62 Lisp_Object Vwin32_enable_italics
;
64 /* Enable palette management. */
65 Lisp_Object Vwin32_enable_palette
;
67 /* Control how close left/right button down events must be to
68 be converted to a middle button down event. */
69 Lisp_Object Vwin32_mouse_button_tolerance
;
71 /* Minimum interval between mouse movement (and scroll bar drag)
72 events that are passed on to the event loop. */
73 Lisp_Object Vwin32_mouse_move_interval
;
75 /* The name we're using in resource queries. */
76 Lisp_Object Vx_resource_name
;
78 /* Non nil if no window manager is in use. */
79 Lisp_Object Vx_no_window_manager
;
81 /* The background and shape of the mouse pointer, and shape when not
82 over text or in the modeline. */
83 Lisp_Object Vx_pointer_shape
, Vx_nontext_pointer_shape
, Vx_mode_pointer_shape
;
84 /* The shape when over mouse-sensitive text. */
85 Lisp_Object Vx_sensitive_text_pointer_shape
;
87 /* Color of chars displayed in cursor box. */
88 Lisp_Object Vx_cursor_fore_pixel
;
90 /* Search path for bitmap files. */
91 Lisp_Object Vx_bitmap_file_path
;
93 /* Evaluate this expression to rebuild the section of syms_of_w32fns
94 that initializes and staticpros the symbols declared below. Note
95 that Emacs 18 has a bug that keeps C-x C-e from being able to
96 evaluate this expression.
99 ;; Accumulate a list of the symbols we want to initialize from the
100 ;; declarations at the top of the file.
101 (goto-char (point-min))
102 (search-forward "/\*&&& symbols declared here &&&*\/\n")
104 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
106 (cons (buffer-substring (match-beginning 1) (match-end 1))
109 (setq symbol-list (nreverse symbol-list))
110 ;; Delete the section of syms_of_... where we initialize the symbols.
111 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
112 (let ((start (point)))
113 (while (looking-at "^ Q")
115 (kill-region start (point)))
116 ;; Write a new symbol initialization section.
118 (insert (format " %s = intern (\"" (car symbol-list)))
119 (let ((start (point)))
120 (insert (substring (car symbol-list) 1))
121 (subst-char-in-region start (point) ?_ ?-))
122 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
123 (setq symbol-list (cdr symbol-list)))))
127 /*&&& symbols declared here &&&*/
128 Lisp_Object Qauto_raise
;
129 Lisp_Object Qauto_lower
;
130 Lisp_Object Qbackground_color
;
132 Lisp_Object Qborder_color
;
133 Lisp_Object Qborder_width
;
135 Lisp_Object Qcursor_color
;
136 Lisp_Object Qcursor_type
;
137 Lisp_Object Qforeground_color
;
138 Lisp_Object Qgeometry
;
139 Lisp_Object Qicon_left
;
140 Lisp_Object Qicon_top
;
141 Lisp_Object Qicon_type
;
142 Lisp_Object Qicon_name
;
143 Lisp_Object Qinternal_border_width
;
145 Lisp_Object Qmouse_color
;
147 Lisp_Object Qparent_id
;
148 Lisp_Object Qscroll_bar_width
;
149 Lisp_Object Qsuppress_icon
;
151 Lisp_Object Qundefined_color
;
152 Lisp_Object Qvertical_scroll_bars
;
153 Lisp_Object Qvisibility
;
154 Lisp_Object Qwindow_id
;
155 Lisp_Object Qx_frame_parameter
;
156 Lisp_Object Qx_resource_name
;
157 Lisp_Object Quser_position
;
158 Lisp_Object Quser_size
;
159 Lisp_Object Qdisplay
;
161 /* State variables for emulating a three button mouse. */
166 static int button_state
= 0;
167 static Win32Msg saved_mouse_button_msg
;
168 static unsigned mouse_button_timer
; /* non-zero when timer is active */
169 static Win32Msg saved_mouse_move_msg
;
170 static unsigned mouse_move_timer
;
172 #define MOUSE_BUTTON_ID 1
173 #define MOUSE_MOVE_ID 2
175 /* The below are defined in frame.c. */
176 extern Lisp_Object Qheight
, Qminibuffer
, Qname
, Qonly
, Qwidth
;
177 extern Lisp_Object Qunsplittable
, Qmenu_bar_lines
;
179 extern Lisp_Object Vwindow_system_version
;
181 extern Lisp_Object last_mouse_scroll_bar
;
182 extern int last_mouse_scroll_bar_pos
;
184 /* From win32term.c. */
185 extern Lisp_Object Vwin32_num_mouse_buttons
;
187 Time last_mouse_movement_time
;
190 /* Extract a frame as a FRAME_PTR, defaulting to the selected frame
191 and checking validity for Win32. */
194 check_x_frame (frame
)
203 CHECK_LIVE_FRAME (frame
, 0);
206 if (! FRAME_WIN32_P (f
))
207 error ("non-win32 frame used");
211 /* Let the user specify an display with a frame.
212 nil stands for the selected frame--or, if that is not a win32 frame,
213 the first display on the list. */
215 static struct win32_display_info
*
216 check_x_display_info (frame
)
221 if (FRAME_WIN32_P (selected_frame
))
222 return FRAME_WIN32_DISPLAY_INFO (selected_frame
);
224 return &one_win32_display_info
;
226 else if (STRINGP (frame
))
227 return x_display_info_for_name (frame
);
232 CHECK_LIVE_FRAME (frame
, 0);
234 if (! FRAME_WIN32_P (f
))
235 error ("non-win32 frame used");
236 return FRAME_WIN32_DISPLAY_INFO (f
);
240 /* Return the Emacs frame-object corresponding to an win32 window.
241 It could be the frame's main window or an icon window. */
243 /* This function can be called during GC, so use GC_xxx type test macros. */
246 x_window_to_frame (dpyinfo
, wdesc
)
247 struct win32_display_info
*dpyinfo
;
250 Lisp_Object tail
, frame
;
253 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCONS (tail
)->cdr
)
255 frame
= XCONS (tail
)->car
;
256 if (!GC_FRAMEP (frame
))
259 if (f
->output_data
.nothing
== 1
260 || FRAME_WIN32_DISPLAY_INFO (f
) != dpyinfo
)
262 if (FRAME_WIN32_WINDOW (f
) == wdesc
)
270 /* Code to deal with bitmaps. Bitmaps are referenced by their bitmap
271 id, which is just an int that this section returns. Bitmaps are
272 reference counted so they can be shared among frames.
274 Bitmap indices are guaranteed to be > 0, so a negative number can
275 be used to indicate no bitmap.
277 If you use x_create_bitmap_from_data, then you must keep track of
278 the bitmaps yourself. That is, creating a bitmap from the same
279 data more than once will not be caught. */
282 /* Functions to access the contents of a bitmap, given an id. */
285 x_bitmap_height (f
, id
)
289 return FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].height
;
293 x_bitmap_width (f
, id
)
297 return FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].width
;
301 x_bitmap_pixmap (f
, id
)
305 return (int) FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].pixmap
;
309 /* Allocate a new bitmap record. Returns index of new record. */
312 x_allocate_bitmap_record (f
)
315 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
318 if (dpyinfo
->bitmaps
== NULL
)
320 dpyinfo
->bitmaps_size
= 10;
322 = (struct win32_bitmap_record
*) xmalloc (dpyinfo
->bitmaps_size
* sizeof (struct win32_bitmap_record
));
323 dpyinfo
->bitmaps_last
= 1;
327 if (dpyinfo
->bitmaps_last
< dpyinfo
->bitmaps_size
)
328 return ++dpyinfo
->bitmaps_last
;
330 for (i
= 0; i
< dpyinfo
->bitmaps_size
; ++i
)
331 if (dpyinfo
->bitmaps
[i
].refcount
== 0)
334 dpyinfo
->bitmaps_size
*= 2;
336 = (struct win32_bitmap_record
*) xrealloc (dpyinfo
->bitmaps
,
337 dpyinfo
->bitmaps_size
* sizeof (struct win32_bitmap_record
));
338 return ++dpyinfo
->bitmaps_last
;
341 /* Add one reference to the reference count of the bitmap with id ID. */
344 x_reference_bitmap (f
, id
)
348 ++FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].refcount
;
351 /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */
354 x_create_bitmap_from_data (f
, bits
, width
, height
)
357 unsigned int width
, height
;
359 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
363 bitmap
= CreateBitmap (width
, height
,
364 FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_planes
,
365 FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_cbits
,
371 id
= x_allocate_bitmap_record (f
);
372 dpyinfo
->bitmaps
[id
- 1].pixmap
= bitmap
;
373 dpyinfo
->bitmaps
[id
- 1].file
= NULL
;
374 dpyinfo
->bitmaps
[id
- 1].hinst
= NULL
;
375 dpyinfo
->bitmaps
[id
- 1].refcount
= 1;
376 dpyinfo
->bitmaps
[id
- 1].depth
= 1;
377 dpyinfo
->bitmaps
[id
- 1].height
= height
;
378 dpyinfo
->bitmaps
[id
- 1].width
= width
;
383 /* Create bitmap from file FILE for frame F. */
386 x_create_bitmap_from_file (f
, file
)
392 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
393 unsigned int width
, height
;
395 int xhot
, yhot
, result
, id
;
401 /* Look for an existing bitmap with the same name. */
402 for (id
= 0; id
< dpyinfo
->bitmaps_last
; ++id
)
404 if (dpyinfo
->bitmaps
[id
].refcount
405 && dpyinfo
->bitmaps
[id
].file
406 && !strcmp (dpyinfo
->bitmaps
[id
].file
, (char *) XSTRING (file
)->data
))
408 ++dpyinfo
->bitmaps
[id
].refcount
;
413 /* Search bitmap-file-path for the file, if appropriate. */
414 fd
= openp (Vx_bitmap_file_path
, file
, "", &found
, 0);
419 filename
= (char *) XSTRING (found
)->data
;
421 hinst
= LoadLibraryEx (filename
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
427 result
= XReadBitmapFile (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
),
428 filename
, &width
, &height
, &bitmap
, &xhot
, &yhot
);
429 if (result
!= BitmapSuccess
)
432 id
= x_allocate_bitmap_record (f
);
433 dpyinfo
->bitmaps
[id
- 1].pixmap
= bitmap
;
434 dpyinfo
->bitmaps
[id
- 1].refcount
= 1;
435 dpyinfo
->bitmaps
[id
- 1].file
= (char *) xmalloc (XSTRING (file
)->size
+ 1);
436 dpyinfo
->bitmaps
[id
- 1].depth
= 1;
437 dpyinfo
->bitmaps
[id
- 1].height
= height
;
438 dpyinfo
->bitmaps
[id
- 1].width
= width
;
439 strcpy (dpyinfo
->bitmaps
[id
- 1].file
, XSTRING (file
)->data
);
445 /* Remove reference to bitmap with id number ID. */
448 x_destroy_bitmap (f
, id
)
452 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
456 --dpyinfo
->bitmaps
[id
- 1].refcount
;
457 if (dpyinfo
->bitmaps
[id
- 1].refcount
== 0)
460 DeleteObject (dpyinfo
->bitmaps
[id
- 1].pixmap
);
461 if (dpyinfo
->bitmaps
[id
- 1].file
)
463 free (dpyinfo
->bitmaps
[id
- 1].file
);
464 dpyinfo
->bitmaps
[id
- 1].file
= NULL
;
471 /* Free all the bitmaps for the display specified by DPYINFO. */
474 x_destroy_all_bitmaps (dpyinfo
)
475 struct win32_display_info
*dpyinfo
;
478 for (i
= 0; i
< dpyinfo
->bitmaps_last
; i
++)
479 if (dpyinfo
->bitmaps
[i
].refcount
> 0)
481 DeleteObject (dpyinfo
->bitmaps
[i
].pixmap
);
482 if (dpyinfo
->bitmaps
[i
].file
)
483 free (dpyinfo
->bitmaps
[i
].file
);
485 dpyinfo
->bitmaps_last
= 0;
488 /* Connect the frame-parameter names for Win32 frames
489 to the ways of passing the parameter values to the window system.
491 The name of a parameter, as a Lisp symbol,
492 has an `x-frame-parameter' property which is an integer in Lisp
493 but can be interpreted as an `enum x_frame_parm' in C. */
497 X_PARM_FOREGROUND_COLOR
,
498 X_PARM_BACKGROUND_COLOR
,
505 X_PARM_INTERNAL_BORDER_WIDTH
,
509 X_PARM_VERT_SCROLL_BAR
,
511 X_PARM_MENU_BAR_LINES
515 struct x_frame_parm_table
518 void (*setter
)( /* struct frame *frame, Lisp_Object val, oldval */ );
521 void x_set_foreground_color ();
522 void x_set_background_color ();
523 void x_set_mouse_color ();
524 void x_set_cursor_color ();
525 void x_set_border_color ();
526 void x_set_cursor_type ();
527 void x_set_icon_type ();
528 void x_set_icon_name ();
530 void x_set_border_width ();
531 void x_set_internal_border_width ();
532 void x_explicitly_set_name ();
533 void x_set_autoraise ();
534 void x_set_autolower ();
535 void x_set_vertical_scroll_bars ();
536 void x_set_visibility ();
537 void x_set_menu_bar_lines ();
538 void x_set_scroll_bar_width ();
539 void x_set_unsplittable ();
541 static struct x_frame_parm_table x_frame_parms
[] =
543 "foreground-color", x_set_foreground_color
,
544 "background-color", x_set_background_color
,
545 "mouse-color", x_set_mouse_color
,
546 "cursor-color", x_set_cursor_color
,
547 "border-color", x_set_border_color
,
548 "cursor-type", x_set_cursor_type
,
549 "icon-type", x_set_icon_type
,
550 "icon-name", x_set_icon_name
,
552 "border-width", x_set_border_width
,
553 "internal-border-width", x_set_internal_border_width
,
554 "name", x_explicitly_set_name
,
555 "auto-raise", x_set_autoraise
,
556 "auto-lower", x_set_autolower
,
557 "vertical-scroll-bars", x_set_vertical_scroll_bars
,
558 "visibility", x_set_visibility
,
559 "menu-bar-lines", x_set_menu_bar_lines
,
560 "scroll-bar-width", x_set_scroll_bar_width
,
561 "unsplittable", x_set_unsplittable
,
564 /* Attach the `x-frame-parameter' properties to
565 the Lisp symbol names of parameters relevant to Win32. */
567 init_x_parm_symbols ()
571 for (i
= 0; i
< sizeof (x_frame_parms
) / sizeof (x_frame_parms
[0]); i
++)
572 Fput (intern (x_frame_parms
[i
].name
), Qx_frame_parameter
,
576 /* Change the parameters of FRAME as specified by ALIST.
577 If a parameter is not specially recognized, do nothing;
578 otherwise call the `x_set_...' function for that parameter. */
581 x_set_frame_parameters (f
, alist
)
587 /* If both of these parameters are present, it's more efficient to
588 set them both at once. So we wait until we've looked at the
589 entire list before we set them. */
593 Lisp_Object left
, top
;
595 /* Same with these. */
596 Lisp_Object icon_left
, icon_top
;
598 /* Record in these vectors all the parms specified. */
602 int left_no_change
= 0, top_no_change
= 0;
603 int icon_left_no_change
= 0, icon_top_no_change
= 0;
606 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
609 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
610 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
612 /* Extract parm names and values into those vectors. */
615 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
617 Lisp_Object elt
, prop
, val
;
620 parms
[i
] = Fcar (elt
);
621 values
[i
] = Fcdr (elt
);
625 top
= left
= Qunbound
;
626 icon_left
= icon_top
= Qunbound
;
628 /* Provide default values for HEIGHT and WIDTH. */
629 width
= FRAME_WIDTH (f
);
630 height
= FRAME_HEIGHT (f
);
632 /* Now process them in reverse of specified order. */
633 for (i
--; i
>= 0; i
--)
635 Lisp_Object prop
, val
;
640 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
641 width
= XFASTINT (val
);
642 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
643 height
= XFASTINT (val
);
644 else if (EQ (prop
, Qtop
))
646 else if (EQ (prop
, Qleft
))
648 else if (EQ (prop
, Qicon_top
))
650 else if (EQ (prop
, Qicon_left
))
654 register Lisp_Object param_index
, old_value
;
656 param_index
= Fget (prop
, Qx_frame_parameter
);
657 old_value
= get_frame_param (f
, prop
);
658 store_frame_param (f
, prop
, val
);
659 if (NATNUMP (param_index
)
660 && (XFASTINT (param_index
)
661 < sizeof (x_frame_parms
)/sizeof (x_frame_parms
[0])))
662 (*x_frame_parms
[XINT (param_index
)].setter
)(f
, val
, old_value
);
666 /* Don't die if just one of these was set. */
667 if (EQ (left
, Qunbound
))
670 if (f
->output_data
.win32
->left_pos
< 0)
671 left
= Fcons (Qplus
, Fcons (make_number (f
->output_data
.win32
->left_pos
), Qnil
));
673 XSETINT (left
, f
->output_data
.win32
->left_pos
);
675 if (EQ (top
, Qunbound
))
678 if (f
->output_data
.win32
->top_pos
< 0)
679 top
= Fcons (Qplus
, Fcons (make_number (f
->output_data
.win32
->top_pos
), Qnil
));
681 XSETINT (top
, f
->output_data
.win32
->top_pos
);
684 /* If one of the icon positions was not set, preserve or default it. */
685 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
687 icon_left_no_change
= 1;
688 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
689 if (NILP (icon_left
))
690 XSETINT (icon_left
, 0);
692 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
694 icon_top_no_change
= 1;
695 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
697 XSETINT (icon_top
, 0);
700 /* Don't set these parameters unless they've been explicitly
701 specified. The window might be mapped or resized while we're in
702 this function, and we don't want to override that unless the lisp
703 code has asked for it.
705 Don't set these parameters unless they actually differ from the
706 window's current parameters; the window may not actually exist
711 check_frame_size (f
, &height
, &width
);
713 XSETFRAME (frame
, f
);
715 if (XINT (width
) != FRAME_WIDTH (f
)
716 || XINT (height
) != FRAME_HEIGHT (f
))
717 Fset_frame_size (frame
, make_number (width
), make_number (height
));
719 if ((!NILP (left
) || !NILP (top
))
720 && ! (left_no_change
&& top_no_change
)
721 && ! (NUMBERP (left
) && XINT (left
) == f
->output_data
.win32
->left_pos
722 && NUMBERP (top
) && XINT (top
) == f
->output_data
.win32
->top_pos
))
727 /* Record the signs. */
728 f
->output_data
.win32
->size_hint_flags
&= ~ (XNegative
| YNegative
);
729 if (EQ (left
, Qminus
))
730 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
731 else if (INTEGERP (left
))
733 leftpos
= XINT (left
);
735 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
737 else if (CONSP (left
) && EQ (XCONS (left
)->car
, Qminus
)
738 && CONSP (XCONS (left
)->cdr
)
739 && INTEGERP (XCONS (XCONS (left
)->cdr
)->car
))
741 leftpos
= - XINT (XCONS (XCONS (left
)->cdr
)->car
);
742 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
744 else if (CONSP (left
) && EQ (XCONS (left
)->car
, Qplus
)
745 && CONSP (XCONS (left
)->cdr
)
746 && INTEGERP (XCONS (XCONS (left
)->cdr
)->car
))
748 leftpos
= XINT (XCONS (XCONS (left
)->cdr
)->car
);
751 if (EQ (top
, Qminus
))
752 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
753 else if (INTEGERP (top
))
757 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
759 else if (CONSP (top
) && EQ (XCONS (top
)->car
, Qminus
)
760 && CONSP (XCONS (top
)->cdr
)
761 && INTEGERP (XCONS (XCONS (top
)->cdr
)->car
))
763 toppos
= - XINT (XCONS (XCONS (top
)->cdr
)->car
);
764 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
766 else if (CONSP (top
) && EQ (XCONS (top
)->car
, Qplus
)
767 && CONSP (XCONS (top
)->cdr
)
768 && INTEGERP (XCONS (XCONS (top
)->cdr
)->car
))
770 toppos
= XINT (XCONS (XCONS (top
)->cdr
)->car
);
774 /* Store the numeric value of the position. */
775 f
->output_data
.win32
->top_pos
= toppos
;
776 f
->output_data
.win32
->left_pos
= leftpos
;
778 f
->output_data
.win32
->win_gravity
= NorthWestGravity
;
780 /* Actually set that position, and convert to absolute. */
781 x_set_offset (f
, leftpos
, toppos
, -1);
784 if ((!NILP (icon_left
) || !NILP (icon_top
))
785 && ! (icon_left_no_change
&& icon_top_no_change
))
786 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
790 /* Store the screen positions of frame F into XPTR and YPTR.
791 These are the positions of the containing window manager window,
792 not Emacs's own window. */
795 x_real_positions (f
, xptr
, yptr
)
804 GetClientRect(FRAME_WIN32_WINDOW(f
), &rect
);
805 AdjustWindowRect(&rect
, f
->output_data
.win32
->dwStyle
, FRAME_EXTERNAL_MENU_BAR(f
));
811 ClientToScreen (FRAME_WIN32_WINDOW(f
), &pt
);
817 /* Insert a description of internally-recorded parameters of frame X
818 into the parameter alist *ALISTPTR that is to be given to the user.
819 Only parameters that are specific to Win32
820 and whose values are not correctly recorded in the frame's
821 param_alist need to be considered here. */
823 x_report_frame_params (f
, alistptr
)
825 Lisp_Object
*alistptr
;
830 /* Represent negative positions (off the top or left screen edge)
831 in a way that Fmodify_frame_parameters will understand correctly. */
832 XSETINT (tem
, f
->output_data
.win32
->left_pos
);
833 if (f
->output_data
.win32
->left_pos
>= 0)
834 store_in_alist (alistptr
, Qleft
, tem
);
836 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
838 XSETINT (tem
, f
->output_data
.win32
->top_pos
);
839 if (f
->output_data
.win32
->top_pos
>= 0)
840 store_in_alist (alistptr
, Qtop
, tem
);
842 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
844 store_in_alist (alistptr
, Qborder_width
,
845 make_number (f
->output_data
.win32
->border_width
));
846 store_in_alist (alistptr
, Qinternal_border_width
,
847 make_number (f
->output_data
.win32
->internal_border_width
));
848 sprintf (buf
, "%ld", (long) FRAME_WIN32_WINDOW (f
));
849 store_in_alist (alistptr
, Qwindow_id
,
851 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
852 FRAME_SAMPLE_VISIBILITY (f
);
853 store_in_alist (alistptr
, Qvisibility
,
854 (FRAME_VISIBLE_P (f
) ? Qt
855 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
856 store_in_alist (alistptr
, Qdisplay
,
857 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->car
);
861 DEFUN ("win32-define-rgb-color", Fwin32_define_rgb_color
, Swin32_define_rgb_color
, 4, 4, 0,
862 "Convert RGB numbers to a windows color reference and associate with NAME (a string).\n\
863 This adds or updates a named color to win32-color-map, making it available for use.\n\
864 The original entry's RGB ref is returned, or nil if the entry is new.")
865 (red
, green
, blue
, name
)
866 Lisp_Object red
, green
, blue
, name
;
869 Lisp_Object oldrgb
= Qnil
;
872 CHECK_NUMBER (red
, 0);
873 CHECK_NUMBER (green
, 0);
874 CHECK_NUMBER (blue
, 0);
875 CHECK_STRING (name
, 0);
877 XSET (rgb
, Lisp_Int
, RGB(XUINT (red
), XUINT (green
), XUINT (blue
)));
881 /* replace existing entry in win32-color-map or add new entry. */
882 entry
= Fassoc (name
, Vwin32_color_map
);
885 entry
= Fcons (name
, rgb
);
886 Vwin32_color_map
= Fcons (entry
, Vwin32_color_map
);
890 oldrgb
= Fcdr (entry
);
891 Fsetcdr (entry
, rgb
);
899 DEFUN ("win32-load-color-file", Fwin32_load_color_file
, Swin32_load_color_file
, 1, 1, 0,
900 "Create an alist of color entries from an external file (ie. rgb.txt).\n\
901 Assign this value to win32-color-map to replace the existing color map.\n\
903 The file should define one named RGB color per line like so:\
905 where R,G,B are numbers between 0 and 255 and name is an arbitrary string.")
907 Lisp_Object filename
;
910 Lisp_Object cmap
= Qnil
;
913 CHECK_STRING (filename
, 0);
914 abspath
= Fexpand_file_name (filename
, Qnil
);
916 fp
= fopen (XSTRING (filename
)->data
, "rt");
920 int red
, green
, blue
;
925 while (fgets (buf
, sizeof (buf
), fp
) != NULL
) {
926 if (sscanf (buf
, "%u %u %u %n", &red
, &green
, &blue
, &num
) == 3)
928 char *name
= buf
+ num
;
929 num
= strlen (name
) - 1;
930 if (name
[num
] == '\n')
932 cmap
= Fcons (Fcons (build_string (name
),
933 make_number (RGB (red
, green
, blue
))),
945 /* The default colors for the win32 color map */
946 typedef struct colormap_t
952 colormap_t win32_color_map
[] =
954 {"snow" , PALETTERGB (255,250,250)},
955 {"ghost white" , PALETTERGB (248,248,255)},
956 {"GhostWhite" , PALETTERGB (248,248,255)},
957 {"white smoke" , PALETTERGB (245,245,245)},
958 {"WhiteSmoke" , PALETTERGB (245,245,245)},
959 {"gainsboro" , PALETTERGB (220,220,220)},
960 {"floral white" , PALETTERGB (255,250,240)},
961 {"FloralWhite" , PALETTERGB (255,250,240)},
962 {"old lace" , PALETTERGB (253,245,230)},
963 {"OldLace" , PALETTERGB (253,245,230)},
964 {"linen" , PALETTERGB (250,240,230)},
965 {"antique white" , PALETTERGB (250,235,215)},
966 {"AntiqueWhite" , PALETTERGB (250,235,215)},
967 {"papaya whip" , PALETTERGB (255,239,213)},
968 {"PapayaWhip" , PALETTERGB (255,239,213)},
969 {"blanched almond" , PALETTERGB (255,235,205)},
970 {"BlanchedAlmond" , PALETTERGB (255,235,205)},
971 {"bisque" , PALETTERGB (255,228,196)},
972 {"peach puff" , PALETTERGB (255,218,185)},
973 {"PeachPuff" , PALETTERGB (255,218,185)},
974 {"navajo white" , PALETTERGB (255,222,173)},
975 {"NavajoWhite" , PALETTERGB (255,222,173)},
976 {"moccasin" , PALETTERGB (255,228,181)},
977 {"cornsilk" , PALETTERGB (255,248,220)},
978 {"ivory" , PALETTERGB (255,255,240)},
979 {"lemon chiffon" , PALETTERGB (255,250,205)},
980 {"LemonChiffon" , PALETTERGB (255,250,205)},
981 {"seashell" , PALETTERGB (255,245,238)},
982 {"honeydew" , PALETTERGB (240,255,240)},
983 {"mint cream" , PALETTERGB (245,255,250)},
984 {"MintCream" , PALETTERGB (245,255,250)},
985 {"azure" , PALETTERGB (240,255,255)},
986 {"alice blue" , PALETTERGB (240,248,255)},
987 {"AliceBlue" , PALETTERGB (240,248,255)},
988 {"lavender" , PALETTERGB (230,230,250)},
989 {"lavender blush" , PALETTERGB (255,240,245)},
990 {"LavenderBlush" , PALETTERGB (255,240,245)},
991 {"misty rose" , PALETTERGB (255,228,225)},
992 {"MistyRose" , PALETTERGB (255,228,225)},
993 {"white" , PALETTERGB (255,255,255)},
994 {"black" , PALETTERGB ( 0, 0, 0)},
995 {"dark slate gray" , PALETTERGB ( 47, 79, 79)},
996 {"DarkSlateGray" , PALETTERGB ( 47, 79, 79)},
997 {"dark slate grey" , PALETTERGB ( 47, 79, 79)},
998 {"DarkSlateGrey" , PALETTERGB ( 47, 79, 79)},
999 {"dim gray" , PALETTERGB (105,105,105)},
1000 {"DimGray" , PALETTERGB (105,105,105)},
1001 {"dim grey" , PALETTERGB (105,105,105)},
1002 {"DimGrey" , PALETTERGB (105,105,105)},
1003 {"slate gray" , PALETTERGB (112,128,144)},
1004 {"SlateGray" , PALETTERGB (112,128,144)},
1005 {"slate grey" , PALETTERGB (112,128,144)},
1006 {"SlateGrey" , PALETTERGB (112,128,144)},
1007 {"light slate gray" , PALETTERGB (119,136,153)},
1008 {"LightSlateGray" , PALETTERGB (119,136,153)},
1009 {"light slate grey" , PALETTERGB (119,136,153)},
1010 {"LightSlateGrey" , PALETTERGB (119,136,153)},
1011 {"gray" , PALETTERGB (190,190,190)},
1012 {"grey" , PALETTERGB (190,190,190)},
1013 {"light grey" , PALETTERGB (211,211,211)},
1014 {"LightGrey" , PALETTERGB (211,211,211)},
1015 {"light gray" , PALETTERGB (211,211,211)},
1016 {"LightGray" , PALETTERGB (211,211,211)},
1017 {"midnight blue" , PALETTERGB ( 25, 25,112)},
1018 {"MidnightBlue" , PALETTERGB ( 25, 25,112)},
1019 {"navy" , PALETTERGB ( 0, 0,128)},
1020 {"navy blue" , PALETTERGB ( 0, 0,128)},
1021 {"NavyBlue" , PALETTERGB ( 0, 0,128)},
1022 {"cornflower blue" , PALETTERGB (100,149,237)},
1023 {"CornflowerBlue" , PALETTERGB (100,149,237)},
1024 {"dark slate blue" , PALETTERGB ( 72, 61,139)},
1025 {"DarkSlateBlue" , PALETTERGB ( 72, 61,139)},
1026 {"slate blue" , PALETTERGB (106, 90,205)},
1027 {"SlateBlue" , PALETTERGB (106, 90,205)},
1028 {"medium slate blue" , PALETTERGB (123,104,238)},
1029 {"MediumSlateBlue" , PALETTERGB (123,104,238)},
1030 {"light slate blue" , PALETTERGB (132,112,255)},
1031 {"LightSlateBlue" , PALETTERGB (132,112,255)},
1032 {"medium blue" , PALETTERGB ( 0, 0,205)},
1033 {"MediumBlue" , PALETTERGB ( 0, 0,205)},
1034 {"royal blue" , PALETTERGB ( 65,105,225)},
1035 {"RoyalBlue" , PALETTERGB ( 65,105,225)},
1036 {"blue" , PALETTERGB ( 0, 0,255)},
1037 {"dodger blue" , PALETTERGB ( 30,144,255)},
1038 {"DodgerBlue" , PALETTERGB ( 30,144,255)},
1039 {"deep sky blue" , PALETTERGB ( 0,191,255)},
1040 {"DeepSkyBlue" , PALETTERGB ( 0,191,255)},
1041 {"sky blue" , PALETTERGB (135,206,235)},
1042 {"SkyBlue" , PALETTERGB (135,206,235)},
1043 {"light sky blue" , PALETTERGB (135,206,250)},
1044 {"LightSkyBlue" , PALETTERGB (135,206,250)},
1045 {"steel blue" , PALETTERGB ( 70,130,180)},
1046 {"SteelBlue" , PALETTERGB ( 70,130,180)},
1047 {"light steel blue" , PALETTERGB (176,196,222)},
1048 {"LightSteelBlue" , PALETTERGB (176,196,222)},
1049 {"light blue" , PALETTERGB (173,216,230)},
1050 {"LightBlue" , PALETTERGB (173,216,230)},
1051 {"powder blue" , PALETTERGB (176,224,230)},
1052 {"PowderBlue" , PALETTERGB (176,224,230)},
1053 {"pale turquoise" , PALETTERGB (175,238,238)},
1054 {"PaleTurquoise" , PALETTERGB (175,238,238)},
1055 {"dark turquoise" , PALETTERGB ( 0,206,209)},
1056 {"DarkTurquoise" , PALETTERGB ( 0,206,209)},
1057 {"medium turquoise" , PALETTERGB ( 72,209,204)},
1058 {"MediumTurquoise" , PALETTERGB ( 72,209,204)},
1059 {"turquoise" , PALETTERGB ( 64,224,208)},
1060 {"cyan" , PALETTERGB ( 0,255,255)},
1061 {"light cyan" , PALETTERGB (224,255,255)},
1062 {"LightCyan" , PALETTERGB (224,255,255)},
1063 {"cadet blue" , PALETTERGB ( 95,158,160)},
1064 {"CadetBlue" , PALETTERGB ( 95,158,160)},
1065 {"medium aquamarine" , PALETTERGB (102,205,170)},
1066 {"MediumAquamarine" , PALETTERGB (102,205,170)},
1067 {"aquamarine" , PALETTERGB (127,255,212)},
1068 {"dark green" , PALETTERGB ( 0,100, 0)},
1069 {"DarkGreen" , PALETTERGB ( 0,100, 0)},
1070 {"dark olive green" , PALETTERGB ( 85,107, 47)},
1071 {"DarkOliveGreen" , PALETTERGB ( 85,107, 47)},
1072 {"dark sea green" , PALETTERGB (143,188,143)},
1073 {"DarkSeaGreen" , PALETTERGB (143,188,143)},
1074 {"sea green" , PALETTERGB ( 46,139, 87)},
1075 {"SeaGreen" , PALETTERGB ( 46,139, 87)},
1076 {"medium sea green" , PALETTERGB ( 60,179,113)},
1077 {"MediumSeaGreen" , PALETTERGB ( 60,179,113)},
1078 {"light sea green" , PALETTERGB ( 32,178,170)},
1079 {"LightSeaGreen" , PALETTERGB ( 32,178,170)},
1080 {"pale green" , PALETTERGB (152,251,152)},
1081 {"PaleGreen" , PALETTERGB (152,251,152)},
1082 {"spring green" , PALETTERGB ( 0,255,127)},
1083 {"SpringGreen" , PALETTERGB ( 0,255,127)},
1084 {"lawn green" , PALETTERGB (124,252, 0)},
1085 {"LawnGreen" , PALETTERGB (124,252, 0)},
1086 {"green" , PALETTERGB ( 0,255, 0)},
1087 {"chartreuse" , PALETTERGB (127,255, 0)},
1088 {"medium spring green" , PALETTERGB ( 0,250,154)},
1089 {"MediumSpringGreen" , PALETTERGB ( 0,250,154)},
1090 {"green yellow" , PALETTERGB (173,255, 47)},
1091 {"GreenYellow" , PALETTERGB (173,255, 47)},
1092 {"lime green" , PALETTERGB ( 50,205, 50)},
1093 {"LimeGreen" , PALETTERGB ( 50,205, 50)},
1094 {"yellow green" , PALETTERGB (154,205, 50)},
1095 {"YellowGreen" , PALETTERGB (154,205, 50)},
1096 {"forest green" , PALETTERGB ( 34,139, 34)},
1097 {"ForestGreen" , PALETTERGB ( 34,139, 34)},
1098 {"olive drab" , PALETTERGB (107,142, 35)},
1099 {"OliveDrab" , PALETTERGB (107,142, 35)},
1100 {"dark khaki" , PALETTERGB (189,183,107)},
1101 {"DarkKhaki" , PALETTERGB (189,183,107)},
1102 {"khaki" , PALETTERGB (240,230,140)},
1103 {"pale goldenrod" , PALETTERGB (238,232,170)},
1104 {"PaleGoldenrod" , PALETTERGB (238,232,170)},
1105 {"light goldenrod yellow" , PALETTERGB (250,250,210)},
1106 {"LightGoldenrodYellow" , PALETTERGB (250,250,210)},
1107 {"light yellow" , PALETTERGB (255,255,224)},
1108 {"LightYellow" , PALETTERGB (255,255,224)},
1109 {"yellow" , PALETTERGB (255,255, 0)},
1110 {"gold" , PALETTERGB (255,215, 0)},
1111 {"light goldenrod" , PALETTERGB (238,221,130)},
1112 {"LightGoldenrod" , PALETTERGB (238,221,130)},
1113 {"goldenrod" , PALETTERGB (218,165, 32)},
1114 {"dark goldenrod" , PALETTERGB (184,134, 11)},
1115 {"DarkGoldenrod" , PALETTERGB (184,134, 11)},
1116 {"rosy brown" , PALETTERGB (188,143,143)},
1117 {"RosyBrown" , PALETTERGB (188,143,143)},
1118 {"indian red" , PALETTERGB (205, 92, 92)},
1119 {"IndianRed" , PALETTERGB (205, 92, 92)},
1120 {"saddle brown" , PALETTERGB (139, 69, 19)},
1121 {"SaddleBrown" , PALETTERGB (139, 69, 19)},
1122 {"sienna" , PALETTERGB (160, 82, 45)},
1123 {"peru" , PALETTERGB (205,133, 63)},
1124 {"burlywood" , PALETTERGB (222,184,135)},
1125 {"beige" , PALETTERGB (245,245,220)},
1126 {"wheat" , PALETTERGB (245,222,179)},
1127 {"sandy brown" , PALETTERGB (244,164, 96)},
1128 {"SandyBrown" , PALETTERGB (244,164, 96)},
1129 {"tan" , PALETTERGB (210,180,140)},
1130 {"chocolate" , PALETTERGB (210,105, 30)},
1131 {"firebrick" , PALETTERGB (178,34, 34)},
1132 {"brown" , PALETTERGB (165,42, 42)},
1133 {"dark salmon" , PALETTERGB (233,150,122)},
1134 {"DarkSalmon" , PALETTERGB (233,150,122)},
1135 {"salmon" , PALETTERGB (250,128,114)},
1136 {"light salmon" , PALETTERGB (255,160,122)},
1137 {"LightSalmon" , PALETTERGB (255,160,122)},
1138 {"orange" , PALETTERGB (255,165, 0)},
1139 {"dark orange" , PALETTERGB (255,140, 0)},
1140 {"DarkOrange" , PALETTERGB (255,140, 0)},
1141 {"coral" , PALETTERGB (255,127, 80)},
1142 {"light coral" , PALETTERGB (240,128,128)},
1143 {"LightCoral" , PALETTERGB (240,128,128)},
1144 {"tomato" , PALETTERGB (255, 99, 71)},
1145 {"orange red" , PALETTERGB (255, 69, 0)},
1146 {"OrangeRed" , PALETTERGB (255, 69, 0)},
1147 {"red" , PALETTERGB (255, 0, 0)},
1148 {"hot pink" , PALETTERGB (255,105,180)},
1149 {"HotPink" , PALETTERGB (255,105,180)},
1150 {"deep pink" , PALETTERGB (255, 20,147)},
1151 {"DeepPink" , PALETTERGB (255, 20,147)},
1152 {"pink" , PALETTERGB (255,192,203)},
1153 {"light pink" , PALETTERGB (255,182,193)},
1154 {"LightPink" , PALETTERGB (255,182,193)},
1155 {"pale violet red" , PALETTERGB (219,112,147)},
1156 {"PaleVioletRed" , PALETTERGB (219,112,147)},
1157 {"maroon" , PALETTERGB (176, 48, 96)},
1158 {"medium violet red" , PALETTERGB (199, 21,133)},
1159 {"MediumVioletRed" , PALETTERGB (199, 21,133)},
1160 {"violet red" , PALETTERGB (208, 32,144)},
1161 {"VioletRed" , PALETTERGB (208, 32,144)},
1162 {"magenta" , PALETTERGB (255, 0,255)},
1163 {"violet" , PALETTERGB (238,130,238)},
1164 {"plum" , PALETTERGB (221,160,221)},
1165 {"orchid" , PALETTERGB (218,112,214)},
1166 {"medium orchid" , PALETTERGB (186, 85,211)},
1167 {"MediumOrchid" , PALETTERGB (186, 85,211)},
1168 {"dark orchid" , PALETTERGB (153, 50,204)},
1169 {"DarkOrchid" , PALETTERGB (153, 50,204)},
1170 {"dark violet" , PALETTERGB (148, 0,211)},
1171 {"DarkViolet" , PALETTERGB (148, 0,211)},
1172 {"blue violet" , PALETTERGB (138, 43,226)},
1173 {"BlueViolet" , PALETTERGB (138, 43,226)},
1174 {"purple" , PALETTERGB (160, 32,240)},
1175 {"medium purple" , PALETTERGB (147,112,219)},
1176 {"MediumPurple" , PALETTERGB (147,112,219)},
1177 {"thistle" , PALETTERGB (216,191,216)},
1178 {"gray0" , PALETTERGB ( 0, 0, 0)},
1179 {"grey0" , PALETTERGB ( 0, 0, 0)},
1180 {"dark grey" , PALETTERGB (169,169,169)},
1181 {"DarkGrey" , PALETTERGB (169,169,169)},
1182 {"dark gray" , PALETTERGB (169,169,169)},
1183 {"DarkGray" , PALETTERGB (169,169,169)},
1184 {"dark blue" , PALETTERGB ( 0, 0,139)},
1185 {"DarkBlue" , PALETTERGB ( 0, 0,139)},
1186 {"dark cyan" , PALETTERGB ( 0,139,139)},
1187 {"DarkCyan" , PALETTERGB ( 0,139,139)},
1188 {"dark magenta" , PALETTERGB (139, 0,139)},
1189 {"DarkMagenta" , PALETTERGB (139, 0,139)},
1190 {"dark red" , PALETTERGB (139, 0, 0)},
1191 {"DarkRed" , PALETTERGB (139, 0, 0)},
1192 {"light green" , PALETTERGB (144,238,144)},
1193 {"LightGreen" , PALETTERGB (144,238,144)},
1196 DEFUN ("win32-default-color-map", Fwin32_default_color_map
, Swin32_default_color_map
,
1197 0, 0, 0, "Return the default color map.")
1201 colormap_t
*pc
= win32_color_map
;
1208 for (i
= 0; i
< sizeof (win32_color_map
) / sizeof (win32_color_map
[0]);
1210 cmap
= Fcons (Fcons (build_string (pc
->name
),
1211 make_number (pc
->colorref
)),
1220 win32_to_x_color (rgb
)
1225 CHECK_NUMBER (rgb
, 0);
1229 color
= Frassq (rgb
, Vwin32_color_map
);
1234 return (Fcar (color
));
1240 x_to_win32_color (colorname
)
1243 register Lisp_Object tail
, ret
= Qnil
;
1247 for (tail
= Vwin32_color_map
; !NILP (tail
); tail
= Fcdr (tail
))
1249 register Lisp_Object elt
, tem
;
1252 if (!CONSP (elt
)) continue;
1256 if (lstrcmpi (XSTRING (tem
)->data
, colorname
) == 0)
1258 ret
= XUINT(Fcdr (elt
));
1272 win32_regenerate_palette (FRAME_PTR f
)
1274 struct win32_palette_entry
* list
;
1275 LOGPALETTE
* log_palette
;
1276 HPALETTE new_palette
;
1279 /* don't bother trying to create palette if not supported */
1280 if (! FRAME_WIN32_DISPLAY_INFO (f
)->has_palette
)
1283 log_palette
= (LOGPALETTE
*)
1284 alloca (sizeof (LOGPALETTE
) +
1285 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
* sizeof (PALETTEENTRY
));
1286 log_palette
->palVersion
= 0x300;
1287 log_palette
->palNumEntries
= FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
;
1289 list
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1291 i
< FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
;
1292 i
++, list
= list
->next
)
1293 log_palette
->palPalEntry
[i
] = list
->entry
;
1295 new_palette
= CreatePalette (log_palette
);
1299 if (FRAME_WIN32_DISPLAY_INFO (f
)->palette
)
1300 DeleteObject (FRAME_WIN32_DISPLAY_INFO (f
)->palette
);
1301 FRAME_WIN32_DISPLAY_INFO (f
)->palette
= new_palette
;
1303 /* Realize display palette and garbage all frames. */
1304 release_frame_dc (f
, get_frame_dc (f
));
1309 #define WIN32_COLOR(pe) RGB (pe.peRed, pe.peGreen, pe.peBlue)
1310 #define SET_WIN32_COLOR(pe, color) \
1313 pe.peRed = GetRValue (color); \
1314 pe.peGreen = GetGValue (color); \
1315 pe.peBlue = GetBValue (color); \
1320 /* Keep these around in case we ever want to track color usage. */
1322 win32_map_color (FRAME_PTR f
, COLORREF color
)
1324 struct win32_palette_entry
* list
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1326 if (NILP (Vwin32_enable_palette
))
1329 /* check if color is already mapped */
1332 if (WIN32_COLOR (list
->entry
) == color
)
1340 /* not already mapped, so add to list and recreate Windows palette */
1341 list
= (struct win32_palette_entry
*)
1342 xmalloc (sizeof (struct win32_palette_entry
));
1343 SET_WIN32_COLOR (list
->entry
, color
);
1345 list
->next
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1346 FRAME_WIN32_DISPLAY_INFO (f
)->color_list
= list
;
1347 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
++;
1349 /* set flag that palette must be regenerated */
1350 FRAME_WIN32_DISPLAY_INFO (f
)->regen_palette
= TRUE
;
1354 win32_unmap_color (FRAME_PTR f
, COLORREF color
)
1356 struct win32_palette_entry
* list
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1357 struct win32_palette_entry
**prev
= &FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1359 if (NILP (Vwin32_enable_palette
))
1362 /* check if color is already mapped */
1365 if (WIN32_COLOR (list
->entry
) == color
)
1367 if (--list
->refcount
== 0)
1371 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
--;
1381 /* set flag that palette must be regenerated */
1382 FRAME_WIN32_DISPLAY_INFO (f
)->regen_palette
= TRUE
;
1386 /* Decide if color named COLOR is valid for the display associated with
1387 the selected frame; if so, return the rgb values in COLOR_DEF.
1388 If ALLOC is nonzero, allocate a new colormap cell. */
1391 defined_color (f
, color
, color_def
, alloc
)
1394 COLORREF
*color_def
;
1397 register Lisp_Object tem
;
1399 tem
= x_to_win32_color (color
);
1403 if (!NILP (Vwin32_enable_palette
))
1405 struct win32_palette_entry
* entry
=
1406 FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1407 struct win32_palette_entry
** prev
=
1408 &FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1410 /* check if color is already mapped */
1413 if (WIN32_COLOR (entry
->entry
) == XUINT (tem
))
1415 prev
= &entry
->next
;
1416 entry
= entry
->next
;
1419 if (entry
== NULL
&& alloc
)
1421 /* not already mapped, so add to list */
1422 entry
= (struct win32_palette_entry
*)
1423 xmalloc (sizeof (struct win32_palette_entry
));
1424 SET_WIN32_COLOR (entry
->entry
, XUINT (tem
));
1427 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
++;
1429 /* set flag that palette must be regenerated */
1430 FRAME_WIN32_DISPLAY_INFO (f
)->regen_palette
= TRUE
;
1433 /* Ensure COLORREF value is snapped to nearest color in (default)
1434 palette by simulating the PALETTERGB macro. This works whether
1435 or not the display device has a palette. */
1436 *color_def
= XUINT (tem
) | 0x2000000;
1445 /* Given a string ARG naming a color, compute a pixel value from it
1446 suitable for screen F.
1447 If F is not a color screen, return DEF (default) regardless of what
1451 x_decode_color (f
, arg
, def
)
1458 CHECK_STRING (arg
, 0);
1460 if (strcmp (XSTRING (arg
)->data
, "black") == 0)
1461 return BLACK_PIX_DEFAULT (f
);
1462 else if (strcmp (XSTRING (arg
)->data
, "white") == 0)
1463 return WHITE_PIX_DEFAULT (f
);
1465 if ((FRAME_WIN32_DISPLAY_INFO (f
)->n_planes
* FRAME_WIN32_DISPLAY_INFO (f
)->n_cbits
) == 1)
1468 /* defined_color is responsible for coping with failures
1469 by looking for a near-miss. */
1470 if (defined_color (f
, XSTRING (arg
)->data
, &cdef
, 1))
1473 /* defined_color failed; return an ultimate default. */
1477 /* Functions called only from `x_set_frame_param'
1478 to set individual parameters.
1480 If FRAME_WIN32_WINDOW (f) is 0,
1481 the frame is being created and its window does not exist yet.
1482 In that case, just record the parameter's new value
1483 in the standard place; do not attempt to change the window. */
1486 x_set_foreground_color (f
, arg
, oldval
)
1488 Lisp_Object arg
, oldval
;
1490 f
->output_data
.win32
->foreground_pixel
1491 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1493 if (FRAME_WIN32_WINDOW (f
) != 0)
1495 recompute_basic_faces (f
);
1496 if (FRAME_VISIBLE_P (f
))
1502 x_set_background_color (f
, arg
, oldval
)
1504 Lisp_Object arg
, oldval
;
1509 f
->output_data
.win32
->background_pixel
1510 = x_decode_color (f
, arg
, WHITE_PIX_DEFAULT (f
));
1512 if (FRAME_WIN32_WINDOW (f
) != 0)
1514 SetWindowLong (FRAME_WIN32_WINDOW (f
), WND_BACKGROUND_INDEX
, f
->output_data
.win32
->background_pixel
);
1516 recompute_basic_faces (f
);
1518 if (FRAME_VISIBLE_P (f
))
1524 x_set_mouse_color (f
, arg
, oldval
)
1526 Lisp_Object arg
, oldval
;
1529 Cursor cursor
, nontext_cursor
, mode_cursor
, cross_cursor
;
1533 if (!EQ (Qnil
, arg
))
1534 f
->output_data
.win32
->mouse_pixel
1535 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1536 mask_color
= f
->output_data
.win32
->background_pixel
;
1537 /* No invisible pointers. */
1538 if (mask_color
== f
->output_data
.win32
->mouse_pixel
1539 && mask_color
== f
->output_data
.win32
->background_pixel
)
1540 f
->output_data
.win32
->mouse_pixel
= f
->output_data
.win32
->foreground_pixel
;
1545 /* It's not okay to crash if the user selects a screwy cursor. */
1546 x_catch_errors (FRAME_WIN32_DISPLAY (f
));
1548 if (!EQ (Qnil
, Vx_pointer_shape
))
1550 CHECK_NUMBER (Vx_pointer_shape
, 0);
1551 cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XINT (Vx_pointer_shape
));
1554 cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_xterm
);
1555 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad text pointer cursor: %s");
1557 if (!EQ (Qnil
, Vx_nontext_pointer_shape
))
1559 CHECK_NUMBER (Vx_nontext_pointer_shape
, 0);
1560 nontext_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1561 XINT (Vx_nontext_pointer_shape
));
1564 nontext_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_left_ptr
);
1565 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad nontext pointer cursor: %s");
1567 if (!EQ (Qnil
, Vx_mode_pointer_shape
))
1569 CHECK_NUMBER (Vx_mode_pointer_shape
, 0);
1570 mode_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1571 XINT (Vx_mode_pointer_shape
));
1574 mode_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_xterm
);
1575 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad modeline pointer cursor: %s");
1577 if (!EQ (Qnil
, Vx_sensitive_text_pointer_shape
))
1579 CHECK_NUMBER (Vx_sensitive_text_pointer_shape
, 0);
1581 = XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1582 XINT (Vx_sensitive_text_pointer_shape
));
1585 cross_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_crosshair
);
1587 /* Check and report errors with the above calls. */
1588 x_check_errors (FRAME_WIN32_DISPLAY (f
), "can't set cursor shape: %s");
1589 x_uncatch_errors (FRAME_WIN32_DISPLAY (f
));
1592 XColor fore_color
, back_color
;
1594 fore_color
.pixel
= f
->output_data
.win32
->mouse_pixel
;
1595 back_color
.pixel
= mask_color
;
1596 XQueryColor (FRAME_WIN32_DISPLAY (f
),
1597 DefaultColormap (FRAME_WIN32_DISPLAY (f
),
1598 DefaultScreen (FRAME_WIN32_DISPLAY (f
))),
1600 XQueryColor (FRAME_WIN32_DISPLAY (f
),
1601 DefaultColormap (FRAME_WIN32_DISPLAY (f
),
1602 DefaultScreen (FRAME_WIN32_DISPLAY (f
))),
1604 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), cursor
,
1605 &fore_color
, &back_color
);
1606 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), nontext_cursor
,
1607 &fore_color
, &back_color
);
1608 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), mode_cursor
,
1609 &fore_color
, &back_color
);
1610 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), cross_cursor
,
1611 &fore_color
, &back_color
);
1614 if (FRAME_WIN32_WINDOW (f
) != 0)
1616 XDefineCursor (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
), cursor
);
1619 if (cursor
!= f
->output_data
.win32
->text_cursor
&& f
->output_data
.win32
->text_cursor
!= 0)
1620 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->text_cursor
);
1621 f
->output_data
.win32
->text_cursor
= cursor
;
1623 if (nontext_cursor
!= f
->output_data
.win32
->nontext_cursor
1624 && f
->output_data
.win32
->nontext_cursor
!= 0)
1625 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->nontext_cursor
);
1626 f
->output_data
.win32
->nontext_cursor
= nontext_cursor
;
1628 if (mode_cursor
!= f
->output_data
.win32
->modeline_cursor
1629 && f
->output_data
.win32
->modeline_cursor
!= 0)
1630 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->modeline_cursor
);
1631 f
->output_data
.win32
->modeline_cursor
= mode_cursor
;
1632 if (cross_cursor
!= f
->output_data
.win32
->cross_cursor
1633 && f
->output_data
.win32
->cross_cursor
!= 0)
1634 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->cross_cursor
);
1635 f
->output_data
.win32
->cross_cursor
= cross_cursor
;
1637 XFlush (FRAME_WIN32_DISPLAY (f
));
1643 x_set_cursor_color (f
, arg
, oldval
)
1645 Lisp_Object arg
, oldval
;
1647 unsigned long fore_pixel
;
1649 if (!EQ (Vx_cursor_fore_pixel
, Qnil
))
1650 fore_pixel
= x_decode_color (f
, Vx_cursor_fore_pixel
,
1651 WHITE_PIX_DEFAULT (f
));
1653 fore_pixel
= f
->output_data
.win32
->background_pixel
;
1654 f
->output_data
.win32
->cursor_pixel
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1656 /* Make sure that the cursor color differs from the background color. */
1657 if (f
->output_data
.win32
->cursor_pixel
== f
->output_data
.win32
->background_pixel
)
1659 f
->output_data
.win32
->cursor_pixel
= f
->output_data
.win32
->mouse_pixel
;
1660 if (f
->output_data
.win32
->cursor_pixel
== fore_pixel
)
1661 fore_pixel
= f
->output_data
.win32
->background_pixel
;
1663 f
->output_data
.win32
->cursor_foreground_pixel
= fore_pixel
;
1665 if (FRAME_WIN32_WINDOW (f
) != 0)
1667 if (FRAME_VISIBLE_P (f
))
1669 x_display_cursor (f
, 0);
1670 x_display_cursor (f
, 1);
1675 /* Set the border-color of frame F to value described by ARG.
1676 ARG can be a string naming a color.
1677 The border-color is used for the border that is drawn by the server.
1678 Note that this does not fully take effect if done before
1679 F has a window; it must be redone when the window is created. */
1682 x_set_border_color (f
, arg
, oldval
)
1684 Lisp_Object arg
, oldval
;
1689 CHECK_STRING (arg
, 0);
1690 str
= XSTRING (arg
)->data
;
1692 pix
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1694 x_set_border_pixel (f
, pix
);
1697 /* Set the border-color of frame F to pixel value PIX.
1698 Note that this does not fully take effect if done before
1701 x_set_border_pixel (f
, pix
)
1705 f
->output_data
.win32
->border_pixel
= pix
;
1707 if (FRAME_WIN32_WINDOW (f
) != 0 && f
->output_data
.win32
->border_width
> 0)
1709 if (FRAME_VISIBLE_P (f
))
1715 x_set_cursor_type (f
, arg
, oldval
)
1717 Lisp_Object arg
, oldval
;
1721 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
1722 f
->output_data
.win32
->cursor_width
= 2;
1724 else if (CONSP (arg
) && EQ (XCONS (arg
)->car
, Qbar
)
1725 && INTEGERP (XCONS (arg
)->cdr
))
1727 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
1728 f
->output_data
.win32
->cursor_width
= XINT (XCONS (arg
)->cdr
);
1731 /* Treat anything unknown as "box cursor".
1732 It was bad to signal an error; people have trouble fixing
1733 .Xdefaults with Emacs, when it has something bad in it. */
1734 FRAME_DESIRED_CURSOR (f
) = filled_box_cursor
;
1736 /* Make sure the cursor gets redrawn. This is overkill, but how
1737 often do people change cursor types? */
1738 update_mode_lines
++;
1742 x_set_icon_type (f
, arg
, oldval
)
1744 Lisp_Object arg
, oldval
;
1752 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1755 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1760 result
= x_text_icon (f
,
1761 (char *) XSTRING ((!NILP (f
->icon_name
)
1765 result
= x_bitmap_icon (f
, arg
);
1770 error ("No icon window available");
1773 /* If the window was unmapped (and its icon was mapped),
1774 the new icon is not mapped, so map the window in its stead. */
1775 if (FRAME_VISIBLE_P (f
))
1777 #ifdef USE_X_TOOLKIT
1778 XtPopup (f
->output_data
.win32
->widget
, XtGrabNone
);
1780 XMapWindow (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
));
1783 XFlush (FRAME_WIN32_DISPLAY (f
));
1788 /* Return non-nil if frame F wants a bitmap icon. */
1796 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
1798 return XCONS (tem
)->cdr
;
1804 x_set_icon_name (f
, arg
, oldval
)
1806 Lisp_Object arg
, oldval
;
1813 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1816 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1822 if (f
->output_data
.win32
->icon_bitmap
!= 0)
1827 result
= x_text_icon (f
,
1828 (char *) XSTRING ((!NILP (f
->icon_name
)
1835 error ("No icon window available");
1838 /* If the window was unmapped (and its icon was mapped),
1839 the new icon is not mapped, so map the window in its stead. */
1840 if (FRAME_VISIBLE_P (f
))
1842 #ifdef USE_X_TOOLKIT
1843 XtPopup (f
->output_data
.win32
->widget
, XtGrabNone
);
1845 XMapWindow (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
));
1848 XFlush (FRAME_WIN32_DISPLAY (f
));
1853 extern Lisp_Object
x_new_font ();
1856 x_set_font (f
, arg
, oldval
)
1858 Lisp_Object arg
, oldval
;
1862 CHECK_STRING (arg
, 1);
1865 result
= x_new_font (f
, XSTRING (arg
)->data
);
1868 if (EQ (result
, Qnil
))
1869 error ("Font \"%s\" is not defined", XSTRING (arg
)->data
);
1870 else if (EQ (result
, Qt
))
1871 error ("the characters of the given font have varying widths");
1872 else if (STRINGP (result
))
1874 recompute_basic_faces (f
);
1875 store_frame_param (f
, Qfont
, result
);
1882 x_set_border_width (f
, arg
, oldval
)
1884 Lisp_Object arg
, oldval
;
1886 CHECK_NUMBER (arg
, 0);
1888 if (XINT (arg
) == f
->output_data
.win32
->border_width
)
1891 if (FRAME_WIN32_WINDOW (f
) != 0)
1892 error ("Cannot change the border width of a window");
1894 f
->output_data
.win32
->border_width
= XINT (arg
);
1898 x_set_internal_border_width (f
, arg
, oldval
)
1900 Lisp_Object arg
, oldval
;
1903 int old
= f
->output_data
.win32
->internal_border_width
;
1905 CHECK_NUMBER (arg
, 0);
1906 f
->output_data
.win32
->internal_border_width
= XINT (arg
);
1907 if (f
->output_data
.win32
->internal_border_width
< 0)
1908 f
->output_data
.win32
->internal_border_width
= 0;
1910 if (f
->output_data
.win32
->internal_border_width
== old
)
1913 if (FRAME_WIN32_WINDOW (f
) != 0)
1916 x_set_window_size (f
, 0, f
->width
, f
->height
);
1918 SET_FRAME_GARBAGED (f
);
1923 x_set_visibility (f
, value
, oldval
)
1925 Lisp_Object value
, oldval
;
1928 XSETFRAME (frame
, f
);
1931 Fmake_frame_invisible (frame
, Qt
);
1932 else if (EQ (value
, Qicon
))
1933 Ficonify_frame (frame
);
1935 Fmake_frame_visible (frame
);
1939 x_set_menu_bar_lines (f
, value
, oldval
)
1941 Lisp_Object value
, oldval
;
1944 int olines
= FRAME_MENU_BAR_LINES (f
);
1946 /* Right now, menu bars don't work properly in minibuf-only frames;
1947 most of the commands try to apply themselves to the minibuffer
1948 frame itslef, and get an error because you can't switch buffers
1949 in or split the minibuffer window. */
1950 if (FRAME_MINIBUF_ONLY_P (f
))
1953 if (INTEGERP (value
))
1954 nlines
= XINT (value
);
1958 FRAME_MENU_BAR_LINES (f
) = 0;
1960 FRAME_EXTERNAL_MENU_BAR (f
) = 1;
1963 if (FRAME_EXTERNAL_MENU_BAR (f
) == 1)
1964 free_frame_menubar (f
);
1965 FRAME_EXTERNAL_MENU_BAR (f
) = 0;
1969 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
1972 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1973 name; if NAME is a string, set F's name to NAME and set
1974 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1976 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1977 suggesting a new name, which lisp code should override; if
1978 F->explicit_name is set, ignore the new name; otherwise, set it. */
1981 x_set_name (f
, name
, explicit)
1986 /* Make sure that requests from lisp code override requests from
1987 Emacs redisplay code. */
1990 /* If we're switching from explicit to implicit, we had better
1991 update the mode lines and thereby update the title. */
1992 if (f
->explicit_name
&& NILP (name
))
1993 update_mode_lines
= 1;
1995 f
->explicit_name
= ! NILP (name
);
1997 else if (f
->explicit_name
)
2000 /* If NAME is nil, set the name to the win32_id_name. */
2003 /* Check for no change needed in this very common case
2004 before we do any consing. */
2005 if (!strcmp (FRAME_WIN32_DISPLAY_INFO (f
)->win32_id_name
,
2006 XSTRING (f
->name
)->data
))
2008 name
= build_string (FRAME_WIN32_DISPLAY_INFO (f
)->win32_id_name
);
2011 CHECK_STRING (name
, 0);
2013 /* Don't change the name if it's already NAME. */
2014 if (! NILP (Fstring_equal (name
, f
->name
)))
2017 if (FRAME_WIN32_WINDOW (f
))
2020 SetWindowText(FRAME_WIN32_WINDOW (f
), XSTRING (name
)->data
);
2027 /* This function should be called when the user's lisp code has
2028 specified a name for the frame; the name will override any set by the
2031 x_explicitly_set_name (f
, arg
, oldval
)
2033 Lisp_Object arg
, oldval
;
2035 x_set_name (f
, arg
, 1);
2038 /* This function should be called by Emacs redisplay code to set the
2039 name; names set this way will never override names set by the user's
2042 x_implicitly_set_name (f
, arg
, oldval
)
2044 Lisp_Object arg
, oldval
;
2046 x_set_name (f
, arg
, 0);
2050 x_set_autoraise (f
, arg
, oldval
)
2052 Lisp_Object arg
, oldval
;
2054 f
->auto_raise
= !EQ (Qnil
, arg
);
2058 x_set_autolower (f
, arg
, oldval
)
2060 Lisp_Object arg
, oldval
;
2062 f
->auto_lower
= !EQ (Qnil
, arg
);
2066 x_set_unsplittable (f
, arg
, oldval
)
2068 Lisp_Object arg
, oldval
;
2070 f
->no_split
= !NILP (arg
);
2074 x_set_vertical_scroll_bars (f
, arg
, oldval
)
2076 Lisp_Object arg
, oldval
;
2078 if (NILP (arg
) != ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
2080 FRAME_HAS_VERTICAL_SCROLL_BARS (f
) = ! NILP (arg
);
2082 /* We set this parameter before creating the window for the
2083 frame, so we can get the geometry right from the start.
2084 However, if the window hasn't been created yet, we shouldn't
2085 call x_set_window_size. */
2086 if (FRAME_WIN32_WINDOW (f
))
2087 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
2092 x_set_scroll_bar_width (f
, arg
, oldval
)
2094 Lisp_Object arg
, oldval
;
2098 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = 0;
2099 FRAME_SCROLL_BAR_COLS (f
) = 2;
2101 else if (INTEGERP (arg
) && XINT (arg
) > 0
2102 && XFASTINT (arg
) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f
))
2104 int wid
= FONT_WIDTH (f
->output_data
.win32
->font
);
2105 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = XFASTINT (arg
);
2106 FRAME_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
2107 if (FRAME_WIN32_WINDOW (f
))
2108 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
2112 /* Subroutines of creating an frame. */
2114 /* Make sure that Vx_resource_name is set to a reasonable value.
2115 Fix it up, or set it to `emacs' if it is too hopeless. */
2118 validate_x_resource_name ()
2121 /* Number of valid characters in the resource name. */
2123 /* Number of invalid characters in the resource name. */
2128 if (STRINGP (Vx_resource_name
))
2130 unsigned char *p
= XSTRING (Vx_resource_name
)->data
;
2133 len
= XSTRING (Vx_resource_name
)->size
;
2135 /* Only letters, digits, - and _ are valid in resource names.
2136 Count the valid characters and count the invalid ones. */
2137 for (i
= 0; i
< len
; i
++)
2140 if (! ((c
>= 'a' && c
<= 'z')
2141 || (c
>= 'A' && c
<= 'Z')
2142 || (c
>= '0' && c
<= '9')
2143 || c
== '-' || c
== '_'))
2150 /* Not a string => completely invalid. */
2151 bad_count
= 5, good_count
= 0;
2153 /* If name is valid already, return. */
2157 /* If name is entirely invalid, or nearly so, use `emacs'. */
2159 || (good_count
== 1 && bad_count
> 0))
2161 Vx_resource_name
= build_string ("emacs");
2165 /* Name is partly valid. Copy it and replace the invalid characters
2166 with underscores. */
2168 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
2170 for (i
= 0; i
< len
; i
++)
2172 int c
= XSTRING (new)->data
[i
];
2173 if (! ((c
>= 'a' && c
<= 'z')
2174 || (c
>= 'A' && c
<= 'Z')
2175 || (c
>= '0' && c
<= '9')
2176 || c
== '-' || c
== '_'))
2177 XSTRING (new)->data
[i
] = '_';
2182 extern char *x_get_string_resource ();
2184 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
2185 "Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.\n\
2186 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the\n\
2187 class, where INSTANCE is the name under which Emacs was invoked, or\n\
2188 the name specified by the `-name' or `-rn' command-line arguments.\n\
2190 The optional arguments COMPONENT and SUBCLASS add to the key and the\n\
2191 class, respectively. You must specify both of them or neither.\n\
2192 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'\n\
2193 and the class is `Emacs.CLASS.SUBCLASS'.")
2194 (attribute
, class, component
, subclass
)
2195 Lisp_Object attribute
, class, component
, subclass
;
2197 register char *value
;
2201 CHECK_STRING (attribute
, 0);
2202 CHECK_STRING (class, 0);
2204 if (!NILP (component
))
2205 CHECK_STRING (component
, 1);
2206 if (!NILP (subclass
))
2207 CHECK_STRING (subclass
, 2);
2208 if (NILP (component
) != NILP (subclass
))
2209 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
2211 validate_x_resource_name ();
2213 /* Allocate space for the components, the dots which separate them,
2214 and the final '\0'. Make them big enough for the worst case. */
2215 name_key
= (char *) alloca (XSTRING (Vx_resource_name
)->size
2216 + (STRINGP (component
)
2217 ? XSTRING (component
)->size
: 0)
2218 + XSTRING (attribute
)->size
2221 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
2222 + XSTRING (class)->size
2223 + (STRINGP (subclass
)
2224 ? XSTRING (subclass
)->size
: 0)
2227 /* Start with emacs.FRAMENAME for the name (the specific one)
2228 and with `Emacs' for the class key (the general one). */
2229 strcpy (name_key
, XSTRING (Vx_resource_name
)->data
);
2230 strcpy (class_key
, EMACS_CLASS
);
2232 strcat (class_key
, ".");
2233 strcat (class_key
, XSTRING (class)->data
);
2235 if (!NILP (component
))
2237 strcat (class_key
, ".");
2238 strcat (class_key
, XSTRING (subclass
)->data
);
2240 strcat (name_key
, ".");
2241 strcat (name_key
, XSTRING (component
)->data
);
2244 strcat (name_key
, ".");
2245 strcat (name_key
, XSTRING (attribute
)->data
);
2247 value
= x_get_string_resource (Qnil
,
2248 name_key
, class_key
);
2250 if (value
!= (char *) 0)
2251 return build_string (value
);
2256 /* Used when C code wants a resource value. */
2259 x_get_resource_string (attribute
, class)
2260 char *attribute
, *class;
2262 register char *value
;
2266 /* Allocate space for the components, the dots which separate them,
2267 and the final '\0'. */
2268 name_key
= (char *) alloca (XSTRING (Vinvocation_name
)->size
2269 + strlen (attribute
) + 2);
2270 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
2271 + strlen (class) + 2);
2273 sprintf (name_key
, "%s.%s",
2274 XSTRING (Vinvocation_name
)->data
,
2276 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
2278 return x_get_string_resource (selected_frame
,
2279 name_key
, class_key
);
2282 /* Types we might convert a resource string into. */
2285 number
, boolean
, string
, symbol
2288 /* Return the value of parameter PARAM.
2290 First search ALIST, then Vdefault_frame_alist, then the X defaults
2291 database, using ATTRIBUTE as the attribute name and CLASS as its class.
2293 Convert the resource to the type specified by desired_type.
2295 If no default is specified, return Qunbound. If you call
2296 x_get_arg, make sure you deal with Qunbound in a reasonable way,
2297 and don't let it get stored in any Lisp-visible variables! */
2300 x_get_arg (alist
, param
, attribute
, class, type
)
2301 Lisp_Object alist
, param
;
2304 enum resource_types type
;
2306 register Lisp_Object tem
;
2308 tem
= Fassq (param
, alist
);
2310 tem
= Fassq (param
, Vdefault_frame_alist
);
2316 tem
= Fx_get_resource (build_string (attribute
),
2317 build_string (class),
2326 return make_number (atoi (XSTRING (tem
)->data
));
2329 tem
= Fdowncase (tem
);
2330 if (!strcmp (XSTRING (tem
)->data
, "on")
2331 || !strcmp (XSTRING (tem
)->data
, "true"))
2340 /* As a special case, we map the values `true' and `on'
2341 to Qt, and `false' and `off' to Qnil. */
2344 lower
= Fdowncase (tem
);
2345 if (!strcmp (XSTRING (lower
)->data
, "on")
2346 || !strcmp (XSTRING (lower
)->data
, "true"))
2348 else if (!strcmp (XSTRING (lower
)->data
, "off")
2349 || !strcmp (XSTRING (lower
)->data
, "false"))
2352 return Fintern (tem
, Qnil
);
2365 /* Record in frame F the specified or default value according to ALIST
2366 of the parameter named PARAM (a Lisp symbol).
2367 If no value is specified for PARAM, look for an X default for XPROP
2368 on the frame named NAME.
2369 If that is not found either, use the value DEFLT. */
2372 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
2379 enum resource_types type
;
2383 tem
= x_get_arg (alist
, prop
, xprop
, xclass
, type
);
2384 if (EQ (tem
, Qunbound
))
2386 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
2390 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
2391 "Parse an X-style geometry string STRING.\n\
2392 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).\n\
2393 The properties returned may include `top', `left', `height', and `width'.\n\
2394 The value of `left' or `top' may be an integer,\n\
2395 or a list (+ N) meaning N pixels relative to top/left corner,\n\
2396 or a list (- N) meaning -N pixels relative to bottom/right corner.")
2401 unsigned int width
, height
;
2404 CHECK_STRING (string
, 0);
2406 geometry
= XParseGeometry ((char *) XSTRING (string
)->data
,
2407 &x
, &y
, &width
, &height
);
2410 if (geometry
& XValue
)
2412 Lisp_Object element
;
2414 if (x
>= 0 && (geometry
& XNegative
))
2415 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
2416 else if (x
< 0 && ! (geometry
& XNegative
))
2417 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
2419 element
= Fcons (Qleft
, make_number (x
));
2420 result
= Fcons (element
, result
);
2423 if (geometry
& YValue
)
2425 Lisp_Object element
;
2427 if (y
>= 0 && (geometry
& YNegative
))
2428 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
2429 else if (y
< 0 && ! (geometry
& YNegative
))
2430 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
2432 element
= Fcons (Qtop
, make_number (y
));
2433 result
= Fcons (element
, result
);
2436 if (geometry
& WidthValue
)
2437 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
2438 if (geometry
& HeightValue
)
2439 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
2444 /* Calculate the desired size and position of this window,
2445 and return the flags saying which aspects were specified.
2447 This function does not make the coordinates positive. */
2449 #define DEFAULT_ROWS 40
2450 #define DEFAULT_COLS 80
2453 x_figure_window_size (f
, parms
)
2457 register Lisp_Object tem0
, tem1
, tem2
;
2458 int height
, width
, left
, top
;
2459 register int geometry
;
2460 long window_prompting
= 0;
2462 /* Default values if we fall through.
2463 Actually, if that happens we should get
2464 window manager prompting. */
2465 f
->width
= DEFAULT_COLS
;
2466 f
->height
= DEFAULT_ROWS
;
2467 /* Window managers expect that if program-specified
2468 positions are not (0,0), they're intentional, not defaults. */
2469 f
->output_data
.win32
->top_pos
= 0;
2470 f
->output_data
.win32
->left_pos
= 0;
2472 tem0
= x_get_arg (parms
, Qheight
, 0, 0, number
);
2473 tem1
= x_get_arg (parms
, Qwidth
, 0, 0, number
);
2474 tem2
= x_get_arg (parms
, Quser_size
, 0, 0, number
);
2475 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
2477 if (!EQ (tem0
, Qunbound
))
2479 CHECK_NUMBER (tem0
, 0);
2480 f
->height
= XINT (tem0
);
2482 if (!EQ (tem1
, Qunbound
))
2484 CHECK_NUMBER (tem1
, 0);
2485 f
->width
= XINT (tem1
);
2487 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
2488 window_prompting
|= USSize
;
2490 window_prompting
|= PSize
;
2493 f
->output_data
.win32
->vertical_scroll_bar_extra
2494 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2496 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) > 0
2497 ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f
)
2498 : (FRAME_SCROLL_BAR_COLS (f
) * FONT_WIDTH (f
->output_data
.win32
->font
)));
2499 f
->output_data
.win32
->pixel_width
= CHAR_TO_PIXEL_WIDTH (f
, f
->width
);
2500 f
->output_data
.win32
->pixel_height
= CHAR_TO_PIXEL_HEIGHT (f
, f
->height
);
2502 tem0
= x_get_arg (parms
, Qtop
, 0, 0, number
);
2503 tem1
= x_get_arg (parms
, Qleft
, 0, 0, number
);
2504 tem2
= x_get_arg (parms
, Quser_position
, 0, 0, number
);
2505 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
2507 if (EQ (tem0
, Qminus
))
2509 f
->output_data
.win32
->top_pos
= 0;
2510 window_prompting
|= YNegative
;
2512 else if (CONSP (tem0
) && EQ (XCONS (tem0
)->car
, Qminus
)
2513 && CONSP (XCONS (tem0
)->cdr
)
2514 && INTEGERP (XCONS (XCONS (tem0
)->cdr
)->car
))
2516 f
->output_data
.win32
->top_pos
= - XINT (XCONS (XCONS (tem0
)->cdr
)->car
);
2517 window_prompting
|= YNegative
;
2519 else if (CONSP (tem0
) && EQ (XCONS (tem0
)->car
, Qplus
)
2520 && CONSP (XCONS (tem0
)->cdr
)
2521 && INTEGERP (XCONS (XCONS (tem0
)->cdr
)->car
))
2523 f
->output_data
.win32
->top_pos
= XINT (XCONS (XCONS (tem0
)->cdr
)->car
);
2525 else if (EQ (tem0
, Qunbound
))
2526 f
->output_data
.win32
->top_pos
= 0;
2529 CHECK_NUMBER (tem0
, 0);
2530 f
->output_data
.win32
->top_pos
= XINT (tem0
);
2531 if (f
->output_data
.win32
->top_pos
< 0)
2532 window_prompting
|= YNegative
;
2535 if (EQ (tem1
, Qminus
))
2537 f
->output_data
.win32
->left_pos
= 0;
2538 window_prompting
|= XNegative
;
2540 else if (CONSP (tem1
) && EQ (XCONS (tem1
)->car
, Qminus
)
2541 && CONSP (XCONS (tem1
)->cdr
)
2542 && INTEGERP (XCONS (XCONS (tem1
)->cdr
)->car
))
2544 f
->output_data
.win32
->left_pos
= - XINT (XCONS (XCONS (tem1
)->cdr
)->car
);
2545 window_prompting
|= XNegative
;
2547 else if (CONSP (tem1
) && EQ (XCONS (tem1
)->car
, Qplus
)
2548 && CONSP (XCONS (tem1
)->cdr
)
2549 && INTEGERP (XCONS (XCONS (tem1
)->cdr
)->car
))
2551 f
->output_data
.win32
->left_pos
= XINT (XCONS (XCONS (tem1
)->cdr
)->car
);
2553 else if (EQ (tem1
, Qunbound
))
2554 f
->output_data
.win32
->left_pos
= 0;
2557 CHECK_NUMBER (tem1
, 0);
2558 f
->output_data
.win32
->left_pos
= XINT (tem1
);
2559 if (f
->output_data
.win32
->left_pos
< 0)
2560 window_prompting
|= XNegative
;
2563 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
2564 window_prompting
|= USPosition
;
2566 window_prompting
|= PPosition
;
2569 return window_prompting
;
2574 extern LRESULT CALLBACK
win32_wnd_proc ();
2577 win32_init_class (hinst
)
2582 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
2583 wc
.lpfnWndProc
= (WNDPROC
) win32_wnd_proc
;
2585 wc
.cbWndExtra
= WND_EXTRA_BYTES
;
2586 wc
.hInstance
= hinst
;
2587 wc
.hIcon
= LoadIcon (hinst
, EMACS_CLASS
);
2588 wc
.hCursor
= LoadCursor (NULL
, IDC_ARROW
);
2589 wc
.hbrBackground
= NULL
; // GetStockObject (WHITE_BRUSH);
2590 wc
.lpszMenuName
= NULL
;
2591 wc
.lpszClassName
= EMACS_CLASS
;
2593 return (RegisterClass (&wc
));
2597 win32_createscrollbar (f
, bar
)
2599 struct scroll_bar
* bar
;
2601 return (CreateWindow ("SCROLLBAR", "", SBS_VERT
| WS_CHILD
| WS_VISIBLE
,
2602 /* Position and size of scroll bar. */
2603 XINT(bar
->left
), XINT(bar
->top
),
2604 XINT(bar
->width
), XINT(bar
->height
),
2605 FRAME_WIN32_WINDOW (f
),
2612 win32_createwindow (f
)
2617 /* Do first time app init */
2621 win32_init_class (hinst
);
2624 FRAME_WIN32_WINDOW (f
) = hwnd
= CreateWindow (EMACS_CLASS
,
2626 f
->output_data
.win32
->dwStyle
| WS_CLIPCHILDREN
,
2627 f
->output_data
.win32
->left_pos
,
2628 f
->output_data
.win32
->top_pos
,
2638 SetWindowLong (hwnd
, WND_X_UNITS_INDEX
, FONT_WIDTH (f
->output_data
.win32
->font
));
2639 SetWindowLong (hwnd
, WND_Y_UNITS_INDEX
, f
->output_data
.win32
->line_height
);
2640 SetWindowLong (hwnd
, WND_BACKGROUND_INDEX
, f
->output_data
.win32
->background_pixel
);
2642 /* Do this to discard the default setting specified by our parent. */
2643 ShowWindow (hwnd
, SW_HIDE
);
2647 /* Convert between the modifier bits Win32 uses and the modifier bits
2650 win32_get_modifiers ()
2652 return (((GetKeyState (VK_SHIFT
)&0x8000) ? shift_modifier
: 0) |
2653 ((GetKeyState (VK_CONTROL
)&0x8000) ? ctrl_modifier
: 0) |
2654 ((GetKeyState (VK_MENU
)&0x8000) ?
2655 ((NILP (Vwin32_alt_is_meta
)) ? alt_modifier
: meta_modifier
) : 0));
2659 my_post_msg (wmsg
, hwnd
, msg
, wParam
, lParam
)
2666 wmsg
->msg
.hwnd
= hwnd
;
2667 wmsg
->msg
.message
= msg
;
2668 wmsg
->msg
.wParam
= wParam
;
2669 wmsg
->msg
.lParam
= lParam
;
2670 wmsg
->msg
.time
= GetMessageTime ();
2675 /* GetKeyState and MapVirtualKey on Win95 do not actually distinguish
2676 between left and right keys as advertised. We test for this
2677 support dynamically, and set a flag when the support is absent. If
2678 absent, we keep track of the left and right control and alt keys
2679 ourselves. This is particularly necessary on keyboards that rely
2680 upon the AltGr key, which is represented as having the left control
2681 and right alt keys pressed. For these keyboards, we need to know
2682 when the left alt key has been pressed in addition to the AltGr key
2683 so that we can properly support M-AltGr-key sequences (such as M-@
2684 on Swedish keyboards). */
2686 #define EMACS_LCONTROL 0
2687 #define EMACS_RCONTROL 1
2688 #define EMACS_LMENU 2
2689 #define EMACS_RMENU 3
2691 static int modifiers
[4];
2692 static int modifiers_recorded
;
2693 static int modifier_key_support_tested
;
2696 test_modifier_support (unsigned int wparam
)
2700 if (wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
)
2702 if (wparam
== VK_CONTROL
)
2712 if (!(GetKeyState (l
) & 0x8000) && !(GetKeyState (r
) & 0x8000))
2713 modifiers_recorded
= 1;
2715 modifiers_recorded
= 0;
2716 modifier_key_support_tested
= 1;
2720 record_keydown (unsigned int wparam
, unsigned int lparam
)
2724 if (!modifier_key_support_tested
)
2725 test_modifier_support (wparam
);
2727 if ((wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
) || !modifiers_recorded
)
2730 if (wparam
== VK_CONTROL
)
2731 i
= (lparam
& 0x1000000) ? EMACS_RCONTROL
: EMACS_LCONTROL
;
2733 i
= (lparam
& 0x1000000) ? EMACS_RMENU
: EMACS_LMENU
;
2739 record_keyup (unsigned int wparam
, unsigned int lparam
)
2743 if ((wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
) || !modifiers_recorded
)
2746 if (wparam
== VK_CONTROL
)
2747 i
= (lparam
& 0x1000000) ? EMACS_RCONTROL
: EMACS_LCONTROL
;
2749 i
= (lparam
& 0x1000000) ? EMACS_RMENU
: EMACS_LMENU
;
2754 /* Emacs can lose focus while a modifier key has been pressed. When
2755 it regains focus, be conservative and clear all modifiers since
2756 we cannot reconstruct the left and right modifier state. */
2762 if (!modifiers_recorded
)
2765 ctrl
= GetAsyncKeyState (VK_CONTROL
);
2766 alt
= GetAsyncKeyState (VK_MENU
);
2768 if (ctrl
== 0 || alt
== 0)
2769 /* Emacs doesn't have keyboard focus. Do nothing. */
2772 if (!(ctrl
& 0x08000))
2773 /* Clear any recorded control modifier state. */
2774 modifiers
[EMACS_RCONTROL
] = modifiers
[EMACS_LCONTROL
] = 0;
2776 if (!(alt
& 0x08000))
2777 /* Clear any recorded alt modifier state. */
2778 modifiers
[EMACS_RMENU
] = modifiers
[EMACS_LMENU
] = 0;
2780 /* Otherwise, leave the modifier state as it was when Emacs lost
2784 /* Synchronize modifier state with what is reported with the current
2785 keystroke. Even if we cannot distinguish between left and right
2786 modifier keys, we know that, if no modifiers are set, then neither
2787 the left or right modifier should be set. */
2791 if (!modifiers_recorded
)
2794 if (!(GetKeyState (VK_CONTROL
) & 0x8000))
2795 modifiers
[EMACS_RCONTROL
] = modifiers
[EMACS_LCONTROL
] = 0;
2797 if (!(GetKeyState (VK_MENU
) & 0x8000))
2798 modifiers
[EMACS_RMENU
] = modifiers
[EMACS_LMENU
] = 0;
2802 modifier_set (int vkey
)
2804 if (vkey
== VK_CAPITAL
)
2805 return (GetKeyState (vkey
) & 0x1);
2806 if (!modifiers_recorded
)
2807 return (GetKeyState (vkey
) & 0x8000);
2812 return modifiers
[EMACS_LCONTROL
];
2814 return modifiers
[EMACS_RCONTROL
];
2816 return modifiers
[EMACS_LMENU
];
2818 return modifiers
[EMACS_RMENU
];
2822 return (GetKeyState (vkey
) & 0x8000);
2825 /* We map the VK_* modifiers into console modifier constants
2826 so that we can use the same routines to handle both console
2827 and window input. */
2830 construct_modifiers (unsigned int wparam
, unsigned int lparam
)
2834 if (wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
)
2835 mods
= GetLastError ();
2838 mods
|= (modifier_set (VK_SHIFT
)) ? SHIFT_PRESSED
: 0;
2839 mods
|= (modifier_set (VK_CAPITAL
)) ? CAPSLOCK_ON
: 0;
2840 mods
|= (modifier_set (VK_LCONTROL
)) ? LEFT_CTRL_PRESSED
: 0;
2841 mods
|= (modifier_set (VK_RCONTROL
)) ? RIGHT_CTRL_PRESSED
: 0;
2842 mods
|= (modifier_set (VK_LMENU
)) ? LEFT_ALT_PRESSED
: 0;
2843 mods
|= (modifier_set (VK_RMENU
)) ? RIGHT_ALT_PRESSED
: 0;
2849 map_keypad_keys (unsigned int wparam
, unsigned int lparam
)
2851 unsigned int extended
= (lparam
& 0x1000000L
);
2853 if (wparam
< VK_CLEAR
|| wparam
> VK_DELETE
)
2856 if (wparam
== VK_RETURN
)
2857 return (extended
? VK_NUMPAD_ENTER
: VK_RETURN
);
2859 if (wparam
>= VK_PRIOR
&& wparam
<= VK_DOWN
)
2860 return (!extended
? (VK_NUMPAD_PRIOR
+ (wparam
- VK_PRIOR
)) : wparam
);
2862 if (wparam
== VK_INSERT
|| wparam
== VK_DELETE
)
2863 return (!extended
? (VK_NUMPAD_INSERT
+ (wparam
- VK_INSERT
)) : wparam
);
2865 if (wparam
== VK_CLEAR
)
2866 return (!extended
? VK_NUMPAD_CLEAR
: wparam
);
2871 /* Main message dispatch loop. */
2879 /* Ensure our message queue is created */
2881 PeekMessage (&msg
, NULL
, 0, 0, PM_NOREMOVE
);
2883 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, 0, 0);
2885 while (GetMessage (&msg
, NULL
, 0, 0))
2887 if (msg
.hwnd
== NULL
)
2889 switch (msg
.message
)
2891 case WM_EMACS_CREATEWINDOW
:
2892 win32_createwindow ((struct frame
*) msg
.wParam
);
2893 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, 0, 0);
2895 case WM_EMACS_CREATESCROLLBAR
:
2897 HWND hwnd
= win32_createscrollbar ((struct frame
*) msg
.wParam
,
2898 (struct scroll_bar
*) msg
.lParam
);
2899 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, (WPARAM
)hwnd
, 0);
2908 DispatchMessage (&msg
);
2915 /* Main window procedure */
2917 extern char *lispy_function_keys
[];
2920 win32_wnd_proc (hwnd
, msg
, wParam
, lParam
)
2928 struct win32_display_info
*dpyinfo
= &one_win32_display_info
;
2930 int windows_translate
;
2932 /* Note that it is okay to call x_window_to_frame, even though we are
2933 not running in the main lisp thread, because frame deletion
2934 requires the lisp thread to synchronize with this thread. Thus, if
2935 a frame struct is returned, it can be used without concern that the
2936 lisp thread might make it disappear while we are using it.
2938 NB. Walking the frame list in this thread is safe (as long as
2939 writes of Lisp_Object slots are atomic, which they are on Windows).
2940 Although delete-frame can destructively modify the frame list while
2941 we are walking it, a garbage collection cannot occur until after
2942 delete-frame has synchronized with this thread.
2944 It is also safe to use functions that make GDI calls, such as
2945 win32_clear_rect, because these functions must obtain a DC handle
2946 from the frame struct using get_frame_dc which is thread-aware. */
2951 f
= x_window_to_frame (dpyinfo
, hwnd
);
2954 GetUpdateRect (hwnd
, &wmsg
.rect
, FALSE
);
2955 win32_clear_rect (f
, NULL
, &wmsg
.rect
);
2958 case WM_PALETTECHANGED
:
2959 /* ignore our own changes */
2960 if ((HWND
)wParam
!= hwnd
)
2962 f
= x_window_to_frame (dpyinfo
, hwnd
);
2964 /* get_frame_dc will realize our palette and force all
2965 frames to be redrawn if needed. */
2966 release_frame_dc (f
, get_frame_dc (f
));
2971 PAINTSTRUCT paintStruct
;
2974 BeginPaint (hwnd
, &paintStruct
);
2975 wmsg
.rect
= paintStruct
.rcPaint
;
2976 EndPaint (hwnd
, &paintStruct
);
2979 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
2986 record_keyup (wParam
, lParam
);
2991 /* Synchronize modifiers with current keystroke. */
2994 record_keydown (wParam
, lParam
);
2996 wParam
= map_keypad_keys (wParam
, lParam
);
2998 windows_translate
= 0;
3003 /* More support for these keys will likely be necessary. */
3004 if (!NILP (Vwin32_pass_optional_keys_to_system
))
3005 windows_translate
= 1;
3008 if (NILP (Vwin32_pass_alt_to_system
))
3010 windows_translate
= 1;
3017 windows_translate
= 1;
3020 /* If not defined as a function key, change it to a WM_CHAR message. */
3021 if (lispy_function_keys
[wParam
] == 0)
3026 if (windows_translate
)
3028 MSG winmsg
= { hwnd
, msg
, wParam
, lParam
, 0, {0,0} };
3030 winmsg
.time
= GetMessageTime ();
3031 TranslateMessage (&winmsg
);
3039 wmsg
.dwModifiers
= construct_modifiers (wParam
, lParam
);
3042 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3045 /* Detect quit_char and set quit-flag directly. Note that we dow
3046 this *after* posting the message to ensure the main thread will
3047 be woken up if blocked in sys_select(). */
3050 if (isalpha (c
) && (wmsg
.dwModifiers
== LEFT_CTRL_PRESSED
3051 || wmsg
.dwModifiers
== RIGHT_CTRL_PRESSED
))
3052 c
= make_ctrl_char (c
) & 0377;
3061 /* Simulate middle mouse button events when left and right buttons
3062 are used together, but only if user has two button mouse. */
3063 case WM_LBUTTONDOWN
:
3064 case WM_RBUTTONDOWN
:
3065 if (XINT (Vwin32_num_mouse_buttons
) == 3)
3066 goto handle_plain_button
;
3069 int this = (msg
== WM_LBUTTONDOWN
) ? LMOUSE
: RMOUSE
;
3070 int other
= (msg
== WM_LBUTTONDOWN
) ? RMOUSE
: LMOUSE
;
3072 if (button_state
& this)
3075 if (button_state
== 0)
3078 button_state
|= this;
3080 if (button_state
& other
)
3082 if (mouse_button_timer
)
3084 KillTimer (hwnd
, mouse_button_timer
);
3085 mouse_button_timer
= 0;
3087 /* Generate middle mouse event instead. */
3088 msg
= WM_MBUTTONDOWN
;
3089 button_state
|= MMOUSE
;
3091 else if (button_state
& MMOUSE
)
3093 /* Ignore button event if we've already generated a
3094 middle mouse down event. This happens if the
3095 user releases and press one of the two buttons
3096 after we've faked a middle mouse event. */
3101 /* Flush out saved message. */
3102 post_msg (&saved_mouse_button_msg
);
3104 wmsg
.dwModifiers
= win32_get_modifiers ();
3105 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3107 /* Clear message buffer. */
3108 saved_mouse_button_msg
.msg
.hwnd
= 0;
3112 /* Hold onto message for now. */
3113 mouse_button_timer
=
3114 SetTimer (hwnd
, MOUSE_BUTTON_ID
, XINT (Vwin32_mouse_button_tolerance
), NULL
);
3115 saved_mouse_button_msg
.msg
.hwnd
= hwnd
;
3116 saved_mouse_button_msg
.msg
.message
= msg
;
3117 saved_mouse_button_msg
.msg
.wParam
= wParam
;
3118 saved_mouse_button_msg
.msg
.lParam
= lParam
;
3119 saved_mouse_button_msg
.msg
.time
= GetMessageTime ();
3120 saved_mouse_button_msg
.dwModifiers
= win32_get_modifiers ();
3127 if (XINT (Vwin32_num_mouse_buttons
) == 3)
3128 goto handle_plain_button
;
3131 int this = (msg
== WM_LBUTTONUP
) ? LMOUSE
: RMOUSE
;
3132 int other
= (msg
== WM_LBUTTONUP
) ? RMOUSE
: LMOUSE
;
3134 if ((button_state
& this) == 0)
3137 button_state
&= ~this;
3139 if (button_state
& MMOUSE
)
3141 /* Only generate event when second button is released. */
3142 if ((button_state
& other
) == 0)
3145 button_state
&= ~MMOUSE
;
3147 if (button_state
) abort ();
3154 /* Flush out saved message if necessary. */
3155 if (saved_mouse_button_msg
.msg
.hwnd
)
3157 post_msg (&saved_mouse_button_msg
);
3160 wmsg
.dwModifiers
= win32_get_modifiers ();
3161 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3163 /* Always clear message buffer and cancel timer. */
3164 saved_mouse_button_msg
.msg
.hwnd
= 0;
3165 KillTimer (hwnd
, mouse_button_timer
);
3166 mouse_button_timer
= 0;
3168 if (button_state
== 0)
3173 case WM_MBUTTONDOWN
:
3175 handle_plain_button
:
3179 if (parse_button (msg
, NULL
, &up
))
3181 if (up
) ReleaseCapture ();
3182 else SetCapture (hwnd
);
3186 wmsg
.dwModifiers
= win32_get_modifiers ();
3187 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3192 if (XINT (Vwin32_mouse_move_interval
) <= 0
3193 || (msg
== WM_MOUSEMOVE
&& button_state
== 0))
3195 wmsg
.dwModifiers
= win32_get_modifiers ();
3196 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3200 /* Hang onto mouse move and scroll messages for a bit, to avoid
3201 sending such events to Emacs faster than it can process them.
3202 If we get more events before the timer from the first message
3203 expires, we just replace the first message. */
3205 if (saved_mouse_move_msg
.msg
.hwnd
== 0)
3207 SetTimer (hwnd
, MOUSE_MOVE_ID
, XINT (Vwin32_mouse_move_interval
), NULL
);
3209 /* Hold onto message for now. */
3210 saved_mouse_move_msg
.msg
.hwnd
= hwnd
;
3211 saved_mouse_move_msg
.msg
.message
= msg
;
3212 saved_mouse_move_msg
.msg
.wParam
= wParam
;
3213 saved_mouse_move_msg
.msg
.lParam
= lParam
;
3214 saved_mouse_move_msg
.msg
.time
= GetMessageTime ();
3215 saved_mouse_move_msg
.dwModifiers
= win32_get_modifiers ();
3220 /* Flush out saved messages if necessary. */
3221 if (wParam
== mouse_button_timer
)
3223 if (saved_mouse_button_msg
.msg
.hwnd
)
3225 post_msg (&saved_mouse_button_msg
);
3226 saved_mouse_button_msg
.msg
.hwnd
= 0;
3228 KillTimer (hwnd
, mouse_button_timer
);
3229 mouse_button_timer
= 0;
3231 else if (wParam
== mouse_move_timer
)
3233 if (saved_mouse_move_msg
.msg
.hwnd
)
3235 post_msg (&saved_mouse_move_msg
);
3236 saved_mouse_move_msg
.msg
.hwnd
= 0;
3238 KillTimer (hwnd
, mouse_move_timer
);
3239 mouse_move_timer
= 0;
3244 /* Windows doesn't send us focus messages when putting up and
3245 taking down a system popup dialog as for Ctrl-Alt-Del on Win95.
3246 The only indication we get that something happened is receiving
3247 this message afterwards. So this is a good time to reset our
3248 keyboard modifiers' state. */
3259 wmsg
.dwModifiers
= win32_get_modifiers ();
3260 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3264 wmsg
.dwModifiers
= win32_get_modifiers ();
3265 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3268 case WM_WINDOWPOSCHANGING
:
3271 LPWINDOWPOS lppos
= (WINDOWPOS
*) lParam
;
3273 GetWindowPlacement (hwnd
, &wp
);
3275 if (wp
.showCmd
!= SW_SHOWMINIMIZED
&& ! (lppos
->flags
& SWP_NOSIZE
))
3284 wp
.length
= sizeof(wp
);
3285 GetWindowRect (hwnd
, &wr
);
3289 dwXUnits
= GetWindowLong (hwnd
, WND_X_UNITS_INDEX
);
3290 dwYUnits
= GetWindowLong (hwnd
, WND_Y_UNITS_INDEX
);
3294 memset (&rect
, 0, sizeof (rect
));
3295 AdjustWindowRect (&rect
, GetWindowLong (hwnd
, GWL_STYLE
),
3296 GetMenu (hwnd
) != NULL
);
3298 /* All windows have an extra pixel so subtract 1 */
3300 wdiff
= (lppos
->cx
- (rect
.right
- rect
.left
) - 0) % dwXUnits
;
3301 hdiff
= (lppos
->cy
- (rect
.bottom
- rect
.top
) - 0) % dwYUnits
;
3305 /* For right/bottom sizing we can just fix the sizes.
3306 However for top/left sizing we will need to fix the X
3307 and Y positions as well. */
3312 if (wp
.showCmd
!= SW_SHOWMAXIMIZED
3313 && ! (lppos
->flags
& SWP_NOMOVE
))
3315 if (lppos
->x
!= wr
.left
|| lppos
->y
!= wr
.top
)
3322 lppos
->flags
|= SWP_NOMOVE
;
3331 if (ret
== 0) return (0);
3334 case WM_EMACS_SHOWWINDOW
:
3335 return ShowWindow (hwnd
, wParam
);
3336 case WM_EMACS_SETWINDOWPOS
:
3338 Win32WindowPos
* pos
= (Win32WindowPos
*) wParam
;
3339 return SetWindowPos (hwnd
, pos
->hwndAfter
,
3340 pos
->x
, pos
->y
, pos
->cx
, pos
->cy
, pos
->flags
);
3342 case WM_EMACS_DESTROYWINDOW
:
3343 DestroyWindow ((HWND
) wParam
);
3347 return DefWindowProc (hwnd
, msg
, wParam
, lParam
);
3354 my_create_window (f
)
3359 PostThreadMessage (dwWinThreadId
, WM_EMACS_CREATEWINDOW
, (WPARAM
)f
, 0);
3360 GetMessage (&msg
, NULL
, WM_EMACS_DONE
, WM_EMACS_DONE
);
3363 /* Create and set up the win32 window for frame F. */
3366 win32_window (f
, window_prompting
, minibuffer_only
)
3368 long window_prompting
;
3369 int minibuffer_only
;
3373 /* Use the resource name as the top-level window name
3374 for looking up resources. Make a non-Lisp copy
3375 for the window manager, so GC relocation won't bother it.
3377 Elsewhere we specify the window name for the window manager. */
3380 char *str
= (char *) XSTRING (Vx_resource_name
)->data
;
3381 f
->namebuf
= (char *) xmalloc (strlen (str
) + 1);
3382 strcpy (f
->namebuf
, str
);
3385 my_create_window (f
);
3387 validate_x_resource_name ();
3389 /* x_set_name normally ignores requests to set the name if the
3390 requested name is the same as the current name. This is the one
3391 place where that assumption isn't correct; f->name is set, but
3392 the server hasn't been told. */
3395 int explicit = f
->explicit_name
;
3397 f
->explicit_name
= 0;
3400 x_set_name (f
, name
, explicit);
3405 if (!minibuffer_only
&& FRAME_EXTERNAL_MENU_BAR (f
))
3406 initialize_frame_menubar (f
);
3408 if (FRAME_WIN32_WINDOW (f
) == 0)
3409 error ("Unable to create window");
3412 /* Handle the icon stuff for this window. Perhaps later we might
3413 want an x_set_icon_position which can be called interactively as
3421 Lisp_Object icon_x
, icon_y
;
3423 /* Set the position of the icon. Note that win95 groups all
3424 icons in the tray. */
3425 icon_x
= x_get_arg (parms
, Qicon_left
, 0, 0, number
);
3426 icon_y
= x_get_arg (parms
, Qicon_top
, 0, 0, number
);
3427 if (!EQ (icon_x
, Qunbound
) && !EQ (icon_y
, Qunbound
))
3429 CHECK_NUMBER (icon_x
, 0);
3430 CHECK_NUMBER (icon_y
, 0);
3432 else if (!EQ (icon_x
, Qunbound
) || !EQ (icon_y
, Qunbound
))
3433 error ("Both left and top icon corners of icon must be specified");
3437 if (! EQ (icon_x
, Qunbound
))
3438 x_wm_set_icon_position (f
, XINT (icon_x
), XINT (icon_y
));
3443 DEFUN ("x-create-frame", Fx_create_frame
, Sx_create_frame
,
3445 "Make a new window, which is called a \"frame\" in Emacs terms.\n\
3446 Returns an Emacs frame object.\n\
3447 ALIST is an alist of frame parameters.\n\
3448 If the parameters specify that the frame should not have a minibuffer,\n\
3449 and do not specify a specific minibuffer window to use,\n\
3450 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
3451 be shared by the new frame.\n\
3453 This function is an internal primitive--use `make-frame' instead.")
3458 Lisp_Object frame
, tem
;
3460 int minibuffer_only
= 0;
3461 long window_prompting
= 0;
3463 int count
= specpdl_ptr
- specpdl
;
3464 struct gcpro gcpro1
;
3465 Lisp_Object display
;
3466 struct win32_display_info
*dpyinfo
;
3470 /* Use this general default value to start with
3471 until we know if this frame has a specified name. */
3472 Vx_resource_name
= Vinvocation_name
;
3474 display
= x_get_arg (parms
, Qdisplay
, 0, 0, string
);
3475 if (EQ (display
, Qunbound
))
3477 dpyinfo
= check_x_display_info (display
);
3479 kb
= dpyinfo
->kboard
;
3481 kb
= &the_only_kboard
;
3484 name
= x_get_arg (parms
, Qname
, "title", "Title", string
);
3486 && ! EQ (name
, Qunbound
)
3488 error ("Invalid frame name--not a string or nil");
3491 Vx_resource_name
= name
;
3493 /* See if parent window is specified. */
3494 parent
= x_get_arg (parms
, Qparent_id
, NULL
, NULL
, number
);
3495 if (EQ (parent
, Qunbound
))
3497 if (! NILP (parent
))
3498 CHECK_NUMBER (parent
, 0);
3500 tem
= x_get_arg (parms
, Qminibuffer
, 0, 0, symbol
);
3501 if (EQ (tem
, Qnone
) || NILP (tem
))
3502 f
= make_frame_without_minibuffer (Qnil
, kb
, display
);
3503 else if (EQ (tem
, Qonly
))
3505 f
= make_minibuffer_frame ();
3506 minibuffer_only
= 1;
3508 else if (WINDOWP (tem
))
3509 f
= make_frame_without_minibuffer (tem
, kb
, display
);
3513 /* Note that Windows does support scroll bars. */
3514 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 1;
3515 /* By default, make scrollbars the system standard width. */
3516 f
->scroll_bar_pixel_width
= GetSystemMetrics (SM_CXVSCROLL
);
3518 XSETFRAME (frame
, f
);
3521 f
->output_method
= output_win32
;
3522 f
->output_data
.win32
= (struct win32_output
*) xmalloc (sizeof (struct win32_output
));
3523 bzero (f
->output_data
.win32
, sizeof (struct win32_output
));
3525 /* FRAME_WIN32_DISPLAY_INFO (f) = dpyinfo; */
3527 FRAME_KBOARD (f
) = kb
;
3530 /* Specify the parent under which to make this window. */
3534 f
->output_data
.win32
->parent_desc
= (Window
) parent
;
3535 f
->output_data
.win32
->explicit_parent
= 1;
3539 f
->output_data
.win32
->parent_desc
= FRAME_WIN32_DISPLAY_INFO (f
)->root_window
;
3540 f
->output_data
.win32
->explicit_parent
= 0;
3543 /* Note that the frame has no physical cursor right now. */
3544 f
->phys_cursor_x
= -1;
3546 /* Set the name; the functions to which we pass f expect the name to
3548 if (EQ (name
, Qunbound
) || NILP (name
))
3550 f
->name
= build_string (dpyinfo
->win32_id_name
);
3551 f
->explicit_name
= 0;
3556 f
->explicit_name
= 1;
3557 /* use the frame's title when getting resources for this frame. */
3558 specbind (Qx_resource_name
, name
);
3561 /* Extract the window parameters from the supplied values
3562 that are needed to determine window geometry. */
3566 font
= x_get_arg (parms
, Qfont
, "font", "Font", string
);
3568 /* First, try whatever font the caller has specified. */
3570 font
= x_new_font (f
, XSTRING (font
)->data
);
3572 /* Try out a font which we hope has bold and italic variations. */
3573 if (!STRINGP (font
))
3574 font
= x_new_font (f
, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3575 if (! STRINGP (font
))
3576 font
= x_new_font (f
, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3577 if (! STRINGP (font
))
3578 /* This was formerly the first thing tried, but it finds too many fonts
3579 and takes too long. */
3580 font
= x_new_font (f
, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
3581 /* If those didn't work, look for something which will at least work. */
3582 if (! STRINGP (font
))
3583 font
= x_new_font (f
, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
3584 if (! STRINGP (font
))
3585 font
= x_new_font (f
, "-*-system-medium-r-normal-*-*-200-*-*-c-120-*-*");
3587 if (! STRINGP (font
))
3588 font
= x_new_font (f
, "-*-Fixedsys-*-r-*-*-12-90-*-*-c-*-*-*");
3590 if (! STRINGP (font
))
3591 font
= build_string ("-*-system");
3593 x_default_parameter (f
, parms
, Qfont
, font
,
3594 "font", "Font", string
);
3597 x_default_parameter (f
, parms
, Qborder_width
, make_number (2),
3598 "borderwidth", "BorderWidth", number
);
3599 /* This defaults to 2 in order to match xterm. We recognize either
3600 internalBorderWidth or internalBorder (which is what xterm calls
3602 if (NILP (Fassq (Qinternal_border_width
, parms
)))
3606 value
= x_get_arg (parms
, Qinternal_border_width
,
3607 "internalBorder", "BorderWidth", number
);
3608 if (! EQ (value
, Qunbound
))
3609 parms
= Fcons (Fcons (Qinternal_border_width
, value
),
3612 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (0),
3613 "internalBorderWidth", "BorderWidth", number
);
3614 x_default_parameter (f
, parms
, Qvertical_scroll_bars
, Qt
,
3615 "verticalScrollBars", "ScrollBars", boolean
);
3617 /* Also do the stuff which must be set before the window exists. */
3618 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
3619 "foreground", "Foreground", string
);
3620 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
3621 "background", "Background", string
);
3622 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
3623 "pointerColor", "Foreground", string
);
3624 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
3625 "cursorColor", "Foreground", string
);
3626 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
3627 "borderColor", "BorderColor", string
);
3629 x_default_parameter (f
, parms
, Qmenu_bar_lines
, make_number (1),
3630 "menuBar", "MenuBar", number
);
3631 x_default_parameter (f
, parms
, Qscroll_bar_width
, Qnil
,
3632 "scrollBarWidth", "ScrollBarWidth", number
);
3634 f
->output_data
.win32
->dwStyle
= WS_OVERLAPPEDWINDOW
;
3635 f
->output_data
.win32
->parent_desc
= FRAME_WIN32_DISPLAY_INFO (f
)->root_window
;
3636 window_prompting
= x_figure_window_size (f
, parms
);
3638 if (window_prompting
& XNegative
)
3640 if (window_prompting
& YNegative
)
3641 f
->output_data
.win32
->win_gravity
= SouthEastGravity
;
3643 f
->output_data
.win32
->win_gravity
= NorthEastGravity
;
3647 if (window_prompting
& YNegative
)
3648 f
->output_data
.win32
->win_gravity
= SouthWestGravity
;
3650 f
->output_data
.win32
->win_gravity
= NorthWestGravity
;
3653 f
->output_data
.win32
->size_hint_flags
= window_prompting
;
3655 win32_window (f
, window_prompting
, minibuffer_only
);
3657 init_frame_faces (f
);
3659 /* We need to do this after creating the window, so that the
3660 icon-creation functions can say whose icon they're describing. */
3661 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
3662 "bitmapIcon", "BitmapIcon", symbol
);
3664 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
3665 "autoRaise", "AutoRaiseLower", boolean
);
3666 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
3667 "autoLower", "AutoRaiseLower", boolean
);
3668 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
3669 "cursorType", "CursorType", symbol
);
3671 /* Dimensions, especially f->height, must be done via change_frame_size.
3672 Change will not be effected unless different from the current
3676 f
->height
= f
->width
= 0;
3677 change_frame_size (f
, height
, width
, 1, 0);
3679 /* Tell the server what size and position, etc, we want,
3680 and how badly we want them. */
3682 x_wm_set_size_hint (f
, window_prompting
, 0);
3685 tem
= x_get_arg (parms
, Qunsplittable
, 0, 0, boolean
);
3686 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
3690 /* It is now ok to make the frame official
3691 even if we get an error below.
3692 And the frame needs to be on Vframe_list
3693 or making it visible won't work. */
3694 Vframe_list
= Fcons (frame
, Vframe_list
);
3696 /* Now that the frame is official, it counts as a reference to
3698 FRAME_WIN32_DISPLAY_INFO (f
)->reference_count
++;
3700 /* Make the window appear on the frame and enable display,
3701 unless the caller says not to. However, with explicit parent,
3702 Emacs cannot control visibility, so don't try. */
3703 if (! f
->output_data
.win32
->explicit_parent
)
3705 Lisp_Object visibility
;
3707 visibility
= x_get_arg (parms
, Qvisibility
, 0, 0, symbol
);
3708 if (EQ (visibility
, Qunbound
))
3711 if (EQ (visibility
, Qicon
))
3712 x_iconify_frame (f
);
3713 else if (! NILP (visibility
))
3714 x_make_frame_visible (f
);
3716 /* Must have been Qnil. */
3720 return unbind_to (count
, frame
);
3723 /* FRAME is used only to get a handle on the X display. We don't pass the
3724 display info directly because we're called from frame.c, which doesn't
3725 know about that structure. */
3727 x_get_focus_frame (frame
)
3728 struct frame
*frame
;
3730 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (frame
);
3732 if (! dpyinfo
->win32_focus_frame
)
3735 XSETFRAME (xfocus
, dpyinfo
->win32_focus_frame
);
3740 win32_load_font (dpyinfo
,name
)
3741 struct win32_display_info
*dpyinfo
;
3744 XFontStruct
* font
= NULL
;
3750 if (!name
|| !x_to_win32_font (name
, &lf
))
3753 font
= (XFontStruct
*) xmalloc (sizeof (XFontStruct
));
3755 if (!font
) return (NULL
);
3759 font
->hfont
= CreateFontIndirect (&lf
);
3762 if (font
->hfont
== NULL
)
3771 hdc
= GetDC (dpyinfo
->root_window
);
3772 oldobj
= SelectObject (hdc
, font
->hfont
);
3773 ok
= GetTextMetrics (hdc
, &font
->tm
);
3774 SelectObject (hdc
, oldobj
);
3775 ReleaseDC (dpyinfo
->root_window
, hdc
);
3780 if (ok
) return (font
);
3782 win32_unload_font (dpyinfo
, font
);
3787 win32_unload_font (dpyinfo
, font
)
3788 struct win32_display_info
*dpyinfo
;
3793 if (font
->hfont
) DeleteObject(font
->hfont
);
3798 /* The font conversion stuff between x and win32 */
3800 /* X font string is as follows (from faces.el)
3804 * (weight "\\(bold\\|demibold\\|medium\\)") ; 1
3805 * (weight\? "\\([^-]*\\)") ; 1
3806 * (slant "\\([ior]\\)") ; 2
3807 * (slant\? "\\([^-]?\\)") ; 2
3808 * (swidth "\\([^-]*\\)") ; 3
3809 * (adstyle "[^-]*") ; 4
3810 * (pixelsize "[0-9]+")
3811 * (pointsize "[0-9][0-9]+")
3812 * (resx "[0-9][0-9]+")
3813 * (resy "[0-9][0-9]+")
3814 * (spacing "[cmp?*]")
3815 * (avgwidth "[0-9]+")
3816 * (registry "[^-]+")
3817 * (encoding "[^-]+")
3819 * (setq x-font-regexp
3820 * (concat "\\`\\*?[-?*]"
3821 * foundry - family - weight\? - slant\? - swidth - adstyle -
3822 * pixelsize - pointsize - resx - resy - spacing - registry -
3823 * encoding "[-?*]\\*?\\'"
3825 * (setq x-font-regexp-head
3826 * (concat "\\`[-?*]" foundry - family - weight\? - slant\?
3827 * "\\([-*?]\\|\\'\\)"))
3828 * (setq x-font-regexp-slant (concat - slant -))
3829 * (setq x-font-regexp-weight (concat - weight -))
3833 #define FONT_START "[-?]"
3834 #define FONT_FOUNDRY "[^-]+"
3835 #define FONT_FAMILY "\\([^-]+\\)" /* 1 */
3836 #define FONT_WEIGHT "\\(bold\\|demibold\\|medium\\)" /* 2 */
3837 #define FONT_WEIGHT_Q "\\([^-]*\\)" /* 2 */
3838 #define FONT_SLANT "\\([ior]\\)" /* 3 */
3839 #define FONT_SLANT_Q "\\([^-]?\\)" /* 3 */
3840 #define FONT_SWIDTH "\\([^-]*\\)" /* 4 */
3841 #define FONT_ADSTYLE "[^-]*"
3842 #define FONT_PIXELSIZE "[^-]*"
3843 #define FONT_POINTSIZE "\\([0-9][0-9]+\\|\\*\\)" /* 5 */
3844 #define FONT_RESX "[0-9][0-9]+"
3845 #define FONT_RESY "[0-9][0-9]+"
3846 #define FONT_SPACING "[cmp?*]"
3847 #define FONT_AVGWIDTH "[0-9]+"
3848 #define FONT_REGISTRY "[^-]+"
3849 #define FONT_ENCODING "[^-]+"
3851 #define FONT_REGEXP ("\\`\\*?[-?*]" \
3858 FONT_PIXELSIZE "-" \
3859 FONT_POINTSIZE "-" \
3862 #define FONT_REGEXP_HEAD ("\\`[-?*]" \
3867 "\\([-*?]\\|\\'\\)")
3869 #define FONT_REGEXP_SLANT "-" FONT_SLANT "-"
3870 #define FONT_REGEXP_WEIGHT "-" FONT_WEIGHT "-"
3873 x_to_win32_weight (lpw
)
3876 if (!lpw
) return (FW_DONTCARE
);
3878 if (stricmp (lpw
,"heavy") == 0) return FW_HEAVY
;
3879 else if (stricmp (lpw
,"extrabold") == 0) return FW_EXTRABOLD
;
3880 else if (stricmp (lpw
,"bold") == 0) return FW_BOLD
;
3881 else if (stricmp (lpw
,"demibold") == 0) return FW_SEMIBOLD
;
3882 else if (stricmp (lpw
,"medium") == 0) return FW_MEDIUM
;
3883 else if (stricmp (lpw
,"normal") == 0) return FW_NORMAL
;
3884 else if (stricmp (lpw
,"light") == 0) return FW_LIGHT
;
3885 else if (stricmp (lpw
,"extralight") == 0) return FW_EXTRALIGHT
;
3886 else if (stricmp (lpw
,"thin") == 0) return FW_THIN
;
3893 win32_to_x_weight (fnweight
)
3896 if (fnweight
>= FW_HEAVY
) return "heavy";
3897 if (fnweight
>= FW_EXTRABOLD
) return "extrabold";
3898 if (fnweight
>= FW_BOLD
) return "bold";
3899 if (fnweight
>= FW_SEMIBOLD
) return "semibold";
3900 if (fnweight
>= FW_MEDIUM
) return "medium";
3901 if (fnweight
>= FW_NORMAL
) return "normal";
3902 if (fnweight
>= FW_LIGHT
) return "light";
3903 if (fnweight
>= FW_EXTRALIGHT
) return "extralight";
3904 if (fnweight
>= FW_THIN
) return "thin";
3910 x_to_win32_charset (lpcs
)
3913 if (!lpcs
) return (0);
3915 if (stricmp (lpcs
,"ansi") == 0) return ANSI_CHARSET
;
3916 else if (stricmp (lpcs
,"iso8859-1") == 0) return ANSI_CHARSET
;
3917 else if (stricmp (lpcs
,"iso8859") == 0) return ANSI_CHARSET
;
3918 else if (stricmp (lpcs
,"oem") == 0) return OEM_CHARSET
;
3919 #ifdef UNICODE_CHARSET
3920 else if (stricmp (lpcs
,"unicode") == 0) return UNICODE_CHARSET
;
3921 else if (stricmp (lpcs
,"iso10646") == 0) return UNICODE_CHARSET
;
3928 win32_to_x_charset (fncharset
)
3933 case ANSI_CHARSET
: return "ansi";
3934 case OEM_CHARSET
: return "oem";
3935 case SYMBOL_CHARSET
: return "symbol";
3936 #ifdef UNICODE_CHARSET
3937 case UNICODE_CHARSET
: return "unicode";
3944 win32_to_x_font (lplogfont
, lpxstr
, len
)
3945 LOGFONT
* lplogfont
;
3949 char height_pixels
[8];
3951 char width_pixels
[8];
3953 if (!lpxstr
) abort ();
3958 if (lplogfont
->lfHeight
)
3960 sprintf (height_pixels
, "%u", abs (lplogfont
->lfHeight
));
3961 sprintf (height_dpi
, "%u",
3962 (abs (lplogfont
->lfHeight
) * 720) / one_win32_display_info
.height_in
);
3966 strcpy (height_pixels
, "*");
3967 strcpy (height_dpi
, "*");
3969 if (lplogfont
->lfWidth
)
3970 sprintf (width_pixels
, "%u", lplogfont
->lfWidth
* 10);
3972 strcpy (width_pixels
, "*");
3974 _snprintf (lpxstr
, len
- 1,
3975 "-*-%s-%s-%c-*-*-%s-%s-*-*-%c-%s-*-%s-",
3976 lplogfont
->lfFaceName
,
3977 win32_to_x_weight (lplogfont
->lfWeight
),
3978 lplogfont
->lfItalic
?'i':'r',
3981 ((lplogfont
->lfPitchAndFamily
& 0x3) == VARIABLE_PITCH
) ? 'p' : 'c',
3983 win32_to_x_charset (lplogfont
->lfCharSet
)
3986 lpxstr
[len
- 1] = 0; /* just to be sure */
3991 x_to_win32_font (lpxstr
, lplogfont
)
3993 LOGFONT
* lplogfont
;
3995 if (!lplogfont
) return (FALSE
);
3997 memset (lplogfont
, 0, sizeof (*lplogfont
));
4000 lplogfont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
4001 lplogfont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
4002 lplogfont
->lfQuality
= DEFAULT_QUALITY
;
4004 /* go for maximum quality */
4005 lplogfont
->lfOutPrecision
= OUT_STROKE_PRECIS
;
4006 lplogfont
->lfClipPrecision
= CLIP_STROKE_PRECIS
;
4007 lplogfont
->lfQuality
= PROOF_QUALITY
;
4013 /* Provide a simple escape mechanism for specifying Windows font names
4014 * directly -- if font spec does not beginning with '-', assume this
4016 * "<font name>[:height in pixels[:width in pixels[:weight]]]"
4022 char name
[50], weight
[20], slant
, pitch
, pixels
[10], height
[10], width
[10], remainder
[20];
4025 fields
= sscanf (lpxstr
,
4026 "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%*[^-]-%c-%9[^-]-%19s",
4027 name
, weight
, &slant
, pixels
, height
, &pitch
, width
, remainder
);
4029 if (fields
== EOF
) return (FALSE
);
4031 if (fields
> 0 && name
[0] != '*')
4033 strncpy (lplogfont
->lfFaceName
,name
, LF_FACESIZE
);
4034 lplogfont
->lfFaceName
[LF_FACESIZE
-1] = 0;
4038 lplogfont
->lfFaceName
[0] = 0;
4043 lplogfont
->lfWeight
= x_to_win32_weight ((fields
> 0 ? weight
: ""));
4047 if (!NILP (Vwin32_enable_italics
))
4048 lplogfont
->lfItalic
= (fields
> 0 && slant
== 'i');
4052 if (fields
> 0 && pixels
[0] != '*')
4053 lplogfont
->lfHeight
= atoi (pixels
);
4057 if (fields
> 0 && lplogfont
->lfHeight
== 0 && height
[0] != '*')
4058 lplogfont
->lfHeight
= (atoi (height
)
4059 * one_win32_display_info
.height_in
) / 720;
4063 lplogfont
->lfPitchAndFamily
=
4064 (fields
> 0 && pitch
== 'p') ? VARIABLE_PITCH
: FIXED_PITCH
;
4068 if (fields
> 0 && width
[0] != '*')
4069 lplogfont
->lfWidth
= atoi (width
) / 10;
4073 /* Not all font specs include the registry field, so we allow for an
4074 optional registry field before the encoding when parsing
4075 remainder. Also we strip the trailing '-' if present. */
4077 int len
= strlen (remainder
);
4078 if (len
> 0 && remainder
[len
-1] == '-')
4079 remainder
[len
-1] = 0;
4081 encoding
= remainder
;
4082 if (strncmp (encoding
, "*-", 2) == 0)
4084 lplogfont
->lfCharSet
= x_to_win32_charset (fields
> 0 ? encoding
: "");
4089 char name
[100], height
[10], width
[10], weight
[20];
4091 fields
= sscanf (lpxstr
,
4092 "%99[^:]:%9[^:]:%9[^:]:%19s",
4093 name
, height
, width
, weight
);
4095 if (fields
== EOF
) return (FALSE
);
4099 strncpy (lplogfont
->lfFaceName
,name
, LF_FACESIZE
);
4100 lplogfont
->lfFaceName
[LF_FACESIZE
-1] = 0;
4104 lplogfont
->lfFaceName
[0] = 0;
4110 lplogfont
->lfHeight
= atoi (height
);
4115 lplogfont
->lfWidth
= atoi (width
);
4119 lplogfont
->lfWeight
= x_to_win32_weight ((fields
> 0 ? weight
: ""));
4122 /* This makes TrueType fonts work better. */
4123 lplogfont
->lfHeight
= - abs (lplogfont
->lfHeight
);
4129 win32_font_match (lpszfont1
, lpszfont2
)
4133 char * s1
= lpszfont1
, *e1
;
4134 char * s2
= lpszfont2
, *e2
;
4136 if (s1
== NULL
|| s2
== NULL
) return (FALSE
);
4138 if (*s1
== '-') s1
++;
4139 if (*s2
== '-') s2
++;
4145 e1
= strchr (s1
, '-');
4146 e2
= strchr (s2
, '-');
4148 if (e1
== NULL
|| e2
== NULL
) return (TRUE
);
4153 if (*s1
!= '*' && *s2
!= '*'
4154 && (len1
!= len2
|| strnicmp (s1
, s2
, len1
) != 0))
4162 typedef struct enumfont_t
4167 XFontStruct
*size_ref
;
4168 Lisp_Object
*pattern
;
4174 enum_font_cb2 (lplf
, lptm
, FontType
, lpef
)
4176 NEWTEXTMETRIC
* lptm
;
4180 if (lplf
->elfLogFont
.lfStrikeOut
|| lplf
->elfLogFont
.lfUnderline
4181 || (lplf
->elfLogFont
.lfCharSet
!= ANSI_CHARSET
&& lplf
->elfLogFont
.lfCharSet
!= OEM_CHARSET
))
4184 /* if (!lpef->size_ref || lptm->tmMaxCharWidth == FONT_WIDTH (lpef->size_ref)) */
4188 if (!NILP (*(lpef
->pattern
)) && FontType
== TRUETYPE_FONTTYPE
)
4190 lplf
->elfLogFont
.lfHeight
= lpef
->logfont
.lfHeight
;
4191 lplf
->elfLogFont
.lfWidth
= lpef
->logfont
.lfWidth
;
4194 if (!win32_to_x_font (lplf
, buf
, 100)) return (0);
4196 if (NILP (*(lpef
->pattern
)) || win32_font_match (buf
, XSTRING (*(lpef
->pattern
))->data
))
4198 *lpef
->tail
= Fcons (build_string (buf
), Qnil
);
4199 lpef
->tail
= &XCONS (*lpef
->tail
)->cdr
;
4208 enum_font_cb1 (lplf
, lptm
, FontType
, lpef
)
4210 NEWTEXTMETRIC
* lptm
;
4214 return EnumFontFamilies (lpef
->hdc
,
4215 lplf
->elfLogFont
.lfFaceName
,
4216 (FONTENUMPROC
) enum_font_cb2
,
4221 DEFUN ("x-list-fonts", Fx_list_fonts
, Sx_list_fonts
, 1, 3, 0,
4222 "Return a list of the names of available fonts matching PATTERN.\n\
4223 If optional arguments FACE and FRAME are specified, return only fonts\n\
4224 the same size as FACE on FRAME.\n\
4226 PATTERN is a string, perhaps with wildcard characters;\n\
4227 the * character matches any substring, and\n\
4228 the ? character matches any single character.\n\
4229 PATTERN is case-insensitive.\n\
4230 FACE is a face name--a symbol.\n\
4232 The return value is a list of strings, suitable as arguments to\n\
4235 Fonts Emacs can't use (i.e. proportional fonts) may or may not be excluded\n\
4236 even if they match PATTERN and FACE.")
4237 (pattern
, face
, frame
)
4238 Lisp_Object pattern
, face
, frame
;
4243 XFontStruct
*size_ref
;
4244 Lisp_Object namelist
;
4249 CHECK_STRING (pattern
, 0);
4251 CHECK_SYMBOL (face
, 1);
4253 f
= check_x_frame (frame
);
4255 /* Determine the width standard for comparison with the fonts we find. */
4263 /* Don't die if we get called with a terminal frame. */
4264 if (! FRAME_WIN32_P (f
))
4265 error ("non-win32 frame used in `x-list-fonts'");
4267 face_id
= face_name_id_number (f
, face
);
4269 if (face_id
< 0 || face_id
>= FRAME_N_PARAM_FACES (f
)
4270 || FRAME_PARAM_FACES (f
) [face_id
] == 0)
4271 size_ref
= f
->output_data
.win32
->font
;
4274 size_ref
= FRAME_PARAM_FACES (f
) [face_id
]->font
;
4275 if (size_ref
== (XFontStruct
*) (~0))
4276 size_ref
= f
->output_data
.win32
->font
;
4280 /* See if we cached the result for this particular query. */
4281 list
= Fassoc (pattern
,
4282 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
);
4284 /* We have info in the cache for this PATTERN. */
4287 Lisp_Object tem
, newlist
;
4289 /* We have info about this pattern. */
4290 list
= XCONS (list
)->cdr
;
4297 /* Filter the cached info and return just the fonts that match FACE. */
4299 for (tem
= list
; CONSP (tem
); tem
= XCONS (tem
)->cdr
)
4301 XFontStruct
*thisinfo
;
4303 thisinfo
= win32_load_font (FRAME_WIN32_DISPLAY_INFO (f
), XSTRING (XCONS (tem
)->car
)->data
);
4305 if (thisinfo
&& same_size_fonts (thisinfo
, size_ref
))
4306 newlist
= Fcons (XCONS (tem
)->car
, newlist
);
4308 win32_unload_font (FRAME_WIN32_DISPLAY_INFO (f
), thisinfo
);
4319 ef
.pattern
= &pattern
;
4320 ef
.tail
= ef
.head
= &namelist
;
4322 x_to_win32_font (STRINGP (pattern
) ? XSTRING (pattern
)->data
: NULL
, &ef
.logfont
);
4325 ef
.hdc
= GetDC (FRAME_WIN32_WINDOW (f
));
4327 EnumFontFamilies (ef
.hdc
, NULL
, (FONTENUMPROC
) enum_font_cb1
, (LPARAM
)&ef
);
4329 ReleaseDC (FRAME_WIN32_WINDOW (f
), ef
.hdc
);
4339 /* Make a list of all the fonts we got back.
4340 Store that in the font cache for the display. */
4341 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
4342 = Fcons (Fcons (pattern
, namelist
),
4343 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
);
4345 /* Make a list of the fonts that have the right width. */
4348 for (i
= 0; i
< ef
.numFonts
; i
++)
4356 XFontStruct
*thisinfo
;
4359 thisinfo
= win32_load_font (FRAME_WIN32_DISPLAY_INFO (f
), XSTRING (Fcar (cur
))->data
);
4361 keeper
= thisinfo
&& same_size_fonts (thisinfo
, size_ref
);
4363 win32_unload_font (FRAME_WIN32_DISPLAY_INFO (f
), thisinfo
);
4368 list
= Fcons (build_string (XSTRING (Fcar (cur
))->data
), list
);
4372 list
= Fnreverse (list
);
4378 DEFUN ("x-color-defined-p", Fx_color_defined_p
, Sx_color_defined_p
, 1, 2, 0,
4379 "Return non-nil if color COLOR is supported on frame FRAME.\n\
4380 If FRAME is omitted or nil, use the selected frame.")
4382 Lisp_Object color
, frame
;
4385 FRAME_PTR f
= check_x_frame (frame
);
4387 CHECK_STRING (color
, 1);
4389 if (defined_color (f
, XSTRING (color
)->data
, &foo
, 0))
4395 DEFUN ("x-color-values", Fx_color_values
, Sx_color_values
, 1, 2, 0,
4396 "Return a description of the color named COLOR on frame FRAME.\n\
4397 The value is a list of integer RGB values--(RED GREEN BLUE).\n\
4398 These values appear to range from 0 to 65280 or 65535, depending\n\
4399 on the system; white is (65280 65280 65280) or (65535 65535 65535).\n\
4400 If FRAME is omitted or nil, use the selected frame.")
4402 Lisp_Object color
, frame
;
4405 FRAME_PTR f
= check_x_frame (frame
);
4407 CHECK_STRING (color
, 1);
4409 if (defined_color (f
, XSTRING (color
)->data
, &foo
, 0))
4413 rgb
[0] = make_number (GetRValue (foo
));
4414 rgb
[1] = make_number (GetGValue (foo
));
4415 rgb
[2] = make_number (GetBValue (foo
));
4416 return Flist (3, rgb
);
4422 DEFUN ("x-display-color-p", Fx_display_color_p
, Sx_display_color_p
, 0, 1, 0,
4423 "Return t if the X display supports color.\n\
4424 The optional argument DISPLAY specifies which display to ask about.\n\
4425 DISPLAY should be either a frame or a display name (a string).\n\
4426 If omitted or nil, that stands for the selected frame's display.")
4428 Lisp_Object display
;
4430 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4432 if ((dpyinfo
->n_planes
* dpyinfo
->n_cbits
) <= 2)
4438 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p
, Sx_display_grayscale_p
,
4440 "Return t if the X display supports shades of gray.\n\
4441 Note that color displays do support shades of gray.\n\
4442 The optional argument DISPLAY specifies which display to ask about.\n\
4443 DISPLAY should be either a frame or a display name (a string).\n\
4444 If omitted or nil, that stands for the selected frame's display.")
4446 Lisp_Object display
;
4448 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4450 if ((dpyinfo
->n_planes
* dpyinfo
->n_cbits
) <= 1)
4456 DEFUN ("x-display-pixel-width", Fx_display_pixel_width
, Sx_display_pixel_width
,
4458 "Returns the width in pixels of the X display DISPLAY.\n\
4459 The optional argument DISPLAY specifies which display to ask about.\n\
4460 DISPLAY should be either a frame or a display name (a string).\n\
4461 If omitted or nil, that stands for the selected frame's display.")
4463 Lisp_Object display
;
4465 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4467 return make_number (dpyinfo
->width
);
4470 DEFUN ("x-display-pixel-height", Fx_display_pixel_height
,
4471 Sx_display_pixel_height
, 0, 1, 0,
4472 "Returns the height in pixels of the X display DISPLAY.\n\
4473 The optional argument DISPLAY specifies which display to ask about.\n\
4474 DISPLAY should be either a frame or a display name (a string).\n\
4475 If omitted or nil, that stands for the selected frame's display.")
4477 Lisp_Object display
;
4479 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4481 return make_number (dpyinfo
->height
);
4484 DEFUN ("x-display-planes", Fx_display_planes
, Sx_display_planes
,
4486 "Returns the number of bitplanes of the display DISPLAY.\n\
4487 The optional argument DISPLAY specifies which display to ask about.\n\
4488 DISPLAY should be either a frame or a display name (a string).\n\
4489 If omitted or nil, that stands for the selected frame's display.")
4491 Lisp_Object display
;
4493 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4495 return make_number (dpyinfo
->n_planes
* dpyinfo
->n_cbits
);
4498 DEFUN ("x-display-color-cells", Fx_display_color_cells
, Sx_display_color_cells
,
4500 "Returns the number of color cells of the display DISPLAY.\n\
4501 The optional argument DISPLAY specifies which display to ask about.\n\
4502 DISPLAY should be either a frame or a display name (a string).\n\
4503 If omitted or nil, that stands for the selected frame's display.")
4505 Lisp_Object display
;
4507 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4511 hdc
= GetDC (dpyinfo
->root_window
);
4512 if (dpyinfo
->has_palette
)
4513 cap
= GetDeviceCaps (hdc
,SIZEPALETTE
);
4515 cap
= GetDeviceCaps (hdc
,NUMCOLORS
);
4517 ReleaseDC (dpyinfo
->root_window
, hdc
);
4519 return make_number (cap
);
4522 DEFUN ("x-server-max-request-size", Fx_server_max_request_size
,
4523 Sx_server_max_request_size
,
4525 "Returns the maximum request size of the server of display DISPLAY.\n\
4526 The optional argument DISPLAY specifies which display to ask about.\n\
4527 DISPLAY should be either a frame or a display name (a string).\n\
4528 If omitted or nil, that stands for the selected frame's display.")
4530 Lisp_Object display
;
4532 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4534 return make_number (1);
4537 DEFUN ("x-server-vendor", Fx_server_vendor
, Sx_server_vendor
, 0, 1, 0,
4538 "Returns the vendor ID string of the Win32 system (Microsoft).\n\
4539 The optional argument DISPLAY specifies which display to ask about.\n\
4540 DISPLAY should be either a frame or a display name (a string).\n\
4541 If omitted or nil, that stands for the selected frame's display.")
4543 Lisp_Object display
;
4545 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4546 char *vendor
= "Microsoft Corp.";
4548 if (! vendor
) vendor
= "";
4549 return build_string (vendor
);
4552 DEFUN ("x-server-version", Fx_server_version
, Sx_server_version
, 0, 1, 0,
4553 "Returns the version numbers of the server of display DISPLAY.\n\
4554 The value is a list of three integers: the major and minor\n\
4555 version numbers, and the vendor-specific release\n\
4556 number. See also the function `x-server-vendor'.\n\n\
4557 The optional argument DISPLAY specifies which display to ask about.\n\
4558 DISPLAY should be either a frame or a display name (a string).\n\
4559 If omitted or nil, that stands for the selected frame's display.")
4561 Lisp_Object display
;
4563 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4565 return Fcons (make_number (nt_major_version
),
4566 Fcons (make_number (nt_minor_version
), Qnil
));
4569 DEFUN ("x-display-screens", Fx_display_screens
, Sx_display_screens
, 0, 1, 0,
4570 "Returns the number of screens on the server of display DISPLAY.\n\
4571 The optional argument DISPLAY specifies which display to ask about.\n\
4572 DISPLAY should be either a frame or a display name (a string).\n\
4573 If omitted or nil, that stands for the selected frame's display.")
4575 Lisp_Object display
;
4577 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4579 return make_number (1);
4582 DEFUN ("x-display-mm-height", Fx_display_mm_height
, Sx_display_mm_height
, 0, 1, 0,
4583 "Returns the height in millimeters of the X display DISPLAY.\n\
4584 The optional argument DISPLAY specifies which display to ask about.\n\
4585 DISPLAY should be either a frame or a display name (a string).\n\
4586 If omitted or nil, that stands for the selected frame's display.")
4588 Lisp_Object display
;
4590 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4594 hdc
= GetDC (dpyinfo
->root_window
);
4596 cap
= GetDeviceCaps (hdc
, VERTSIZE
);
4598 ReleaseDC (dpyinfo
->root_window
, hdc
);
4600 return make_number (cap
);
4603 DEFUN ("x-display-mm-width", Fx_display_mm_width
, Sx_display_mm_width
, 0, 1, 0,
4604 "Returns the width in millimeters of the X display DISPLAY.\n\
4605 The optional argument DISPLAY specifies which display to ask about.\n\
4606 DISPLAY should be either a frame or a display name (a string).\n\
4607 If omitted or nil, that stands for the selected frame's display.")
4609 Lisp_Object display
;
4611 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4616 hdc
= GetDC (dpyinfo
->root_window
);
4618 cap
= GetDeviceCaps (hdc
, HORZSIZE
);
4620 ReleaseDC (dpyinfo
->root_window
, hdc
);
4622 return make_number (cap
);
4625 DEFUN ("x-display-backing-store", Fx_display_backing_store
,
4626 Sx_display_backing_store
, 0, 1, 0,
4627 "Returns an indication of whether display DISPLAY does backing store.\n\
4628 The value may be `always', `when-mapped', or `not-useful'.\n\
4629 The optional argument DISPLAY specifies which display to ask about.\n\
4630 DISPLAY should be either a frame or a display name (a string).\n\
4631 If omitted or nil, that stands for the selected frame's display.")
4633 Lisp_Object display
;
4635 return intern ("not-useful");
4638 DEFUN ("x-display-visual-class", Fx_display_visual_class
,
4639 Sx_display_visual_class
, 0, 1, 0,
4640 "Returns the visual class of the display DISPLAY.\n\
4641 The value is one of the symbols `static-gray', `gray-scale',\n\
4642 `static-color', `pseudo-color', `true-color', or `direct-color'.\n\n\
4643 The optional argument DISPLAY specifies which display to ask about.\n\
4644 DISPLAY should be either a frame or a display name (a string).\n\
4645 If omitted or nil, that stands for the selected frame's display.")
4647 Lisp_Object display
;
4649 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4652 switch (dpyinfo
->visual
->class)
4654 case StaticGray
: return (intern ("static-gray"));
4655 case GrayScale
: return (intern ("gray-scale"));
4656 case StaticColor
: return (intern ("static-color"));
4657 case PseudoColor
: return (intern ("pseudo-color"));
4658 case TrueColor
: return (intern ("true-color"));
4659 case DirectColor
: return (intern ("direct-color"));
4661 error ("Display has an unknown visual class");
4665 error ("Display has an unknown visual class");
4668 DEFUN ("x-display-save-under", Fx_display_save_under
,
4669 Sx_display_save_under
, 0, 1, 0,
4670 "Returns t if the display DISPLAY supports the save-under feature.\n\
4671 The optional argument DISPLAY specifies which display to ask about.\n\
4672 DISPLAY should be either a frame or a display name (a string).\n\
4673 If omitted or nil, that stands for the selected frame's display.")
4675 Lisp_Object display
;
4677 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4684 register struct frame
*f
;
4686 return PIXEL_WIDTH (f
);
4691 register struct frame
*f
;
4693 return PIXEL_HEIGHT (f
);
4698 register struct frame
*f
;
4700 return FONT_WIDTH (f
->output_data
.win32
->font
);
4705 register struct frame
*f
;
4707 return f
->output_data
.win32
->line_height
;
4711 x_screen_planes (frame
)
4714 return (FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_planes
*
4715 FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_cbits
);
4718 /* Return the display structure for the display named NAME.
4719 Open a new connection if necessary. */
4721 struct win32_display_info
*
4722 x_display_info_for_name (name
)
4726 struct win32_display_info
*dpyinfo
;
4728 CHECK_STRING (name
, 0);
4730 for (dpyinfo
= &one_win32_display_info
, names
= win32_display_name_list
;
4732 dpyinfo
= dpyinfo
->next
, names
= XCONS (names
)->cdr
)
4735 tem
= Fstring_equal (XCONS (XCONS (names
)->car
)->car
, name
);
4740 /* Use this general default value to start with. */
4741 Vx_resource_name
= Vinvocation_name
;
4743 validate_x_resource_name ();
4745 dpyinfo
= win32_term_init (name
, (unsigned char *)0,
4746 (char *) XSTRING (Vx_resource_name
)->data
);
4749 error ("Cannot connect to server %s", XSTRING (name
)->data
);
4751 XSETFASTINT (Vwindow_system_version
, 3);
4756 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
4757 1, 3, 0, "Open a connection to a server.\n\
4758 DISPLAY is the name of the display to connect to.\n\
4759 Optional second arg XRM-STRING is a string of resources in xrdb format.\n\
4760 If the optional third arg MUST-SUCCEED is non-nil,\n\
4761 terminate Emacs if we can't open the connection.")
4762 (display
, xrm_string
, must_succeed
)
4763 Lisp_Object display
, xrm_string
, must_succeed
;
4765 unsigned int n_planes
;
4766 unsigned char *xrm_option
;
4767 struct win32_display_info
*dpyinfo
;
4769 CHECK_STRING (display
, 0);
4770 if (! NILP (xrm_string
))
4771 CHECK_STRING (xrm_string
, 1);
4773 /* Allow color mapping to be defined externally; first look in user's
4774 HOME directory, then in Emacs etc dir for a file called rgb.txt. */
4776 Lisp_Object color_file
;
4777 struct gcpro gcpro1
;
4779 color_file
= build_string("~/rgb.txt");
4781 GCPRO1 (color_file
);
4783 if (NILP (Ffile_readable_p (color_file
)))
4785 Fexpand_file_name (build_string ("rgb.txt"),
4786 Fsymbol_value (intern ("data-directory")));
4788 Vwin32_color_map
= Fwin32_load_color_file (color_file
);
4792 if (NILP (Vwin32_color_map
))
4793 Vwin32_color_map
= Fwin32_default_color_map ();
4795 if (! NILP (xrm_string
))
4796 xrm_option
= (unsigned char *) XSTRING (xrm_string
)->data
;
4798 xrm_option
= (unsigned char *) 0;
4800 /* Use this general default value to start with. */
4801 /* First remove .exe suffix from invocation-name - it looks ugly. */
4803 char basename
[ MAX_PATH
], *str
;
4805 strcpy (basename
, XSTRING (Vinvocation_name
)->data
);
4806 str
= strrchr (basename
, '.');
4808 Vinvocation_name
= build_string (basename
);
4810 Vx_resource_name
= Vinvocation_name
;
4812 validate_x_resource_name ();
4814 /* This is what opens the connection and sets x_current_display.
4815 This also initializes many symbols, such as those used for input. */
4816 dpyinfo
= win32_term_init (display
, xrm_option
,
4817 (char *) XSTRING (Vx_resource_name
)->data
);
4821 if (!NILP (must_succeed
))
4822 fatal ("Cannot connect to server %s.\n",
4823 XSTRING (display
)->data
);
4825 error ("Cannot connect to server %s", XSTRING (display
)->data
);
4828 XSETFASTINT (Vwindow_system_version
, 3);
4832 DEFUN ("x-close-connection", Fx_close_connection
,
4833 Sx_close_connection
, 1, 1, 0,
4834 "Close the connection to DISPLAY's server.\n\
4835 For DISPLAY, specify either a frame or a display name (a string).\n\
4836 If DISPLAY is nil, that stands for the selected frame's display.")
4838 Lisp_Object display
;
4840 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4841 struct win32_display_info
*tail
;
4844 if (dpyinfo
->reference_count
> 0)
4845 error ("Display still has frames on it");
4848 /* Free the fonts in the font table. */
4849 for (i
= 0; i
< dpyinfo
->n_fonts
; i
++)
4851 if (dpyinfo
->font_table
[i
].name
)
4852 free (dpyinfo
->font_table
[i
].name
);
4853 /* Don't free the full_name string;
4854 it is always shared with something else. */
4855 win32_unload_font (dpyinfo
, dpyinfo
->font_table
[i
].font
);
4857 x_destroy_all_bitmaps (dpyinfo
);
4859 x_delete_display (dpyinfo
);
4865 DEFUN ("x-display-list", Fx_display_list
, Sx_display_list
, 0, 0, 0,
4866 "Return the list of display names that Emacs has connections to.")
4869 Lisp_Object tail
, result
;
4872 for (tail
= win32_display_name_list
; ! NILP (tail
); tail
= XCONS (tail
)->cdr
)
4873 result
= Fcons (XCONS (XCONS (tail
)->car
)->car
, result
);
4878 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
, 1, 2, 0,
4879 "If ON is non-nil, report errors as soon as the erring request is made.\n\
4880 If ON is nil, allow buffering of requests.\n\
4881 This is a noop on Win32 systems.\n\
4882 The optional second argument DISPLAY specifies which display to act on.\n\
4883 DISPLAY should be either a frame or a display name (a string).\n\
4884 If DISPLAY is omitted or nil, that stands for the selected frame's display.")
4886 Lisp_Object display
, on
;
4888 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4894 /* These are the win32 specialized functions */
4896 DEFUN ("win32-select-font", Fwin32_select_font
, Swin32_select_font
, 0, 1, 0,
4897 "This will display the Win32 font dialog and return an X font string corresponding to the selection.")
4901 FRAME_PTR f
= check_x_frame (frame
);
4906 bzero (&cf
, sizeof (cf
));
4908 cf
.lStructSize
= sizeof (cf
);
4909 cf
.hwndOwner
= FRAME_WIN32_WINDOW (f
);
4910 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
| CF_SCREENFONTS
;
4913 if (!ChooseFont (&cf
) || !win32_to_x_font (&lf
, buf
, 100))
4916 return build_string (buf
);
4922 /* The section below is built by the lisp expression at the top of the file,
4923 just above where these variables are declared. */
4924 /*&&& init symbols here &&&*/
4925 Qauto_raise
= intern ("auto-raise");
4926 staticpro (&Qauto_raise
);
4927 Qauto_lower
= intern ("auto-lower");
4928 staticpro (&Qauto_lower
);
4929 Qbackground_color
= intern ("background-color");
4930 staticpro (&Qbackground_color
);
4931 Qbar
= intern ("bar");
4933 Qborder_color
= intern ("border-color");
4934 staticpro (&Qborder_color
);
4935 Qborder_width
= intern ("border-width");
4936 staticpro (&Qborder_width
);
4937 Qbox
= intern ("box");
4939 Qcursor_color
= intern ("cursor-color");
4940 staticpro (&Qcursor_color
);
4941 Qcursor_type
= intern ("cursor-type");
4942 staticpro (&Qcursor_type
);
4943 Qforeground_color
= intern ("foreground-color");
4944 staticpro (&Qforeground_color
);
4945 Qgeometry
= intern ("geometry");
4946 staticpro (&Qgeometry
);
4947 Qicon_left
= intern ("icon-left");
4948 staticpro (&Qicon_left
);
4949 Qicon_top
= intern ("icon-top");
4950 staticpro (&Qicon_top
);
4951 Qicon_type
= intern ("icon-type");
4952 staticpro (&Qicon_type
);
4953 Qicon_name
= intern ("icon-name");
4954 staticpro (&Qicon_name
);
4955 Qinternal_border_width
= intern ("internal-border-width");
4956 staticpro (&Qinternal_border_width
);
4957 Qleft
= intern ("left");
4959 Qmouse_color
= intern ("mouse-color");
4960 staticpro (&Qmouse_color
);
4961 Qnone
= intern ("none");
4963 Qparent_id
= intern ("parent-id");
4964 staticpro (&Qparent_id
);
4965 Qscroll_bar_width
= intern ("scroll-bar-width");
4966 staticpro (&Qscroll_bar_width
);
4967 Qsuppress_icon
= intern ("suppress-icon");
4968 staticpro (&Qsuppress_icon
);
4969 Qtop
= intern ("top");
4971 Qundefined_color
= intern ("undefined-color");
4972 staticpro (&Qundefined_color
);
4973 Qvertical_scroll_bars
= intern ("vertical-scroll-bars");
4974 staticpro (&Qvertical_scroll_bars
);
4975 Qvisibility
= intern ("visibility");
4976 staticpro (&Qvisibility
);
4977 Qwindow_id
= intern ("window-id");
4978 staticpro (&Qwindow_id
);
4979 Qx_frame_parameter
= intern ("x-frame-parameter");
4980 staticpro (&Qx_frame_parameter
);
4981 Qx_resource_name
= intern ("x-resource-name");
4982 staticpro (&Qx_resource_name
);
4983 Quser_position
= intern ("user-position");
4984 staticpro (&Quser_position
);
4985 Quser_size
= intern ("user-size");
4986 staticpro (&Quser_size
);
4987 Qdisplay
= intern ("display");
4988 staticpro (&Qdisplay
);
4989 /* This is the end of symbol initialization. */
4991 Fput (Qundefined_color
, Qerror_conditions
,
4992 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
4993 Fput (Qundefined_color
, Qerror_message
,
4994 build_string ("Undefined color"));
4996 DEFVAR_LISP ("win32-color-map", &Vwin32_color_map
,
4997 "A array of color name mappings for windows.");
4998 Vwin32_color_map
= Qnil
;
5000 DEFVAR_LISP ("win32-pass-alt-to-system", &Vwin32_pass_alt_to_system
,
5001 "Non-nil if alt key presses are passed on to Windows.\n\
5002 When non-nil, for example, alt pressed and released and then space will\n\
5003 open the System menu. When nil, Emacs silently swallows alt key events.");
5004 Vwin32_pass_alt_to_system
= Qnil
;
5006 DEFVAR_LISP ("win32-alt-is-meta", &Vwin32_alt_is_meta
,
5007 "Non-nil if the alt key is to be considered the same as the meta key.\n\
5008 When nil, Emacs will translate the alt key to the Alt modifier, and not Meta.");
5009 Vwin32_alt_is_meta
= Qt
;
5011 DEFVAR_LISP ("win32-pass-optional-keys-to-system",
5012 &Vwin32_pass_optional_keys_to_system
,
5013 "Non-nil if the 'optional' keys (left window, right window,\n\
5014 and application keys) are passed on to Windows.");
5015 Vwin32_pass_optional_keys_to_system
= Qnil
;
5017 DEFVAR_LISP ("win32-enable-italics", &Vwin32_enable_italics
,
5018 "Non-nil enables selection of artificially italicized fonts.");
5019 Vwin32_enable_italics
= Qnil
;
5021 DEFVAR_LISP ("win32-enable-palette", &Vwin32_enable_palette
,
5022 "Non-nil enables Windows palette management to map colors exactly.");
5023 Vwin32_enable_palette
= Qt
;
5025 DEFVAR_INT ("win32-mouse-button-tolerance",
5026 &Vwin32_mouse_button_tolerance
,
5027 "Analogue of double click interval for faking middle mouse events.\n\
5028 The value is the minimum time in milliseconds that must elapse between\n\
5029 left/right button down events before they are considered distinct events.\n\
5030 If both mouse buttons are depressed within this interval, a middle mouse\n\
5031 button down event is generated instead.");
5032 XSETINT (Vwin32_mouse_button_tolerance
, GetDoubleClickTime () / 2);
5034 DEFVAR_INT ("win32-mouse-move-interval",
5035 &Vwin32_mouse_move_interval
,
5036 "Minimum interval between mouse move events.\n\
5037 The value is the minimum time in milliseconds that must elapse between\n\
5038 successive mouse move (or scroll bar drag) events before they are\n\
5039 reported as lisp events.");
5040 XSETINT (Vwin32_mouse_move_interval
, 50);
5042 init_x_parm_symbols ();
5044 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path
,
5045 "List of directories to search for bitmap files for win32.");
5046 Vx_bitmap_file_path
= decode_env_path ((char *) 0, "PATH");
5048 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape
,
5049 "The shape of the pointer when over text.\n\
5050 Changing the value does not affect existing frames\n\
5051 unless you set the mouse color.");
5052 Vx_pointer_shape
= Qnil
;
5054 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
5055 "The name Emacs uses to look up resources; for internal use only.\n\
5056 `x-get-resource' uses this as the first component of the instance name\n\
5057 when requesting resource values.\n\
5058 Emacs initially sets `x-resource-name' to the name under which Emacs\n\
5059 was invoked, or to the value specified with the `-name' or `-rn'\n\
5060 switches, if present.");
5061 Vx_resource_name
= Qnil
;
5063 Vx_nontext_pointer_shape
= Qnil
;
5065 Vx_mode_pointer_shape
= Qnil
;
5067 DEFVAR_INT ("x-sensitive-text-pointer-shape",
5068 &Vx_sensitive_text_pointer_shape
,
5069 "The shape of the pointer when over mouse-sensitive text.\n\
5070 This variable takes effect when you create a new frame\n\
5071 or when you set the mouse color.");
5072 Vx_sensitive_text_pointer_shape
= Qnil
;
5074 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
5075 "A string indicating the foreground color of the cursor box.");
5076 Vx_cursor_fore_pixel
= Qnil
;
5078 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
5079 "Non-nil if no window manager is in use.\n\
5080 Emacs doesn't try to figure this out; this is always nil\n\
5081 unless you set it to something else.");
5082 /* We don't have any way to find this out, so set it to nil
5083 and maybe the user would like to set it to t. */
5084 Vx_no_window_manager
= Qnil
;
5086 defsubr (&Sx_get_resource
);
5087 defsubr (&Sx_list_fonts
);
5088 defsubr (&Sx_display_color_p
);
5089 defsubr (&Sx_display_grayscale_p
);
5090 defsubr (&Sx_color_defined_p
);
5091 defsubr (&Sx_color_values
);
5092 defsubr (&Sx_server_max_request_size
);
5093 defsubr (&Sx_server_vendor
);
5094 defsubr (&Sx_server_version
);
5095 defsubr (&Sx_display_pixel_width
);
5096 defsubr (&Sx_display_pixel_height
);
5097 defsubr (&Sx_display_mm_width
);
5098 defsubr (&Sx_display_mm_height
);
5099 defsubr (&Sx_display_screens
);
5100 defsubr (&Sx_display_planes
);
5101 defsubr (&Sx_display_color_cells
);
5102 defsubr (&Sx_display_visual_class
);
5103 defsubr (&Sx_display_backing_store
);
5104 defsubr (&Sx_display_save_under
);
5105 defsubr (&Sx_parse_geometry
);
5106 defsubr (&Sx_create_frame
);
5107 defsubr (&Sfocus_frame
);
5108 defsubr (&Sunfocus_frame
);
5109 defsubr (&Sx_open_connection
);
5110 defsubr (&Sx_close_connection
);
5111 defsubr (&Sx_display_list
);
5112 defsubr (&Sx_synchronize
);
5114 /* Win32 specific functions */
5116 defsubr (&Swin32_select_font
);
5117 defsubr (&Swin32_define_rgb_color
);
5118 defsubr (&Swin32_default_color_map
);
5119 defsubr (&Swin32_load_color_file
);
5128 button
= MessageBox (NULL
,
5129 "A fatal error has occurred!\n\n"
5130 "Select Abort to exit, Retry to debug, Ignore to continue",
5131 "Emacs Abort Dialog",
5132 MB_ICONEXCLAMATION
| MB_TASKMODAL
5133 | MB_SETFOREGROUND
| MB_ABORTRETRYIGNORE
);