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. */
590 Lisp_Object width
, height
;
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 width
= height
= top
= left
= Qunbound
;
626 icon_left
= icon_top
= Qunbound
;
628 /* Now process them in reverse of specified order. */
629 for (i
--; i
>= 0; i
--)
631 Lisp_Object prop
, val
;
636 if (EQ (prop
, Qwidth
))
638 else if (EQ (prop
, Qheight
))
640 else if (EQ (prop
, Qtop
))
642 else if (EQ (prop
, Qleft
))
644 else if (EQ (prop
, Qicon_top
))
646 else if (EQ (prop
, Qicon_left
))
650 register Lisp_Object param_index
, old_value
;
652 param_index
= Fget (prop
, Qx_frame_parameter
);
653 old_value
= get_frame_param (f
, prop
);
654 store_frame_param (f
, prop
, val
);
655 if (NATNUMP (param_index
)
656 && (XFASTINT (param_index
)
657 < sizeof (x_frame_parms
)/sizeof (x_frame_parms
[0])))
658 (*x_frame_parms
[XINT (param_index
)].setter
)(f
, val
, old_value
);
662 /* Don't die if just one of these was set. */
663 if (EQ (left
, Qunbound
))
666 if (f
->output_data
.win32
->left_pos
< 0)
667 left
= Fcons (Qplus
, Fcons (make_number (f
->output_data
.win32
->left_pos
), Qnil
));
669 XSETINT (left
, f
->output_data
.win32
->left_pos
);
671 if (EQ (top
, Qunbound
))
674 if (f
->output_data
.win32
->top_pos
< 0)
675 top
= Fcons (Qplus
, Fcons (make_number (f
->output_data
.win32
->top_pos
), Qnil
));
677 XSETINT (top
, f
->output_data
.win32
->top_pos
);
680 /* If one of the icon positions was not set, preserve or default it. */
681 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
683 icon_left_no_change
= 1;
684 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
685 if (NILP (icon_left
))
686 XSETINT (icon_left
, 0);
688 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
690 icon_top_no_change
= 1;
691 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
693 XSETINT (icon_top
, 0);
696 /* Don't die if just one of these was set. */
697 if (EQ (width
, Qunbound
))
698 XSETINT (width
, FRAME_WIDTH (f
));
699 if (EQ (height
, Qunbound
))
700 XSETINT (height
, FRAME_HEIGHT (f
));
702 /* Don't set these parameters unless they've been explicitly
703 specified. The window might be mapped or resized while we're in
704 this function, and we don't want to override that unless the lisp
705 code has asked for it.
707 Don't set these parameters unless they actually differ from the
708 window's current parameters; the window may not actually exist
713 check_frame_size (f
, &height
, &width
);
715 XSETFRAME (frame
, f
);
717 if ((NUMBERP (width
) && XINT (width
) != FRAME_WIDTH (f
))
718 || (NUMBERP (height
) && XINT (height
) != FRAME_HEIGHT (f
)))
719 Fset_frame_size (frame
, width
, height
);
721 if ((!NILP (left
) || !NILP (top
))
722 && ! (left_no_change
&& top_no_change
)
723 && ! (NUMBERP (left
) && XINT (left
) == f
->output_data
.win32
->left_pos
724 && NUMBERP (top
) && XINT (top
) == f
->output_data
.win32
->top_pos
))
729 /* Record the signs. */
730 f
->output_data
.win32
->size_hint_flags
&= ~ (XNegative
| YNegative
);
731 if (EQ (left
, Qminus
))
732 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
733 else if (INTEGERP (left
))
735 leftpos
= XINT (left
);
737 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
739 else if (CONSP (left
) && EQ (XCONS (left
)->car
, Qminus
)
740 && CONSP (XCONS (left
)->cdr
)
741 && INTEGERP (XCONS (XCONS (left
)->cdr
)->car
))
743 leftpos
= - XINT (XCONS (XCONS (left
)->cdr
)->car
);
744 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
746 else if (CONSP (left
) && EQ (XCONS (left
)->car
, Qplus
)
747 && CONSP (XCONS (left
)->cdr
)
748 && INTEGERP (XCONS (XCONS (left
)->cdr
)->car
))
750 leftpos
= XINT (XCONS (XCONS (left
)->cdr
)->car
);
753 if (EQ (top
, Qminus
))
754 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
755 else if (INTEGERP (top
))
759 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
761 else if (CONSP (top
) && EQ (XCONS (top
)->car
, Qminus
)
762 && CONSP (XCONS (top
)->cdr
)
763 && INTEGERP (XCONS (XCONS (top
)->cdr
)->car
))
765 toppos
= - XINT (XCONS (XCONS (top
)->cdr
)->car
);
766 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
768 else if (CONSP (top
) && EQ (XCONS (top
)->car
, Qplus
)
769 && CONSP (XCONS (top
)->cdr
)
770 && INTEGERP (XCONS (XCONS (top
)->cdr
)->car
))
772 toppos
= XINT (XCONS (XCONS (top
)->cdr
)->car
);
776 /* Store the numeric value of the position. */
777 f
->output_data
.win32
->top_pos
= toppos
;
778 f
->output_data
.win32
->left_pos
= leftpos
;
780 f
->output_data
.win32
->win_gravity
= NorthWestGravity
;
782 /* Actually set that position, and convert to absolute. */
783 x_set_offset (f
, leftpos
, toppos
, -1);
786 if ((!NILP (icon_left
) || !NILP (icon_top
))
787 && ! (icon_left_no_change
&& icon_top_no_change
))
788 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
792 /* Store the screen positions of frame F into XPTR and YPTR.
793 These are the positions of the containing window manager window,
794 not Emacs's own window. */
797 x_real_positions (f
, xptr
, yptr
)
806 GetClientRect(FRAME_WIN32_WINDOW(f
), &rect
);
807 AdjustWindowRect(&rect
, f
->output_data
.win32
->dwStyle
, FRAME_EXTERNAL_MENU_BAR(f
));
813 ClientToScreen (FRAME_WIN32_WINDOW(f
), &pt
);
819 /* Insert a description of internally-recorded parameters of frame X
820 into the parameter alist *ALISTPTR that is to be given to the user.
821 Only parameters that are specific to Win32
822 and whose values are not correctly recorded in the frame's
823 param_alist need to be considered here. */
825 x_report_frame_params (f
, alistptr
)
827 Lisp_Object
*alistptr
;
832 /* Represent negative positions (off the top or left screen edge)
833 in a way that Fmodify_frame_parameters will understand correctly. */
834 XSETINT (tem
, f
->output_data
.win32
->left_pos
);
835 if (f
->output_data
.win32
->left_pos
>= 0)
836 store_in_alist (alistptr
, Qleft
, tem
);
838 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
840 XSETINT (tem
, f
->output_data
.win32
->top_pos
);
841 if (f
->output_data
.win32
->top_pos
>= 0)
842 store_in_alist (alistptr
, Qtop
, tem
);
844 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
846 store_in_alist (alistptr
, Qborder_width
,
847 make_number (f
->output_data
.win32
->border_width
));
848 store_in_alist (alistptr
, Qinternal_border_width
,
849 make_number (f
->output_data
.win32
->internal_border_width
));
850 sprintf (buf
, "%ld", (long) FRAME_WIN32_WINDOW (f
));
851 store_in_alist (alistptr
, Qwindow_id
,
853 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
854 FRAME_SAMPLE_VISIBILITY (f
);
855 store_in_alist (alistptr
, Qvisibility
,
856 (FRAME_VISIBLE_P (f
) ? Qt
857 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
858 store_in_alist (alistptr
, Qdisplay
,
859 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->car
);
863 DEFUN ("win32-define-rgb-color", Fwin32_define_rgb_color
, Swin32_define_rgb_color
, 4, 4, 0,
864 "Convert RGB numbers to a windows color reference and associate with NAME (a string).\n\
865 This adds or updates a named color to win32-color-map, making it available for use.\n\
866 The original entry's RGB ref is returned, or nil if the entry is new.")
867 (red
, green
, blue
, name
)
868 Lisp_Object red
, green
, blue
, name
;
871 Lisp_Object oldrgb
= Qnil
;
874 CHECK_NUMBER (red
, 0);
875 CHECK_NUMBER (green
, 0);
876 CHECK_NUMBER (blue
, 0);
877 CHECK_STRING (name
, 0);
879 XSET (rgb
, Lisp_Int
, RGB(XUINT (red
), XUINT (green
), XUINT (blue
)));
883 /* replace existing entry in win32-color-map or add new entry. */
884 entry
= Fassoc (name
, Vwin32_color_map
);
887 entry
= Fcons (name
, rgb
);
888 Vwin32_color_map
= Fcons (entry
, Vwin32_color_map
);
892 oldrgb
= Fcdr (entry
);
893 Fsetcdr (entry
, rgb
);
901 DEFUN ("win32-load-color-file", Fwin32_load_color_file
, Swin32_load_color_file
, 1, 1, 0,
902 "Create an alist of color entries from an external file (ie. rgb.txt).\n\
903 Assign this value to win32-color-map to replace the existing color map.\n\
905 The file should define one named RGB color per line like so:\
907 where R,G,B are numbers between 0 and 255 and name is an arbitrary string.")
909 Lisp_Object filename
;
912 Lisp_Object cmap
= Qnil
;
915 CHECK_STRING (filename
, 0);
916 abspath
= Fexpand_file_name (filename
, Qnil
);
918 fp
= fopen (XSTRING (filename
)->data
, "rt");
922 int red
, green
, blue
;
927 while (fgets (buf
, sizeof (buf
), fp
) != NULL
) {
928 if (sscanf (buf
, "%u %u %u %n", &red
, &green
, &blue
, &num
) == 3)
930 char *name
= buf
+ num
;
931 num
= strlen (name
) - 1;
932 if (name
[num
] == '\n')
934 cmap
= Fcons (Fcons (build_string (name
),
935 make_number (RGB (red
, green
, blue
))),
947 /* The default colors for the win32 color map */
948 typedef struct colormap_t
954 colormap_t win32_color_map
[] =
956 {"snow" , PALETTERGB (255,250,250)},
957 {"ghost white" , PALETTERGB (248,248,255)},
958 {"GhostWhite" , PALETTERGB (248,248,255)},
959 {"white smoke" , PALETTERGB (245,245,245)},
960 {"WhiteSmoke" , PALETTERGB (245,245,245)},
961 {"gainsboro" , PALETTERGB (220,220,220)},
962 {"floral white" , PALETTERGB (255,250,240)},
963 {"FloralWhite" , PALETTERGB (255,250,240)},
964 {"old lace" , PALETTERGB (253,245,230)},
965 {"OldLace" , PALETTERGB (253,245,230)},
966 {"linen" , PALETTERGB (250,240,230)},
967 {"antique white" , PALETTERGB (250,235,215)},
968 {"AntiqueWhite" , PALETTERGB (250,235,215)},
969 {"papaya whip" , PALETTERGB (255,239,213)},
970 {"PapayaWhip" , PALETTERGB (255,239,213)},
971 {"blanched almond" , PALETTERGB (255,235,205)},
972 {"BlanchedAlmond" , PALETTERGB (255,235,205)},
973 {"bisque" , PALETTERGB (255,228,196)},
974 {"peach puff" , PALETTERGB (255,218,185)},
975 {"PeachPuff" , PALETTERGB (255,218,185)},
976 {"navajo white" , PALETTERGB (255,222,173)},
977 {"NavajoWhite" , PALETTERGB (255,222,173)},
978 {"moccasin" , PALETTERGB (255,228,181)},
979 {"cornsilk" , PALETTERGB (255,248,220)},
980 {"ivory" , PALETTERGB (255,255,240)},
981 {"lemon chiffon" , PALETTERGB (255,250,205)},
982 {"LemonChiffon" , PALETTERGB (255,250,205)},
983 {"seashell" , PALETTERGB (255,245,238)},
984 {"honeydew" , PALETTERGB (240,255,240)},
985 {"mint cream" , PALETTERGB (245,255,250)},
986 {"MintCream" , PALETTERGB (245,255,250)},
987 {"azure" , PALETTERGB (240,255,255)},
988 {"alice blue" , PALETTERGB (240,248,255)},
989 {"AliceBlue" , PALETTERGB (240,248,255)},
990 {"lavender" , PALETTERGB (230,230,250)},
991 {"lavender blush" , PALETTERGB (255,240,245)},
992 {"LavenderBlush" , PALETTERGB (255,240,245)},
993 {"misty rose" , PALETTERGB (255,228,225)},
994 {"MistyRose" , PALETTERGB (255,228,225)},
995 {"white" , PALETTERGB (255,255,255)},
996 {"black" , PALETTERGB ( 0, 0, 0)},
997 {"dark slate gray" , PALETTERGB ( 47, 79, 79)},
998 {"DarkSlateGray" , PALETTERGB ( 47, 79, 79)},
999 {"dark slate grey" , PALETTERGB ( 47, 79, 79)},
1000 {"DarkSlateGrey" , PALETTERGB ( 47, 79, 79)},
1001 {"dim gray" , PALETTERGB (105,105,105)},
1002 {"DimGray" , PALETTERGB (105,105,105)},
1003 {"dim grey" , PALETTERGB (105,105,105)},
1004 {"DimGrey" , PALETTERGB (105,105,105)},
1005 {"slate gray" , PALETTERGB (112,128,144)},
1006 {"SlateGray" , PALETTERGB (112,128,144)},
1007 {"slate grey" , PALETTERGB (112,128,144)},
1008 {"SlateGrey" , PALETTERGB (112,128,144)},
1009 {"light slate gray" , PALETTERGB (119,136,153)},
1010 {"LightSlateGray" , PALETTERGB (119,136,153)},
1011 {"light slate grey" , PALETTERGB (119,136,153)},
1012 {"LightSlateGrey" , PALETTERGB (119,136,153)},
1013 {"gray" , PALETTERGB (190,190,190)},
1014 {"grey" , PALETTERGB (190,190,190)},
1015 {"light grey" , PALETTERGB (211,211,211)},
1016 {"LightGrey" , PALETTERGB (211,211,211)},
1017 {"light gray" , PALETTERGB (211,211,211)},
1018 {"LightGray" , PALETTERGB (211,211,211)},
1019 {"midnight blue" , PALETTERGB ( 25, 25,112)},
1020 {"MidnightBlue" , PALETTERGB ( 25, 25,112)},
1021 {"navy" , PALETTERGB ( 0, 0,128)},
1022 {"navy blue" , PALETTERGB ( 0, 0,128)},
1023 {"NavyBlue" , PALETTERGB ( 0, 0,128)},
1024 {"cornflower blue" , PALETTERGB (100,149,237)},
1025 {"CornflowerBlue" , PALETTERGB (100,149,237)},
1026 {"dark slate blue" , PALETTERGB ( 72, 61,139)},
1027 {"DarkSlateBlue" , PALETTERGB ( 72, 61,139)},
1028 {"slate blue" , PALETTERGB (106, 90,205)},
1029 {"SlateBlue" , PALETTERGB (106, 90,205)},
1030 {"medium slate blue" , PALETTERGB (123,104,238)},
1031 {"MediumSlateBlue" , PALETTERGB (123,104,238)},
1032 {"light slate blue" , PALETTERGB (132,112,255)},
1033 {"LightSlateBlue" , PALETTERGB (132,112,255)},
1034 {"medium blue" , PALETTERGB ( 0, 0,205)},
1035 {"MediumBlue" , PALETTERGB ( 0, 0,205)},
1036 {"royal blue" , PALETTERGB ( 65,105,225)},
1037 {"RoyalBlue" , PALETTERGB ( 65,105,225)},
1038 {"blue" , PALETTERGB ( 0, 0,255)},
1039 {"dodger blue" , PALETTERGB ( 30,144,255)},
1040 {"DodgerBlue" , PALETTERGB ( 30,144,255)},
1041 {"deep sky blue" , PALETTERGB ( 0,191,255)},
1042 {"DeepSkyBlue" , PALETTERGB ( 0,191,255)},
1043 {"sky blue" , PALETTERGB (135,206,235)},
1044 {"SkyBlue" , PALETTERGB (135,206,235)},
1045 {"light sky blue" , PALETTERGB (135,206,250)},
1046 {"LightSkyBlue" , PALETTERGB (135,206,250)},
1047 {"steel blue" , PALETTERGB ( 70,130,180)},
1048 {"SteelBlue" , PALETTERGB ( 70,130,180)},
1049 {"light steel blue" , PALETTERGB (176,196,222)},
1050 {"LightSteelBlue" , PALETTERGB (176,196,222)},
1051 {"light blue" , PALETTERGB (173,216,230)},
1052 {"LightBlue" , PALETTERGB (173,216,230)},
1053 {"powder blue" , PALETTERGB (176,224,230)},
1054 {"PowderBlue" , PALETTERGB (176,224,230)},
1055 {"pale turquoise" , PALETTERGB (175,238,238)},
1056 {"PaleTurquoise" , PALETTERGB (175,238,238)},
1057 {"dark turquoise" , PALETTERGB ( 0,206,209)},
1058 {"DarkTurquoise" , PALETTERGB ( 0,206,209)},
1059 {"medium turquoise" , PALETTERGB ( 72,209,204)},
1060 {"MediumTurquoise" , PALETTERGB ( 72,209,204)},
1061 {"turquoise" , PALETTERGB ( 64,224,208)},
1062 {"cyan" , PALETTERGB ( 0,255,255)},
1063 {"light cyan" , PALETTERGB (224,255,255)},
1064 {"LightCyan" , PALETTERGB (224,255,255)},
1065 {"cadet blue" , PALETTERGB ( 95,158,160)},
1066 {"CadetBlue" , PALETTERGB ( 95,158,160)},
1067 {"medium aquamarine" , PALETTERGB (102,205,170)},
1068 {"MediumAquamarine" , PALETTERGB (102,205,170)},
1069 {"aquamarine" , PALETTERGB (127,255,212)},
1070 {"dark green" , PALETTERGB ( 0,100, 0)},
1071 {"DarkGreen" , PALETTERGB ( 0,100, 0)},
1072 {"dark olive green" , PALETTERGB ( 85,107, 47)},
1073 {"DarkOliveGreen" , PALETTERGB ( 85,107, 47)},
1074 {"dark sea green" , PALETTERGB (143,188,143)},
1075 {"DarkSeaGreen" , PALETTERGB (143,188,143)},
1076 {"sea green" , PALETTERGB ( 46,139, 87)},
1077 {"SeaGreen" , PALETTERGB ( 46,139, 87)},
1078 {"medium sea green" , PALETTERGB ( 60,179,113)},
1079 {"MediumSeaGreen" , PALETTERGB ( 60,179,113)},
1080 {"light sea green" , PALETTERGB ( 32,178,170)},
1081 {"LightSeaGreen" , PALETTERGB ( 32,178,170)},
1082 {"pale green" , PALETTERGB (152,251,152)},
1083 {"PaleGreen" , PALETTERGB (152,251,152)},
1084 {"spring green" , PALETTERGB ( 0,255,127)},
1085 {"SpringGreen" , PALETTERGB ( 0,255,127)},
1086 {"lawn green" , PALETTERGB (124,252, 0)},
1087 {"LawnGreen" , PALETTERGB (124,252, 0)},
1088 {"green" , PALETTERGB ( 0,255, 0)},
1089 {"chartreuse" , PALETTERGB (127,255, 0)},
1090 {"medium spring green" , PALETTERGB ( 0,250,154)},
1091 {"MediumSpringGreen" , PALETTERGB ( 0,250,154)},
1092 {"green yellow" , PALETTERGB (173,255, 47)},
1093 {"GreenYellow" , PALETTERGB (173,255, 47)},
1094 {"lime green" , PALETTERGB ( 50,205, 50)},
1095 {"LimeGreen" , PALETTERGB ( 50,205, 50)},
1096 {"yellow green" , PALETTERGB (154,205, 50)},
1097 {"YellowGreen" , PALETTERGB (154,205, 50)},
1098 {"forest green" , PALETTERGB ( 34,139, 34)},
1099 {"ForestGreen" , PALETTERGB ( 34,139, 34)},
1100 {"olive drab" , PALETTERGB (107,142, 35)},
1101 {"OliveDrab" , PALETTERGB (107,142, 35)},
1102 {"dark khaki" , PALETTERGB (189,183,107)},
1103 {"DarkKhaki" , PALETTERGB (189,183,107)},
1104 {"khaki" , PALETTERGB (240,230,140)},
1105 {"pale goldenrod" , PALETTERGB (238,232,170)},
1106 {"PaleGoldenrod" , PALETTERGB (238,232,170)},
1107 {"light goldenrod yellow" , PALETTERGB (250,250,210)},
1108 {"LightGoldenrodYellow" , PALETTERGB (250,250,210)},
1109 {"light yellow" , PALETTERGB (255,255,224)},
1110 {"LightYellow" , PALETTERGB (255,255,224)},
1111 {"yellow" , PALETTERGB (255,255, 0)},
1112 {"gold" , PALETTERGB (255,215, 0)},
1113 {"light goldenrod" , PALETTERGB (238,221,130)},
1114 {"LightGoldenrod" , PALETTERGB (238,221,130)},
1115 {"goldenrod" , PALETTERGB (218,165, 32)},
1116 {"dark goldenrod" , PALETTERGB (184,134, 11)},
1117 {"DarkGoldenrod" , PALETTERGB (184,134, 11)},
1118 {"rosy brown" , PALETTERGB (188,143,143)},
1119 {"RosyBrown" , PALETTERGB (188,143,143)},
1120 {"indian red" , PALETTERGB (205, 92, 92)},
1121 {"IndianRed" , PALETTERGB (205, 92, 92)},
1122 {"saddle brown" , PALETTERGB (139, 69, 19)},
1123 {"SaddleBrown" , PALETTERGB (139, 69, 19)},
1124 {"sienna" , PALETTERGB (160, 82, 45)},
1125 {"peru" , PALETTERGB (205,133, 63)},
1126 {"burlywood" , PALETTERGB (222,184,135)},
1127 {"beige" , PALETTERGB (245,245,220)},
1128 {"wheat" , PALETTERGB (245,222,179)},
1129 {"sandy brown" , PALETTERGB (244,164, 96)},
1130 {"SandyBrown" , PALETTERGB (244,164, 96)},
1131 {"tan" , PALETTERGB (210,180,140)},
1132 {"chocolate" , PALETTERGB (210,105, 30)},
1133 {"firebrick" , PALETTERGB (178,34, 34)},
1134 {"brown" , PALETTERGB (165,42, 42)},
1135 {"dark salmon" , PALETTERGB (233,150,122)},
1136 {"DarkSalmon" , PALETTERGB (233,150,122)},
1137 {"salmon" , PALETTERGB (250,128,114)},
1138 {"light salmon" , PALETTERGB (255,160,122)},
1139 {"LightSalmon" , PALETTERGB (255,160,122)},
1140 {"orange" , PALETTERGB (255,165, 0)},
1141 {"dark orange" , PALETTERGB (255,140, 0)},
1142 {"DarkOrange" , PALETTERGB (255,140, 0)},
1143 {"coral" , PALETTERGB (255,127, 80)},
1144 {"light coral" , PALETTERGB (240,128,128)},
1145 {"LightCoral" , PALETTERGB (240,128,128)},
1146 {"tomato" , PALETTERGB (255, 99, 71)},
1147 {"orange red" , PALETTERGB (255, 69, 0)},
1148 {"OrangeRed" , PALETTERGB (255, 69, 0)},
1149 {"red" , PALETTERGB (255, 0, 0)},
1150 {"hot pink" , PALETTERGB (255,105,180)},
1151 {"HotPink" , PALETTERGB (255,105,180)},
1152 {"deep pink" , PALETTERGB (255, 20,147)},
1153 {"DeepPink" , PALETTERGB (255, 20,147)},
1154 {"pink" , PALETTERGB (255,192,203)},
1155 {"light pink" , PALETTERGB (255,182,193)},
1156 {"LightPink" , PALETTERGB (255,182,193)},
1157 {"pale violet red" , PALETTERGB (219,112,147)},
1158 {"PaleVioletRed" , PALETTERGB (219,112,147)},
1159 {"maroon" , PALETTERGB (176, 48, 96)},
1160 {"medium violet red" , PALETTERGB (199, 21,133)},
1161 {"MediumVioletRed" , PALETTERGB (199, 21,133)},
1162 {"violet red" , PALETTERGB (208, 32,144)},
1163 {"VioletRed" , PALETTERGB (208, 32,144)},
1164 {"magenta" , PALETTERGB (255, 0,255)},
1165 {"violet" , PALETTERGB (238,130,238)},
1166 {"plum" , PALETTERGB (221,160,221)},
1167 {"orchid" , PALETTERGB (218,112,214)},
1168 {"medium orchid" , PALETTERGB (186, 85,211)},
1169 {"MediumOrchid" , PALETTERGB (186, 85,211)},
1170 {"dark orchid" , PALETTERGB (153, 50,204)},
1171 {"DarkOrchid" , PALETTERGB (153, 50,204)},
1172 {"dark violet" , PALETTERGB (148, 0,211)},
1173 {"DarkViolet" , PALETTERGB (148, 0,211)},
1174 {"blue violet" , PALETTERGB (138, 43,226)},
1175 {"BlueViolet" , PALETTERGB (138, 43,226)},
1176 {"purple" , PALETTERGB (160, 32,240)},
1177 {"medium purple" , PALETTERGB (147,112,219)},
1178 {"MediumPurple" , PALETTERGB (147,112,219)},
1179 {"thistle" , PALETTERGB (216,191,216)},
1180 {"gray0" , PALETTERGB ( 0, 0, 0)},
1181 {"grey0" , PALETTERGB ( 0, 0, 0)},
1182 {"dark grey" , PALETTERGB (169,169,169)},
1183 {"DarkGrey" , PALETTERGB (169,169,169)},
1184 {"dark gray" , PALETTERGB (169,169,169)},
1185 {"DarkGray" , PALETTERGB (169,169,169)},
1186 {"dark blue" , PALETTERGB ( 0, 0,139)},
1187 {"DarkBlue" , PALETTERGB ( 0, 0,139)},
1188 {"dark cyan" , PALETTERGB ( 0,139,139)},
1189 {"DarkCyan" , PALETTERGB ( 0,139,139)},
1190 {"dark magenta" , PALETTERGB (139, 0,139)},
1191 {"DarkMagenta" , PALETTERGB (139, 0,139)},
1192 {"dark red" , PALETTERGB (139, 0, 0)},
1193 {"DarkRed" , PALETTERGB (139, 0, 0)},
1194 {"light green" , PALETTERGB (144,238,144)},
1195 {"LightGreen" , PALETTERGB (144,238,144)},
1198 DEFUN ("win32-default-color-map", Fwin32_default_color_map
, Swin32_default_color_map
,
1199 0, 0, 0, "Return the default color map.")
1203 colormap_t
*pc
= win32_color_map
;
1210 for (i
= 0; i
< sizeof (win32_color_map
) / sizeof (win32_color_map
[0]);
1212 cmap
= Fcons (Fcons (build_string (pc
->name
),
1213 make_number (pc
->colorref
)),
1222 win32_to_x_color (rgb
)
1227 CHECK_NUMBER (rgb
, 0);
1231 color
= Frassq (rgb
, Vwin32_color_map
);
1236 return (Fcar (color
));
1242 x_to_win32_color (colorname
)
1245 register Lisp_Object tail
, ret
= Qnil
;
1249 for (tail
= Vwin32_color_map
; !NILP (tail
); tail
= Fcdr (tail
))
1251 register Lisp_Object elt
, tem
;
1254 if (!CONSP (elt
)) continue;
1258 if (lstrcmpi (XSTRING (tem
)->data
, colorname
) == 0)
1260 ret
= XUINT(Fcdr (elt
));
1274 win32_regenerate_palette (FRAME_PTR f
)
1276 struct win32_palette_entry
* list
;
1277 LOGPALETTE
* log_palette
;
1278 HPALETTE new_palette
;
1281 /* don't bother trying to create palette if not supported */
1282 if (! FRAME_WIN32_DISPLAY_INFO (f
)->has_palette
)
1285 log_palette
= (LOGPALETTE
*)
1286 alloca (sizeof (LOGPALETTE
) +
1287 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
* sizeof (PALETTEENTRY
));
1288 log_palette
->palVersion
= 0x300;
1289 log_palette
->palNumEntries
= FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
;
1291 list
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1293 i
< FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
;
1294 i
++, list
= list
->next
)
1295 log_palette
->palPalEntry
[i
] = list
->entry
;
1297 new_palette
= CreatePalette (log_palette
);
1301 if (FRAME_WIN32_DISPLAY_INFO (f
)->palette
)
1302 DeleteObject (FRAME_WIN32_DISPLAY_INFO (f
)->palette
);
1303 FRAME_WIN32_DISPLAY_INFO (f
)->palette
= new_palette
;
1305 /* Realize display palette and garbage all frames. */
1306 release_frame_dc (f
, get_frame_dc (f
));
1311 #define WIN32_COLOR(pe) RGB (pe.peRed, pe.peGreen, pe.peBlue)
1312 #define SET_WIN32_COLOR(pe, color) \
1315 pe.peRed = GetRValue (color); \
1316 pe.peGreen = GetGValue (color); \
1317 pe.peBlue = GetBValue (color); \
1322 /* Keep these around in case we ever want to track color usage. */
1324 win32_map_color (FRAME_PTR f
, COLORREF color
)
1326 struct win32_palette_entry
* list
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1328 if (NILP (Vwin32_enable_palette
))
1331 /* check if color is already mapped */
1334 if (WIN32_COLOR (list
->entry
) == color
)
1342 /* not already mapped, so add to list and recreate Windows palette */
1343 list
= (struct win32_palette_entry
*)
1344 xmalloc (sizeof (struct win32_palette_entry
));
1345 SET_WIN32_COLOR (list
->entry
, color
);
1347 list
->next
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1348 FRAME_WIN32_DISPLAY_INFO (f
)->color_list
= list
;
1349 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
++;
1351 /* set flag that palette must be regenerated */
1352 FRAME_WIN32_DISPLAY_INFO (f
)->regen_palette
= TRUE
;
1356 win32_unmap_color (FRAME_PTR f
, COLORREF color
)
1358 struct win32_palette_entry
* list
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1359 struct win32_palette_entry
**prev
= &FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1361 if (NILP (Vwin32_enable_palette
))
1364 /* check if color is already mapped */
1367 if (WIN32_COLOR (list
->entry
) == color
)
1369 if (--list
->refcount
== 0)
1373 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
--;
1383 /* set flag that palette must be regenerated */
1384 FRAME_WIN32_DISPLAY_INFO (f
)->regen_palette
= TRUE
;
1388 /* Decide if color named COLOR is valid for the display associated with
1389 the selected frame; if so, return the rgb values in COLOR_DEF.
1390 If ALLOC is nonzero, allocate a new colormap cell. */
1393 defined_color (f
, color
, color_def
, alloc
)
1396 COLORREF
*color_def
;
1399 register Lisp_Object tem
;
1401 tem
= x_to_win32_color (color
);
1405 if (!NILP (Vwin32_enable_palette
))
1407 struct win32_palette_entry
* entry
=
1408 FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1409 struct win32_palette_entry
** prev
=
1410 &FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1412 /* check if color is already mapped */
1415 if (WIN32_COLOR (entry
->entry
) == XUINT (tem
))
1417 prev
= &entry
->next
;
1418 entry
= entry
->next
;
1421 if (entry
== NULL
&& alloc
)
1423 /* not already mapped, so add to list */
1424 entry
= (struct win32_palette_entry
*)
1425 xmalloc (sizeof (struct win32_palette_entry
));
1426 SET_WIN32_COLOR (entry
->entry
, XUINT (tem
));
1429 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
++;
1431 /* set flag that palette must be regenerated */
1432 FRAME_WIN32_DISPLAY_INFO (f
)->regen_palette
= TRUE
;
1435 /* Ensure COLORREF value is snapped to nearest color in (default)
1436 palette by simulating the PALETTERGB macro. This works whether
1437 or not the display device has a palette. */
1438 *color_def
= XUINT (tem
) | 0x2000000;
1447 /* Given a string ARG naming a color, compute a pixel value from it
1448 suitable for screen F.
1449 If F is not a color screen, return DEF (default) regardless of what
1453 x_decode_color (f
, arg
, def
)
1460 CHECK_STRING (arg
, 0);
1462 if (strcmp (XSTRING (arg
)->data
, "black") == 0)
1463 return BLACK_PIX_DEFAULT (f
);
1464 else if (strcmp (XSTRING (arg
)->data
, "white") == 0)
1465 return WHITE_PIX_DEFAULT (f
);
1467 if ((FRAME_WIN32_DISPLAY_INFO (f
)->n_planes
* FRAME_WIN32_DISPLAY_INFO (f
)->n_cbits
) == 1)
1470 /* defined_color is responsible for coping with failures
1471 by looking for a near-miss. */
1472 if (defined_color (f
, XSTRING (arg
)->data
, &cdef
, 1))
1475 /* defined_color failed; return an ultimate default. */
1479 /* Functions called only from `x_set_frame_param'
1480 to set individual parameters.
1482 If FRAME_WIN32_WINDOW (f) is 0,
1483 the frame is being created and its window does not exist yet.
1484 In that case, just record the parameter's new value
1485 in the standard place; do not attempt to change the window. */
1488 x_set_foreground_color (f
, arg
, oldval
)
1490 Lisp_Object arg
, oldval
;
1492 f
->output_data
.win32
->foreground_pixel
1493 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1495 if (FRAME_WIN32_WINDOW (f
) != 0)
1497 recompute_basic_faces (f
);
1498 if (FRAME_VISIBLE_P (f
))
1504 x_set_background_color (f
, arg
, oldval
)
1506 Lisp_Object arg
, oldval
;
1511 f
->output_data
.win32
->background_pixel
1512 = x_decode_color (f
, arg
, WHITE_PIX_DEFAULT (f
));
1514 if (FRAME_WIN32_WINDOW (f
) != 0)
1516 SetWindowLong (FRAME_WIN32_WINDOW (f
), WND_BACKGROUND_INDEX
, f
->output_data
.win32
->background_pixel
);
1518 recompute_basic_faces (f
);
1520 if (FRAME_VISIBLE_P (f
))
1526 x_set_mouse_color (f
, arg
, oldval
)
1528 Lisp_Object arg
, oldval
;
1531 Cursor cursor
, nontext_cursor
, mode_cursor
, cross_cursor
;
1535 if (!EQ (Qnil
, arg
))
1536 f
->output_data
.win32
->mouse_pixel
1537 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1538 mask_color
= f
->output_data
.win32
->background_pixel
;
1539 /* No invisible pointers. */
1540 if (mask_color
== f
->output_data
.win32
->mouse_pixel
1541 && mask_color
== f
->output_data
.win32
->background_pixel
)
1542 f
->output_data
.win32
->mouse_pixel
= f
->output_data
.win32
->foreground_pixel
;
1547 /* It's not okay to crash if the user selects a screwy cursor. */
1548 x_catch_errors (FRAME_WIN32_DISPLAY (f
));
1550 if (!EQ (Qnil
, Vx_pointer_shape
))
1552 CHECK_NUMBER (Vx_pointer_shape
, 0);
1553 cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XINT (Vx_pointer_shape
));
1556 cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_xterm
);
1557 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad text pointer cursor: %s");
1559 if (!EQ (Qnil
, Vx_nontext_pointer_shape
))
1561 CHECK_NUMBER (Vx_nontext_pointer_shape
, 0);
1562 nontext_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1563 XINT (Vx_nontext_pointer_shape
));
1566 nontext_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_left_ptr
);
1567 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad nontext pointer cursor: %s");
1569 if (!EQ (Qnil
, Vx_mode_pointer_shape
))
1571 CHECK_NUMBER (Vx_mode_pointer_shape
, 0);
1572 mode_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1573 XINT (Vx_mode_pointer_shape
));
1576 mode_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_xterm
);
1577 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad modeline pointer cursor: %s");
1579 if (!EQ (Qnil
, Vx_sensitive_text_pointer_shape
))
1581 CHECK_NUMBER (Vx_sensitive_text_pointer_shape
, 0);
1583 = XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1584 XINT (Vx_sensitive_text_pointer_shape
));
1587 cross_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_crosshair
);
1589 /* Check and report errors with the above calls. */
1590 x_check_errors (FRAME_WIN32_DISPLAY (f
), "can't set cursor shape: %s");
1591 x_uncatch_errors (FRAME_WIN32_DISPLAY (f
));
1594 XColor fore_color
, back_color
;
1596 fore_color
.pixel
= f
->output_data
.win32
->mouse_pixel
;
1597 back_color
.pixel
= mask_color
;
1598 XQueryColor (FRAME_WIN32_DISPLAY (f
),
1599 DefaultColormap (FRAME_WIN32_DISPLAY (f
),
1600 DefaultScreen (FRAME_WIN32_DISPLAY (f
))),
1602 XQueryColor (FRAME_WIN32_DISPLAY (f
),
1603 DefaultColormap (FRAME_WIN32_DISPLAY (f
),
1604 DefaultScreen (FRAME_WIN32_DISPLAY (f
))),
1606 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), cursor
,
1607 &fore_color
, &back_color
);
1608 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), nontext_cursor
,
1609 &fore_color
, &back_color
);
1610 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), mode_cursor
,
1611 &fore_color
, &back_color
);
1612 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), cross_cursor
,
1613 &fore_color
, &back_color
);
1616 if (FRAME_WIN32_WINDOW (f
) != 0)
1618 XDefineCursor (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
), cursor
);
1621 if (cursor
!= f
->output_data
.win32
->text_cursor
&& f
->output_data
.win32
->text_cursor
!= 0)
1622 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->text_cursor
);
1623 f
->output_data
.win32
->text_cursor
= cursor
;
1625 if (nontext_cursor
!= f
->output_data
.win32
->nontext_cursor
1626 && f
->output_data
.win32
->nontext_cursor
!= 0)
1627 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->nontext_cursor
);
1628 f
->output_data
.win32
->nontext_cursor
= nontext_cursor
;
1630 if (mode_cursor
!= f
->output_data
.win32
->modeline_cursor
1631 && f
->output_data
.win32
->modeline_cursor
!= 0)
1632 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->modeline_cursor
);
1633 f
->output_data
.win32
->modeline_cursor
= mode_cursor
;
1634 if (cross_cursor
!= f
->output_data
.win32
->cross_cursor
1635 && f
->output_data
.win32
->cross_cursor
!= 0)
1636 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->cross_cursor
);
1637 f
->output_data
.win32
->cross_cursor
= cross_cursor
;
1639 XFlush (FRAME_WIN32_DISPLAY (f
));
1645 x_set_cursor_color (f
, arg
, oldval
)
1647 Lisp_Object arg
, oldval
;
1649 unsigned long fore_pixel
;
1651 if (!EQ (Vx_cursor_fore_pixel
, Qnil
))
1652 fore_pixel
= x_decode_color (f
, Vx_cursor_fore_pixel
,
1653 WHITE_PIX_DEFAULT (f
));
1655 fore_pixel
= f
->output_data
.win32
->background_pixel
;
1656 f
->output_data
.win32
->cursor_pixel
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1658 /* Make sure that the cursor color differs from the background color. */
1659 if (f
->output_data
.win32
->cursor_pixel
== f
->output_data
.win32
->background_pixel
)
1661 f
->output_data
.win32
->cursor_pixel
= f
->output_data
.win32
->mouse_pixel
;
1662 if (f
->output_data
.win32
->cursor_pixel
== fore_pixel
)
1663 fore_pixel
= f
->output_data
.win32
->background_pixel
;
1665 f
->output_data
.win32
->cursor_foreground_pixel
= fore_pixel
;
1667 if (FRAME_WIN32_WINDOW (f
) != 0)
1669 if (FRAME_VISIBLE_P (f
))
1671 x_display_cursor (f
, 0);
1672 x_display_cursor (f
, 1);
1677 /* Set the border-color of frame F to value described by ARG.
1678 ARG can be a string naming a color.
1679 The border-color is used for the border that is drawn by the server.
1680 Note that this does not fully take effect if done before
1681 F has a window; it must be redone when the window is created. */
1684 x_set_border_color (f
, arg
, oldval
)
1686 Lisp_Object arg
, oldval
;
1691 CHECK_STRING (arg
, 0);
1692 str
= XSTRING (arg
)->data
;
1694 pix
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1696 x_set_border_pixel (f
, pix
);
1699 /* Set the border-color of frame F to pixel value PIX.
1700 Note that this does not fully take effect if done before
1703 x_set_border_pixel (f
, pix
)
1707 f
->output_data
.win32
->border_pixel
= pix
;
1709 if (FRAME_WIN32_WINDOW (f
) != 0 && f
->output_data
.win32
->border_width
> 0)
1711 if (FRAME_VISIBLE_P (f
))
1717 x_set_cursor_type (f
, arg
, oldval
)
1719 Lisp_Object arg
, oldval
;
1723 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
1724 f
->output_data
.win32
->cursor_width
= 2;
1726 else if (CONSP (arg
) && EQ (XCONS (arg
)->car
, Qbar
)
1727 && INTEGERP (XCONS (arg
)->cdr
))
1729 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
1730 f
->output_data
.win32
->cursor_width
= XINT (XCONS (arg
)->cdr
);
1733 /* Treat anything unknown as "box cursor".
1734 It was bad to signal an error; people have trouble fixing
1735 .Xdefaults with Emacs, when it has something bad in it. */
1736 FRAME_DESIRED_CURSOR (f
) = filled_box_cursor
;
1738 /* Make sure the cursor gets redrawn. This is overkill, but how
1739 often do people change cursor types? */
1740 update_mode_lines
++;
1744 x_set_icon_type (f
, arg
, oldval
)
1746 Lisp_Object arg
, oldval
;
1754 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1757 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1762 result
= x_text_icon (f
,
1763 (char *) XSTRING ((!NILP (f
->icon_name
)
1767 result
= x_bitmap_icon (f
, arg
);
1772 error ("No icon window available");
1775 /* If the window was unmapped (and its icon was mapped),
1776 the new icon is not mapped, so map the window in its stead. */
1777 if (FRAME_VISIBLE_P (f
))
1779 #ifdef USE_X_TOOLKIT
1780 XtPopup (f
->output_data
.win32
->widget
, XtGrabNone
);
1782 XMapWindow (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
));
1785 XFlush (FRAME_WIN32_DISPLAY (f
));
1790 /* Return non-nil if frame F wants a bitmap icon. */
1798 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
1800 return XCONS (tem
)->cdr
;
1806 x_set_icon_name (f
, arg
, oldval
)
1808 Lisp_Object arg
, oldval
;
1815 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1818 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1824 if (f
->output_data
.win32
->icon_bitmap
!= 0)
1829 result
= x_text_icon (f
,
1830 (char *) XSTRING ((!NILP (f
->icon_name
)
1837 error ("No icon window available");
1840 /* If the window was unmapped (and its icon was mapped),
1841 the new icon is not mapped, so map the window in its stead. */
1842 if (FRAME_VISIBLE_P (f
))
1844 #ifdef USE_X_TOOLKIT
1845 XtPopup (f
->output_data
.win32
->widget
, XtGrabNone
);
1847 XMapWindow (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
));
1850 XFlush (FRAME_WIN32_DISPLAY (f
));
1855 extern Lisp_Object
x_new_font ();
1858 x_set_font (f
, arg
, oldval
)
1860 Lisp_Object arg
, oldval
;
1864 CHECK_STRING (arg
, 1);
1867 result
= x_new_font (f
, XSTRING (arg
)->data
);
1870 if (EQ (result
, Qnil
))
1871 error ("Font \"%s\" is not defined", XSTRING (arg
)->data
);
1872 else if (EQ (result
, Qt
))
1873 error ("the characters of the given font have varying widths");
1874 else if (STRINGP (result
))
1876 recompute_basic_faces (f
);
1877 store_frame_param (f
, Qfont
, result
);
1884 x_set_border_width (f
, arg
, oldval
)
1886 Lisp_Object arg
, oldval
;
1888 CHECK_NUMBER (arg
, 0);
1890 if (XINT (arg
) == f
->output_data
.win32
->border_width
)
1893 if (FRAME_WIN32_WINDOW (f
) != 0)
1894 error ("Cannot change the border width of a window");
1896 f
->output_data
.win32
->border_width
= XINT (arg
);
1900 x_set_internal_border_width (f
, arg
, oldval
)
1902 Lisp_Object arg
, oldval
;
1905 int old
= f
->output_data
.win32
->internal_border_width
;
1907 CHECK_NUMBER (arg
, 0);
1908 f
->output_data
.win32
->internal_border_width
= XINT (arg
);
1909 if (f
->output_data
.win32
->internal_border_width
< 0)
1910 f
->output_data
.win32
->internal_border_width
= 0;
1912 if (f
->output_data
.win32
->internal_border_width
== old
)
1915 if (FRAME_WIN32_WINDOW (f
) != 0)
1918 x_set_window_size (f
, 0, f
->width
, f
->height
);
1920 SET_FRAME_GARBAGED (f
);
1925 x_set_visibility (f
, value
, oldval
)
1927 Lisp_Object value
, oldval
;
1930 XSETFRAME (frame
, f
);
1933 Fmake_frame_invisible (frame
, Qt
);
1934 else if (EQ (value
, Qicon
))
1935 Ficonify_frame (frame
);
1937 Fmake_frame_visible (frame
);
1941 x_set_menu_bar_lines (f
, value
, oldval
)
1943 Lisp_Object value
, oldval
;
1946 int olines
= FRAME_MENU_BAR_LINES (f
);
1948 /* Right now, menu bars don't work properly in minibuf-only frames;
1949 most of the commands try to apply themselves to the minibuffer
1950 frame itslef, and get an error because you can't switch buffers
1951 in or split the minibuffer window. */
1952 if (FRAME_MINIBUF_ONLY_P (f
))
1955 if (INTEGERP (value
))
1956 nlines
= XINT (value
);
1960 FRAME_MENU_BAR_LINES (f
) = 0;
1962 FRAME_EXTERNAL_MENU_BAR (f
) = 1;
1965 if (FRAME_EXTERNAL_MENU_BAR (f
) == 1)
1966 free_frame_menubar (f
);
1967 FRAME_EXTERNAL_MENU_BAR (f
) = 0;
1971 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
1974 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1975 name; if NAME is a string, set F's name to NAME and set
1976 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1978 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1979 suggesting a new name, which lisp code should override; if
1980 F->explicit_name is set, ignore the new name; otherwise, set it. */
1983 x_set_name (f
, name
, explicit)
1988 /* Make sure that requests from lisp code override requests from
1989 Emacs redisplay code. */
1992 /* If we're switching from explicit to implicit, we had better
1993 update the mode lines and thereby update the title. */
1994 if (f
->explicit_name
&& NILP (name
))
1995 update_mode_lines
= 1;
1997 f
->explicit_name
= ! NILP (name
);
1999 else if (f
->explicit_name
)
2002 /* If NAME is nil, set the name to the win32_id_name. */
2005 /* Check for no change needed in this very common case
2006 before we do any consing. */
2007 if (!strcmp (FRAME_WIN32_DISPLAY_INFO (f
)->win32_id_name
,
2008 XSTRING (f
->name
)->data
))
2010 name
= build_string (FRAME_WIN32_DISPLAY_INFO (f
)->win32_id_name
);
2013 CHECK_STRING (name
, 0);
2015 /* Don't change the name if it's already NAME. */
2016 if (! NILP (Fstring_equal (name
, f
->name
)))
2019 if (FRAME_WIN32_WINDOW (f
))
2022 SetWindowText(FRAME_WIN32_WINDOW (f
), XSTRING (name
)->data
);
2029 /* This function should be called when the user's lisp code has
2030 specified a name for the frame; the name will override any set by the
2033 x_explicitly_set_name (f
, arg
, oldval
)
2035 Lisp_Object arg
, oldval
;
2037 x_set_name (f
, arg
, 1);
2040 /* This function should be called by Emacs redisplay code to set the
2041 name; names set this way will never override names set by the user's
2044 x_implicitly_set_name (f
, arg
, oldval
)
2046 Lisp_Object arg
, oldval
;
2048 x_set_name (f
, arg
, 0);
2052 x_set_autoraise (f
, arg
, oldval
)
2054 Lisp_Object arg
, oldval
;
2056 f
->auto_raise
= !EQ (Qnil
, arg
);
2060 x_set_autolower (f
, arg
, oldval
)
2062 Lisp_Object arg
, oldval
;
2064 f
->auto_lower
= !EQ (Qnil
, arg
);
2068 x_set_unsplittable (f
, arg
, oldval
)
2070 Lisp_Object arg
, oldval
;
2072 f
->no_split
= !NILP (arg
);
2076 x_set_vertical_scroll_bars (f
, arg
, oldval
)
2078 Lisp_Object arg
, oldval
;
2080 if (NILP (arg
) != ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
2082 FRAME_HAS_VERTICAL_SCROLL_BARS (f
) = ! NILP (arg
);
2084 /* We set this parameter before creating the window for the
2085 frame, so we can get the geometry right from the start.
2086 However, if the window hasn't been created yet, we shouldn't
2087 call x_set_window_size. */
2088 if (FRAME_WIN32_WINDOW (f
))
2089 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
2094 x_set_scroll_bar_width (f
, arg
, oldval
)
2096 Lisp_Object arg
, oldval
;
2100 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = 0;
2101 FRAME_SCROLL_BAR_COLS (f
) = 2;
2103 else if (INTEGERP (arg
) && XINT (arg
) > 0
2104 && XFASTINT (arg
) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f
))
2106 int wid
= FONT_WIDTH (f
->output_data
.win32
->font
);
2107 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = XFASTINT (arg
);
2108 FRAME_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
2109 if (FRAME_WIN32_WINDOW (f
))
2110 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
2114 /* Subroutines of creating an frame. */
2116 /* Make sure that Vx_resource_name is set to a reasonable value.
2117 Fix it up, or set it to `emacs' if it is too hopeless. */
2120 validate_x_resource_name ()
2123 /* Number of valid characters in the resource name. */
2125 /* Number of invalid characters in the resource name. */
2130 if (STRINGP (Vx_resource_name
))
2132 unsigned char *p
= XSTRING (Vx_resource_name
)->data
;
2135 len
= XSTRING (Vx_resource_name
)->size
;
2137 /* Only letters, digits, - and _ are valid in resource names.
2138 Count the valid characters and count the invalid ones. */
2139 for (i
= 0; i
< len
; i
++)
2142 if (! ((c
>= 'a' && c
<= 'z')
2143 || (c
>= 'A' && c
<= 'Z')
2144 || (c
>= '0' && c
<= '9')
2145 || c
== '-' || c
== '_'))
2152 /* Not a string => completely invalid. */
2153 bad_count
= 5, good_count
= 0;
2155 /* If name is valid already, return. */
2159 /* If name is entirely invalid, or nearly so, use `emacs'. */
2161 || (good_count
== 1 && bad_count
> 0))
2163 Vx_resource_name
= build_string ("emacs");
2167 /* Name is partly valid. Copy it and replace the invalid characters
2168 with underscores. */
2170 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
2172 for (i
= 0; i
< len
; i
++)
2174 int c
= XSTRING (new)->data
[i
];
2175 if (! ((c
>= 'a' && c
<= 'z')
2176 || (c
>= 'A' && c
<= 'Z')
2177 || (c
>= '0' && c
<= '9')
2178 || c
== '-' || c
== '_'))
2179 XSTRING (new)->data
[i
] = '_';
2184 extern char *x_get_string_resource ();
2186 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
2187 "Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.\n\
2188 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the\n\
2189 class, where INSTANCE is the name under which Emacs was invoked, or\n\
2190 the name specified by the `-name' or `-rn' command-line arguments.\n\
2192 The optional arguments COMPONENT and SUBCLASS add to the key and the\n\
2193 class, respectively. You must specify both of them or neither.\n\
2194 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'\n\
2195 and the class is `Emacs.CLASS.SUBCLASS'.")
2196 (attribute
, class, component
, subclass
)
2197 Lisp_Object attribute
, class, component
, subclass
;
2199 register char *value
;
2203 CHECK_STRING (attribute
, 0);
2204 CHECK_STRING (class, 0);
2206 if (!NILP (component
))
2207 CHECK_STRING (component
, 1);
2208 if (!NILP (subclass
))
2209 CHECK_STRING (subclass
, 2);
2210 if (NILP (component
) != NILP (subclass
))
2211 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
2213 validate_x_resource_name ();
2215 /* Allocate space for the components, the dots which separate them,
2216 and the final '\0'. Make them big enough for the worst case. */
2217 name_key
= (char *) alloca (XSTRING (Vx_resource_name
)->size
2218 + (STRINGP (component
)
2219 ? XSTRING (component
)->size
: 0)
2220 + XSTRING (attribute
)->size
2223 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
2224 + XSTRING (class)->size
2225 + (STRINGP (subclass
)
2226 ? XSTRING (subclass
)->size
: 0)
2229 /* Start with emacs.FRAMENAME for the name (the specific one)
2230 and with `Emacs' for the class key (the general one). */
2231 strcpy (name_key
, XSTRING (Vx_resource_name
)->data
);
2232 strcpy (class_key
, EMACS_CLASS
);
2234 strcat (class_key
, ".");
2235 strcat (class_key
, XSTRING (class)->data
);
2237 if (!NILP (component
))
2239 strcat (class_key
, ".");
2240 strcat (class_key
, XSTRING (subclass
)->data
);
2242 strcat (name_key
, ".");
2243 strcat (name_key
, XSTRING (component
)->data
);
2246 strcat (name_key
, ".");
2247 strcat (name_key
, XSTRING (attribute
)->data
);
2249 value
= x_get_string_resource (Qnil
,
2250 name_key
, class_key
);
2252 if (value
!= (char *) 0)
2253 return build_string (value
);
2258 /* Used when C code wants a resource value. */
2261 x_get_resource_string (attribute
, class)
2262 char *attribute
, *class;
2264 register char *value
;
2268 /* Allocate space for the components, the dots which separate them,
2269 and the final '\0'. */
2270 name_key
= (char *) alloca (XSTRING (Vinvocation_name
)->size
2271 + strlen (attribute
) + 2);
2272 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
2273 + strlen (class) + 2);
2275 sprintf (name_key
, "%s.%s",
2276 XSTRING (Vinvocation_name
)->data
,
2278 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
2280 return x_get_string_resource (selected_frame
,
2281 name_key
, class_key
);
2284 /* Types we might convert a resource string into. */
2287 number
, boolean
, string
, symbol
2290 /* Return the value of parameter PARAM.
2292 First search ALIST, then Vdefault_frame_alist, then the X defaults
2293 database, using ATTRIBUTE as the attribute name and CLASS as its class.
2295 Convert the resource to the type specified by desired_type.
2297 If no default is specified, return Qunbound. If you call
2298 x_get_arg, make sure you deal with Qunbound in a reasonable way,
2299 and don't let it get stored in any Lisp-visible variables! */
2302 x_get_arg (alist
, param
, attribute
, class, type
)
2303 Lisp_Object alist
, param
;
2306 enum resource_types type
;
2308 register Lisp_Object tem
;
2310 tem
= Fassq (param
, alist
);
2312 tem
= Fassq (param
, Vdefault_frame_alist
);
2318 tem
= Fx_get_resource (build_string (attribute
),
2319 build_string (class),
2328 return make_number (atoi (XSTRING (tem
)->data
));
2331 tem
= Fdowncase (tem
);
2332 if (!strcmp (XSTRING (tem
)->data
, "on")
2333 || !strcmp (XSTRING (tem
)->data
, "true"))
2342 /* As a special case, we map the values `true' and `on'
2343 to Qt, and `false' and `off' to Qnil. */
2346 lower
= Fdowncase (tem
);
2347 if (!strcmp (XSTRING (lower
)->data
, "on")
2348 || !strcmp (XSTRING (lower
)->data
, "true"))
2350 else if (!strcmp (XSTRING (lower
)->data
, "off")
2351 || !strcmp (XSTRING (lower
)->data
, "false"))
2354 return Fintern (tem
, Qnil
);
2367 /* Record in frame F the specified or default value according to ALIST
2368 of the parameter named PARAM (a Lisp symbol).
2369 If no value is specified for PARAM, look for an X default for XPROP
2370 on the frame named NAME.
2371 If that is not found either, use the value DEFLT. */
2374 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
2381 enum resource_types type
;
2385 tem
= x_get_arg (alist
, prop
, xprop
, xclass
, type
);
2386 if (EQ (tem
, Qunbound
))
2388 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
2392 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
2393 "Parse an X-style geometry string STRING.\n\
2394 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).\n\
2395 The properties returned may include `top', `left', `height', and `width'.\n\
2396 The value of `left' or `top' may be an integer,\n\
2397 or a list (+ N) meaning N pixels relative to top/left corner,\n\
2398 or a list (- N) meaning -N pixels relative to bottom/right corner.")
2403 unsigned int width
, height
;
2406 CHECK_STRING (string
, 0);
2408 geometry
= XParseGeometry ((char *) XSTRING (string
)->data
,
2409 &x
, &y
, &width
, &height
);
2412 if (geometry
& XValue
)
2414 Lisp_Object element
;
2416 if (x
>= 0 && (geometry
& XNegative
))
2417 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
2418 else if (x
< 0 && ! (geometry
& XNegative
))
2419 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
2421 element
= Fcons (Qleft
, make_number (x
));
2422 result
= Fcons (element
, result
);
2425 if (geometry
& YValue
)
2427 Lisp_Object element
;
2429 if (y
>= 0 && (geometry
& YNegative
))
2430 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
2431 else if (y
< 0 && ! (geometry
& YNegative
))
2432 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
2434 element
= Fcons (Qtop
, make_number (y
));
2435 result
= Fcons (element
, result
);
2438 if (geometry
& WidthValue
)
2439 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
2440 if (geometry
& HeightValue
)
2441 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
2446 /* Calculate the desired size and position of this window,
2447 and return the flags saying which aspects were specified.
2449 This function does not make the coordinates positive. */
2451 #define DEFAULT_ROWS 40
2452 #define DEFAULT_COLS 80
2455 x_figure_window_size (f
, parms
)
2459 register Lisp_Object tem0
, tem1
, tem2
;
2460 int height
, width
, left
, top
;
2461 register int geometry
;
2462 long window_prompting
= 0;
2464 /* Default values if we fall through.
2465 Actually, if that happens we should get
2466 window manager prompting. */
2467 f
->width
= DEFAULT_COLS
;
2468 f
->height
= DEFAULT_ROWS
;
2469 /* Window managers expect that if program-specified
2470 positions are not (0,0), they're intentional, not defaults. */
2471 f
->output_data
.win32
->top_pos
= 0;
2472 f
->output_data
.win32
->left_pos
= 0;
2474 tem0
= x_get_arg (parms
, Qheight
, 0, 0, number
);
2475 tem1
= x_get_arg (parms
, Qwidth
, 0, 0, number
);
2476 tem2
= x_get_arg (parms
, Quser_size
, 0, 0, number
);
2477 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
2479 if (!EQ (tem0
, Qunbound
))
2481 CHECK_NUMBER (tem0
, 0);
2482 f
->height
= XINT (tem0
);
2484 if (!EQ (tem1
, Qunbound
))
2486 CHECK_NUMBER (tem1
, 0);
2487 f
->width
= XINT (tem1
);
2489 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
2490 window_prompting
|= USSize
;
2492 window_prompting
|= PSize
;
2495 f
->output_data
.win32
->vertical_scroll_bar_extra
2496 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2498 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) > 0
2499 ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f
)
2500 : (FRAME_SCROLL_BAR_COLS (f
) * FONT_WIDTH (f
->output_data
.win32
->font
)));
2501 f
->output_data
.win32
->pixel_width
= CHAR_TO_PIXEL_WIDTH (f
, f
->width
);
2502 f
->output_data
.win32
->pixel_height
= CHAR_TO_PIXEL_HEIGHT (f
, f
->height
);
2504 tem0
= x_get_arg (parms
, Qtop
, 0, 0, number
);
2505 tem1
= x_get_arg (parms
, Qleft
, 0, 0, number
);
2506 tem2
= x_get_arg (parms
, Quser_position
, 0, 0, number
);
2507 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
2509 if (EQ (tem0
, Qminus
))
2511 f
->output_data
.win32
->top_pos
= 0;
2512 window_prompting
|= YNegative
;
2514 else if (CONSP (tem0
) && EQ (XCONS (tem0
)->car
, Qminus
)
2515 && CONSP (XCONS (tem0
)->cdr
)
2516 && INTEGERP (XCONS (XCONS (tem0
)->cdr
)->car
))
2518 f
->output_data
.win32
->top_pos
= - XINT (XCONS (XCONS (tem0
)->cdr
)->car
);
2519 window_prompting
|= YNegative
;
2521 else if (CONSP (tem0
) && EQ (XCONS (tem0
)->car
, Qplus
)
2522 && CONSP (XCONS (tem0
)->cdr
)
2523 && INTEGERP (XCONS (XCONS (tem0
)->cdr
)->car
))
2525 f
->output_data
.win32
->top_pos
= XINT (XCONS (XCONS (tem0
)->cdr
)->car
);
2527 else if (EQ (tem0
, Qunbound
))
2528 f
->output_data
.win32
->top_pos
= 0;
2531 CHECK_NUMBER (tem0
, 0);
2532 f
->output_data
.win32
->top_pos
= XINT (tem0
);
2533 if (f
->output_data
.win32
->top_pos
< 0)
2534 window_prompting
|= YNegative
;
2537 if (EQ (tem1
, Qminus
))
2539 f
->output_data
.win32
->left_pos
= 0;
2540 window_prompting
|= XNegative
;
2542 else if (CONSP (tem1
) && EQ (XCONS (tem1
)->car
, Qminus
)
2543 && CONSP (XCONS (tem1
)->cdr
)
2544 && INTEGERP (XCONS (XCONS (tem1
)->cdr
)->car
))
2546 f
->output_data
.win32
->left_pos
= - XINT (XCONS (XCONS (tem1
)->cdr
)->car
);
2547 window_prompting
|= XNegative
;
2549 else if (CONSP (tem1
) && EQ (XCONS (tem1
)->car
, Qplus
)
2550 && CONSP (XCONS (tem1
)->cdr
)
2551 && INTEGERP (XCONS (XCONS (tem1
)->cdr
)->car
))
2553 f
->output_data
.win32
->left_pos
= XINT (XCONS (XCONS (tem1
)->cdr
)->car
);
2555 else if (EQ (tem1
, Qunbound
))
2556 f
->output_data
.win32
->left_pos
= 0;
2559 CHECK_NUMBER (tem1
, 0);
2560 f
->output_data
.win32
->left_pos
= XINT (tem1
);
2561 if (f
->output_data
.win32
->left_pos
< 0)
2562 window_prompting
|= XNegative
;
2565 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
2566 window_prompting
|= USPosition
;
2568 window_prompting
|= PPosition
;
2571 return window_prompting
;
2576 extern LRESULT CALLBACK
win32_wnd_proc ();
2579 win32_init_class (hinst
)
2584 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
2585 wc
.lpfnWndProc
= (WNDPROC
) win32_wnd_proc
;
2587 wc
.cbWndExtra
= WND_EXTRA_BYTES
;
2588 wc
.hInstance
= hinst
;
2589 wc
.hIcon
= LoadIcon (hinst
, EMACS_CLASS
);
2590 wc
.hCursor
= LoadCursor (NULL
, IDC_ARROW
);
2591 wc
.hbrBackground
= NULL
; // GetStockObject (WHITE_BRUSH);
2592 wc
.lpszMenuName
= NULL
;
2593 wc
.lpszClassName
= EMACS_CLASS
;
2595 return (RegisterClass (&wc
));
2599 win32_createscrollbar (f
, bar
)
2601 struct scroll_bar
* bar
;
2603 return (CreateWindow ("SCROLLBAR", "", SBS_VERT
| WS_CHILD
| WS_VISIBLE
,
2604 /* Position and size of scroll bar. */
2605 XINT(bar
->left
), XINT(bar
->top
),
2606 XINT(bar
->width
), XINT(bar
->height
),
2607 FRAME_WIN32_WINDOW (f
),
2614 win32_createwindow (f
)
2619 /* Do first time app init */
2623 win32_init_class (hinst
);
2626 FRAME_WIN32_WINDOW (f
) = hwnd
= CreateWindow (EMACS_CLASS
,
2628 f
->output_data
.win32
->dwStyle
| WS_CLIPCHILDREN
,
2629 f
->output_data
.win32
->left_pos
,
2630 f
->output_data
.win32
->top_pos
,
2640 SetWindowLong (hwnd
, WND_X_UNITS_INDEX
, FONT_WIDTH (f
->output_data
.win32
->font
));
2641 SetWindowLong (hwnd
, WND_Y_UNITS_INDEX
, f
->output_data
.win32
->line_height
);
2642 SetWindowLong (hwnd
, WND_BACKGROUND_INDEX
, f
->output_data
.win32
->background_pixel
);
2644 /* Do this to discard the default setting specified by our parent. */
2645 ShowWindow (hwnd
, SW_HIDE
);
2649 /* Convert between the modifier bits Win32 uses and the modifier bits
2652 win32_get_modifiers ()
2654 return (((GetKeyState (VK_SHIFT
)&0x8000) ? shift_modifier
: 0) |
2655 ((GetKeyState (VK_CONTROL
)&0x8000) ? ctrl_modifier
: 0) |
2656 ((GetKeyState (VK_MENU
)&0x8000) ?
2657 ((NILP (Vwin32_alt_is_meta
)) ? alt_modifier
: meta_modifier
) : 0));
2661 my_post_msg (wmsg
, hwnd
, msg
, wParam
, lParam
)
2668 wmsg
->msg
.hwnd
= hwnd
;
2669 wmsg
->msg
.message
= msg
;
2670 wmsg
->msg
.wParam
= wParam
;
2671 wmsg
->msg
.lParam
= lParam
;
2672 wmsg
->msg
.time
= GetMessageTime ();
2677 /* GetKeyState and MapVirtualKey on Win95 do not actually distinguish
2678 between left and right keys as advertised. We test for this
2679 support dynamically, and set a flag when the support is absent. If
2680 absent, we keep track of the left and right control and alt keys
2681 ourselves. This is particularly necessary on keyboards that rely
2682 upon the AltGr key, which is represented as having the left control
2683 and right alt keys pressed. For these keyboards, we need to know
2684 when the left alt key has been pressed in addition to the AltGr key
2685 so that we can properly support M-AltGr-key sequences (such as M-@
2686 on Swedish keyboards). */
2688 #define EMACS_LCONTROL 0
2689 #define EMACS_RCONTROL 1
2690 #define EMACS_LMENU 2
2691 #define EMACS_RMENU 3
2693 static int modifiers
[4];
2694 static int modifiers_recorded
;
2695 static int modifier_key_support_tested
;
2698 test_modifier_support (unsigned int wparam
)
2702 if (wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
)
2704 if (wparam
== VK_CONTROL
)
2714 if (!(GetKeyState (l
) & 0x8000) && !(GetKeyState (r
) & 0x8000))
2715 modifiers_recorded
= 1;
2717 modifiers_recorded
= 0;
2718 modifier_key_support_tested
= 1;
2722 record_keydown (unsigned int wparam
, unsigned int lparam
)
2726 if (!modifier_key_support_tested
)
2727 test_modifier_support (wparam
);
2729 if ((wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
) || !modifiers_recorded
)
2732 if (wparam
== VK_CONTROL
)
2733 i
= (lparam
& 0x1000000) ? EMACS_RCONTROL
: EMACS_LCONTROL
;
2735 i
= (lparam
& 0x1000000) ? EMACS_RMENU
: EMACS_LMENU
;
2741 record_keyup (unsigned int wparam
, unsigned int lparam
)
2745 if ((wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
) || !modifiers_recorded
)
2748 if (wparam
== VK_CONTROL
)
2749 i
= (lparam
& 0x1000000) ? EMACS_RCONTROL
: EMACS_LCONTROL
;
2751 i
= (lparam
& 0x1000000) ? EMACS_RMENU
: EMACS_LMENU
;
2756 /* Emacs can lose focus while a modifier key has been pressed. When
2757 it regains focus, be conservative and clear all modifiers since
2758 we cannot reconstruct the left and right modifier state. */
2764 if (!modifiers_recorded
)
2767 ctrl
= GetAsyncKeyState (VK_CONTROL
);
2768 alt
= GetAsyncKeyState (VK_MENU
);
2770 if (ctrl
== 0 || alt
== 0)
2771 /* Emacs doesn't have keyboard focus. Do nothing. */
2774 if (!(ctrl
& 0x08000))
2775 /* Clear any recorded control modifier state. */
2776 modifiers
[EMACS_RCONTROL
] = modifiers
[EMACS_LCONTROL
] = 0;
2778 if (!(alt
& 0x08000))
2779 /* Clear any recorded alt modifier state. */
2780 modifiers
[EMACS_RMENU
] = modifiers
[EMACS_LMENU
] = 0;
2782 /* Otherwise, leave the modifier state as it was when Emacs lost
2786 /* Synchronize modifier state with what is reported with the current
2787 keystroke. Even if we cannot distinguish between left and right
2788 modifier keys, we know that, if no modifiers are set, then neither
2789 the left or right modifier should be set. */
2793 if (!modifiers_recorded
)
2796 if (!(GetKeyState (VK_CONTROL
) & 0x8000))
2797 modifiers
[EMACS_RCONTROL
] = modifiers
[EMACS_LCONTROL
] = 0;
2799 if (!(GetKeyState (VK_MENU
) & 0x8000))
2800 modifiers
[EMACS_RMENU
] = modifiers
[EMACS_LMENU
] = 0;
2804 modifier_set (int vkey
)
2806 if (vkey
== VK_CAPITAL
)
2807 return (GetKeyState (vkey
) & 0x1);
2808 if (!modifiers_recorded
)
2809 return (GetKeyState (vkey
) & 0x8000);
2814 return modifiers
[EMACS_LCONTROL
];
2816 return modifiers
[EMACS_RCONTROL
];
2818 return modifiers
[EMACS_LMENU
];
2820 return modifiers
[EMACS_RMENU
];
2824 return (GetKeyState (vkey
) & 0x8000);
2827 /* We map the VK_* modifiers into console modifier constants
2828 so that we can use the same routines to handle both console
2829 and window input. */
2832 construct_modifiers (unsigned int wparam
, unsigned int lparam
)
2836 if (wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
)
2837 mods
= GetLastError ();
2840 mods
|= (modifier_set (VK_SHIFT
)) ? SHIFT_PRESSED
: 0;
2841 mods
|= (modifier_set (VK_CAPITAL
)) ? CAPSLOCK_ON
: 0;
2842 mods
|= (modifier_set (VK_LCONTROL
)) ? LEFT_CTRL_PRESSED
: 0;
2843 mods
|= (modifier_set (VK_RCONTROL
)) ? RIGHT_CTRL_PRESSED
: 0;
2844 mods
|= (modifier_set (VK_LMENU
)) ? LEFT_ALT_PRESSED
: 0;
2845 mods
|= (modifier_set (VK_RMENU
)) ? RIGHT_ALT_PRESSED
: 0;
2851 map_keypad_keys (unsigned int wparam
, unsigned int lparam
)
2853 unsigned int extended
= (lparam
& 0x1000000L
);
2855 if (wparam
< VK_CLEAR
|| wparam
> VK_DELETE
)
2858 if (wparam
== VK_RETURN
)
2859 return (extended
? VK_NUMPAD_ENTER
: VK_RETURN
);
2861 if (wparam
>= VK_PRIOR
&& wparam
<= VK_DOWN
)
2862 return (!extended
? (VK_NUMPAD_PRIOR
+ (wparam
- VK_PRIOR
)) : wparam
);
2864 if (wparam
== VK_INSERT
|| wparam
== VK_DELETE
)
2865 return (!extended
? (VK_NUMPAD_INSERT
+ (wparam
- VK_INSERT
)) : wparam
);
2867 if (wparam
== VK_CLEAR
)
2868 return (!extended
? VK_NUMPAD_CLEAR
: wparam
);
2873 /* Main message dispatch loop. */
2881 /* Ensure our message queue is created */
2883 PeekMessage (&msg
, NULL
, 0, 0, PM_NOREMOVE
);
2885 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, 0, 0);
2887 while (GetMessage (&msg
, NULL
, 0, 0))
2889 if (msg
.hwnd
== NULL
)
2891 switch (msg
.message
)
2893 case WM_EMACS_CREATEWINDOW
:
2894 win32_createwindow ((struct frame
*) msg
.wParam
);
2895 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, 0, 0);
2897 case WM_EMACS_CREATESCROLLBAR
:
2899 HWND hwnd
= win32_createscrollbar ((struct frame
*) msg
.wParam
,
2900 (struct scroll_bar
*) msg
.lParam
);
2901 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, (WPARAM
)hwnd
, 0);
2910 DispatchMessage (&msg
);
2917 /* Main window procedure */
2919 extern char *lispy_function_keys
[];
2922 win32_wnd_proc (hwnd
, msg
, wParam
, lParam
)
2930 struct win32_display_info
*dpyinfo
= &one_win32_display_info
;
2932 int windows_translate
;
2934 /* Note that it is okay to call x_window_to_frame, even though we are
2935 not running in the main lisp thread, because frame deletion
2936 requires the lisp thread to synchronize with this thread. Thus, if
2937 a frame struct is returned, it can be used without concern that the
2938 lisp thread might make it disappear while we are using it.
2940 NB. Walking the frame list in this thread is safe (as long as
2941 writes of Lisp_Object slots are atomic, which they are on Windows).
2942 Although delete-frame can destructively modify the frame list while
2943 we are walking it, a garbage collection cannot occur until after
2944 delete-frame has synchronized with this thread.
2946 It is also safe to use functions that make GDI calls, such as
2947 win32_clear_rect, because these functions must obtain a DC handle
2948 from the frame struct using get_frame_dc which is thread-aware. */
2953 f
= x_window_to_frame (dpyinfo
, hwnd
);
2956 GetUpdateRect (hwnd
, &wmsg
.rect
, FALSE
);
2957 win32_clear_rect (f
, NULL
, &wmsg
.rect
);
2960 case WM_PALETTECHANGED
:
2961 /* ignore our own changes */
2962 if ((HWND
)wParam
!= hwnd
)
2964 f
= x_window_to_frame (dpyinfo
, hwnd
);
2966 /* get_frame_dc will realize our palette and force all
2967 frames to be redrawn if needed. */
2968 release_frame_dc (f
, get_frame_dc (f
));
2973 PAINTSTRUCT paintStruct
;
2976 BeginPaint (hwnd
, &paintStruct
);
2977 wmsg
.rect
= paintStruct
.rcPaint
;
2978 EndPaint (hwnd
, &paintStruct
);
2981 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
2988 record_keyup (wParam
, lParam
);
2993 /* Synchronize modifiers with current keystroke. */
2996 record_keydown (wParam
, lParam
);
2998 wParam
= map_keypad_keys (wParam
, lParam
);
3000 windows_translate
= 0;
3005 /* More support for these keys will likely be necessary. */
3006 if (!NILP (Vwin32_pass_optional_keys_to_system
))
3007 windows_translate
= 1;
3010 if (NILP (Vwin32_pass_alt_to_system
))
3012 windows_translate
= 1;
3019 windows_translate
= 1;
3022 /* If not defined as a function key, change it to a WM_CHAR message. */
3023 if (lispy_function_keys
[wParam
] == 0)
3028 if (windows_translate
)
3030 MSG winmsg
= { hwnd
, msg
, wParam
, lParam
, 0, {0,0} };
3032 winmsg
.time
= GetMessageTime ();
3033 TranslateMessage (&winmsg
);
3041 wmsg
.dwModifiers
= construct_modifiers (wParam
, lParam
);
3044 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3047 /* Detect quit_char and set quit-flag directly. Note that we dow
3048 this *after* posting the message to ensure the main thread will
3049 be woken up if blocked in sys_select(). */
3052 if (isalpha (c
) && (wmsg
.dwModifiers
== LEFT_CTRL_PRESSED
3053 || wmsg
.dwModifiers
== RIGHT_CTRL_PRESSED
))
3054 c
= make_ctrl_char (c
) & 0377;
3063 /* Simulate middle mouse button events when left and right buttons
3064 are used together, but only if user has two button mouse. */
3065 case WM_LBUTTONDOWN
:
3066 case WM_RBUTTONDOWN
:
3067 if (XINT (Vwin32_num_mouse_buttons
) == 3)
3068 goto handle_plain_button
;
3071 int this = (msg
== WM_LBUTTONDOWN
) ? LMOUSE
: RMOUSE
;
3072 int other
= (msg
== WM_LBUTTONDOWN
) ? RMOUSE
: LMOUSE
;
3074 if (button_state
& this)
3077 if (button_state
== 0)
3080 button_state
|= this;
3082 if (button_state
& other
)
3084 if (mouse_button_timer
)
3086 KillTimer (hwnd
, mouse_button_timer
);
3087 mouse_button_timer
= 0;
3089 /* Generate middle mouse event instead. */
3090 msg
= WM_MBUTTONDOWN
;
3091 button_state
|= MMOUSE
;
3093 else if (button_state
& MMOUSE
)
3095 /* Ignore button event if we've already generated a
3096 middle mouse down event. This happens if the
3097 user releases and press one of the two buttons
3098 after we've faked a middle mouse event. */
3103 /* Flush out saved message. */
3104 post_msg (&saved_mouse_button_msg
);
3106 wmsg
.dwModifiers
= win32_get_modifiers ();
3107 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3109 /* Clear message buffer. */
3110 saved_mouse_button_msg
.msg
.hwnd
= 0;
3114 /* Hold onto message for now. */
3115 mouse_button_timer
=
3116 SetTimer (hwnd
, MOUSE_BUTTON_ID
, XINT (Vwin32_mouse_button_tolerance
), NULL
);
3117 saved_mouse_button_msg
.msg
.hwnd
= hwnd
;
3118 saved_mouse_button_msg
.msg
.message
= msg
;
3119 saved_mouse_button_msg
.msg
.wParam
= wParam
;
3120 saved_mouse_button_msg
.msg
.lParam
= lParam
;
3121 saved_mouse_button_msg
.msg
.time
= GetMessageTime ();
3122 saved_mouse_button_msg
.dwModifiers
= win32_get_modifiers ();
3129 if (XINT (Vwin32_num_mouse_buttons
) == 3)
3130 goto handle_plain_button
;
3133 int this = (msg
== WM_LBUTTONUP
) ? LMOUSE
: RMOUSE
;
3134 int other
= (msg
== WM_LBUTTONUP
) ? RMOUSE
: LMOUSE
;
3136 if ((button_state
& this) == 0)
3139 button_state
&= ~this;
3141 if (button_state
& MMOUSE
)
3143 /* Only generate event when second button is released. */
3144 if ((button_state
& other
) == 0)
3147 button_state
&= ~MMOUSE
;
3149 if (button_state
) abort ();
3156 /* Flush out saved message if necessary. */
3157 if (saved_mouse_button_msg
.msg
.hwnd
)
3159 post_msg (&saved_mouse_button_msg
);
3162 wmsg
.dwModifiers
= win32_get_modifiers ();
3163 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3165 /* Always clear message buffer and cancel timer. */
3166 saved_mouse_button_msg
.msg
.hwnd
= 0;
3167 KillTimer (hwnd
, mouse_button_timer
);
3168 mouse_button_timer
= 0;
3170 if (button_state
== 0)
3175 case WM_MBUTTONDOWN
:
3177 handle_plain_button
:
3181 if (parse_button (msg
, NULL
, &up
))
3183 if (up
) ReleaseCapture ();
3184 else SetCapture (hwnd
);
3188 wmsg
.dwModifiers
= win32_get_modifiers ();
3189 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3194 if (XINT (Vwin32_mouse_move_interval
) <= 0
3195 || (msg
== WM_MOUSEMOVE
&& button_state
== 0))
3197 wmsg
.dwModifiers
= win32_get_modifiers ();
3198 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3202 /* Hang onto mouse move and scroll messages for a bit, to avoid
3203 sending such events to Emacs faster than it can process them.
3204 If we get more events before the timer from the first message
3205 expires, we just replace the first message. */
3207 if (saved_mouse_move_msg
.msg
.hwnd
== 0)
3209 SetTimer (hwnd
, MOUSE_MOVE_ID
, XINT (Vwin32_mouse_move_interval
), NULL
);
3211 /* Hold onto message for now. */
3212 saved_mouse_move_msg
.msg
.hwnd
= hwnd
;
3213 saved_mouse_move_msg
.msg
.message
= msg
;
3214 saved_mouse_move_msg
.msg
.wParam
= wParam
;
3215 saved_mouse_move_msg
.msg
.lParam
= lParam
;
3216 saved_mouse_move_msg
.msg
.time
= GetMessageTime ();
3217 saved_mouse_move_msg
.dwModifiers
= win32_get_modifiers ();
3222 /* Flush out saved messages if necessary. */
3223 if (wParam
== mouse_button_timer
)
3225 if (saved_mouse_button_msg
.msg
.hwnd
)
3227 post_msg (&saved_mouse_button_msg
);
3228 saved_mouse_button_msg
.msg
.hwnd
= 0;
3230 KillTimer (hwnd
, mouse_button_timer
);
3231 mouse_button_timer
= 0;
3233 else if (wParam
== mouse_move_timer
)
3235 if (saved_mouse_move_msg
.msg
.hwnd
)
3237 post_msg (&saved_mouse_move_msg
);
3238 saved_mouse_move_msg
.msg
.hwnd
= 0;
3240 KillTimer (hwnd
, mouse_move_timer
);
3241 mouse_move_timer
= 0;
3246 /* Windows doesn't send us focus messages when putting up and
3247 taking down a system popup dialog as for Ctrl-Alt-Del on Win95.
3248 The only indication we get that something happened is receiving
3249 this message afterwards. So this is a good time to reset our
3250 keyboard modifiers' state. */
3261 wmsg
.dwModifiers
= win32_get_modifiers ();
3262 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3266 wmsg
.dwModifiers
= win32_get_modifiers ();
3267 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3270 case WM_WINDOWPOSCHANGING
:
3273 LPWINDOWPOS lppos
= (WINDOWPOS
*) lParam
;
3275 GetWindowPlacement (hwnd
, &wp
);
3277 if (wp
.showCmd
!= SW_SHOWMINIMIZED
&& ! (lppos
->flags
& SWP_NOSIZE
))
3286 wp
.length
= sizeof(wp
);
3287 GetWindowRect (hwnd
, &wr
);
3291 dwXUnits
= GetWindowLong (hwnd
, WND_X_UNITS_INDEX
);
3292 dwYUnits
= GetWindowLong (hwnd
, WND_Y_UNITS_INDEX
);
3296 memset (&rect
, 0, sizeof (rect
));
3297 AdjustWindowRect (&rect
, GetWindowLong (hwnd
, GWL_STYLE
),
3298 GetMenu (hwnd
) != NULL
);
3300 /* All windows have an extra pixel so subtract 1 */
3302 wdiff
= (lppos
->cx
- (rect
.right
- rect
.left
) - 0) % dwXUnits
;
3303 hdiff
= (lppos
->cy
- (rect
.bottom
- rect
.top
) - 0) % dwYUnits
;
3307 /* For right/bottom sizing we can just fix the sizes.
3308 However for top/left sizing we will need to fix the X
3309 and Y positions as well. */
3314 if (wp
.showCmd
!= SW_SHOWMAXIMIZED
3315 && ! (lppos
->flags
& SWP_NOMOVE
))
3317 if (lppos
->x
!= wr
.left
|| lppos
->y
!= wr
.top
)
3324 lppos
->flags
|= SWP_NOMOVE
;
3333 if (ret
== 0) return (0);
3336 case WM_EMACS_SHOWWINDOW
:
3337 return ShowWindow (hwnd
, wParam
);
3338 case WM_EMACS_SETWINDOWPOS
:
3340 Win32WindowPos
* pos
= (Win32WindowPos
*) wParam
;
3341 return SetWindowPos (hwnd
, pos
->hwndAfter
,
3342 pos
->x
, pos
->y
, pos
->cx
, pos
->cy
, pos
->flags
);
3344 case WM_EMACS_DESTROYWINDOW
:
3345 DestroyWindow ((HWND
) wParam
);
3349 return DefWindowProc (hwnd
, msg
, wParam
, lParam
);
3356 my_create_window (f
)
3361 PostThreadMessage (dwWinThreadId
, WM_EMACS_CREATEWINDOW
, (WPARAM
)f
, 0);
3362 GetMessage (&msg
, NULL
, WM_EMACS_DONE
, WM_EMACS_DONE
);
3365 /* Create and set up the win32 window for frame F. */
3368 win32_window (f
, window_prompting
, minibuffer_only
)
3370 long window_prompting
;
3371 int minibuffer_only
;
3375 /* Use the resource name as the top-level window name
3376 for looking up resources. Make a non-Lisp copy
3377 for the window manager, so GC relocation won't bother it.
3379 Elsewhere we specify the window name for the window manager. */
3382 char *str
= (char *) XSTRING (Vx_resource_name
)->data
;
3383 f
->namebuf
= (char *) xmalloc (strlen (str
) + 1);
3384 strcpy (f
->namebuf
, str
);
3387 my_create_window (f
);
3389 validate_x_resource_name ();
3391 /* x_set_name normally ignores requests to set the name if the
3392 requested name is the same as the current name. This is the one
3393 place where that assumption isn't correct; f->name is set, but
3394 the server hasn't been told. */
3397 int explicit = f
->explicit_name
;
3399 f
->explicit_name
= 0;
3402 x_set_name (f
, name
, explicit);
3407 if (!minibuffer_only
&& FRAME_EXTERNAL_MENU_BAR (f
))
3408 initialize_frame_menubar (f
);
3410 if (FRAME_WIN32_WINDOW (f
) == 0)
3411 error ("Unable to create window");
3414 /* Handle the icon stuff for this window. Perhaps later we might
3415 want an x_set_icon_position which can be called interactively as
3423 Lisp_Object icon_x
, icon_y
;
3425 /* Set the position of the icon. Note that win95 groups all
3426 icons in the tray. */
3427 icon_x
= x_get_arg (parms
, Qicon_left
, 0, 0, number
);
3428 icon_y
= x_get_arg (parms
, Qicon_top
, 0, 0, number
);
3429 if (!EQ (icon_x
, Qunbound
) && !EQ (icon_y
, Qunbound
))
3431 CHECK_NUMBER (icon_x
, 0);
3432 CHECK_NUMBER (icon_y
, 0);
3434 else if (!EQ (icon_x
, Qunbound
) || !EQ (icon_y
, Qunbound
))
3435 error ("Both left and top icon corners of icon must be specified");
3439 if (! EQ (icon_x
, Qunbound
))
3440 x_wm_set_icon_position (f
, XINT (icon_x
), XINT (icon_y
));
3445 DEFUN ("x-create-frame", Fx_create_frame
, Sx_create_frame
,
3447 "Make a new window, which is called a \"frame\" in Emacs terms.\n\
3448 Returns an Emacs frame object.\n\
3449 ALIST is an alist of frame parameters.\n\
3450 If the parameters specify that the frame should not have a minibuffer,\n\
3451 and do not specify a specific minibuffer window to use,\n\
3452 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
3453 be shared by the new frame.\n\
3455 This function is an internal primitive--use `make-frame' instead.")
3460 Lisp_Object frame
, tem
;
3462 int minibuffer_only
= 0;
3463 long window_prompting
= 0;
3465 int count
= specpdl_ptr
- specpdl
;
3466 struct gcpro gcpro1
;
3467 Lisp_Object display
;
3468 struct win32_display_info
*dpyinfo
;
3472 /* Use this general default value to start with
3473 until we know if this frame has a specified name. */
3474 Vx_resource_name
= Vinvocation_name
;
3476 display
= x_get_arg (parms
, Qdisplay
, 0, 0, string
);
3477 if (EQ (display
, Qunbound
))
3479 dpyinfo
= check_x_display_info (display
);
3481 kb
= dpyinfo
->kboard
;
3483 kb
= &the_only_kboard
;
3486 name
= x_get_arg (parms
, Qname
, "title", "Title", string
);
3488 && ! EQ (name
, Qunbound
)
3490 error ("Invalid frame name--not a string or nil");
3493 Vx_resource_name
= name
;
3495 /* See if parent window is specified. */
3496 parent
= x_get_arg (parms
, Qparent_id
, NULL
, NULL
, number
);
3497 if (EQ (parent
, Qunbound
))
3499 if (! NILP (parent
))
3500 CHECK_NUMBER (parent
, 0);
3502 tem
= x_get_arg (parms
, Qminibuffer
, 0, 0, symbol
);
3503 if (EQ (tem
, Qnone
) || NILP (tem
))
3504 f
= make_frame_without_minibuffer (Qnil
, kb
, display
);
3505 else if (EQ (tem
, Qonly
))
3507 f
= make_minibuffer_frame ();
3508 minibuffer_only
= 1;
3510 else if (WINDOWP (tem
))
3511 f
= make_frame_without_minibuffer (tem
, kb
, display
);
3515 /* Note that Windows does support scroll bars. */
3516 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 1;
3517 /* By default, make scrollbars the system standard width. */
3518 f
->scroll_bar_pixel_width
= GetSystemMetrics (SM_CXVSCROLL
);
3520 XSETFRAME (frame
, f
);
3523 f
->output_method
= output_win32
;
3524 f
->output_data
.win32
= (struct win32_output
*) xmalloc (sizeof (struct win32_output
));
3525 bzero (f
->output_data
.win32
, sizeof (struct win32_output
));
3527 /* FRAME_WIN32_DISPLAY_INFO (f) = dpyinfo; */
3529 FRAME_KBOARD (f
) = kb
;
3532 /* Specify the parent under which to make this window. */
3536 f
->output_data
.win32
->parent_desc
= (Window
) parent
;
3537 f
->output_data
.win32
->explicit_parent
= 1;
3541 f
->output_data
.win32
->parent_desc
= FRAME_WIN32_DISPLAY_INFO (f
)->root_window
;
3542 f
->output_data
.win32
->explicit_parent
= 0;
3545 /* Note that the frame has no physical cursor right now. */
3546 f
->phys_cursor_x
= -1;
3548 /* Set the name; the functions to which we pass f expect the name to
3550 if (EQ (name
, Qunbound
) || NILP (name
))
3552 f
->name
= build_string (dpyinfo
->win32_id_name
);
3553 f
->explicit_name
= 0;
3558 f
->explicit_name
= 1;
3559 /* use the frame's title when getting resources for this frame. */
3560 specbind (Qx_resource_name
, name
);
3563 /* Extract the window parameters from the supplied values
3564 that are needed to determine window geometry. */
3568 font
= x_get_arg (parms
, Qfont
, "font", "Font", string
);
3570 /* First, try whatever font the caller has specified. */
3572 font
= x_new_font (f
, XSTRING (font
)->data
);
3574 /* Try out a font which we hope has bold and italic variations. */
3575 if (!STRINGP (font
))
3576 font
= x_new_font (f
, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3577 if (! STRINGP (font
))
3578 font
= x_new_font (f
, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3579 if (! STRINGP (font
))
3580 /* This was formerly the first thing tried, but it finds too many fonts
3581 and takes too long. */
3582 font
= x_new_font (f
, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
3583 /* If those didn't work, look for something which will at least work. */
3584 if (! STRINGP (font
))
3585 font
= x_new_font (f
, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
3586 if (! STRINGP (font
))
3587 font
= x_new_font (f
, "-*-system-medium-r-normal-*-*-200-*-*-c-120-*-*");
3589 if (! STRINGP (font
))
3590 font
= x_new_font (f
, "-*-Fixedsys-*-r-*-*-12-90-*-*-c-*-*-*");
3592 if (! STRINGP (font
))
3593 font
= build_string ("-*-system");
3595 x_default_parameter (f
, parms
, Qfont
, font
,
3596 "font", "Font", string
);
3599 x_default_parameter (f
, parms
, Qborder_width
, make_number (2),
3600 "borderwidth", "BorderWidth", number
);
3601 /* This defaults to 2 in order to match xterm. We recognize either
3602 internalBorderWidth or internalBorder (which is what xterm calls
3604 if (NILP (Fassq (Qinternal_border_width
, parms
)))
3608 value
= x_get_arg (parms
, Qinternal_border_width
,
3609 "internalBorder", "BorderWidth", number
);
3610 if (! EQ (value
, Qunbound
))
3611 parms
= Fcons (Fcons (Qinternal_border_width
, value
),
3614 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (0),
3615 "internalBorderWidth", "BorderWidth", number
);
3616 x_default_parameter (f
, parms
, Qvertical_scroll_bars
, Qt
,
3617 "verticalScrollBars", "ScrollBars", boolean
);
3619 /* Also do the stuff which must be set before the window exists. */
3620 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
3621 "foreground", "Foreground", string
);
3622 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
3623 "background", "Background", string
);
3624 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
3625 "pointerColor", "Foreground", string
);
3626 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
3627 "cursorColor", "Foreground", string
);
3628 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
3629 "borderColor", "BorderColor", string
);
3631 x_default_parameter (f
, parms
, Qmenu_bar_lines
, make_number (1),
3632 "menuBar", "MenuBar", number
);
3633 x_default_parameter (f
, parms
, Qscroll_bar_width
, Qnil
,
3634 "scrollBarWidth", "ScrollBarWidth", number
);
3636 f
->output_data
.win32
->dwStyle
= WS_OVERLAPPEDWINDOW
;
3637 f
->output_data
.win32
->parent_desc
= FRAME_WIN32_DISPLAY_INFO (f
)->root_window
;
3638 window_prompting
= x_figure_window_size (f
, parms
);
3640 if (window_prompting
& XNegative
)
3642 if (window_prompting
& YNegative
)
3643 f
->output_data
.win32
->win_gravity
= SouthEastGravity
;
3645 f
->output_data
.win32
->win_gravity
= NorthEastGravity
;
3649 if (window_prompting
& YNegative
)
3650 f
->output_data
.win32
->win_gravity
= SouthWestGravity
;
3652 f
->output_data
.win32
->win_gravity
= NorthWestGravity
;
3655 f
->output_data
.win32
->size_hint_flags
= window_prompting
;
3657 win32_window (f
, window_prompting
, minibuffer_only
);
3659 init_frame_faces (f
);
3661 /* We need to do this after creating the window, so that the
3662 icon-creation functions can say whose icon they're describing. */
3663 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
3664 "bitmapIcon", "BitmapIcon", symbol
);
3666 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
3667 "autoRaise", "AutoRaiseLower", boolean
);
3668 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
3669 "autoLower", "AutoRaiseLower", boolean
);
3670 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
3671 "cursorType", "CursorType", symbol
);
3673 /* Dimensions, especially f->height, must be done via change_frame_size.
3674 Change will not be effected unless different from the current
3678 f
->height
= f
->width
= 0;
3679 change_frame_size (f
, height
, width
, 1, 0);
3681 /* Tell the server what size and position, etc, we want,
3682 and how badly we want them. */
3684 x_wm_set_size_hint (f
, window_prompting
, 0);
3687 tem
= x_get_arg (parms
, Qunsplittable
, 0, 0, boolean
);
3688 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
3692 /* It is now ok to make the frame official
3693 even if we get an error below.
3694 And the frame needs to be on Vframe_list
3695 or making it visible won't work. */
3696 Vframe_list
= Fcons (frame
, Vframe_list
);
3698 /* Now that the frame is official, it counts as a reference to
3700 FRAME_WIN32_DISPLAY_INFO (f
)->reference_count
++;
3702 /* Make the window appear on the frame and enable display,
3703 unless the caller says not to. However, with explicit parent,
3704 Emacs cannot control visibility, so don't try. */
3705 if (! f
->output_data
.win32
->explicit_parent
)
3707 Lisp_Object visibility
;
3709 visibility
= x_get_arg (parms
, Qvisibility
, 0, 0, symbol
);
3710 if (EQ (visibility
, Qunbound
))
3713 if (EQ (visibility
, Qicon
))
3714 x_iconify_frame (f
);
3715 else if (! NILP (visibility
))
3716 x_make_frame_visible (f
);
3718 /* Must have been Qnil. */
3722 return unbind_to (count
, frame
);
3725 /* FRAME is used only to get a handle on the X display. We don't pass the
3726 display info directly because we're called from frame.c, which doesn't
3727 know about that structure. */
3729 x_get_focus_frame (frame
)
3730 struct frame
*frame
;
3732 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (frame
);
3734 if (! dpyinfo
->win32_focus_frame
)
3737 XSETFRAME (xfocus
, dpyinfo
->win32_focus_frame
);
3741 DEFUN ("focus-frame", Ffocus_frame
, Sfocus_frame
, 1, 1, 0,
3742 "This function is obsolete, and does nothing.")
3749 DEFUN ("unfocus-frame", Funfocus_frame
, Sunfocus_frame
, 0, 0, 0,
3750 "This function is obsolete, and does nothing.")
3757 win32_load_font (dpyinfo
,name
)
3758 struct win32_display_info
*dpyinfo
;
3761 XFontStruct
* font
= NULL
;
3767 if (!name
|| !x_to_win32_font (name
, &lf
))
3770 font
= (XFontStruct
*) xmalloc (sizeof (XFontStruct
));
3772 if (!font
) return (NULL
);
3776 font
->hfont
= CreateFontIndirect (&lf
);
3779 if (font
->hfont
== NULL
)
3788 hdc
= GetDC (dpyinfo
->root_window
);
3789 oldobj
= SelectObject (hdc
, font
->hfont
);
3790 ok
= GetTextMetrics (hdc
, &font
->tm
);
3791 SelectObject (hdc
, oldobj
);
3792 ReleaseDC (dpyinfo
->root_window
, hdc
);
3797 if (ok
) return (font
);
3799 win32_unload_font (dpyinfo
, font
);
3804 win32_unload_font (dpyinfo
, font
)
3805 struct win32_display_info
*dpyinfo
;
3810 if (font
->hfont
) DeleteObject(font
->hfont
);
3815 /* The font conversion stuff between x and win32 */
3817 /* X font string is as follows (from faces.el)
3821 * (weight "\\(bold\\|demibold\\|medium\\)") ; 1
3822 * (weight\? "\\([^-]*\\)") ; 1
3823 * (slant "\\([ior]\\)") ; 2
3824 * (slant\? "\\([^-]?\\)") ; 2
3825 * (swidth "\\([^-]*\\)") ; 3
3826 * (adstyle "[^-]*") ; 4
3827 * (pixelsize "[0-9]+")
3828 * (pointsize "[0-9][0-9]+")
3829 * (resx "[0-9][0-9]+")
3830 * (resy "[0-9][0-9]+")
3831 * (spacing "[cmp?*]")
3832 * (avgwidth "[0-9]+")
3833 * (registry "[^-]+")
3834 * (encoding "[^-]+")
3836 * (setq x-font-regexp
3837 * (concat "\\`\\*?[-?*]"
3838 * foundry - family - weight\? - slant\? - swidth - adstyle -
3839 * pixelsize - pointsize - resx - resy - spacing - registry -
3840 * encoding "[-?*]\\*?\\'"
3842 * (setq x-font-regexp-head
3843 * (concat "\\`[-?*]" foundry - family - weight\? - slant\?
3844 * "\\([-*?]\\|\\'\\)"))
3845 * (setq x-font-regexp-slant (concat - slant -))
3846 * (setq x-font-regexp-weight (concat - weight -))
3850 #define FONT_START "[-?]"
3851 #define FONT_FOUNDRY "[^-]+"
3852 #define FONT_FAMILY "\\([^-]+\\)" /* 1 */
3853 #define FONT_WEIGHT "\\(bold\\|demibold\\|medium\\)" /* 2 */
3854 #define FONT_WEIGHT_Q "\\([^-]*\\)" /* 2 */
3855 #define FONT_SLANT "\\([ior]\\)" /* 3 */
3856 #define FONT_SLANT_Q "\\([^-]?\\)" /* 3 */
3857 #define FONT_SWIDTH "\\([^-]*\\)" /* 4 */
3858 #define FONT_ADSTYLE "[^-]*"
3859 #define FONT_PIXELSIZE "[^-]*"
3860 #define FONT_POINTSIZE "\\([0-9][0-9]+\\|\\*\\)" /* 5 */
3861 #define FONT_RESX "[0-9][0-9]+"
3862 #define FONT_RESY "[0-9][0-9]+"
3863 #define FONT_SPACING "[cmp?*]"
3864 #define FONT_AVGWIDTH "[0-9]+"
3865 #define FONT_REGISTRY "[^-]+"
3866 #define FONT_ENCODING "[^-]+"
3868 #define FONT_REGEXP ("\\`\\*?[-?*]" \
3875 FONT_PIXELSIZE "-" \
3876 FONT_POINTSIZE "-" \
3879 #define FONT_REGEXP_HEAD ("\\`[-?*]" \
3884 "\\([-*?]\\|\\'\\)")
3886 #define FONT_REGEXP_SLANT "-" FONT_SLANT "-"
3887 #define FONT_REGEXP_WEIGHT "-" FONT_WEIGHT "-"
3890 x_to_win32_weight (lpw
)
3893 if (!lpw
) return (FW_DONTCARE
);
3895 if (stricmp (lpw
,"heavy") == 0) return FW_HEAVY
;
3896 else if (stricmp (lpw
,"extrabold") == 0) return FW_EXTRABOLD
;
3897 else if (stricmp (lpw
,"bold") == 0) return FW_BOLD
;
3898 else if (stricmp (lpw
,"demibold") == 0) return FW_SEMIBOLD
;
3899 else if (stricmp (lpw
,"medium") == 0) return FW_MEDIUM
;
3900 else if (stricmp (lpw
,"normal") == 0) return FW_NORMAL
;
3901 else if (stricmp (lpw
,"light") == 0) return FW_LIGHT
;
3902 else if (stricmp (lpw
,"extralight") == 0) return FW_EXTRALIGHT
;
3903 else if (stricmp (lpw
,"thin") == 0) return FW_THIN
;
3910 win32_to_x_weight (fnweight
)
3913 if (fnweight
>= FW_HEAVY
) return "heavy";
3914 if (fnweight
>= FW_EXTRABOLD
) return "extrabold";
3915 if (fnweight
>= FW_BOLD
) return "bold";
3916 if (fnweight
>= FW_SEMIBOLD
) return "semibold";
3917 if (fnweight
>= FW_MEDIUM
) return "medium";
3918 if (fnweight
>= FW_NORMAL
) return "normal";
3919 if (fnweight
>= FW_LIGHT
) return "light";
3920 if (fnweight
>= FW_EXTRALIGHT
) return "extralight";
3921 if (fnweight
>= FW_THIN
) return "thin";
3927 x_to_win32_charset (lpcs
)
3930 if (!lpcs
) return (0);
3932 if (stricmp (lpcs
,"ansi") == 0) return ANSI_CHARSET
;
3933 else if (stricmp (lpcs
,"iso8859-1") == 0) return ANSI_CHARSET
;
3934 else if (stricmp (lpcs
,"iso8859") == 0) return ANSI_CHARSET
;
3935 else if (stricmp (lpcs
,"oem") == 0) return OEM_CHARSET
;
3936 #ifdef UNICODE_CHARSET
3937 else if (stricmp (lpcs
,"unicode") == 0) return UNICODE_CHARSET
;
3938 else if (stricmp (lpcs
,"iso10646") == 0) return UNICODE_CHARSET
;
3945 win32_to_x_charset (fncharset
)
3950 case ANSI_CHARSET
: return "ansi";
3951 case OEM_CHARSET
: return "oem";
3952 case SYMBOL_CHARSET
: return "symbol";
3953 #ifdef UNICODE_CHARSET
3954 case UNICODE_CHARSET
: return "unicode";
3961 win32_to_x_font (lplogfont
, lpxstr
, len
)
3962 LOGFONT
* lplogfont
;
3966 char height_pixels
[8];
3968 char width_pixels
[8];
3970 if (!lpxstr
) abort ();
3975 if (lplogfont
->lfHeight
)
3977 sprintf (height_pixels
, "%u", abs (lplogfont
->lfHeight
));
3978 sprintf (height_dpi
, "%u",
3979 (abs (lplogfont
->lfHeight
) * 720) / one_win32_display_info
.height_in
);
3983 strcpy (height_pixels
, "*");
3984 strcpy (height_dpi
, "*");
3986 if (lplogfont
->lfWidth
)
3987 sprintf (width_pixels
, "%u", lplogfont
->lfWidth
* 10);
3989 strcpy (width_pixels
, "*");
3991 _snprintf (lpxstr
, len
- 1,
3992 "-*-%s-%s-%c-*-*-%s-%s-*-*-%c-%s-*-%s-",
3993 lplogfont
->lfFaceName
,
3994 win32_to_x_weight (lplogfont
->lfWeight
),
3995 lplogfont
->lfItalic
?'i':'r',
3998 ((lplogfont
->lfPitchAndFamily
& 0x3) == VARIABLE_PITCH
) ? 'p' : 'c',
4000 win32_to_x_charset (lplogfont
->lfCharSet
)
4003 lpxstr
[len
- 1] = 0; /* just to be sure */
4008 x_to_win32_font (lpxstr
, lplogfont
)
4010 LOGFONT
* lplogfont
;
4012 if (!lplogfont
) return (FALSE
);
4014 memset (lplogfont
, 0, sizeof (*lplogfont
));
4017 lplogfont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
4018 lplogfont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
4019 lplogfont
->lfQuality
= DEFAULT_QUALITY
;
4021 /* go for maximum quality */
4022 lplogfont
->lfOutPrecision
= OUT_STROKE_PRECIS
;
4023 lplogfont
->lfClipPrecision
= CLIP_STROKE_PRECIS
;
4024 lplogfont
->lfQuality
= PROOF_QUALITY
;
4030 /* Provide a simple escape mechanism for specifying Windows font names
4031 * directly -- if font spec does not beginning with '-', assume this
4033 * "<font name>[:height in pixels[:width in pixels[:weight]]]"
4039 char name
[50], weight
[20], slant
, pitch
, pixels
[10], height
[10], width
[10], remainder
[20];
4042 fields
= sscanf (lpxstr
,
4043 "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%*[^-]-%c-%9[^-]-%19s",
4044 name
, weight
, &slant
, pixels
, height
, &pitch
, width
, remainder
);
4046 if (fields
== EOF
) return (FALSE
);
4048 if (fields
> 0 && name
[0] != '*')
4050 strncpy (lplogfont
->lfFaceName
,name
, LF_FACESIZE
);
4051 lplogfont
->lfFaceName
[LF_FACESIZE
-1] = 0;
4055 lplogfont
->lfFaceName
[0] = 0;
4060 lplogfont
->lfWeight
= x_to_win32_weight ((fields
> 0 ? weight
: ""));
4064 if (!NILP (Vwin32_enable_italics
))
4065 lplogfont
->lfItalic
= (fields
> 0 && slant
== 'i');
4069 if (fields
> 0 && pixels
[0] != '*')
4070 lplogfont
->lfHeight
= atoi (pixels
);
4074 if (fields
> 0 && lplogfont
->lfHeight
== 0 && height
[0] != '*')
4075 lplogfont
->lfHeight
= (atoi (height
)
4076 * one_win32_display_info
.height_in
) / 720;
4080 lplogfont
->lfPitchAndFamily
=
4081 (fields
> 0 && pitch
== 'p') ? VARIABLE_PITCH
: FIXED_PITCH
;
4085 if (fields
> 0 && width
[0] != '*')
4086 lplogfont
->lfWidth
= atoi (width
) / 10;
4090 /* Not all font specs include the registry field, so we allow for an
4091 optional registry field before the encoding when parsing
4092 remainder. Also we strip the trailing '-' if present. */
4094 int len
= strlen (remainder
);
4095 if (len
> 0 && remainder
[len
-1] == '-')
4096 remainder
[len
-1] = 0;
4098 encoding
= remainder
;
4099 if (strncmp (encoding
, "*-", 2) == 0)
4101 lplogfont
->lfCharSet
= x_to_win32_charset (fields
> 0 ? encoding
: "");
4106 char name
[100], height
[10], width
[10], weight
[20];
4108 fields
= sscanf (lpxstr
,
4109 "%99[^:]:%9[^:]:%9[^:]:%19s",
4110 name
, height
, width
, weight
);
4112 if (fields
== EOF
) return (FALSE
);
4116 strncpy (lplogfont
->lfFaceName
,name
, LF_FACESIZE
);
4117 lplogfont
->lfFaceName
[LF_FACESIZE
-1] = 0;
4121 lplogfont
->lfFaceName
[0] = 0;
4127 lplogfont
->lfHeight
= atoi (height
);
4132 lplogfont
->lfWidth
= atoi (width
);
4136 lplogfont
->lfWeight
= x_to_win32_weight ((fields
> 0 ? weight
: ""));
4139 /* This makes TrueType fonts work better. */
4140 lplogfont
->lfHeight
= - abs (lplogfont
->lfHeight
);
4146 win32_font_match (lpszfont1
, lpszfont2
)
4150 char * s1
= lpszfont1
, *e1
;
4151 char * s2
= lpszfont2
, *e2
;
4153 if (s1
== NULL
|| s2
== NULL
) return (FALSE
);
4155 if (*s1
== '-') s1
++;
4156 if (*s2
== '-') s2
++;
4162 e1
= strchr (s1
, '-');
4163 e2
= strchr (s2
, '-');
4165 if (e1
== NULL
|| e2
== NULL
) return (TRUE
);
4170 if (*s1
!= '*' && *s2
!= '*'
4171 && (len1
!= len2
|| strnicmp (s1
, s2
, len1
) != 0))
4179 typedef struct enumfont_t
4184 XFontStruct
*size_ref
;
4185 Lisp_Object
*pattern
;
4191 enum_font_cb2 (lplf
, lptm
, FontType
, lpef
)
4193 NEWTEXTMETRIC
* lptm
;
4197 if (lplf
->elfLogFont
.lfStrikeOut
|| lplf
->elfLogFont
.lfUnderline
4198 || (lplf
->elfLogFont
.lfCharSet
!= ANSI_CHARSET
&& lplf
->elfLogFont
.lfCharSet
!= OEM_CHARSET
))
4201 /* if (!lpef->size_ref || lptm->tmMaxCharWidth == FONT_WIDTH (lpef->size_ref)) */
4205 if (!NILP (*(lpef
->pattern
)) && FontType
== TRUETYPE_FONTTYPE
)
4207 lplf
->elfLogFont
.lfHeight
= lpef
->logfont
.lfHeight
;
4208 lplf
->elfLogFont
.lfWidth
= lpef
->logfont
.lfWidth
;
4211 if (!win32_to_x_font (lplf
, buf
, 100)) return (0);
4213 if (NILP (*(lpef
->pattern
)) || win32_font_match (buf
, XSTRING (*(lpef
->pattern
))->data
))
4215 *lpef
->tail
= Fcons (build_string (buf
), Qnil
);
4216 lpef
->tail
= &XCONS (*lpef
->tail
)->cdr
;
4225 enum_font_cb1 (lplf
, lptm
, FontType
, lpef
)
4227 NEWTEXTMETRIC
* lptm
;
4231 return EnumFontFamilies (lpef
->hdc
,
4232 lplf
->elfLogFont
.lfFaceName
,
4233 (FONTENUMPROC
) enum_font_cb2
,
4238 DEFUN ("x-list-fonts", Fx_list_fonts
, Sx_list_fonts
, 1, 3, 0,
4239 "Return a list of the names of available fonts matching PATTERN.\n\
4240 If optional arguments FACE and FRAME are specified, return only fonts\n\
4241 the same size as FACE on FRAME.\n\
4243 PATTERN is a string, perhaps with wildcard characters;\n\
4244 the * character matches any substring, and\n\
4245 the ? character matches any single character.\n\
4246 PATTERN is case-insensitive.\n\
4247 FACE is a face name--a symbol.\n\
4249 The return value is a list of strings, suitable as arguments to\n\
4252 Fonts Emacs can't use (i.e. proportional fonts) may or may not be excluded\n\
4253 even if they match PATTERN and FACE.")
4254 (pattern
, face
, frame
)
4255 Lisp_Object pattern
, face
, frame
;
4260 XFontStruct
*size_ref
;
4261 Lisp_Object namelist
;
4266 CHECK_STRING (pattern
, 0);
4268 CHECK_SYMBOL (face
, 1);
4270 f
= check_x_frame (frame
);
4272 /* Determine the width standard for comparison with the fonts we find. */
4280 /* Don't die if we get called with a terminal frame. */
4281 if (! FRAME_WIN32_P (f
))
4282 error ("non-win32 frame used in `x-list-fonts'");
4284 face_id
= face_name_id_number (f
, face
);
4286 if (face_id
< 0 || face_id
>= FRAME_N_PARAM_FACES (f
)
4287 || FRAME_PARAM_FACES (f
) [face_id
] == 0)
4288 size_ref
= f
->output_data
.win32
->font
;
4291 size_ref
= FRAME_PARAM_FACES (f
) [face_id
]->font
;
4292 if (size_ref
== (XFontStruct
*) (~0))
4293 size_ref
= f
->output_data
.win32
->font
;
4297 /* See if we cached the result for this particular query. */
4298 list
= Fassoc (pattern
,
4299 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
);
4301 /* We have info in the cache for this PATTERN. */
4304 Lisp_Object tem
, newlist
;
4306 /* We have info about this pattern. */
4307 list
= XCONS (list
)->cdr
;
4314 /* Filter the cached info and return just the fonts that match FACE. */
4316 for (tem
= list
; CONSP (tem
); tem
= XCONS (tem
)->cdr
)
4318 XFontStruct
*thisinfo
;
4320 thisinfo
= win32_load_font (FRAME_WIN32_DISPLAY_INFO (f
), XSTRING (XCONS (tem
)->car
)->data
);
4322 if (thisinfo
&& same_size_fonts (thisinfo
, size_ref
))
4323 newlist
= Fcons (XCONS (tem
)->car
, newlist
);
4325 win32_unload_font (FRAME_WIN32_DISPLAY_INFO (f
), thisinfo
);
4336 ef
.pattern
= &pattern
;
4337 ef
.tail
= ef
.head
= &namelist
;
4339 x_to_win32_font (STRINGP (pattern
) ? XSTRING (pattern
)->data
: NULL
, &ef
.logfont
);
4342 ef
.hdc
= GetDC (FRAME_WIN32_WINDOW (f
));
4344 EnumFontFamilies (ef
.hdc
, NULL
, (FONTENUMPROC
) enum_font_cb1
, (LPARAM
)&ef
);
4346 ReleaseDC (FRAME_WIN32_WINDOW (f
), ef
.hdc
);
4356 /* Make a list of all the fonts we got back.
4357 Store that in the font cache for the display. */
4358 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
4359 = Fcons (Fcons (pattern
, namelist
),
4360 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
);
4362 /* Make a list of the fonts that have the right width. */
4365 for (i
= 0; i
< ef
.numFonts
; i
++)
4373 XFontStruct
*thisinfo
;
4376 thisinfo
= win32_load_font (FRAME_WIN32_DISPLAY_INFO (f
), XSTRING (Fcar (cur
))->data
);
4378 keeper
= thisinfo
&& same_size_fonts (thisinfo
, size_ref
);
4380 win32_unload_font (FRAME_WIN32_DISPLAY_INFO (f
), thisinfo
);
4385 list
= Fcons (build_string (XSTRING (Fcar (cur
))->data
), list
);
4389 list
= Fnreverse (list
);
4395 DEFUN ("x-color-defined-p", Fx_color_defined_p
, Sx_color_defined_p
, 1, 2, 0,
4396 "Return non-nil if color COLOR is supported on frame FRAME.\n\
4397 If FRAME is omitted or nil, use the selected frame.")
4399 Lisp_Object color
, frame
;
4402 FRAME_PTR f
= check_x_frame (frame
);
4404 CHECK_STRING (color
, 1);
4406 if (defined_color (f
, XSTRING (color
)->data
, &foo
, 0))
4412 DEFUN ("x-color-values", Fx_color_values
, Sx_color_values
, 1, 2, 0,
4413 "Return a description of the color named COLOR on frame FRAME.\n\
4414 The value is a list of integer RGB values--(RED GREEN BLUE).\n\
4415 These values appear to range from 0 to 65280 or 65535, depending\n\
4416 on the system; white is (65280 65280 65280) or (65535 65535 65535).\n\
4417 If FRAME is omitted or nil, use the selected frame.")
4419 Lisp_Object color
, frame
;
4422 FRAME_PTR f
= check_x_frame (frame
);
4424 CHECK_STRING (color
, 1);
4426 if (defined_color (f
, XSTRING (color
)->data
, &foo
, 0))
4430 rgb
[0] = make_number (GetRValue (foo
));
4431 rgb
[1] = make_number (GetGValue (foo
));
4432 rgb
[2] = make_number (GetBValue (foo
));
4433 return Flist (3, rgb
);
4439 DEFUN ("x-display-color-p", Fx_display_color_p
, Sx_display_color_p
, 0, 1, 0,
4440 "Return t if the X display supports color.\n\
4441 The optional argument DISPLAY specifies which display to ask about.\n\
4442 DISPLAY should be either a frame or a display name (a string).\n\
4443 If omitted or nil, that stands for the selected frame's display.")
4445 Lisp_Object display
;
4447 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4449 if ((dpyinfo
->n_planes
* dpyinfo
->n_cbits
) <= 2)
4455 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p
, Sx_display_grayscale_p
,
4457 "Return t if the X display supports shades of gray.\n\
4458 Note that color displays do support shades of gray.\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 if ((dpyinfo
->n_planes
* dpyinfo
->n_cbits
) <= 1)
4473 DEFUN ("x-display-pixel-width", Fx_display_pixel_width
, Sx_display_pixel_width
,
4475 "Returns the width in pixels of the X display DISPLAY.\n\
4476 The optional argument DISPLAY specifies which display to ask about.\n\
4477 DISPLAY should be either a frame or a display name (a string).\n\
4478 If omitted or nil, that stands for the selected frame's display.")
4480 Lisp_Object display
;
4482 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4484 return make_number (dpyinfo
->width
);
4487 DEFUN ("x-display-pixel-height", Fx_display_pixel_height
,
4488 Sx_display_pixel_height
, 0, 1, 0,
4489 "Returns the height in pixels of the X display DISPLAY.\n\
4490 The optional argument DISPLAY specifies which display to ask about.\n\
4491 DISPLAY should be either a frame or a display name (a string).\n\
4492 If omitted or nil, that stands for the selected frame's display.")
4494 Lisp_Object display
;
4496 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4498 return make_number (dpyinfo
->height
);
4501 DEFUN ("x-display-planes", Fx_display_planes
, Sx_display_planes
,
4503 "Returns the number of bitplanes of the display DISPLAY.\n\
4504 The optional argument DISPLAY specifies which display to ask about.\n\
4505 DISPLAY should be either a frame or a display name (a string).\n\
4506 If omitted or nil, that stands for the selected frame's display.")
4508 Lisp_Object display
;
4510 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4512 return make_number (dpyinfo
->n_planes
* dpyinfo
->n_cbits
);
4515 DEFUN ("x-display-color-cells", Fx_display_color_cells
, Sx_display_color_cells
,
4517 "Returns the number of color cells of the display DISPLAY.\n\
4518 The optional argument DISPLAY specifies which display to ask about.\n\
4519 DISPLAY should be either a frame or a display name (a string).\n\
4520 If omitted or nil, that stands for the selected frame's display.")
4522 Lisp_Object display
;
4524 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4528 hdc
= GetDC (dpyinfo
->root_window
);
4529 if (dpyinfo
->has_palette
)
4530 cap
= GetDeviceCaps (hdc
,SIZEPALETTE
);
4532 cap
= GetDeviceCaps (hdc
,NUMCOLORS
);
4534 ReleaseDC (dpyinfo
->root_window
, hdc
);
4536 return make_number (cap
);
4539 DEFUN ("x-server-max-request-size", Fx_server_max_request_size
,
4540 Sx_server_max_request_size
,
4542 "Returns the maximum request size of the server of display DISPLAY.\n\
4543 The optional argument DISPLAY specifies which display to ask about.\n\
4544 DISPLAY should be either a frame or a display name (a string).\n\
4545 If omitted or nil, that stands for the selected frame's display.")
4547 Lisp_Object display
;
4549 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4551 return make_number (1);
4554 DEFUN ("x-server-vendor", Fx_server_vendor
, Sx_server_vendor
, 0, 1, 0,
4555 "Returns the vendor ID string of the Win32 system (Microsoft).\n\
4556 The optional argument DISPLAY specifies which display to ask about.\n\
4557 DISPLAY should be either a frame or a display name (a string).\n\
4558 If omitted or nil, that stands for the selected frame's display.")
4560 Lisp_Object display
;
4562 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4563 char *vendor
= "Microsoft Corp.";
4565 if (! vendor
) vendor
= "";
4566 return build_string (vendor
);
4569 DEFUN ("x-server-version", Fx_server_version
, Sx_server_version
, 0, 1, 0,
4570 "Returns the version numbers of the server of display DISPLAY.\n\
4571 The value is a list of three integers: the major and minor\n\
4572 version numbers, and the vendor-specific release\n\
4573 number. See also the function `x-server-vendor'.\n\n\
4574 The optional argument DISPLAY specifies which display to ask about.\n\
4575 DISPLAY should be either a frame or a display name (a string).\n\
4576 If omitted or nil, that stands for the selected frame's display.")
4578 Lisp_Object display
;
4580 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4582 return Fcons (make_number (nt_major_version
),
4583 Fcons (make_number (nt_minor_version
), Qnil
));
4586 DEFUN ("x-display-screens", Fx_display_screens
, Sx_display_screens
, 0, 1, 0,
4587 "Returns the number of screens on the server of display DISPLAY.\n\
4588 The optional argument DISPLAY specifies which display to ask about.\n\
4589 DISPLAY should be either a frame or a display name (a string).\n\
4590 If omitted or nil, that stands for the selected frame's display.")
4592 Lisp_Object display
;
4594 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4596 return make_number (1);
4599 DEFUN ("x-display-mm-height", Fx_display_mm_height
, Sx_display_mm_height
, 0, 1, 0,
4600 "Returns the height in millimeters of the X display DISPLAY.\n\
4601 The optional argument DISPLAY specifies which display to ask about.\n\
4602 DISPLAY should be either a frame or a display name (a string).\n\
4603 If omitted or nil, that stands for the selected frame's display.")
4605 Lisp_Object display
;
4607 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4611 hdc
= GetDC (dpyinfo
->root_window
);
4613 cap
= GetDeviceCaps (hdc
, VERTSIZE
);
4615 ReleaseDC (dpyinfo
->root_window
, hdc
);
4617 return make_number (cap
);
4620 DEFUN ("x-display-mm-width", Fx_display_mm_width
, Sx_display_mm_width
, 0, 1, 0,
4621 "Returns the width in millimeters of the X display DISPLAY.\n\
4622 The optional argument DISPLAY specifies which display to ask about.\n\
4623 DISPLAY should be either a frame or a display name (a string).\n\
4624 If omitted or nil, that stands for the selected frame's display.")
4626 Lisp_Object display
;
4628 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4633 hdc
= GetDC (dpyinfo
->root_window
);
4635 cap
= GetDeviceCaps (hdc
, HORZSIZE
);
4637 ReleaseDC (dpyinfo
->root_window
, hdc
);
4639 return make_number (cap
);
4642 DEFUN ("x-display-backing-store", Fx_display_backing_store
,
4643 Sx_display_backing_store
, 0, 1, 0,
4644 "Returns an indication of whether display DISPLAY does backing store.\n\
4645 The value may be `always', `when-mapped', or `not-useful'.\n\
4646 The optional argument DISPLAY specifies which display to ask about.\n\
4647 DISPLAY should be either a frame or a display name (a string).\n\
4648 If omitted or nil, that stands for the selected frame's display.")
4650 Lisp_Object display
;
4652 return intern ("not-useful");
4655 DEFUN ("x-display-visual-class", Fx_display_visual_class
,
4656 Sx_display_visual_class
, 0, 1, 0,
4657 "Returns the visual class of the display DISPLAY.\n\
4658 The value is one of the symbols `static-gray', `gray-scale',\n\
4659 `static-color', `pseudo-color', `true-color', or `direct-color'.\n\n\
4660 The optional argument DISPLAY specifies which display to ask about.\n\
4661 DISPLAY should be either a frame or a display name (a string).\n\
4662 If omitted or nil, that stands for the selected frame's display.")
4664 Lisp_Object display
;
4666 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4669 switch (dpyinfo
->visual
->class)
4671 case StaticGray
: return (intern ("static-gray"));
4672 case GrayScale
: return (intern ("gray-scale"));
4673 case StaticColor
: return (intern ("static-color"));
4674 case PseudoColor
: return (intern ("pseudo-color"));
4675 case TrueColor
: return (intern ("true-color"));
4676 case DirectColor
: return (intern ("direct-color"));
4678 error ("Display has an unknown visual class");
4682 error ("Display has an unknown visual class");
4685 DEFUN ("x-display-save-under", Fx_display_save_under
,
4686 Sx_display_save_under
, 0, 1, 0,
4687 "Returns t if the display DISPLAY supports the save-under feature.\n\
4688 The optional argument DISPLAY specifies which display to ask about.\n\
4689 DISPLAY should be either a frame or a display name (a string).\n\
4690 If omitted or nil, that stands for the selected frame's display.")
4692 Lisp_Object display
;
4694 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4701 register struct frame
*f
;
4703 return PIXEL_WIDTH (f
);
4708 register struct frame
*f
;
4710 return PIXEL_HEIGHT (f
);
4715 register struct frame
*f
;
4717 return FONT_WIDTH (f
->output_data
.win32
->font
);
4722 register struct frame
*f
;
4724 return f
->output_data
.win32
->line_height
;
4728 x_screen_planes (frame
)
4731 return (FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_planes
*
4732 FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_cbits
);
4735 /* Return the display structure for the display named NAME.
4736 Open a new connection if necessary. */
4738 struct win32_display_info
*
4739 x_display_info_for_name (name
)
4743 struct win32_display_info
*dpyinfo
;
4745 CHECK_STRING (name
, 0);
4747 for (dpyinfo
= &one_win32_display_info
, names
= win32_display_name_list
;
4749 dpyinfo
= dpyinfo
->next
, names
= XCONS (names
)->cdr
)
4752 tem
= Fstring_equal (XCONS (XCONS (names
)->car
)->car
, name
);
4757 /* Use this general default value to start with. */
4758 Vx_resource_name
= Vinvocation_name
;
4760 validate_x_resource_name ();
4762 dpyinfo
= win32_term_init (name
, (unsigned char *)0,
4763 (char *) XSTRING (Vx_resource_name
)->data
);
4766 error ("Cannot connect to server %s", XSTRING (name
)->data
);
4768 XSETFASTINT (Vwindow_system_version
, 3);
4773 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
4774 1, 3, 0, "Open a connection to a server.\n\
4775 DISPLAY is the name of the display to connect to.\n\
4776 Optional second arg XRM-STRING is a string of resources in xrdb format.\n\
4777 If the optional third arg MUST-SUCCEED is non-nil,\n\
4778 terminate Emacs if we can't open the connection.")
4779 (display
, xrm_string
, must_succeed
)
4780 Lisp_Object display
, xrm_string
, must_succeed
;
4782 unsigned int n_planes
;
4783 unsigned char *xrm_option
;
4784 struct win32_display_info
*dpyinfo
;
4786 CHECK_STRING (display
, 0);
4787 if (! NILP (xrm_string
))
4788 CHECK_STRING (xrm_string
, 1);
4790 /* Allow color mapping to be defined externally; first look in user's
4791 HOME directory, then in Emacs etc dir for a file called rgb.txt. */
4793 Lisp_Object color_file
;
4794 struct gcpro gcpro1
;
4796 color_file
= build_string("~/rgb.txt");
4798 GCPRO1 (color_file
);
4800 if (NILP (Ffile_readable_p (color_file
)))
4802 Fexpand_file_name (build_string ("rgb.txt"),
4803 Fsymbol_value (intern ("data-directory")));
4805 Vwin32_color_map
= Fwin32_load_color_file (color_file
);
4809 if (NILP (Vwin32_color_map
))
4810 Vwin32_color_map
= Fwin32_default_color_map ();
4812 if (! NILP (xrm_string
))
4813 xrm_option
= (unsigned char *) XSTRING (xrm_string
)->data
;
4815 xrm_option
= (unsigned char *) 0;
4817 /* Use this general default value to start with. */
4818 /* First remove .exe suffix from invocation-name - it looks ugly. */
4820 char basename
[ MAX_PATH
], *str
;
4822 strcpy (basename
, XSTRING (Vinvocation_name
)->data
);
4823 str
= strrchr (basename
, '.');
4825 Vinvocation_name
= build_string (basename
);
4827 Vx_resource_name
= Vinvocation_name
;
4829 validate_x_resource_name ();
4831 /* This is what opens the connection and sets x_current_display.
4832 This also initializes many symbols, such as those used for input. */
4833 dpyinfo
= win32_term_init (display
, xrm_option
,
4834 (char *) XSTRING (Vx_resource_name
)->data
);
4838 if (!NILP (must_succeed
))
4839 fatal ("Cannot connect to server %s.\n",
4840 XSTRING (display
)->data
);
4842 error ("Cannot connect to server %s", XSTRING (display
)->data
);
4845 XSETFASTINT (Vwindow_system_version
, 3);
4849 DEFUN ("x-close-connection", Fx_close_connection
,
4850 Sx_close_connection
, 1, 1, 0,
4851 "Close the connection to DISPLAY's server.\n\
4852 For DISPLAY, specify either a frame or a display name (a string).\n\
4853 If DISPLAY is nil, that stands for the selected frame's display.")
4855 Lisp_Object display
;
4857 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4858 struct win32_display_info
*tail
;
4861 if (dpyinfo
->reference_count
> 0)
4862 error ("Display still has frames on it");
4865 /* Free the fonts in the font table. */
4866 for (i
= 0; i
< dpyinfo
->n_fonts
; i
++)
4868 if (dpyinfo
->font_table
[i
].name
)
4869 free (dpyinfo
->font_table
[i
].name
);
4870 /* Don't free the full_name string;
4871 it is always shared with something else. */
4872 win32_unload_font (dpyinfo
, dpyinfo
->font_table
[i
].font
);
4874 x_destroy_all_bitmaps (dpyinfo
);
4876 x_delete_display (dpyinfo
);
4882 DEFUN ("x-display-list", Fx_display_list
, Sx_display_list
, 0, 0, 0,
4883 "Return the list of display names that Emacs has connections to.")
4886 Lisp_Object tail
, result
;
4889 for (tail
= win32_display_name_list
; ! NILP (tail
); tail
= XCONS (tail
)->cdr
)
4890 result
= Fcons (XCONS (XCONS (tail
)->car
)->car
, result
);
4895 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
, 1, 2, 0,
4896 "If ON is non-nil, report errors as soon as the erring request is made.\n\
4897 If ON is nil, allow buffering of requests.\n\
4898 This is a noop on Win32 systems.\n\
4899 The optional second argument DISPLAY specifies which display to act on.\n\
4900 DISPLAY should be either a frame or a display name (a string).\n\
4901 If DISPLAY is omitted or nil, that stands for the selected frame's display.")
4903 Lisp_Object display
, on
;
4905 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4911 /* These are the win32 specialized functions */
4913 DEFUN ("win32-select-font", Fwin32_select_font
, Swin32_select_font
, 0, 1, 0,
4914 "This will display the Win32 font dialog and return an X font string corresponding to the selection.")
4918 FRAME_PTR f
= check_x_frame (frame
);
4923 bzero (&cf
, sizeof (cf
));
4925 cf
.lStructSize
= sizeof (cf
);
4926 cf
.hwndOwner
= FRAME_WIN32_WINDOW (f
);
4927 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
| CF_SCREENFONTS
;
4930 if (!ChooseFont (&cf
) || !win32_to_x_font (&lf
, buf
, 100))
4933 return build_string (buf
);
4939 /* The section below is built by the lisp expression at the top of the file,
4940 just above where these variables are declared. */
4941 /*&&& init symbols here &&&*/
4942 Qauto_raise
= intern ("auto-raise");
4943 staticpro (&Qauto_raise
);
4944 Qauto_lower
= intern ("auto-lower");
4945 staticpro (&Qauto_lower
);
4946 Qbackground_color
= intern ("background-color");
4947 staticpro (&Qbackground_color
);
4948 Qbar
= intern ("bar");
4950 Qborder_color
= intern ("border-color");
4951 staticpro (&Qborder_color
);
4952 Qborder_width
= intern ("border-width");
4953 staticpro (&Qborder_width
);
4954 Qbox
= intern ("box");
4956 Qcursor_color
= intern ("cursor-color");
4957 staticpro (&Qcursor_color
);
4958 Qcursor_type
= intern ("cursor-type");
4959 staticpro (&Qcursor_type
);
4960 Qforeground_color
= intern ("foreground-color");
4961 staticpro (&Qforeground_color
);
4962 Qgeometry
= intern ("geometry");
4963 staticpro (&Qgeometry
);
4964 Qicon_left
= intern ("icon-left");
4965 staticpro (&Qicon_left
);
4966 Qicon_top
= intern ("icon-top");
4967 staticpro (&Qicon_top
);
4968 Qicon_type
= intern ("icon-type");
4969 staticpro (&Qicon_type
);
4970 Qicon_name
= intern ("icon-name");
4971 staticpro (&Qicon_name
);
4972 Qinternal_border_width
= intern ("internal-border-width");
4973 staticpro (&Qinternal_border_width
);
4974 Qleft
= intern ("left");
4976 Qmouse_color
= intern ("mouse-color");
4977 staticpro (&Qmouse_color
);
4978 Qnone
= intern ("none");
4980 Qparent_id
= intern ("parent-id");
4981 staticpro (&Qparent_id
);
4982 Qscroll_bar_width
= intern ("scroll-bar-width");
4983 staticpro (&Qscroll_bar_width
);
4984 Qsuppress_icon
= intern ("suppress-icon");
4985 staticpro (&Qsuppress_icon
);
4986 Qtop
= intern ("top");
4988 Qundefined_color
= intern ("undefined-color");
4989 staticpro (&Qundefined_color
);
4990 Qvertical_scroll_bars
= intern ("vertical-scroll-bars");
4991 staticpro (&Qvertical_scroll_bars
);
4992 Qvisibility
= intern ("visibility");
4993 staticpro (&Qvisibility
);
4994 Qwindow_id
= intern ("window-id");
4995 staticpro (&Qwindow_id
);
4996 Qx_frame_parameter
= intern ("x-frame-parameter");
4997 staticpro (&Qx_frame_parameter
);
4998 Qx_resource_name
= intern ("x-resource-name");
4999 staticpro (&Qx_resource_name
);
5000 Quser_position
= intern ("user-position");
5001 staticpro (&Quser_position
);
5002 Quser_size
= intern ("user-size");
5003 staticpro (&Quser_size
);
5004 Qdisplay
= intern ("display");
5005 staticpro (&Qdisplay
);
5006 /* This is the end of symbol initialization. */
5008 Fput (Qundefined_color
, Qerror_conditions
,
5009 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
5010 Fput (Qundefined_color
, Qerror_message
,
5011 build_string ("Undefined color"));
5013 DEFVAR_LISP ("win32-color-map", &Vwin32_color_map
,
5014 "A array of color name mappings for windows.");
5015 Vwin32_color_map
= Qnil
;
5017 DEFVAR_LISP ("win32-pass-alt-to-system", &Vwin32_pass_alt_to_system
,
5018 "Non-nil if alt key presses are passed on to Windows.\n\
5019 When non-nil, for example, alt pressed and released and then space will\n\
5020 open the System menu. When nil, Emacs silently swallows alt key events.");
5021 Vwin32_pass_alt_to_system
= Qnil
;
5023 DEFVAR_LISP ("win32-alt-is-meta", &Vwin32_alt_is_meta
,
5024 "Non-nil if the alt key is to be considered the same as the meta key.\n\
5025 When nil, Emacs will translate the alt key to the Alt modifier, and not Meta.");
5026 Vwin32_alt_is_meta
= Qt
;
5028 DEFVAR_LISP ("win32-pass-optional-keys-to-system",
5029 &Vwin32_pass_optional_keys_to_system
,
5030 "Non-nil if the 'optional' keys (left window, right window,\n\
5031 and application keys) are passed on to Windows.");
5032 Vwin32_pass_optional_keys_to_system
= Qnil
;
5034 DEFVAR_LISP ("win32-enable-italics", &Vwin32_enable_italics
,
5035 "Non-nil enables selection of artificially italicized fonts.");
5036 Vwin32_enable_italics
= Qnil
;
5038 DEFVAR_LISP ("win32-enable-palette", &Vwin32_enable_palette
,
5039 "Non-nil enables Windows palette management to map colors exactly.");
5040 Vwin32_enable_palette
= Qt
;
5042 DEFVAR_INT ("win32-mouse-button-tolerance",
5043 &Vwin32_mouse_button_tolerance
,
5044 "Analogue of double click interval for faking middle mouse events.\n\
5045 The value is the minimum time in milliseconds that must elapse between\n\
5046 left/right button down events before they are considered distinct events.\n\
5047 If both mouse buttons are depressed within this interval, a middle mouse\n\
5048 button down event is generated instead.");
5049 XSETINT (Vwin32_mouse_button_tolerance
, GetDoubleClickTime () / 2);
5051 DEFVAR_INT ("win32-mouse-move-interval",
5052 &Vwin32_mouse_move_interval
,
5053 "Minimum interval between mouse move events.\n\
5054 The value is the minimum time in milliseconds that must elapse between\n\
5055 successive mouse move (or scroll bar drag) events before they are\n\
5056 reported as lisp events.");
5057 XSETINT (Vwin32_mouse_move_interval
, 50);
5059 init_x_parm_symbols ();
5061 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path
,
5062 "List of directories to search for bitmap files for win32.");
5063 Vx_bitmap_file_path
= decode_env_path ((char *) 0, "PATH");
5065 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape
,
5066 "The shape of the pointer when over text.\n\
5067 Changing the value does not affect existing frames\n\
5068 unless you set the mouse color.");
5069 Vx_pointer_shape
= Qnil
;
5071 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
5072 "The name Emacs uses to look up resources; for internal use only.\n\
5073 `x-get-resource' uses this as the first component of the instance name\n\
5074 when requesting resource values.\n\
5075 Emacs initially sets `x-resource-name' to the name under which Emacs\n\
5076 was invoked, or to the value specified with the `-name' or `-rn'\n\
5077 switches, if present.");
5078 Vx_resource_name
= Qnil
;
5080 Vx_nontext_pointer_shape
= Qnil
;
5082 Vx_mode_pointer_shape
= Qnil
;
5084 DEFVAR_INT ("x-sensitive-text-pointer-shape",
5085 &Vx_sensitive_text_pointer_shape
,
5086 "The shape of the pointer when over mouse-sensitive text.\n\
5087 This variable takes effect when you create a new frame\n\
5088 or when you set the mouse color.");
5089 Vx_sensitive_text_pointer_shape
= Qnil
;
5091 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
5092 "A string indicating the foreground color of the cursor box.");
5093 Vx_cursor_fore_pixel
= Qnil
;
5095 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
5096 "Non-nil if no window manager is in use.\n\
5097 Emacs doesn't try to figure this out; this is always nil\n\
5098 unless you set it to something else.");
5099 /* We don't have any way to find this out, so set it to nil
5100 and maybe the user would like to set it to t. */
5101 Vx_no_window_manager
= Qnil
;
5103 defsubr (&Sx_get_resource
);
5104 defsubr (&Sx_list_fonts
);
5105 defsubr (&Sx_display_color_p
);
5106 defsubr (&Sx_display_grayscale_p
);
5107 defsubr (&Sx_color_defined_p
);
5108 defsubr (&Sx_color_values
);
5109 defsubr (&Sx_server_max_request_size
);
5110 defsubr (&Sx_server_vendor
);
5111 defsubr (&Sx_server_version
);
5112 defsubr (&Sx_display_pixel_width
);
5113 defsubr (&Sx_display_pixel_height
);
5114 defsubr (&Sx_display_mm_width
);
5115 defsubr (&Sx_display_mm_height
);
5116 defsubr (&Sx_display_screens
);
5117 defsubr (&Sx_display_planes
);
5118 defsubr (&Sx_display_color_cells
);
5119 defsubr (&Sx_display_visual_class
);
5120 defsubr (&Sx_display_backing_store
);
5121 defsubr (&Sx_display_save_under
);
5122 defsubr (&Sx_parse_geometry
);
5123 defsubr (&Sx_create_frame
);
5124 defsubr (&Sfocus_frame
);
5125 defsubr (&Sunfocus_frame
);
5126 defsubr (&Sx_open_connection
);
5127 defsubr (&Sx_close_connection
);
5128 defsubr (&Sx_display_list
);
5129 defsubr (&Sx_synchronize
);
5131 /* Win32 specific functions */
5133 defsubr (&Swin32_select_font
);
5134 defsubr (&Swin32_define_rgb_color
);
5135 defsubr (&Swin32_default_color_map
);
5136 defsubr (&Swin32_load_color_file
);
5145 button
= MessageBox (NULL
,
5146 "A fatal error has occurred!\n\n"
5147 "Select Abort to exit, Retry to debug, Ignore to continue",
5148 "Emacs Abort Dialog",
5149 MB_ICONEXCLAMATION
| MB_TASKMODAL
5150 | MB_SETFOREGROUND
| MB_ABORTRETRYIGNORE
);