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
;
146 Lisp_Object Qmouse_color
;
148 Lisp_Object Qparent_id
;
149 Lisp_Object Qscroll_bar_width
;
150 Lisp_Object Qsuppress_icon
;
152 Lisp_Object Qundefined_color
;
153 Lisp_Object Qvertical_scroll_bars
;
154 Lisp_Object Qvisibility
;
155 Lisp_Object Qwindow_id
;
156 Lisp_Object Qx_frame_parameter
;
157 Lisp_Object Qx_resource_name
;
158 Lisp_Object Quser_position
;
159 Lisp_Object Quser_size
;
160 Lisp_Object Qdisplay
;
162 /* State variables for emulating a three button mouse. */
167 static int button_state
= 0;
168 static Win32Msg saved_mouse_button_msg
;
169 static unsigned mouse_button_timer
; /* non-zero when timer is active */
170 static Win32Msg saved_mouse_move_msg
;
171 static unsigned mouse_move_timer
;
173 #define MOUSE_BUTTON_ID 1
174 #define MOUSE_MOVE_ID 2
176 /* The below are defined in frame.c. */
177 extern Lisp_Object Qheight
, Qminibuffer
, Qname
, Qonly
, Qwidth
;
178 extern Lisp_Object Qunsplittable
, Qmenu_bar_lines
;
180 extern Lisp_Object Vwindow_system_version
;
182 extern Lisp_Object last_mouse_scroll_bar
;
183 extern int last_mouse_scroll_bar_pos
;
185 /* From win32term.c. */
186 extern Lisp_Object Vwin32_num_mouse_buttons
;
188 Time last_mouse_movement_time
;
191 /* Extract a frame as a FRAME_PTR, defaulting to the selected frame
192 and checking validity for Win32. */
195 check_x_frame (frame
)
204 CHECK_LIVE_FRAME (frame
, 0);
207 if (! FRAME_WIN32_P (f
))
208 error ("non-win32 frame used");
212 /* Let the user specify an display with a frame.
213 nil stands for the selected frame--or, if that is not a win32 frame,
214 the first display on the list. */
216 static struct win32_display_info
*
217 check_x_display_info (frame
)
222 if (FRAME_WIN32_P (selected_frame
))
223 return FRAME_WIN32_DISPLAY_INFO (selected_frame
);
225 return &one_win32_display_info
;
227 else if (STRINGP (frame
))
228 return x_display_info_for_name (frame
);
233 CHECK_LIVE_FRAME (frame
, 0);
235 if (! FRAME_WIN32_P (f
))
236 error ("non-win32 frame used");
237 return FRAME_WIN32_DISPLAY_INFO (f
);
241 /* Return the Emacs frame-object corresponding to an win32 window.
242 It could be the frame's main window or an icon window. */
244 /* This function can be called during GC, so use GC_xxx type test macros. */
247 x_window_to_frame (dpyinfo
, wdesc
)
248 struct win32_display_info
*dpyinfo
;
251 Lisp_Object tail
, frame
;
254 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCONS (tail
)->cdr
)
256 frame
= XCONS (tail
)->car
;
257 if (!GC_FRAMEP (frame
))
260 if (f
->output_data
.nothing
== 1
261 || FRAME_WIN32_DISPLAY_INFO (f
) != dpyinfo
)
263 if (FRAME_WIN32_WINDOW (f
) == wdesc
)
271 /* Code to deal with bitmaps. Bitmaps are referenced by their bitmap
272 id, which is just an int that this section returns. Bitmaps are
273 reference counted so they can be shared among frames.
275 Bitmap indices are guaranteed to be > 0, so a negative number can
276 be used to indicate no bitmap.
278 If you use x_create_bitmap_from_data, then you must keep track of
279 the bitmaps yourself. That is, creating a bitmap from the same
280 data more than once will not be caught. */
283 /* Functions to access the contents of a bitmap, given an id. */
286 x_bitmap_height (f
, id
)
290 return FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].height
;
294 x_bitmap_width (f
, id
)
298 return FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].width
;
302 x_bitmap_pixmap (f
, id
)
306 return (int) FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].pixmap
;
310 /* Allocate a new bitmap record. Returns index of new record. */
313 x_allocate_bitmap_record (f
)
316 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
319 if (dpyinfo
->bitmaps
== NULL
)
321 dpyinfo
->bitmaps_size
= 10;
323 = (struct win32_bitmap_record
*) xmalloc (dpyinfo
->bitmaps_size
* sizeof (struct win32_bitmap_record
));
324 dpyinfo
->bitmaps_last
= 1;
328 if (dpyinfo
->bitmaps_last
< dpyinfo
->bitmaps_size
)
329 return ++dpyinfo
->bitmaps_last
;
331 for (i
= 0; i
< dpyinfo
->bitmaps_size
; ++i
)
332 if (dpyinfo
->bitmaps
[i
].refcount
== 0)
335 dpyinfo
->bitmaps_size
*= 2;
337 = (struct win32_bitmap_record
*) xrealloc (dpyinfo
->bitmaps
,
338 dpyinfo
->bitmaps_size
* sizeof (struct win32_bitmap_record
));
339 return ++dpyinfo
->bitmaps_last
;
342 /* Add one reference to the reference count of the bitmap with id ID. */
345 x_reference_bitmap (f
, id
)
349 ++FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].refcount
;
352 /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */
355 x_create_bitmap_from_data (f
, bits
, width
, height
)
358 unsigned int width
, height
;
360 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
364 bitmap
= CreateBitmap (width
, height
,
365 FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_planes
,
366 FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_cbits
,
372 id
= x_allocate_bitmap_record (f
);
373 dpyinfo
->bitmaps
[id
- 1].pixmap
= bitmap
;
374 dpyinfo
->bitmaps
[id
- 1].file
= NULL
;
375 dpyinfo
->bitmaps
[id
- 1].hinst
= NULL
;
376 dpyinfo
->bitmaps
[id
- 1].refcount
= 1;
377 dpyinfo
->bitmaps
[id
- 1].depth
= 1;
378 dpyinfo
->bitmaps
[id
- 1].height
= height
;
379 dpyinfo
->bitmaps
[id
- 1].width
= width
;
384 /* Create bitmap from file FILE for frame F. */
387 x_create_bitmap_from_file (f
, file
)
393 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
394 unsigned int width
, height
;
396 int xhot
, yhot
, result
, id
;
402 /* Look for an existing bitmap with the same name. */
403 for (id
= 0; id
< dpyinfo
->bitmaps_last
; ++id
)
405 if (dpyinfo
->bitmaps
[id
].refcount
406 && dpyinfo
->bitmaps
[id
].file
407 && !strcmp (dpyinfo
->bitmaps
[id
].file
, (char *) XSTRING (file
)->data
))
409 ++dpyinfo
->bitmaps
[id
].refcount
;
414 /* Search bitmap-file-path for the file, if appropriate. */
415 fd
= openp (Vx_bitmap_file_path
, file
, "", &found
, 0);
420 filename
= (char *) XSTRING (found
)->data
;
422 hinst
= LoadLibraryEx (filename
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
428 result
= XReadBitmapFile (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
),
429 filename
, &width
, &height
, &bitmap
, &xhot
, &yhot
);
430 if (result
!= BitmapSuccess
)
433 id
= x_allocate_bitmap_record (f
);
434 dpyinfo
->bitmaps
[id
- 1].pixmap
= bitmap
;
435 dpyinfo
->bitmaps
[id
- 1].refcount
= 1;
436 dpyinfo
->bitmaps
[id
- 1].file
= (char *) xmalloc (XSTRING (file
)->size
+ 1);
437 dpyinfo
->bitmaps
[id
- 1].depth
= 1;
438 dpyinfo
->bitmaps
[id
- 1].height
= height
;
439 dpyinfo
->bitmaps
[id
- 1].width
= width
;
440 strcpy (dpyinfo
->bitmaps
[id
- 1].file
, XSTRING (file
)->data
);
446 /* Remove reference to bitmap with id number ID. */
449 x_destroy_bitmap (f
, id
)
453 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
457 --dpyinfo
->bitmaps
[id
- 1].refcount
;
458 if (dpyinfo
->bitmaps
[id
- 1].refcount
== 0)
461 DeleteObject (dpyinfo
->bitmaps
[id
- 1].pixmap
);
462 if (dpyinfo
->bitmaps
[id
- 1].file
)
464 free (dpyinfo
->bitmaps
[id
- 1].file
);
465 dpyinfo
->bitmaps
[id
- 1].file
= NULL
;
472 /* Free all the bitmaps for the display specified by DPYINFO. */
475 x_destroy_all_bitmaps (dpyinfo
)
476 struct win32_display_info
*dpyinfo
;
479 for (i
= 0; i
< dpyinfo
->bitmaps_last
; i
++)
480 if (dpyinfo
->bitmaps
[i
].refcount
> 0)
482 DeleteObject (dpyinfo
->bitmaps
[i
].pixmap
);
483 if (dpyinfo
->bitmaps
[i
].file
)
484 free (dpyinfo
->bitmaps
[i
].file
);
486 dpyinfo
->bitmaps_last
= 0;
489 /* Connect the frame-parameter names for Win32 frames
490 to the ways of passing the parameter values to the window system.
492 The name of a parameter, as a Lisp symbol,
493 has an `x-frame-parameter' property which is an integer in Lisp
494 but can be interpreted as an `enum x_frame_parm' in C. */
498 X_PARM_FOREGROUND_COLOR
,
499 X_PARM_BACKGROUND_COLOR
,
506 X_PARM_INTERNAL_BORDER_WIDTH
,
510 X_PARM_VERT_SCROLL_BAR
,
512 X_PARM_MENU_BAR_LINES
516 struct x_frame_parm_table
519 void (*setter
)( /* struct frame *frame, Lisp_Object val, oldval */ );
522 void x_set_foreground_color ();
523 void x_set_background_color ();
524 void x_set_mouse_color ();
525 void x_set_cursor_color ();
526 void x_set_border_color ();
527 void x_set_cursor_type ();
528 void x_set_icon_type ();
529 void x_set_icon_name ();
531 void x_set_border_width ();
532 void x_set_internal_border_width ();
533 void x_explicitly_set_name ();
534 void x_set_autoraise ();
535 void x_set_autolower ();
536 void x_set_vertical_scroll_bars ();
537 void x_set_visibility ();
538 void x_set_menu_bar_lines ();
539 void x_set_scroll_bar_width ();
540 void x_set_unsplittable ();
542 static struct x_frame_parm_table x_frame_parms
[] =
544 "foreground-color", x_set_foreground_color
,
545 "background-color", x_set_background_color
,
546 "mouse-color", x_set_mouse_color
,
547 "cursor-color", x_set_cursor_color
,
548 "border-color", x_set_border_color
,
549 "cursor-type", x_set_cursor_type
,
550 "icon-type", x_set_icon_type
,
551 "icon-name", x_set_icon_name
,
553 "border-width", x_set_border_width
,
554 "internal-border-width", x_set_internal_border_width
,
555 "name", x_explicitly_set_name
,
556 "auto-raise", x_set_autoraise
,
557 "auto-lower", x_set_autolower
,
558 "vertical-scroll-bars", x_set_vertical_scroll_bars
,
559 "visibility", x_set_visibility
,
560 "menu-bar-lines", x_set_menu_bar_lines
,
561 "scroll-bar-width", x_set_scroll_bar_width
,
562 "unsplittable", x_set_unsplittable
,
565 /* Attach the `x-frame-parameter' properties to
566 the Lisp symbol names of parameters relevant to Win32. */
568 init_x_parm_symbols ()
572 for (i
= 0; i
< sizeof (x_frame_parms
) / sizeof (x_frame_parms
[0]); i
++)
573 Fput (intern (x_frame_parms
[i
].name
), Qx_frame_parameter
,
577 /* Change the parameters of FRAME as specified by ALIST.
578 If a parameter is not specially recognized, do nothing;
579 otherwise call the `x_set_...' function for that parameter. */
582 x_set_frame_parameters (f
, alist
)
588 /* If both of these parameters are present, it's more efficient to
589 set them both at once. So we wait until we've looked at the
590 entire list before we set them. */
594 Lisp_Object left
, top
;
596 /* Same with these. */
597 Lisp_Object icon_left
, icon_top
;
599 /* Record in these vectors all the parms specified. */
603 int left_no_change
= 0, top_no_change
= 0;
604 int icon_left_no_change
= 0, icon_top_no_change
= 0;
607 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
610 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
611 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
613 /* Extract parm names and values into those vectors. */
616 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
618 Lisp_Object elt
, prop
, val
;
621 parms
[i
] = Fcar (elt
);
622 values
[i
] = Fcdr (elt
);
626 top
= left
= Qunbound
;
627 icon_left
= icon_top
= Qunbound
;
629 /* Provide default values for HEIGHT and WIDTH. */
630 width
= FRAME_WIDTH (f
);
631 height
= FRAME_HEIGHT (f
);
633 /* Now process them in reverse of specified order. */
634 for (i
--; i
>= 0; i
--)
636 Lisp_Object prop
, val
;
641 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
642 width
= XFASTINT (val
);
643 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
644 height
= XFASTINT (val
);
645 else if (EQ (prop
, Qtop
))
647 else if (EQ (prop
, Qleft
))
649 else if (EQ (prop
, Qicon_top
))
651 else if (EQ (prop
, Qicon_left
))
655 register Lisp_Object param_index
, old_value
;
657 param_index
= Fget (prop
, Qx_frame_parameter
);
658 old_value
= get_frame_param (f
, prop
);
659 store_frame_param (f
, prop
, val
);
660 if (NATNUMP (param_index
)
661 && (XFASTINT (param_index
)
662 < sizeof (x_frame_parms
)/sizeof (x_frame_parms
[0])))
663 (*x_frame_parms
[XINT (param_index
)].setter
)(f
, val
, old_value
);
667 /* Don't die if just one of these was set. */
668 if (EQ (left
, Qunbound
))
671 if (f
->output_data
.win32
->left_pos
< 0)
672 left
= Fcons (Qplus
, Fcons (make_number (f
->output_data
.win32
->left_pos
), Qnil
));
674 XSETINT (left
, f
->output_data
.win32
->left_pos
);
676 if (EQ (top
, Qunbound
))
679 if (f
->output_data
.win32
->top_pos
< 0)
680 top
= Fcons (Qplus
, Fcons (make_number (f
->output_data
.win32
->top_pos
), Qnil
));
682 XSETINT (top
, f
->output_data
.win32
->top_pos
);
685 /* If one of the icon positions was not set, preserve or default it. */
686 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
688 icon_left_no_change
= 1;
689 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
690 if (NILP (icon_left
))
691 XSETINT (icon_left
, 0);
693 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
695 icon_top_no_change
= 1;
696 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
698 XSETINT (icon_top
, 0);
701 /* Don't set these parameters unless they've been explicitly
702 specified. The window might be mapped or resized while we're in
703 this function, and we don't want to override that unless the lisp
704 code has asked for it.
706 Don't set these parameters unless they actually differ from the
707 window's current parameters; the window may not actually exist
712 check_frame_size (f
, &height
, &width
);
714 XSETFRAME (frame
, f
);
716 if (XINT (width
) != FRAME_WIDTH (f
)
717 || XINT (height
) != FRAME_HEIGHT (f
))
718 Fset_frame_size (frame
, make_number (width
), make_number (height
));
720 if ((!NILP (left
) || !NILP (top
))
721 && ! (left_no_change
&& top_no_change
)
722 && ! (NUMBERP (left
) && XINT (left
) == f
->output_data
.win32
->left_pos
723 && NUMBERP (top
) && XINT (top
) == f
->output_data
.win32
->top_pos
))
728 /* Record the signs. */
729 f
->output_data
.win32
->size_hint_flags
&= ~ (XNegative
| YNegative
);
730 if (EQ (left
, Qminus
))
731 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
732 else if (INTEGERP (left
))
734 leftpos
= XINT (left
);
736 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
738 else if (CONSP (left
) && EQ (XCONS (left
)->car
, Qminus
)
739 && CONSP (XCONS (left
)->cdr
)
740 && INTEGERP (XCONS (XCONS (left
)->cdr
)->car
))
742 leftpos
= - XINT (XCONS (XCONS (left
)->cdr
)->car
);
743 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
745 else if (CONSP (left
) && EQ (XCONS (left
)->car
, Qplus
)
746 && CONSP (XCONS (left
)->cdr
)
747 && INTEGERP (XCONS (XCONS (left
)->cdr
)->car
))
749 leftpos
= XINT (XCONS (XCONS (left
)->cdr
)->car
);
752 if (EQ (top
, Qminus
))
753 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
754 else if (INTEGERP (top
))
758 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
760 else if (CONSP (top
) && EQ (XCONS (top
)->car
, Qminus
)
761 && CONSP (XCONS (top
)->cdr
)
762 && INTEGERP (XCONS (XCONS (top
)->cdr
)->car
))
764 toppos
= - XINT (XCONS (XCONS (top
)->cdr
)->car
);
765 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
767 else if (CONSP (top
) && EQ (XCONS (top
)->car
, Qplus
)
768 && CONSP (XCONS (top
)->cdr
)
769 && INTEGERP (XCONS (XCONS (top
)->cdr
)->car
))
771 toppos
= XINT (XCONS (XCONS (top
)->cdr
)->car
);
775 /* Store the numeric value of the position. */
776 f
->output_data
.win32
->top_pos
= toppos
;
777 f
->output_data
.win32
->left_pos
= leftpos
;
779 f
->output_data
.win32
->win_gravity
= NorthWestGravity
;
781 /* Actually set that position, and convert to absolute. */
782 x_set_offset (f
, leftpos
, toppos
, -1);
785 if ((!NILP (icon_left
) || !NILP (icon_top
))
786 && ! (icon_left_no_change
&& icon_top_no_change
))
787 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
791 /* Store the screen positions of frame F into XPTR and YPTR.
792 These are the positions of the containing window manager window,
793 not Emacs's own window. */
796 x_real_positions (f
, xptr
, yptr
)
805 GetClientRect(FRAME_WIN32_WINDOW(f
), &rect
);
806 AdjustWindowRect(&rect
, f
->output_data
.win32
->dwStyle
, FRAME_EXTERNAL_MENU_BAR(f
));
812 ClientToScreen (FRAME_WIN32_WINDOW(f
), &pt
);
818 /* Insert a description of internally-recorded parameters of frame X
819 into the parameter alist *ALISTPTR that is to be given to the user.
820 Only parameters that are specific to Win32
821 and whose values are not correctly recorded in the frame's
822 param_alist need to be considered here. */
824 x_report_frame_params (f
, alistptr
)
826 Lisp_Object
*alistptr
;
831 /* Represent negative positions (off the top or left screen edge)
832 in a way that Fmodify_frame_parameters will understand correctly. */
833 XSETINT (tem
, f
->output_data
.win32
->left_pos
);
834 if (f
->output_data
.win32
->left_pos
>= 0)
835 store_in_alist (alistptr
, Qleft
, tem
);
837 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
839 XSETINT (tem
, f
->output_data
.win32
->top_pos
);
840 if (f
->output_data
.win32
->top_pos
>= 0)
841 store_in_alist (alistptr
, Qtop
, tem
);
843 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
845 store_in_alist (alistptr
, Qborder_width
,
846 make_number (f
->output_data
.win32
->border_width
));
847 store_in_alist (alistptr
, Qinternal_border_width
,
848 make_number (f
->output_data
.win32
->internal_border_width
));
849 sprintf (buf
, "%ld", (long) FRAME_WIN32_WINDOW (f
));
850 store_in_alist (alistptr
, Qwindow_id
,
852 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
853 FRAME_SAMPLE_VISIBILITY (f
);
854 store_in_alist (alistptr
, Qvisibility
,
855 (FRAME_VISIBLE_P (f
) ? Qt
856 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
857 store_in_alist (alistptr
, Qdisplay
,
858 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->car
);
862 DEFUN ("win32-define-rgb-color", Fwin32_define_rgb_color
, Swin32_define_rgb_color
, 4, 4, 0,
863 "Convert RGB numbers to a windows color reference and associate with NAME (a string).\n\
864 This adds or updates a named color to win32-color-map, making it available for use.\n\
865 The original entry's RGB ref is returned, or nil if the entry is new.")
866 (red
, green
, blue
, name
)
867 Lisp_Object red
, green
, blue
, name
;
870 Lisp_Object oldrgb
= Qnil
;
873 CHECK_NUMBER (red
, 0);
874 CHECK_NUMBER (green
, 0);
875 CHECK_NUMBER (blue
, 0);
876 CHECK_STRING (name
, 0);
878 XSET (rgb
, Lisp_Int
, RGB(XUINT (red
), XUINT (green
), XUINT (blue
)));
882 /* replace existing entry in win32-color-map or add new entry. */
883 entry
= Fassoc (name
, Vwin32_color_map
);
886 entry
= Fcons (name
, rgb
);
887 Vwin32_color_map
= Fcons (entry
, Vwin32_color_map
);
891 oldrgb
= Fcdr (entry
);
892 Fsetcdr (entry
, rgb
);
900 DEFUN ("win32-load-color-file", Fwin32_load_color_file
, Swin32_load_color_file
, 1, 1, 0,
901 "Create an alist of color entries from an external file (ie. rgb.txt).\n\
902 Assign this value to win32-color-map to replace the existing color map.\n\
904 The file should define one named RGB color per line like so:\
906 where R,G,B are numbers between 0 and 255 and name is an arbitrary string.")
908 Lisp_Object filename
;
911 Lisp_Object cmap
= Qnil
;
914 CHECK_STRING (filename
, 0);
915 abspath
= Fexpand_file_name (filename
, Qnil
);
917 fp
= fopen (XSTRING (filename
)->data
, "rt");
921 int red
, green
, blue
;
926 while (fgets (buf
, sizeof (buf
), fp
) != NULL
) {
927 if (sscanf (buf
, "%u %u %u %n", &red
, &green
, &blue
, &num
) == 3)
929 char *name
= buf
+ num
;
930 num
= strlen (name
) - 1;
931 if (name
[num
] == '\n')
933 cmap
= Fcons (Fcons (build_string (name
),
934 make_number (RGB (red
, green
, blue
))),
946 /* The default colors for the win32 color map */
947 typedef struct colormap_t
953 colormap_t win32_color_map
[] =
955 {"snow" , PALETTERGB (255,250,250)},
956 {"ghost white" , PALETTERGB (248,248,255)},
957 {"GhostWhite" , PALETTERGB (248,248,255)},
958 {"white smoke" , PALETTERGB (245,245,245)},
959 {"WhiteSmoke" , PALETTERGB (245,245,245)},
960 {"gainsboro" , PALETTERGB (220,220,220)},
961 {"floral white" , PALETTERGB (255,250,240)},
962 {"FloralWhite" , PALETTERGB (255,250,240)},
963 {"old lace" , PALETTERGB (253,245,230)},
964 {"OldLace" , PALETTERGB (253,245,230)},
965 {"linen" , PALETTERGB (250,240,230)},
966 {"antique white" , PALETTERGB (250,235,215)},
967 {"AntiqueWhite" , PALETTERGB (250,235,215)},
968 {"papaya whip" , PALETTERGB (255,239,213)},
969 {"PapayaWhip" , PALETTERGB (255,239,213)},
970 {"blanched almond" , PALETTERGB (255,235,205)},
971 {"BlanchedAlmond" , PALETTERGB (255,235,205)},
972 {"bisque" , PALETTERGB (255,228,196)},
973 {"peach puff" , PALETTERGB (255,218,185)},
974 {"PeachPuff" , PALETTERGB (255,218,185)},
975 {"navajo white" , PALETTERGB (255,222,173)},
976 {"NavajoWhite" , PALETTERGB (255,222,173)},
977 {"moccasin" , PALETTERGB (255,228,181)},
978 {"cornsilk" , PALETTERGB (255,248,220)},
979 {"ivory" , PALETTERGB (255,255,240)},
980 {"lemon chiffon" , PALETTERGB (255,250,205)},
981 {"LemonChiffon" , PALETTERGB (255,250,205)},
982 {"seashell" , PALETTERGB (255,245,238)},
983 {"honeydew" , PALETTERGB (240,255,240)},
984 {"mint cream" , PALETTERGB (245,255,250)},
985 {"MintCream" , PALETTERGB (245,255,250)},
986 {"azure" , PALETTERGB (240,255,255)},
987 {"alice blue" , PALETTERGB (240,248,255)},
988 {"AliceBlue" , PALETTERGB (240,248,255)},
989 {"lavender" , PALETTERGB (230,230,250)},
990 {"lavender blush" , PALETTERGB (255,240,245)},
991 {"LavenderBlush" , PALETTERGB (255,240,245)},
992 {"misty rose" , PALETTERGB (255,228,225)},
993 {"MistyRose" , PALETTERGB (255,228,225)},
994 {"white" , PALETTERGB (255,255,255)},
995 {"black" , PALETTERGB ( 0, 0, 0)},
996 {"dark slate gray" , PALETTERGB ( 47, 79, 79)},
997 {"DarkSlateGray" , PALETTERGB ( 47, 79, 79)},
998 {"dark slate grey" , PALETTERGB ( 47, 79, 79)},
999 {"DarkSlateGrey" , PALETTERGB ( 47, 79, 79)},
1000 {"dim gray" , PALETTERGB (105,105,105)},
1001 {"DimGray" , PALETTERGB (105,105,105)},
1002 {"dim grey" , PALETTERGB (105,105,105)},
1003 {"DimGrey" , PALETTERGB (105,105,105)},
1004 {"slate gray" , PALETTERGB (112,128,144)},
1005 {"SlateGray" , PALETTERGB (112,128,144)},
1006 {"slate grey" , PALETTERGB (112,128,144)},
1007 {"SlateGrey" , PALETTERGB (112,128,144)},
1008 {"light slate gray" , PALETTERGB (119,136,153)},
1009 {"LightSlateGray" , PALETTERGB (119,136,153)},
1010 {"light slate grey" , PALETTERGB (119,136,153)},
1011 {"LightSlateGrey" , PALETTERGB (119,136,153)},
1012 {"gray" , PALETTERGB (190,190,190)},
1013 {"grey" , PALETTERGB (190,190,190)},
1014 {"light grey" , PALETTERGB (211,211,211)},
1015 {"LightGrey" , PALETTERGB (211,211,211)},
1016 {"light gray" , PALETTERGB (211,211,211)},
1017 {"LightGray" , PALETTERGB (211,211,211)},
1018 {"midnight blue" , PALETTERGB ( 25, 25,112)},
1019 {"MidnightBlue" , PALETTERGB ( 25, 25,112)},
1020 {"navy" , PALETTERGB ( 0, 0,128)},
1021 {"navy blue" , PALETTERGB ( 0, 0,128)},
1022 {"NavyBlue" , PALETTERGB ( 0, 0,128)},
1023 {"cornflower blue" , PALETTERGB (100,149,237)},
1024 {"CornflowerBlue" , PALETTERGB (100,149,237)},
1025 {"dark slate blue" , PALETTERGB ( 72, 61,139)},
1026 {"DarkSlateBlue" , PALETTERGB ( 72, 61,139)},
1027 {"slate blue" , PALETTERGB (106, 90,205)},
1028 {"SlateBlue" , PALETTERGB (106, 90,205)},
1029 {"medium slate blue" , PALETTERGB (123,104,238)},
1030 {"MediumSlateBlue" , PALETTERGB (123,104,238)},
1031 {"light slate blue" , PALETTERGB (132,112,255)},
1032 {"LightSlateBlue" , PALETTERGB (132,112,255)},
1033 {"medium blue" , PALETTERGB ( 0, 0,205)},
1034 {"MediumBlue" , PALETTERGB ( 0, 0,205)},
1035 {"royal blue" , PALETTERGB ( 65,105,225)},
1036 {"RoyalBlue" , PALETTERGB ( 65,105,225)},
1037 {"blue" , PALETTERGB ( 0, 0,255)},
1038 {"dodger blue" , PALETTERGB ( 30,144,255)},
1039 {"DodgerBlue" , PALETTERGB ( 30,144,255)},
1040 {"deep sky blue" , PALETTERGB ( 0,191,255)},
1041 {"DeepSkyBlue" , PALETTERGB ( 0,191,255)},
1042 {"sky blue" , PALETTERGB (135,206,235)},
1043 {"SkyBlue" , PALETTERGB (135,206,235)},
1044 {"light sky blue" , PALETTERGB (135,206,250)},
1045 {"LightSkyBlue" , PALETTERGB (135,206,250)},
1046 {"steel blue" , PALETTERGB ( 70,130,180)},
1047 {"SteelBlue" , PALETTERGB ( 70,130,180)},
1048 {"light steel blue" , PALETTERGB (176,196,222)},
1049 {"LightSteelBlue" , PALETTERGB (176,196,222)},
1050 {"light blue" , PALETTERGB (173,216,230)},
1051 {"LightBlue" , PALETTERGB (173,216,230)},
1052 {"powder blue" , PALETTERGB (176,224,230)},
1053 {"PowderBlue" , PALETTERGB (176,224,230)},
1054 {"pale turquoise" , PALETTERGB (175,238,238)},
1055 {"PaleTurquoise" , PALETTERGB (175,238,238)},
1056 {"dark turquoise" , PALETTERGB ( 0,206,209)},
1057 {"DarkTurquoise" , PALETTERGB ( 0,206,209)},
1058 {"medium turquoise" , PALETTERGB ( 72,209,204)},
1059 {"MediumTurquoise" , PALETTERGB ( 72,209,204)},
1060 {"turquoise" , PALETTERGB ( 64,224,208)},
1061 {"cyan" , PALETTERGB ( 0,255,255)},
1062 {"light cyan" , PALETTERGB (224,255,255)},
1063 {"LightCyan" , PALETTERGB (224,255,255)},
1064 {"cadet blue" , PALETTERGB ( 95,158,160)},
1065 {"CadetBlue" , PALETTERGB ( 95,158,160)},
1066 {"medium aquamarine" , PALETTERGB (102,205,170)},
1067 {"MediumAquamarine" , PALETTERGB (102,205,170)},
1068 {"aquamarine" , PALETTERGB (127,255,212)},
1069 {"dark green" , PALETTERGB ( 0,100, 0)},
1070 {"DarkGreen" , PALETTERGB ( 0,100, 0)},
1071 {"dark olive green" , PALETTERGB ( 85,107, 47)},
1072 {"DarkOliveGreen" , PALETTERGB ( 85,107, 47)},
1073 {"dark sea green" , PALETTERGB (143,188,143)},
1074 {"DarkSeaGreen" , PALETTERGB (143,188,143)},
1075 {"sea green" , PALETTERGB ( 46,139, 87)},
1076 {"SeaGreen" , PALETTERGB ( 46,139, 87)},
1077 {"medium sea green" , PALETTERGB ( 60,179,113)},
1078 {"MediumSeaGreen" , PALETTERGB ( 60,179,113)},
1079 {"light sea green" , PALETTERGB ( 32,178,170)},
1080 {"LightSeaGreen" , PALETTERGB ( 32,178,170)},
1081 {"pale green" , PALETTERGB (152,251,152)},
1082 {"PaleGreen" , PALETTERGB (152,251,152)},
1083 {"spring green" , PALETTERGB ( 0,255,127)},
1084 {"SpringGreen" , PALETTERGB ( 0,255,127)},
1085 {"lawn green" , PALETTERGB (124,252, 0)},
1086 {"LawnGreen" , PALETTERGB (124,252, 0)},
1087 {"green" , PALETTERGB ( 0,255, 0)},
1088 {"chartreuse" , PALETTERGB (127,255, 0)},
1089 {"medium spring green" , PALETTERGB ( 0,250,154)},
1090 {"MediumSpringGreen" , PALETTERGB ( 0,250,154)},
1091 {"green yellow" , PALETTERGB (173,255, 47)},
1092 {"GreenYellow" , PALETTERGB (173,255, 47)},
1093 {"lime green" , PALETTERGB ( 50,205, 50)},
1094 {"LimeGreen" , PALETTERGB ( 50,205, 50)},
1095 {"yellow green" , PALETTERGB (154,205, 50)},
1096 {"YellowGreen" , PALETTERGB (154,205, 50)},
1097 {"forest green" , PALETTERGB ( 34,139, 34)},
1098 {"ForestGreen" , PALETTERGB ( 34,139, 34)},
1099 {"olive drab" , PALETTERGB (107,142, 35)},
1100 {"OliveDrab" , PALETTERGB (107,142, 35)},
1101 {"dark khaki" , PALETTERGB (189,183,107)},
1102 {"DarkKhaki" , PALETTERGB (189,183,107)},
1103 {"khaki" , PALETTERGB (240,230,140)},
1104 {"pale goldenrod" , PALETTERGB (238,232,170)},
1105 {"PaleGoldenrod" , PALETTERGB (238,232,170)},
1106 {"light goldenrod yellow" , PALETTERGB (250,250,210)},
1107 {"LightGoldenrodYellow" , PALETTERGB (250,250,210)},
1108 {"light yellow" , PALETTERGB (255,255,224)},
1109 {"LightYellow" , PALETTERGB (255,255,224)},
1110 {"yellow" , PALETTERGB (255,255, 0)},
1111 {"gold" , PALETTERGB (255,215, 0)},
1112 {"light goldenrod" , PALETTERGB (238,221,130)},
1113 {"LightGoldenrod" , PALETTERGB (238,221,130)},
1114 {"goldenrod" , PALETTERGB (218,165, 32)},
1115 {"dark goldenrod" , PALETTERGB (184,134, 11)},
1116 {"DarkGoldenrod" , PALETTERGB (184,134, 11)},
1117 {"rosy brown" , PALETTERGB (188,143,143)},
1118 {"RosyBrown" , PALETTERGB (188,143,143)},
1119 {"indian red" , PALETTERGB (205, 92, 92)},
1120 {"IndianRed" , PALETTERGB (205, 92, 92)},
1121 {"saddle brown" , PALETTERGB (139, 69, 19)},
1122 {"SaddleBrown" , PALETTERGB (139, 69, 19)},
1123 {"sienna" , PALETTERGB (160, 82, 45)},
1124 {"peru" , PALETTERGB (205,133, 63)},
1125 {"burlywood" , PALETTERGB (222,184,135)},
1126 {"beige" , PALETTERGB (245,245,220)},
1127 {"wheat" , PALETTERGB (245,222,179)},
1128 {"sandy brown" , PALETTERGB (244,164, 96)},
1129 {"SandyBrown" , PALETTERGB (244,164, 96)},
1130 {"tan" , PALETTERGB (210,180,140)},
1131 {"chocolate" , PALETTERGB (210,105, 30)},
1132 {"firebrick" , PALETTERGB (178,34, 34)},
1133 {"brown" , PALETTERGB (165,42, 42)},
1134 {"dark salmon" , PALETTERGB (233,150,122)},
1135 {"DarkSalmon" , PALETTERGB (233,150,122)},
1136 {"salmon" , PALETTERGB (250,128,114)},
1137 {"light salmon" , PALETTERGB (255,160,122)},
1138 {"LightSalmon" , PALETTERGB (255,160,122)},
1139 {"orange" , PALETTERGB (255,165, 0)},
1140 {"dark orange" , PALETTERGB (255,140, 0)},
1141 {"DarkOrange" , PALETTERGB (255,140, 0)},
1142 {"coral" , PALETTERGB (255,127, 80)},
1143 {"light coral" , PALETTERGB (240,128,128)},
1144 {"LightCoral" , PALETTERGB (240,128,128)},
1145 {"tomato" , PALETTERGB (255, 99, 71)},
1146 {"orange red" , PALETTERGB (255, 69, 0)},
1147 {"OrangeRed" , PALETTERGB (255, 69, 0)},
1148 {"red" , PALETTERGB (255, 0, 0)},
1149 {"hot pink" , PALETTERGB (255,105,180)},
1150 {"HotPink" , PALETTERGB (255,105,180)},
1151 {"deep pink" , PALETTERGB (255, 20,147)},
1152 {"DeepPink" , PALETTERGB (255, 20,147)},
1153 {"pink" , PALETTERGB (255,192,203)},
1154 {"light pink" , PALETTERGB (255,182,193)},
1155 {"LightPink" , PALETTERGB (255,182,193)},
1156 {"pale violet red" , PALETTERGB (219,112,147)},
1157 {"PaleVioletRed" , PALETTERGB (219,112,147)},
1158 {"maroon" , PALETTERGB (176, 48, 96)},
1159 {"medium violet red" , PALETTERGB (199, 21,133)},
1160 {"MediumVioletRed" , PALETTERGB (199, 21,133)},
1161 {"violet red" , PALETTERGB (208, 32,144)},
1162 {"VioletRed" , PALETTERGB (208, 32,144)},
1163 {"magenta" , PALETTERGB (255, 0,255)},
1164 {"violet" , PALETTERGB (238,130,238)},
1165 {"plum" , PALETTERGB (221,160,221)},
1166 {"orchid" , PALETTERGB (218,112,214)},
1167 {"medium orchid" , PALETTERGB (186, 85,211)},
1168 {"MediumOrchid" , PALETTERGB (186, 85,211)},
1169 {"dark orchid" , PALETTERGB (153, 50,204)},
1170 {"DarkOrchid" , PALETTERGB (153, 50,204)},
1171 {"dark violet" , PALETTERGB (148, 0,211)},
1172 {"DarkViolet" , PALETTERGB (148, 0,211)},
1173 {"blue violet" , PALETTERGB (138, 43,226)},
1174 {"BlueViolet" , PALETTERGB (138, 43,226)},
1175 {"purple" , PALETTERGB (160, 32,240)},
1176 {"medium purple" , PALETTERGB (147,112,219)},
1177 {"MediumPurple" , PALETTERGB (147,112,219)},
1178 {"thistle" , PALETTERGB (216,191,216)},
1179 {"gray0" , PALETTERGB ( 0, 0, 0)},
1180 {"grey0" , PALETTERGB ( 0, 0, 0)},
1181 {"dark grey" , PALETTERGB (169,169,169)},
1182 {"DarkGrey" , PALETTERGB (169,169,169)},
1183 {"dark gray" , PALETTERGB (169,169,169)},
1184 {"DarkGray" , PALETTERGB (169,169,169)},
1185 {"dark blue" , PALETTERGB ( 0, 0,139)},
1186 {"DarkBlue" , PALETTERGB ( 0, 0,139)},
1187 {"dark cyan" , PALETTERGB ( 0,139,139)},
1188 {"DarkCyan" , PALETTERGB ( 0,139,139)},
1189 {"dark magenta" , PALETTERGB (139, 0,139)},
1190 {"DarkMagenta" , PALETTERGB (139, 0,139)},
1191 {"dark red" , PALETTERGB (139, 0, 0)},
1192 {"DarkRed" , PALETTERGB (139, 0, 0)},
1193 {"light green" , PALETTERGB (144,238,144)},
1194 {"LightGreen" , PALETTERGB (144,238,144)},
1197 DEFUN ("win32-default-color-map", Fwin32_default_color_map
, Swin32_default_color_map
,
1198 0, 0, 0, "Return the default color map.")
1202 colormap_t
*pc
= win32_color_map
;
1209 for (i
= 0; i
< sizeof (win32_color_map
) / sizeof (win32_color_map
[0]);
1211 cmap
= Fcons (Fcons (build_string (pc
->name
),
1212 make_number (pc
->colorref
)),
1221 win32_to_x_color (rgb
)
1226 CHECK_NUMBER (rgb
, 0);
1230 color
= Frassq (rgb
, Vwin32_color_map
);
1235 return (Fcar (color
));
1241 x_to_win32_color (colorname
)
1244 register Lisp_Object tail
, ret
= Qnil
;
1248 for (tail
= Vwin32_color_map
; !NILP (tail
); tail
= Fcdr (tail
))
1250 register Lisp_Object elt
, tem
;
1253 if (!CONSP (elt
)) continue;
1257 if (lstrcmpi (XSTRING (tem
)->data
, colorname
) == 0)
1259 ret
= XUINT(Fcdr (elt
));
1273 win32_regenerate_palette (FRAME_PTR f
)
1275 struct win32_palette_entry
* list
;
1276 LOGPALETTE
* log_palette
;
1277 HPALETTE new_palette
;
1280 /* don't bother trying to create palette if not supported */
1281 if (! FRAME_WIN32_DISPLAY_INFO (f
)->has_palette
)
1284 log_palette
= (LOGPALETTE
*)
1285 alloca (sizeof (LOGPALETTE
) +
1286 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
* sizeof (PALETTEENTRY
));
1287 log_palette
->palVersion
= 0x300;
1288 log_palette
->palNumEntries
= FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
;
1290 list
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1292 i
< FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
;
1293 i
++, list
= list
->next
)
1294 log_palette
->palPalEntry
[i
] = list
->entry
;
1296 new_palette
= CreatePalette (log_palette
);
1300 if (FRAME_WIN32_DISPLAY_INFO (f
)->palette
)
1301 DeleteObject (FRAME_WIN32_DISPLAY_INFO (f
)->palette
);
1302 FRAME_WIN32_DISPLAY_INFO (f
)->palette
= new_palette
;
1304 /* Realize display palette and garbage all frames. */
1305 release_frame_dc (f
, get_frame_dc (f
));
1310 #define WIN32_COLOR(pe) RGB (pe.peRed, pe.peGreen, pe.peBlue)
1311 #define SET_WIN32_COLOR(pe, color) \
1314 pe.peRed = GetRValue (color); \
1315 pe.peGreen = GetGValue (color); \
1316 pe.peBlue = GetBValue (color); \
1321 /* Keep these around in case we ever want to track color usage. */
1323 win32_map_color (FRAME_PTR f
, COLORREF color
)
1325 struct win32_palette_entry
* list
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1327 if (NILP (Vwin32_enable_palette
))
1330 /* check if color is already mapped */
1333 if (WIN32_COLOR (list
->entry
) == color
)
1341 /* not already mapped, so add to list and recreate Windows palette */
1342 list
= (struct win32_palette_entry
*)
1343 xmalloc (sizeof (struct win32_palette_entry
));
1344 SET_WIN32_COLOR (list
->entry
, color
);
1346 list
->next
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1347 FRAME_WIN32_DISPLAY_INFO (f
)->color_list
= list
;
1348 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
++;
1350 /* set flag that palette must be regenerated */
1351 FRAME_WIN32_DISPLAY_INFO (f
)->regen_palette
= TRUE
;
1355 win32_unmap_color (FRAME_PTR f
, COLORREF color
)
1357 struct win32_palette_entry
* list
= FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1358 struct win32_palette_entry
**prev
= &FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1360 if (NILP (Vwin32_enable_palette
))
1363 /* check if color is already mapped */
1366 if (WIN32_COLOR (list
->entry
) == color
)
1368 if (--list
->refcount
== 0)
1372 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
--;
1382 /* set flag that palette must be regenerated */
1383 FRAME_WIN32_DISPLAY_INFO (f
)->regen_palette
= TRUE
;
1387 /* Decide if color named COLOR is valid for the display associated with
1388 the selected frame; if so, return the rgb values in COLOR_DEF.
1389 If ALLOC is nonzero, allocate a new colormap cell. */
1392 defined_color (f
, color
, color_def
, alloc
)
1395 COLORREF
*color_def
;
1398 register Lisp_Object tem
;
1400 tem
= x_to_win32_color (color
);
1404 if (!NILP (Vwin32_enable_palette
))
1406 struct win32_palette_entry
* entry
=
1407 FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1408 struct win32_palette_entry
** prev
=
1409 &FRAME_WIN32_DISPLAY_INFO (f
)->color_list
;
1411 /* check if color is already mapped */
1414 if (WIN32_COLOR (entry
->entry
) == XUINT (tem
))
1416 prev
= &entry
->next
;
1417 entry
= entry
->next
;
1420 if (entry
== NULL
&& alloc
)
1422 /* not already mapped, so add to list */
1423 entry
= (struct win32_palette_entry
*)
1424 xmalloc (sizeof (struct win32_palette_entry
));
1425 SET_WIN32_COLOR (entry
->entry
, XUINT (tem
));
1428 FRAME_WIN32_DISPLAY_INFO (f
)->num_colors
++;
1430 /* set flag that palette must be regenerated */
1431 FRAME_WIN32_DISPLAY_INFO (f
)->regen_palette
= TRUE
;
1434 /* Ensure COLORREF value is snapped to nearest color in (default)
1435 palette by simulating the PALETTERGB macro. This works whether
1436 or not the display device has a palette. */
1437 *color_def
= XUINT (tem
) | 0x2000000;
1446 /* Given a string ARG naming a color, compute a pixel value from it
1447 suitable for screen F.
1448 If F is not a color screen, return DEF (default) regardless of what
1452 x_decode_color (f
, arg
, def
)
1459 CHECK_STRING (arg
, 0);
1461 if (strcmp (XSTRING (arg
)->data
, "black") == 0)
1462 return BLACK_PIX_DEFAULT (f
);
1463 else if (strcmp (XSTRING (arg
)->data
, "white") == 0)
1464 return WHITE_PIX_DEFAULT (f
);
1466 if ((FRAME_WIN32_DISPLAY_INFO (f
)->n_planes
* FRAME_WIN32_DISPLAY_INFO (f
)->n_cbits
) == 1)
1469 /* defined_color is responsible for coping with failures
1470 by looking for a near-miss. */
1471 if (defined_color (f
, XSTRING (arg
)->data
, &cdef
, 1))
1474 /* defined_color failed; return an ultimate default. */
1478 /* Functions called only from `x_set_frame_param'
1479 to set individual parameters.
1481 If FRAME_WIN32_WINDOW (f) is 0,
1482 the frame is being created and its window does not exist yet.
1483 In that case, just record the parameter's new value
1484 in the standard place; do not attempt to change the window. */
1487 x_set_foreground_color (f
, arg
, oldval
)
1489 Lisp_Object arg
, oldval
;
1491 f
->output_data
.win32
->foreground_pixel
1492 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1494 if (FRAME_WIN32_WINDOW (f
) != 0)
1496 recompute_basic_faces (f
);
1497 if (FRAME_VISIBLE_P (f
))
1503 x_set_background_color (f
, arg
, oldval
)
1505 Lisp_Object arg
, oldval
;
1510 f
->output_data
.win32
->background_pixel
1511 = x_decode_color (f
, arg
, WHITE_PIX_DEFAULT (f
));
1513 if (FRAME_WIN32_WINDOW (f
) != 0)
1515 SetWindowLong (FRAME_WIN32_WINDOW (f
), WND_BACKGROUND_INDEX
, f
->output_data
.win32
->background_pixel
);
1517 recompute_basic_faces (f
);
1519 if (FRAME_VISIBLE_P (f
))
1525 x_set_mouse_color (f
, arg
, oldval
)
1527 Lisp_Object arg
, oldval
;
1530 Cursor cursor
, nontext_cursor
, mode_cursor
, cross_cursor
;
1534 if (!EQ (Qnil
, arg
))
1535 f
->output_data
.win32
->mouse_pixel
1536 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1537 mask_color
= f
->output_data
.win32
->background_pixel
;
1538 /* No invisible pointers. */
1539 if (mask_color
== f
->output_data
.win32
->mouse_pixel
1540 && mask_color
== f
->output_data
.win32
->background_pixel
)
1541 f
->output_data
.win32
->mouse_pixel
= f
->output_data
.win32
->foreground_pixel
;
1546 /* It's not okay to crash if the user selects a screwy cursor. */
1547 x_catch_errors (FRAME_WIN32_DISPLAY (f
));
1549 if (!EQ (Qnil
, Vx_pointer_shape
))
1551 CHECK_NUMBER (Vx_pointer_shape
, 0);
1552 cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XINT (Vx_pointer_shape
));
1555 cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_xterm
);
1556 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad text pointer cursor: %s");
1558 if (!EQ (Qnil
, Vx_nontext_pointer_shape
))
1560 CHECK_NUMBER (Vx_nontext_pointer_shape
, 0);
1561 nontext_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1562 XINT (Vx_nontext_pointer_shape
));
1565 nontext_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_left_ptr
);
1566 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad nontext pointer cursor: %s");
1568 if (!EQ (Qnil
, Vx_mode_pointer_shape
))
1570 CHECK_NUMBER (Vx_mode_pointer_shape
, 0);
1571 mode_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1572 XINT (Vx_mode_pointer_shape
));
1575 mode_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_xterm
);
1576 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad modeline pointer cursor: %s");
1578 if (!EQ (Qnil
, Vx_sensitive_text_pointer_shape
))
1580 CHECK_NUMBER (Vx_sensitive_text_pointer_shape
, 0);
1582 = XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1583 XINT (Vx_sensitive_text_pointer_shape
));
1586 cross_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_crosshair
);
1588 /* Check and report errors with the above calls. */
1589 x_check_errors (FRAME_WIN32_DISPLAY (f
), "can't set cursor shape: %s");
1590 x_uncatch_errors (FRAME_WIN32_DISPLAY (f
));
1593 XColor fore_color
, back_color
;
1595 fore_color
.pixel
= f
->output_data
.win32
->mouse_pixel
;
1596 back_color
.pixel
= mask_color
;
1597 XQueryColor (FRAME_WIN32_DISPLAY (f
),
1598 DefaultColormap (FRAME_WIN32_DISPLAY (f
),
1599 DefaultScreen (FRAME_WIN32_DISPLAY (f
))),
1601 XQueryColor (FRAME_WIN32_DISPLAY (f
),
1602 DefaultColormap (FRAME_WIN32_DISPLAY (f
),
1603 DefaultScreen (FRAME_WIN32_DISPLAY (f
))),
1605 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), cursor
,
1606 &fore_color
, &back_color
);
1607 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), nontext_cursor
,
1608 &fore_color
, &back_color
);
1609 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), mode_cursor
,
1610 &fore_color
, &back_color
);
1611 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), cross_cursor
,
1612 &fore_color
, &back_color
);
1615 if (FRAME_WIN32_WINDOW (f
) != 0)
1617 XDefineCursor (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
), cursor
);
1620 if (cursor
!= f
->output_data
.win32
->text_cursor
&& f
->output_data
.win32
->text_cursor
!= 0)
1621 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->text_cursor
);
1622 f
->output_data
.win32
->text_cursor
= cursor
;
1624 if (nontext_cursor
!= f
->output_data
.win32
->nontext_cursor
1625 && f
->output_data
.win32
->nontext_cursor
!= 0)
1626 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->nontext_cursor
);
1627 f
->output_data
.win32
->nontext_cursor
= nontext_cursor
;
1629 if (mode_cursor
!= f
->output_data
.win32
->modeline_cursor
1630 && f
->output_data
.win32
->modeline_cursor
!= 0)
1631 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->modeline_cursor
);
1632 f
->output_data
.win32
->modeline_cursor
= mode_cursor
;
1633 if (cross_cursor
!= f
->output_data
.win32
->cross_cursor
1634 && f
->output_data
.win32
->cross_cursor
!= 0)
1635 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->cross_cursor
);
1636 f
->output_data
.win32
->cross_cursor
= cross_cursor
;
1638 XFlush (FRAME_WIN32_DISPLAY (f
));
1644 x_set_cursor_color (f
, arg
, oldval
)
1646 Lisp_Object arg
, oldval
;
1648 unsigned long fore_pixel
;
1650 if (!EQ (Vx_cursor_fore_pixel
, Qnil
))
1651 fore_pixel
= x_decode_color (f
, Vx_cursor_fore_pixel
,
1652 WHITE_PIX_DEFAULT (f
));
1654 fore_pixel
= f
->output_data
.win32
->background_pixel
;
1655 f
->output_data
.win32
->cursor_pixel
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1657 /* Make sure that the cursor color differs from the background color. */
1658 if (f
->output_data
.win32
->cursor_pixel
== f
->output_data
.win32
->background_pixel
)
1660 f
->output_data
.win32
->cursor_pixel
= f
->output_data
.win32
->mouse_pixel
;
1661 if (f
->output_data
.win32
->cursor_pixel
== fore_pixel
)
1662 fore_pixel
= f
->output_data
.win32
->background_pixel
;
1664 f
->output_data
.win32
->cursor_foreground_pixel
= fore_pixel
;
1666 if (FRAME_WIN32_WINDOW (f
) != 0)
1668 if (FRAME_VISIBLE_P (f
))
1670 x_display_cursor (f
, 0);
1671 x_display_cursor (f
, 1);
1676 /* Set the border-color of frame F to value described by ARG.
1677 ARG can be a string naming a color.
1678 The border-color is used for the border that is drawn by the server.
1679 Note that this does not fully take effect if done before
1680 F has a window; it must be redone when the window is created. */
1683 x_set_border_color (f
, arg
, oldval
)
1685 Lisp_Object arg
, oldval
;
1690 CHECK_STRING (arg
, 0);
1691 str
= XSTRING (arg
)->data
;
1693 pix
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1695 x_set_border_pixel (f
, pix
);
1698 /* Set the border-color of frame F to pixel value PIX.
1699 Note that this does not fully take effect if done before
1702 x_set_border_pixel (f
, pix
)
1706 f
->output_data
.win32
->border_pixel
= pix
;
1708 if (FRAME_WIN32_WINDOW (f
) != 0 && f
->output_data
.win32
->border_width
> 0)
1710 if (FRAME_VISIBLE_P (f
))
1716 x_set_cursor_type (f
, arg
, oldval
)
1718 Lisp_Object arg
, oldval
;
1722 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
1723 f
->output_data
.win32
->cursor_width
= 2;
1725 else if (CONSP (arg
) && EQ (XCONS (arg
)->car
, Qbar
)
1726 && INTEGERP (XCONS (arg
)->cdr
))
1728 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
1729 f
->output_data
.win32
->cursor_width
= XINT (XCONS (arg
)->cdr
);
1732 /* Treat anything unknown as "box cursor".
1733 It was bad to signal an error; people have trouble fixing
1734 .Xdefaults with Emacs, when it has something bad in it. */
1735 FRAME_DESIRED_CURSOR (f
) = filled_box_cursor
;
1737 /* Make sure the cursor gets redrawn. This is overkill, but how
1738 often do people change cursor types? */
1739 update_mode_lines
++;
1743 x_set_icon_type (f
, arg
, oldval
)
1745 Lisp_Object arg
, oldval
;
1753 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1756 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1761 result
= x_text_icon (f
,
1762 (char *) XSTRING ((!NILP (f
->icon_name
)
1766 result
= x_bitmap_icon (f
, arg
);
1771 error ("No icon window available");
1774 /* If the window was unmapped (and its icon was mapped),
1775 the new icon is not mapped, so map the window in its stead. */
1776 if (FRAME_VISIBLE_P (f
))
1778 #ifdef USE_X_TOOLKIT
1779 XtPopup (f
->output_data
.win32
->widget
, XtGrabNone
);
1781 XMapWindow (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
));
1784 XFlush (FRAME_WIN32_DISPLAY (f
));
1789 /* Return non-nil if frame F wants a bitmap icon. */
1797 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
1799 return XCONS (tem
)->cdr
;
1805 x_set_icon_name (f
, arg
, oldval
)
1807 Lisp_Object arg
, oldval
;
1814 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1817 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1823 if (f
->output_data
.win32
->icon_bitmap
!= 0)
1828 result
= x_text_icon (f
,
1829 (char *) XSTRING ((!NILP (f
->icon_name
)
1836 error ("No icon window available");
1839 /* If the window was unmapped (and its icon was mapped),
1840 the new icon is not mapped, so map the window in its stead. */
1841 if (FRAME_VISIBLE_P (f
))
1843 #ifdef USE_X_TOOLKIT
1844 XtPopup (f
->output_data
.win32
->widget
, XtGrabNone
);
1846 XMapWindow (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
));
1849 XFlush (FRAME_WIN32_DISPLAY (f
));
1854 extern Lisp_Object
x_new_font ();
1857 x_set_font (f
, arg
, oldval
)
1859 Lisp_Object arg
, oldval
;
1863 CHECK_STRING (arg
, 1);
1866 result
= x_new_font (f
, XSTRING (arg
)->data
);
1869 if (EQ (result
, Qnil
))
1870 error ("Font \"%s\" is not defined", XSTRING (arg
)->data
);
1871 else if (EQ (result
, Qt
))
1872 error ("the characters of the given font have varying widths");
1873 else if (STRINGP (result
))
1875 recompute_basic_faces (f
);
1876 store_frame_param (f
, Qfont
, result
);
1883 x_set_border_width (f
, arg
, oldval
)
1885 Lisp_Object arg
, oldval
;
1887 CHECK_NUMBER (arg
, 0);
1889 if (XINT (arg
) == f
->output_data
.win32
->border_width
)
1892 if (FRAME_WIN32_WINDOW (f
) != 0)
1893 error ("Cannot change the border width of a window");
1895 f
->output_data
.win32
->border_width
= XINT (arg
);
1899 x_set_internal_border_width (f
, arg
, oldval
)
1901 Lisp_Object arg
, oldval
;
1904 int old
= f
->output_data
.win32
->internal_border_width
;
1906 CHECK_NUMBER (arg
, 0);
1907 f
->output_data
.win32
->internal_border_width
= XINT (arg
);
1908 if (f
->output_data
.win32
->internal_border_width
< 0)
1909 f
->output_data
.win32
->internal_border_width
= 0;
1911 if (f
->output_data
.win32
->internal_border_width
== old
)
1914 if (FRAME_WIN32_WINDOW (f
) != 0)
1917 x_set_window_size (f
, 0, f
->width
, f
->height
);
1919 SET_FRAME_GARBAGED (f
);
1924 x_set_visibility (f
, value
, oldval
)
1926 Lisp_Object value
, oldval
;
1929 XSETFRAME (frame
, f
);
1932 Fmake_frame_invisible (frame
, Qt
);
1933 else if (EQ (value
, Qicon
))
1934 Ficonify_frame (frame
);
1936 Fmake_frame_visible (frame
);
1940 x_set_menu_bar_lines (f
, value
, oldval
)
1942 Lisp_Object value
, oldval
;
1945 int olines
= FRAME_MENU_BAR_LINES (f
);
1947 /* Right now, menu bars don't work properly in minibuf-only frames;
1948 most of the commands try to apply themselves to the minibuffer
1949 frame itslef, and get an error because you can't switch buffers
1950 in or split the minibuffer window. */
1951 if (FRAME_MINIBUF_ONLY_P (f
))
1954 if (INTEGERP (value
))
1955 nlines
= XINT (value
);
1959 FRAME_MENU_BAR_LINES (f
) = 0;
1961 FRAME_EXTERNAL_MENU_BAR (f
) = 1;
1964 if (FRAME_EXTERNAL_MENU_BAR (f
) == 1)
1965 free_frame_menubar (f
);
1966 FRAME_EXTERNAL_MENU_BAR (f
) = 0;
1970 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
1973 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1974 name; if NAME is a string, set F's name to NAME and set
1975 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1977 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1978 suggesting a new name, which lisp code should override; if
1979 F->explicit_name is set, ignore the new name; otherwise, set it. */
1982 x_set_name (f
, name
, explicit)
1987 /* Make sure that requests from lisp code override requests from
1988 Emacs redisplay code. */
1991 /* If we're switching from explicit to implicit, we had better
1992 update the mode lines and thereby update the title. */
1993 if (f
->explicit_name
&& NILP (name
))
1994 update_mode_lines
= 1;
1996 f
->explicit_name
= ! NILP (name
);
1998 else if (f
->explicit_name
)
2001 /* If NAME is nil, set the name to the win32_id_name. */
2004 /* Check for no change needed in this very common case
2005 before we do any consing. */
2006 if (!strcmp (FRAME_WIN32_DISPLAY_INFO (f
)->win32_id_name
,
2007 XSTRING (f
->name
)->data
))
2009 name
= build_string (FRAME_WIN32_DISPLAY_INFO (f
)->win32_id_name
);
2012 CHECK_STRING (name
, 0);
2014 /* Don't change the name if it's already NAME. */
2015 if (! NILP (Fstring_equal (name
, f
->name
)))
2018 if (FRAME_WIN32_WINDOW (f
))
2021 SetWindowText(FRAME_WIN32_WINDOW (f
), XSTRING (name
)->data
);
2028 /* This function should be called when the user's lisp code has
2029 specified a name for the frame; the name will override any set by the
2032 x_explicitly_set_name (f
, arg
, oldval
)
2034 Lisp_Object arg
, oldval
;
2036 x_set_name (f
, arg
, 1);
2039 /* This function should be called by Emacs redisplay code to set the
2040 name; names set this way will never override names set by the user's
2043 x_implicitly_set_name (f
, arg
, oldval
)
2045 Lisp_Object arg
, oldval
;
2047 x_set_name (f
, arg
, 0);
2051 x_set_autoraise (f
, arg
, oldval
)
2053 Lisp_Object arg
, oldval
;
2055 f
->auto_raise
= !EQ (Qnil
, arg
);
2059 x_set_autolower (f
, arg
, oldval
)
2061 Lisp_Object arg
, oldval
;
2063 f
->auto_lower
= !EQ (Qnil
, arg
);
2067 x_set_unsplittable (f
, arg
, oldval
)
2069 Lisp_Object arg
, oldval
;
2071 f
->no_split
= !NILP (arg
);
2075 x_set_vertical_scroll_bars (f
, arg
, oldval
)
2077 Lisp_Object arg
, oldval
;
2079 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
2080 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
2081 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
2082 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
2084 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = NILP (arg
) ?
2085 vertical_scroll_bar_none
:
2087 ? vertical_scroll_bar_right
2088 : vertical_scroll_bar_left
;
2090 /* We set this parameter before creating the window for the
2091 frame, so we can get the geometry right from the start.
2092 However, if the window hasn't been created yet, we shouldn't
2093 call x_set_window_size. */
2094 if (FRAME_WIN32_WINDOW (f
))
2095 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
2100 x_set_scroll_bar_width (f
, arg
, oldval
)
2102 Lisp_Object arg
, oldval
;
2106 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = 0;
2107 FRAME_SCROLL_BAR_COLS (f
) = 2;
2109 else if (INTEGERP (arg
) && XINT (arg
) > 0
2110 && XFASTINT (arg
) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f
))
2112 int wid
= FONT_WIDTH (f
->output_data
.win32
->font
);
2113 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = XFASTINT (arg
);
2114 FRAME_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
2115 if (FRAME_WIN32_WINDOW (f
))
2116 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
2120 /* Subroutines of creating an frame. */
2122 /* Make sure that Vx_resource_name is set to a reasonable value.
2123 Fix it up, or set it to `emacs' if it is too hopeless. */
2126 validate_x_resource_name ()
2129 /* Number of valid characters in the resource name. */
2131 /* Number of invalid characters in the resource name. */
2136 if (STRINGP (Vx_resource_name
))
2138 unsigned char *p
= XSTRING (Vx_resource_name
)->data
;
2141 len
= XSTRING (Vx_resource_name
)->size
;
2143 /* Only letters, digits, - and _ are valid in resource names.
2144 Count the valid characters and count the invalid ones. */
2145 for (i
= 0; i
< len
; i
++)
2148 if (! ((c
>= 'a' && c
<= 'z')
2149 || (c
>= 'A' && c
<= 'Z')
2150 || (c
>= '0' && c
<= '9')
2151 || c
== '-' || c
== '_'))
2158 /* Not a string => completely invalid. */
2159 bad_count
= 5, good_count
= 0;
2161 /* If name is valid already, return. */
2165 /* If name is entirely invalid, or nearly so, use `emacs'. */
2167 || (good_count
== 1 && bad_count
> 0))
2169 Vx_resource_name
= build_string ("emacs");
2173 /* Name is partly valid. Copy it and replace the invalid characters
2174 with underscores. */
2176 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
2178 for (i
= 0; i
< len
; i
++)
2180 int c
= XSTRING (new)->data
[i
];
2181 if (! ((c
>= 'a' && c
<= 'z')
2182 || (c
>= 'A' && c
<= 'Z')
2183 || (c
>= '0' && c
<= '9')
2184 || c
== '-' || c
== '_'))
2185 XSTRING (new)->data
[i
] = '_';
2190 extern char *x_get_string_resource ();
2192 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
2193 "Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.\n\
2194 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the\n\
2195 class, where INSTANCE is the name under which Emacs was invoked, or\n\
2196 the name specified by the `-name' or `-rn' command-line arguments.\n\
2198 The optional arguments COMPONENT and SUBCLASS add to the key and the\n\
2199 class, respectively. You must specify both of them or neither.\n\
2200 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'\n\
2201 and the class is `Emacs.CLASS.SUBCLASS'.")
2202 (attribute
, class, component
, subclass
)
2203 Lisp_Object attribute
, class, component
, subclass
;
2205 register char *value
;
2209 CHECK_STRING (attribute
, 0);
2210 CHECK_STRING (class, 0);
2212 if (!NILP (component
))
2213 CHECK_STRING (component
, 1);
2214 if (!NILP (subclass
))
2215 CHECK_STRING (subclass
, 2);
2216 if (NILP (component
) != NILP (subclass
))
2217 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
2219 validate_x_resource_name ();
2221 /* Allocate space for the components, the dots which separate them,
2222 and the final '\0'. Make them big enough for the worst case. */
2223 name_key
= (char *) alloca (XSTRING (Vx_resource_name
)->size
2224 + (STRINGP (component
)
2225 ? XSTRING (component
)->size
: 0)
2226 + XSTRING (attribute
)->size
2229 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
2230 + XSTRING (class)->size
2231 + (STRINGP (subclass
)
2232 ? XSTRING (subclass
)->size
: 0)
2235 /* Start with emacs.FRAMENAME for the name (the specific one)
2236 and with `Emacs' for the class key (the general one). */
2237 strcpy (name_key
, XSTRING (Vx_resource_name
)->data
);
2238 strcpy (class_key
, EMACS_CLASS
);
2240 strcat (class_key
, ".");
2241 strcat (class_key
, XSTRING (class)->data
);
2243 if (!NILP (component
))
2245 strcat (class_key
, ".");
2246 strcat (class_key
, XSTRING (subclass
)->data
);
2248 strcat (name_key
, ".");
2249 strcat (name_key
, XSTRING (component
)->data
);
2252 strcat (name_key
, ".");
2253 strcat (name_key
, XSTRING (attribute
)->data
);
2255 value
= x_get_string_resource (Qnil
,
2256 name_key
, class_key
);
2258 if (value
!= (char *) 0)
2259 return build_string (value
);
2264 /* Used when C code wants a resource value. */
2267 x_get_resource_string (attribute
, class)
2268 char *attribute
, *class;
2270 register char *value
;
2274 /* Allocate space for the components, the dots which separate them,
2275 and the final '\0'. */
2276 name_key
= (char *) alloca (XSTRING (Vinvocation_name
)->size
2277 + strlen (attribute
) + 2);
2278 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
2279 + strlen (class) + 2);
2281 sprintf (name_key
, "%s.%s",
2282 XSTRING (Vinvocation_name
)->data
,
2284 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
2286 return x_get_string_resource (selected_frame
,
2287 name_key
, class_key
);
2290 /* Types we might convert a resource string into. */
2293 number
, boolean
, string
, symbol
2296 /* Return the value of parameter PARAM.
2298 First search ALIST, then Vdefault_frame_alist, then the X defaults
2299 database, using ATTRIBUTE as the attribute name and CLASS as its class.
2301 Convert the resource to the type specified by desired_type.
2303 If no default is specified, return Qunbound. If you call
2304 x_get_arg, make sure you deal with Qunbound in a reasonable way,
2305 and don't let it get stored in any Lisp-visible variables! */
2308 x_get_arg (alist
, param
, attribute
, class, type
)
2309 Lisp_Object alist
, param
;
2312 enum resource_types type
;
2314 register Lisp_Object tem
;
2316 tem
= Fassq (param
, alist
);
2318 tem
= Fassq (param
, Vdefault_frame_alist
);
2324 tem
= Fx_get_resource (build_string (attribute
),
2325 build_string (class),
2334 return make_number (atoi (XSTRING (tem
)->data
));
2337 tem
= Fdowncase (tem
);
2338 if (!strcmp (XSTRING (tem
)->data
, "on")
2339 || !strcmp (XSTRING (tem
)->data
, "true"))
2348 /* As a special case, we map the values `true' and `on'
2349 to Qt, and `false' and `off' to Qnil. */
2352 lower
= Fdowncase (tem
);
2353 if (!strcmp (XSTRING (lower
)->data
, "on")
2354 || !strcmp (XSTRING (lower
)->data
, "true"))
2356 else if (!strcmp (XSTRING (lower
)->data
, "off")
2357 || !strcmp (XSTRING (lower
)->data
, "false"))
2360 return Fintern (tem
, Qnil
);
2373 /* Record in frame F the specified or default value according to ALIST
2374 of the parameter named PARAM (a Lisp symbol).
2375 If no value is specified for PARAM, look for an X default for XPROP
2376 on the frame named NAME.
2377 If that is not found either, use the value DEFLT. */
2380 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
2387 enum resource_types type
;
2391 tem
= x_get_arg (alist
, prop
, xprop
, xclass
, type
);
2392 if (EQ (tem
, Qunbound
))
2394 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
2398 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
2399 "Parse an X-style geometry string STRING.\n\
2400 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).\n\
2401 The properties returned may include `top', `left', `height', and `width'.\n\
2402 The value of `left' or `top' may be an integer,\n\
2403 or a list (+ N) meaning N pixels relative to top/left corner,\n\
2404 or a list (- N) meaning -N pixels relative to bottom/right corner.")
2409 unsigned int width
, height
;
2412 CHECK_STRING (string
, 0);
2414 geometry
= XParseGeometry ((char *) XSTRING (string
)->data
,
2415 &x
, &y
, &width
, &height
);
2418 if (geometry
& XValue
)
2420 Lisp_Object element
;
2422 if (x
>= 0 && (geometry
& XNegative
))
2423 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
2424 else if (x
< 0 && ! (geometry
& XNegative
))
2425 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
2427 element
= Fcons (Qleft
, make_number (x
));
2428 result
= Fcons (element
, result
);
2431 if (geometry
& YValue
)
2433 Lisp_Object element
;
2435 if (y
>= 0 && (geometry
& YNegative
))
2436 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
2437 else if (y
< 0 && ! (geometry
& YNegative
))
2438 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
2440 element
= Fcons (Qtop
, make_number (y
));
2441 result
= Fcons (element
, result
);
2444 if (geometry
& WidthValue
)
2445 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
2446 if (geometry
& HeightValue
)
2447 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
2452 /* Calculate the desired size and position of this window,
2453 and return the flags saying which aspects were specified.
2455 This function does not make the coordinates positive. */
2457 #define DEFAULT_ROWS 40
2458 #define DEFAULT_COLS 80
2461 x_figure_window_size (f
, parms
)
2465 register Lisp_Object tem0
, tem1
, tem2
;
2466 int height
, width
, left
, top
;
2467 register int geometry
;
2468 long window_prompting
= 0;
2470 /* Default values if we fall through.
2471 Actually, if that happens we should get
2472 window manager prompting. */
2473 SET_FRAME_WIDTH (f
, DEFAULT_COLS
);
2474 f
->height
= DEFAULT_ROWS
;
2475 /* Window managers expect that if program-specified
2476 positions are not (0,0), they're intentional, not defaults. */
2477 f
->output_data
.win32
->top_pos
= 0;
2478 f
->output_data
.win32
->left_pos
= 0;
2480 tem0
= x_get_arg (parms
, Qheight
, 0, 0, number
);
2481 tem1
= x_get_arg (parms
, Qwidth
, 0, 0, number
);
2482 tem2
= x_get_arg (parms
, Quser_size
, 0, 0, number
);
2483 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
2485 if (!EQ (tem0
, Qunbound
))
2487 CHECK_NUMBER (tem0
, 0);
2488 f
->height
= XINT (tem0
);
2490 if (!EQ (tem1
, Qunbound
))
2492 CHECK_NUMBER (tem1
, 0);
2493 SET_FRAME_WIDTH (f
, XINT (tem1
));
2495 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
2496 window_prompting
|= USSize
;
2498 window_prompting
|= PSize
;
2501 f
->output_data
.win32
->vertical_scroll_bar_extra
2502 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2504 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) > 0
2505 ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f
)
2506 : (FRAME_SCROLL_BAR_COLS (f
) * FONT_WIDTH (f
->output_data
.win32
->font
)));
2507 f
->output_data
.win32
->pixel_width
= CHAR_TO_PIXEL_WIDTH (f
, f
->width
);
2508 f
->output_data
.win32
->pixel_height
= CHAR_TO_PIXEL_HEIGHT (f
, f
->height
);
2510 tem0
= x_get_arg (parms
, Qtop
, 0, 0, number
);
2511 tem1
= x_get_arg (parms
, Qleft
, 0, 0, number
);
2512 tem2
= x_get_arg (parms
, Quser_position
, 0, 0, number
);
2513 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
2515 if (EQ (tem0
, Qminus
))
2517 f
->output_data
.win32
->top_pos
= 0;
2518 window_prompting
|= YNegative
;
2520 else if (CONSP (tem0
) && EQ (XCONS (tem0
)->car
, Qminus
)
2521 && CONSP (XCONS (tem0
)->cdr
)
2522 && INTEGERP (XCONS (XCONS (tem0
)->cdr
)->car
))
2524 f
->output_data
.win32
->top_pos
= - XINT (XCONS (XCONS (tem0
)->cdr
)->car
);
2525 window_prompting
|= YNegative
;
2527 else if (CONSP (tem0
) && EQ (XCONS (tem0
)->car
, Qplus
)
2528 && CONSP (XCONS (tem0
)->cdr
)
2529 && INTEGERP (XCONS (XCONS (tem0
)->cdr
)->car
))
2531 f
->output_data
.win32
->top_pos
= XINT (XCONS (XCONS (tem0
)->cdr
)->car
);
2533 else if (EQ (tem0
, Qunbound
))
2534 f
->output_data
.win32
->top_pos
= 0;
2537 CHECK_NUMBER (tem0
, 0);
2538 f
->output_data
.win32
->top_pos
= XINT (tem0
);
2539 if (f
->output_data
.win32
->top_pos
< 0)
2540 window_prompting
|= YNegative
;
2543 if (EQ (tem1
, Qminus
))
2545 f
->output_data
.win32
->left_pos
= 0;
2546 window_prompting
|= XNegative
;
2548 else if (CONSP (tem1
) && EQ (XCONS (tem1
)->car
, Qminus
)
2549 && CONSP (XCONS (tem1
)->cdr
)
2550 && INTEGERP (XCONS (XCONS (tem1
)->cdr
)->car
))
2552 f
->output_data
.win32
->left_pos
= - XINT (XCONS (XCONS (tem1
)->cdr
)->car
);
2553 window_prompting
|= XNegative
;
2555 else if (CONSP (tem1
) && EQ (XCONS (tem1
)->car
, Qplus
)
2556 && CONSP (XCONS (tem1
)->cdr
)
2557 && INTEGERP (XCONS (XCONS (tem1
)->cdr
)->car
))
2559 f
->output_data
.win32
->left_pos
= XINT (XCONS (XCONS (tem1
)->cdr
)->car
);
2561 else if (EQ (tem1
, Qunbound
))
2562 f
->output_data
.win32
->left_pos
= 0;
2565 CHECK_NUMBER (tem1
, 0);
2566 f
->output_data
.win32
->left_pos
= XINT (tem1
);
2567 if (f
->output_data
.win32
->left_pos
< 0)
2568 window_prompting
|= XNegative
;
2571 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
2572 window_prompting
|= USPosition
;
2574 window_prompting
|= PPosition
;
2577 return window_prompting
;
2582 extern LRESULT CALLBACK
win32_wnd_proc ();
2585 win32_init_class (hinst
)
2590 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
2591 wc
.lpfnWndProc
= (WNDPROC
) win32_wnd_proc
;
2593 wc
.cbWndExtra
= WND_EXTRA_BYTES
;
2594 wc
.hInstance
= hinst
;
2595 wc
.hIcon
= LoadIcon (hinst
, EMACS_CLASS
);
2596 wc
.hCursor
= LoadCursor (NULL
, IDC_ARROW
);
2597 wc
.hbrBackground
= NULL
; // GetStockObject (WHITE_BRUSH);
2598 wc
.lpszMenuName
= NULL
;
2599 wc
.lpszClassName
= EMACS_CLASS
;
2601 return (RegisterClass (&wc
));
2605 win32_createscrollbar (f
, bar
)
2607 struct scroll_bar
* bar
;
2609 return (CreateWindow ("SCROLLBAR", "", SBS_VERT
| WS_CHILD
| WS_VISIBLE
,
2610 /* Position and size of scroll bar. */
2611 XINT(bar
->left
), XINT(bar
->top
),
2612 XINT(bar
->width
), XINT(bar
->height
),
2613 FRAME_WIN32_WINDOW (f
),
2620 win32_createwindow (f
)
2625 /* Do first time app init */
2629 win32_init_class (hinst
);
2632 FRAME_WIN32_WINDOW (f
) = hwnd
= CreateWindow (EMACS_CLASS
,
2634 f
->output_data
.win32
->dwStyle
| WS_CLIPCHILDREN
,
2635 f
->output_data
.win32
->left_pos
,
2636 f
->output_data
.win32
->top_pos
,
2646 SetWindowLong (hwnd
, WND_X_UNITS_INDEX
, FONT_WIDTH (f
->output_data
.win32
->font
));
2647 SetWindowLong (hwnd
, WND_Y_UNITS_INDEX
, f
->output_data
.win32
->line_height
);
2648 SetWindowLong (hwnd
, WND_BACKGROUND_INDEX
, f
->output_data
.win32
->background_pixel
);
2650 /* Do this to discard the default setting specified by our parent. */
2651 ShowWindow (hwnd
, SW_HIDE
);
2655 /* Convert between the modifier bits Win32 uses and the modifier bits
2658 win32_get_modifiers ()
2660 return (((GetKeyState (VK_SHIFT
)&0x8000) ? shift_modifier
: 0) |
2661 ((GetKeyState (VK_CONTROL
)&0x8000) ? ctrl_modifier
: 0) |
2662 ((GetKeyState (VK_MENU
)&0x8000) ?
2663 ((NILP (Vwin32_alt_is_meta
)) ? alt_modifier
: meta_modifier
) : 0));
2667 my_post_msg (wmsg
, hwnd
, msg
, wParam
, lParam
)
2674 wmsg
->msg
.hwnd
= hwnd
;
2675 wmsg
->msg
.message
= msg
;
2676 wmsg
->msg
.wParam
= wParam
;
2677 wmsg
->msg
.lParam
= lParam
;
2678 wmsg
->msg
.time
= GetMessageTime ();
2683 /* GetKeyState and MapVirtualKey on Win95 do not actually distinguish
2684 between left and right keys as advertised. We test for this
2685 support dynamically, and set a flag when the support is absent. If
2686 absent, we keep track of the left and right control and alt keys
2687 ourselves. This is particularly necessary on keyboards that rely
2688 upon the AltGr key, which is represented as having the left control
2689 and right alt keys pressed. For these keyboards, we need to know
2690 when the left alt key has been pressed in addition to the AltGr key
2691 so that we can properly support M-AltGr-key sequences (such as M-@
2692 on Swedish keyboards). */
2694 #define EMACS_LCONTROL 0
2695 #define EMACS_RCONTROL 1
2696 #define EMACS_LMENU 2
2697 #define EMACS_RMENU 3
2699 static int modifiers
[4];
2700 static int modifiers_recorded
;
2701 static int modifier_key_support_tested
;
2704 test_modifier_support (unsigned int wparam
)
2708 if (wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
)
2710 if (wparam
== VK_CONTROL
)
2720 if (!(GetKeyState (l
) & 0x8000) && !(GetKeyState (r
) & 0x8000))
2721 modifiers_recorded
= 1;
2723 modifiers_recorded
= 0;
2724 modifier_key_support_tested
= 1;
2728 record_keydown (unsigned int wparam
, unsigned int lparam
)
2732 if (!modifier_key_support_tested
)
2733 test_modifier_support (wparam
);
2735 if ((wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
) || !modifiers_recorded
)
2738 if (wparam
== VK_CONTROL
)
2739 i
= (lparam
& 0x1000000) ? EMACS_RCONTROL
: EMACS_LCONTROL
;
2741 i
= (lparam
& 0x1000000) ? EMACS_RMENU
: EMACS_LMENU
;
2747 record_keyup (unsigned int wparam
, unsigned int lparam
)
2751 if ((wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
) || !modifiers_recorded
)
2754 if (wparam
== VK_CONTROL
)
2755 i
= (lparam
& 0x1000000) ? EMACS_RCONTROL
: EMACS_LCONTROL
;
2757 i
= (lparam
& 0x1000000) ? EMACS_RMENU
: EMACS_LMENU
;
2762 /* Emacs can lose focus while a modifier key has been pressed. When
2763 it regains focus, be conservative and clear all modifiers since
2764 we cannot reconstruct the left and right modifier state. */
2770 if (!modifiers_recorded
)
2773 ctrl
= GetAsyncKeyState (VK_CONTROL
);
2774 alt
= GetAsyncKeyState (VK_MENU
);
2776 if (ctrl
== 0 || alt
== 0)
2777 /* Emacs doesn't have keyboard focus. Do nothing. */
2780 if (!(ctrl
& 0x08000))
2781 /* Clear any recorded control modifier state. */
2782 modifiers
[EMACS_RCONTROL
] = modifiers
[EMACS_LCONTROL
] = 0;
2784 if (!(alt
& 0x08000))
2785 /* Clear any recorded alt modifier state. */
2786 modifiers
[EMACS_RMENU
] = modifiers
[EMACS_LMENU
] = 0;
2788 /* Otherwise, leave the modifier state as it was when Emacs lost
2792 /* Synchronize modifier state with what is reported with the current
2793 keystroke. Even if we cannot distinguish between left and right
2794 modifier keys, we know that, if no modifiers are set, then neither
2795 the left or right modifier should be set. */
2799 if (!modifiers_recorded
)
2802 if (!(GetKeyState (VK_CONTROL
) & 0x8000))
2803 modifiers
[EMACS_RCONTROL
] = modifiers
[EMACS_LCONTROL
] = 0;
2805 if (!(GetKeyState (VK_MENU
) & 0x8000))
2806 modifiers
[EMACS_RMENU
] = modifiers
[EMACS_LMENU
] = 0;
2810 modifier_set (int vkey
)
2812 if (vkey
== VK_CAPITAL
)
2813 return (GetKeyState (vkey
) & 0x1);
2814 if (!modifiers_recorded
)
2815 return (GetKeyState (vkey
) & 0x8000);
2820 return modifiers
[EMACS_LCONTROL
];
2822 return modifiers
[EMACS_RCONTROL
];
2824 return modifiers
[EMACS_LMENU
];
2826 return modifiers
[EMACS_RMENU
];
2830 return (GetKeyState (vkey
) & 0x8000);
2833 /* We map the VK_* modifiers into console modifier constants
2834 so that we can use the same routines to handle both console
2835 and window input. */
2838 construct_modifiers (unsigned int wparam
, unsigned int lparam
)
2842 if (wparam
!= VK_CONTROL
&& wparam
!= VK_MENU
)
2843 mods
= GetLastError ();
2846 mods
|= (modifier_set (VK_SHIFT
)) ? SHIFT_PRESSED
: 0;
2847 mods
|= (modifier_set (VK_CAPITAL
)) ? CAPSLOCK_ON
: 0;
2848 mods
|= (modifier_set (VK_LCONTROL
)) ? LEFT_CTRL_PRESSED
: 0;
2849 mods
|= (modifier_set (VK_RCONTROL
)) ? RIGHT_CTRL_PRESSED
: 0;
2850 mods
|= (modifier_set (VK_LMENU
)) ? LEFT_ALT_PRESSED
: 0;
2851 mods
|= (modifier_set (VK_RMENU
)) ? RIGHT_ALT_PRESSED
: 0;
2857 map_keypad_keys (unsigned int wparam
, unsigned int lparam
)
2859 unsigned int extended
= (lparam
& 0x1000000L
);
2861 if (wparam
< VK_CLEAR
|| wparam
> VK_DELETE
)
2864 if (wparam
== VK_RETURN
)
2865 return (extended
? VK_NUMPAD_ENTER
: VK_RETURN
);
2867 if (wparam
>= VK_PRIOR
&& wparam
<= VK_DOWN
)
2868 return (!extended
? (VK_NUMPAD_PRIOR
+ (wparam
- VK_PRIOR
)) : wparam
);
2870 if (wparam
== VK_INSERT
|| wparam
== VK_DELETE
)
2871 return (!extended
? (VK_NUMPAD_INSERT
+ (wparam
- VK_INSERT
)) : wparam
);
2873 if (wparam
== VK_CLEAR
)
2874 return (!extended
? VK_NUMPAD_CLEAR
: wparam
);
2879 /* Main message dispatch loop. */
2887 /* Ensure our message queue is created */
2889 PeekMessage (&msg
, NULL
, 0, 0, PM_NOREMOVE
);
2891 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, 0, 0);
2893 while (GetMessage (&msg
, NULL
, 0, 0))
2895 if (msg
.hwnd
== NULL
)
2897 switch (msg
.message
)
2899 case WM_EMACS_CREATEWINDOW
:
2900 win32_createwindow ((struct frame
*) msg
.wParam
);
2901 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, 0, 0);
2903 case WM_EMACS_CREATESCROLLBAR
:
2905 HWND hwnd
= win32_createscrollbar ((struct frame
*) msg
.wParam
,
2906 (struct scroll_bar
*) msg
.lParam
);
2907 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, (WPARAM
)hwnd
, 0);
2916 DispatchMessage (&msg
);
2923 /* Main window procedure */
2925 extern char *lispy_function_keys
[];
2928 win32_wnd_proc (hwnd
, msg
, wParam
, lParam
)
2936 struct win32_display_info
*dpyinfo
= &one_win32_display_info
;
2938 int windows_translate
;
2940 /* Note that it is okay to call x_window_to_frame, even though we are
2941 not running in the main lisp thread, because frame deletion
2942 requires the lisp thread to synchronize with this thread. Thus, if
2943 a frame struct is returned, it can be used without concern that the
2944 lisp thread might make it disappear while we are using it.
2946 NB. Walking the frame list in this thread is safe (as long as
2947 writes of Lisp_Object slots are atomic, which they are on Windows).
2948 Although delete-frame can destructively modify the frame list while
2949 we are walking it, a garbage collection cannot occur until after
2950 delete-frame has synchronized with this thread.
2952 It is also safe to use functions that make GDI calls, such as
2953 win32_clear_rect, because these functions must obtain a DC handle
2954 from the frame struct using get_frame_dc which is thread-aware. */
2959 f
= x_window_to_frame (dpyinfo
, hwnd
);
2962 GetUpdateRect (hwnd
, &wmsg
.rect
, FALSE
);
2963 win32_clear_rect (f
, NULL
, &wmsg
.rect
);
2966 case WM_PALETTECHANGED
:
2967 /* ignore our own changes */
2968 if ((HWND
)wParam
!= hwnd
)
2970 f
= x_window_to_frame (dpyinfo
, hwnd
);
2972 /* get_frame_dc will realize our palette and force all
2973 frames to be redrawn if needed. */
2974 release_frame_dc (f
, get_frame_dc (f
));
2979 PAINTSTRUCT paintStruct
;
2982 BeginPaint (hwnd
, &paintStruct
);
2983 wmsg
.rect
= paintStruct
.rcPaint
;
2984 EndPaint (hwnd
, &paintStruct
);
2987 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
2994 record_keyup (wParam
, lParam
);
2999 /* Synchronize modifiers with current keystroke. */
3002 record_keydown (wParam
, lParam
);
3004 wParam
= map_keypad_keys (wParam
, lParam
);
3006 windows_translate
= 0;
3011 /* More support for these keys will likely be necessary. */
3012 if (!NILP (Vwin32_pass_optional_keys_to_system
))
3013 windows_translate
= 1;
3016 if (NILP (Vwin32_pass_alt_to_system
))
3018 windows_translate
= 1;
3025 windows_translate
= 1;
3028 /* If not defined as a function key, change it to a WM_CHAR message. */
3029 if (lispy_function_keys
[wParam
] == 0)
3034 if (windows_translate
)
3036 MSG winmsg
= { hwnd
, msg
, wParam
, lParam
, 0, {0,0} };
3038 winmsg
.time
= GetMessageTime ();
3039 TranslateMessage (&winmsg
);
3047 wmsg
.dwModifiers
= construct_modifiers (wParam
, lParam
);
3050 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3053 /* Detect quit_char and set quit-flag directly. Note that we dow
3054 this *after* posting the message to ensure the main thread will
3055 be woken up if blocked in sys_select(). */
3058 if (isalpha (c
) && (wmsg
.dwModifiers
== LEFT_CTRL_PRESSED
3059 || wmsg
.dwModifiers
== RIGHT_CTRL_PRESSED
))
3060 c
= make_ctrl_char (c
) & 0377;
3069 /* Simulate middle mouse button events when left and right buttons
3070 are used together, but only if user has two button mouse. */
3071 case WM_LBUTTONDOWN
:
3072 case WM_RBUTTONDOWN
:
3073 if (XINT (Vwin32_num_mouse_buttons
) == 3)
3074 goto handle_plain_button
;
3077 int this = (msg
== WM_LBUTTONDOWN
) ? LMOUSE
: RMOUSE
;
3078 int other
= (msg
== WM_LBUTTONDOWN
) ? RMOUSE
: LMOUSE
;
3080 if (button_state
& this)
3083 if (button_state
== 0)
3086 button_state
|= this;
3088 if (button_state
& other
)
3090 if (mouse_button_timer
)
3092 KillTimer (hwnd
, mouse_button_timer
);
3093 mouse_button_timer
= 0;
3095 /* Generate middle mouse event instead. */
3096 msg
= WM_MBUTTONDOWN
;
3097 button_state
|= MMOUSE
;
3099 else if (button_state
& MMOUSE
)
3101 /* Ignore button event if we've already generated a
3102 middle mouse down event. This happens if the
3103 user releases and press one of the two buttons
3104 after we've faked a middle mouse event. */
3109 /* Flush out saved message. */
3110 post_msg (&saved_mouse_button_msg
);
3112 wmsg
.dwModifiers
= win32_get_modifiers ();
3113 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3115 /* Clear message buffer. */
3116 saved_mouse_button_msg
.msg
.hwnd
= 0;
3120 /* Hold onto message for now. */
3121 mouse_button_timer
=
3122 SetTimer (hwnd
, MOUSE_BUTTON_ID
, XINT (Vwin32_mouse_button_tolerance
), NULL
);
3123 saved_mouse_button_msg
.msg
.hwnd
= hwnd
;
3124 saved_mouse_button_msg
.msg
.message
= msg
;
3125 saved_mouse_button_msg
.msg
.wParam
= wParam
;
3126 saved_mouse_button_msg
.msg
.lParam
= lParam
;
3127 saved_mouse_button_msg
.msg
.time
= GetMessageTime ();
3128 saved_mouse_button_msg
.dwModifiers
= win32_get_modifiers ();
3135 if (XINT (Vwin32_num_mouse_buttons
) == 3)
3136 goto handle_plain_button
;
3139 int this = (msg
== WM_LBUTTONUP
) ? LMOUSE
: RMOUSE
;
3140 int other
= (msg
== WM_LBUTTONUP
) ? RMOUSE
: LMOUSE
;
3142 if ((button_state
& this) == 0)
3145 button_state
&= ~this;
3147 if (button_state
& MMOUSE
)
3149 /* Only generate event when second button is released. */
3150 if ((button_state
& other
) == 0)
3153 button_state
&= ~MMOUSE
;
3155 if (button_state
) abort ();
3162 /* Flush out saved message if necessary. */
3163 if (saved_mouse_button_msg
.msg
.hwnd
)
3165 post_msg (&saved_mouse_button_msg
);
3168 wmsg
.dwModifiers
= win32_get_modifiers ();
3169 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3171 /* Always clear message buffer and cancel timer. */
3172 saved_mouse_button_msg
.msg
.hwnd
= 0;
3173 KillTimer (hwnd
, mouse_button_timer
);
3174 mouse_button_timer
= 0;
3176 if (button_state
== 0)
3181 case WM_MBUTTONDOWN
:
3183 handle_plain_button
:
3187 if (parse_button (msg
, NULL
, &up
))
3189 if (up
) ReleaseCapture ();
3190 else SetCapture (hwnd
);
3194 wmsg
.dwModifiers
= win32_get_modifiers ();
3195 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3200 if (XINT (Vwin32_mouse_move_interval
) <= 0
3201 || (msg
== WM_MOUSEMOVE
&& button_state
== 0))
3203 wmsg
.dwModifiers
= win32_get_modifiers ();
3204 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3208 /* Hang onto mouse move and scroll messages for a bit, to avoid
3209 sending such events to Emacs faster than it can process them.
3210 If we get more events before the timer from the first message
3211 expires, we just replace the first message. */
3213 if (saved_mouse_move_msg
.msg
.hwnd
== 0)
3215 SetTimer (hwnd
, MOUSE_MOVE_ID
, XINT (Vwin32_mouse_move_interval
), NULL
);
3217 /* Hold onto message for now. */
3218 saved_mouse_move_msg
.msg
.hwnd
= hwnd
;
3219 saved_mouse_move_msg
.msg
.message
= msg
;
3220 saved_mouse_move_msg
.msg
.wParam
= wParam
;
3221 saved_mouse_move_msg
.msg
.lParam
= lParam
;
3222 saved_mouse_move_msg
.msg
.time
= GetMessageTime ();
3223 saved_mouse_move_msg
.dwModifiers
= win32_get_modifiers ();
3228 /* Flush out saved messages if necessary. */
3229 if (wParam
== mouse_button_timer
)
3231 if (saved_mouse_button_msg
.msg
.hwnd
)
3233 post_msg (&saved_mouse_button_msg
);
3234 saved_mouse_button_msg
.msg
.hwnd
= 0;
3236 KillTimer (hwnd
, mouse_button_timer
);
3237 mouse_button_timer
= 0;
3239 else if (wParam
== mouse_move_timer
)
3241 if (saved_mouse_move_msg
.msg
.hwnd
)
3243 post_msg (&saved_mouse_move_msg
);
3244 saved_mouse_move_msg
.msg
.hwnd
= 0;
3246 KillTimer (hwnd
, mouse_move_timer
);
3247 mouse_move_timer
= 0;
3252 /* Windows doesn't send us focus messages when putting up and
3253 taking down a system popup dialog as for Ctrl-Alt-Del on Win95.
3254 The only indication we get that something happened is receiving
3255 this message afterwards. So this is a good time to reset our
3256 keyboard modifiers' state. */
3267 wmsg
.dwModifiers
= win32_get_modifiers ();
3268 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3272 wmsg
.dwModifiers
= win32_get_modifiers ();
3273 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
3276 case WM_WINDOWPOSCHANGING
:
3279 LPWINDOWPOS lppos
= (WINDOWPOS
*) lParam
;
3281 GetWindowPlacement (hwnd
, &wp
);
3283 if (wp
.showCmd
!= SW_SHOWMINIMIZED
&& ! (lppos
->flags
& SWP_NOSIZE
))
3292 wp
.length
= sizeof(wp
);
3293 GetWindowRect (hwnd
, &wr
);
3297 dwXUnits
= GetWindowLong (hwnd
, WND_X_UNITS_INDEX
);
3298 dwYUnits
= GetWindowLong (hwnd
, WND_Y_UNITS_INDEX
);
3302 memset (&rect
, 0, sizeof (rect
));
3303 AdjustWindowRect (&rect
, GetWindowLong (hwnd
, GWL_STYLE
),
3304 GetMenu (hwnd
) != NULL
);
3306 /* All windows have an extra pixel so subtract 1 */
3308 wdiff
= (lppos
->cx
- (rect
.right
- rect
.left
) - 0) % dwXUnits
;
3309 hdiff
= (lppos
->cy
- (rect
.bottom
- rect
.top
) - 0) % dwYUnits
;
3313 /* For right/bottom sizing we can just fix the sizes.
3314 However for top/left sizing we will need to fix the X
3315 and Y positions as well. */
3320 if (wp
.showCmd
!= SW_SHOWMAXIMIZED
3321 && ! (lppos
->flags
& SWP_NOMOVE
))
3323 if (lppos
->x
!= wr
.left
|| lppos
->y
!= wr
.top
)
3330 lppos
->flags
|= SWP_NOMOVE
;
3339 if (ret
== 0) return (0);
3342 case WM_EMACS_SHOWWINDOW
:
3343 return ShowWindow (hwnd
, wParam
);
3344 case WM_EMACS_SETWINDOWPOS
:
3346 Win32WindowPos
* pos
= (Win32WindowPos
*) wParam
;
3347 return SetWindowPos (hwnd
, pos
->hwndAfter
,
3348 pos
->x
, pos
->y
, pos
->cx
, pos
->cy
, pos
->flags
);
3350 case WM_EMACS_DESTROYWINDOW
:
3351 DestroyWindow ((HWND
) wParam
);
3355 return DefWindowProc (hwnd
, msg
, wParam
, lParam
);
3362 my_create_window (f
)
3367 PostThreadMessage (dwWinThreadId
, WM_EMACS_CREATEWINDOW
, (WPARAM
)f
, 0);
3368 GetMessage (&msg
, NULL
, WM_EMACS_DONE
, WM_EMACS_DONE
);
3371 /* Create and set up the win32 window for frame F. */
3374 win32_window (f
, window_prompting
, minibuffer_only
)
3376 long window_prompting
;
3377 int minibuffer_only
;
3381 /* Use the resource name as the top-level window name
3382 for looking up resources. Make a non-Lisp copy
3383 for the window manager, so GC relocation won't bother it.
3385 Elsewhere we specify the window name for the window manager. */
3388 char *str
= (char *) XSTRING (Vx_resource_name
)->data
;
3389 f
->namebuf
= (char *) xmalloc (strlen (str
) + 1);
3390 strcpy (f
->namebuf
, str
);
3393 my_create_window (f
);
3395 validate_x_resource_name ();
3397 /* x_set_name normally ignores requests to set the name if the
3398 requested name is the same as the current name. This is the one
3399 place where that assumption isn't correct; f->name is set, but
3400 the server hasn't been told. */
3403 int explicit = f
->explicit_name
;
3405 f
->explicit_name
= 0;
3408 x_set_name (f
, name
, explicit);
3413 if (!minibuffer_only
&& FRAME_EXTERNAL_MENU_BAR (f
))
3414 initialize_frame_menubar (f
);
3416 if (FRAME_WIN32_WINDOW (f
) == 0)
3417 error ("Unable to create window");
3420 /* Handle the icon stuff for this window. Perhaps later we might
3421 want an x_set_icon_position which can be called interactively as
3429 Lisp_Object icon_x
, icon_y
;
3431 /* Set the position of the icon. Note that win95 groups all
3432 icons in the tray. */
3433 icon_x
= x_get_arg (parms
, Qicon_left
, 0, 0, number
);
3434 icon_y
= x_get_arg (parms
, Qicon_top
, 0, 0, number
);
3435 if (!EQ (icon_x
, Qunbound
) && !EQ (icon_y
, Qunbound
))
3437 CHECK_NUMBER (icon_x
, 0);
3438 CHECK_NUMBER (icon_y
, 0);
3440 else if (!EQ (icon_x
, Qunbound
) || !EQ (icon_y
, Qunbound
))
3441 error ("Both left and top icon corners of icon must be specified");
3445 if (! EQ (icon_x
, Qunbound
))
3446 x_wm_set_icon_position (f
, XINT (icon_x
), XINT (icon_y
));
3451 DEFUN ("x-create-frame", Fx_create_frame
, Sx_create_frame
,
3453 "Make a new window, which is called a \"frame\" in Emacs terms.\n\
3454 Returns an Emacs frame object.\n\
3455 ALIST is an alist of frame parameters.\n\
3456 If the parameters specify that the frame should not have a minibuffer,\n\
3457 and do not specify a specific minibuffer window to use,\n\
3458 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
3459 be shared by the new frame.\n\
3461 This function is an internal primitive--use `make-frame' instead.")
3466 Lisp_Object frame
, tem
;
3468 int minibuffer_only
= 0;
3469 long window_prompting
= 0;
3471 int count
= specpdl_ptr
- specpdl
;
3472 struct gcpro gcpro1
;
3473 Lisp_Object display
;
3474 struct win32_display_info
*dpyinfo
;
3478 /* Use this general default value to start with
3479 until we know if this frame has a specified name. */
3480 Vx_resource_name
= Vinvocation_name
;
3482 display
= x_get_arg (parms
, Qdisplay
, 0, 0, string
);
3483 if (EQ (display
, Qunbound
))
3485 dpyinfo
= check_x_display_info (display
);
3487 kb
= dpyinfo
->kboard
;
3489 kb
= &the_only_kboard
;
3492 name
= x_get_arg (parms
, Qname
, "title", "Title", string
);
3494 && ! EQ (name
, Qunbound
)
3496 error ("Invalid frame name--not a string or nil");
3499 Vx_resource_name
= name
;
3501 /* See if parent window is specified. */
3502 parent
= x_get_arg (parms
, Qparent_id
, NULL
, NULL
, number
);
3503 if (EQ (parent
, Qunbound
))
3505 if (! NILP (parent
))
3506 CHECK_NUMBER (parent
, 0);
3508 tem
= x_get_arg (parms
, Qminibuffer
, 0, 0, symbol
);
3509 if (EQ (tem
, Qnone
) || NILP (tem
))
3510 f
= make_frame_without_minibuffer (Qnil
, kb
, display
);
3511 else if (EQ (tem
, Qonly
))
3513 f
= make_minibuffer_frame ();
3514 minibuffer_only
= 1;
3516 else if (WINDOWP (tem
))
3517 f
= make_frame_without_minibuffer (tem
, kb
, display
);
3521 /* Note that Windows does support scroll bars. */
3522 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 1;
3523 /* By default, make scrollbars the system standard width. */
3524 f
->scroll_bar_pixel_width
= GetSystemMetrics (SM_CXVSCROLL
);
3526 XSETFRAME (frame
, f
);
3529 f
->output_method
= output_win32
;
3530 f
->output_data
.win32
= (struct win32_output
*) xmalloc (sizeof (struct win32_output
));
3531 bzero (f
->output_data
.win32
, sizeof (struct win32_output
));
3533 /* FRAME_WIN32_DISPLAY_INFO (f) = dpyinfo; */
3535 FRAME_KBOARD (f
) = kb
;
3538 /* Specify the parent under which to make this window. */
3542 f
->output_data
.win32
->parent_desc
= (Window
) parent
;
3543 f
->output_data
.win32
->explicit_parent
= 1;
3547 f
->output_data
.win32
->parent_desc
= FRAME_WIN32_DISPLAY_INFO (f
)->root_window
;
3548 f
->output_data
.win32
->explicit_parent
= 0;
3551 /* Note that the frame has no physical cursor right now. */
3552 f
->phys_cursor_x
= -1;
3554 /* Set the name; the functions to which we pass f expect the name to
3556 if (EQ (name
, Qunbound
) || NILP (name
))
3558 f
->name
= build_string (dpyinfo
->win32_id_name
);
3559 f
->explicit_name
= 0;
3564 f
->explicit_name
= 1;
3565 /* use the frame's title when getting resources for this frame. */
3566 specbind (Qx_resource_name
, name
);
3569 /* Extract the window parameters from the supplied values
3570 that are needed to determine window geometry. */
3574 font
= x_get_arg (parms
, Qfont
, "font", "Font", string
);
3576 /* First, try whatever font the caller has specified. */
3578 font
= x_new_font (f
, XSTRING (font
)->data
);
3580 /* Try out a font which we hope has bold and italic variations. */
3581 if (!STRINGP (font
))
3582 font
= x_new_font (f
, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3583 if (! STRINGP (font
))
3584 font
= x_new_font (f
, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3585 if (! STRINGP (font
))
3586 /* This was formerly the first thing tried, but it finds too many fonts
3587 and takes too long. */
3588 font
= x_new_font (f
, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
3589 /* If those didn't work, look for something which will at least work. */
3590 if (! STRINGP (font
))
3591 font
= x_new_font (f
, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
3592 if (! STRINGP (font
))
3593 font
= x_new_font (f
, "-*-system-medium-r-normal-*-*-200-*-*-c-120-*-*");
3595 if (! STRINGP (font
))
3596 font
= x_new_font (f
, "-*-Fixedsys-*-r-*-*-12-90-*-*-c-*-*-*");
3598 if (! STRINGP (font
))
3599 font
= build_string ("-*-system");
3601 x_default_parameter (f
, parms
, Qfont
, font
,
3602 "font", "Font", string
);
3605 x_default_parameter (f
, parms
, Qborder_width
, make_number (2),
3606 "borderwidth", "BorderWidth", number
);
3607 /* This defaults to 2 in order to match xterm. We recognize either
3608 internalBorderWidth or internalBorder (which is what xterm calls
3610 if (NILP (Fassq (Qinternal_border_width
, parms
)))
3614 value
= x_get_arg (parms
, Qinternal_border_width
,
3615 "internalBorder", "BorderWidth", number
);
3616 if (! EQ (value
, Qunbound
))
3617 parms
= Fcons (Fcons (Qinternal_border_width
, value
),
3620 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (0),
3621 "internalBorderWidth", "BorderWidth", number
);
3622 x_default_parameter (f
, parms
, Qvertical_scroll_bars
, Qt
,
3623 "verticalScrollBars", "ScrollBars", boolean
);
3625 /* Also do the stuff which must be set before the window exists. */
3626 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
3627 "foreground", "Foreground", string
);
3628 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
3629 "background", "Background", string
);
3630 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
3631 "pointerColor", "Foreground", string
);
3632 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
3633 "cursorColor", "Foreground", string
);
3634 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
3635 "borderColor", "BorderColor", string
);
3637 x_default_parameter (f
, parms
, Qmenu_bar_lines
, make_number (1),
3638 "menuBar", "MenuBar", number
);
3639 x_default_parameter (f
, parms
, Qscroll_bar_width
, Qnil
,
3640 "scrollBarWidth", "ScrollBarWidth", number
);
3642 f
->output_data
.win32
->dwStyle
= WS_OVERLAPPEDWINDOW
;
3643 f
->output_data
.win32
->parent_desc
= FRAME_WIN32_DISPLAY_INFO (f
)->root_window
;
3644 window_prompting
= x_figure_window_size (f
, parms
);
3646 if (window_prompting
& XNegative
)
3648 if (window_prompting
& YNegative
)
3649 f
->output_data
.win32
->win_gravity
= SouthEastGravity
;
3651 f
->output_data
.win32
->win_gravity
= NorthEastGravity
;
3655 if (window_prompting
& YNegative
)
3656 f
->output_data
.win32
->win_gravity
= SouthWestGravity
;
3658 f
->output_data
.win32
->win_gravity
= NorthWestGravity
;
3661 f
->output_data
.win32
->size_hint_flags
= window_prompting
;
3663 win32_window (f
, window_prompting
, minibuffer_only
);
3665 init_frame_faces (f
);
3667 /* We need to do this after creating the window, so that the
3668 icon-creation functions can say whose icon they're describing. */
3669 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
3670 "bitmapIcon", "BitmapIcon", symbol
);
3672 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
3673 "autoRaise", "AutoRaiseLower", boolean
);
3674 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
3675 "autoLower", "AutoRaiseLower", boolean
);
3676 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
3677 "cursorType", "CursorType", symbol
);
3679 /* Dimensions, especially f->height, must be done via change_frame_size.
3680 Change will not be effected unless different from the current
3685 SET_FRAME_WIDTH (f
, 0);
3686 change_frame_size (f
, height
, width
, 1, 0);
3688 /* Tell the server what size and position, etc, we want,
3689 and how badly we want them. */
3691 x_wm_set_size_hint (f
, window_prompting
, 0);
3694 tem
= x_get_arg (parms
, Qunsplittable
, 0, 0, boolean
);
3695 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
3699 /* It is now ok to make the frame official
3700 even if we get an error below.
3701 And the frame needs to be on Vframe_list
3702 or making it visible won't work. */
3703 Vframe_list
= Fcons (frame
, Vframe_list
);
3705 /* Now that the frame is official, it counts as a reference to
3707 FRAME_WIN32_DISPLAY_INFO (f
)->reference_count
++;
3709 /* Make the window appear on the frame and enable display,
3710 unless the caller says not to. However, with explicit parent,
3711 Emacs cannot control visibility, so don't try. */
3712 if (! f
->output_data
.win32
->explicit_parent
)
3714 Lisp_Object visibility
;
3716 visibility
= x_get_arg (parms
, Qvisibility
, 0, 0, symbol
);
3717 if (EQ (visibility
, Qunbound
))
3720 if (EQ (visibility
, Qicon
))
3721 x_iconify_frame (f
);
3722 else if (! NILP (visibility
))
3723 x_make_frame_visible (f
);
3725 /* Must have been Qnil. */
3729 return unbind_to (count
, frame
);
3732 /* FRAME is used only to get a handle on the X display. We don't pass the
3733 display info directly because we're called from frame.c, which doesn't
3734 know about that structure. */
3736 x_get_focus_frame (frame
)
3737 struct frame
*frame
;
3739 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (frame
);
3741 if (! dpyinfo
->win32_focus_frame
)
3744 XSETFRAME (xfocus
, dpyinfo
->win32_focus_frame
);
3749 win32_load_font (dpyinfo
,name
)
3750 struct win32_display_info
*dpyinfo
;
3753 XFontStruct
* font
= NULL
;
3759 if (!name
|| !x_to_win32_font (name
, &lf
))
3762 font
= (XFontStruct
*) xmalloc (sizeof (XFontStruct
));
3764 if (!font
) return (NULL
);
3768 font
->hfont
= CreateFontIndirect (&lf
);
3771 if (font
->hfont
== NULL
)
3780 hdc
= GetDC (dpyinfo
->root_window
);
3781 oldobj
= SelectObject (hdc
, font
->hfont
);
3782 ok
= GetTextMetrics (hdc
, &font
->tm
);
3783 SelectObject (hdc
, oldobj
);
3784 ReleaseDC (dpyinfo
->root_window
, hdc
);
3789 if (ok
) return (font
);
3791 win32_unload_font (dpyinfo
, font
);
3796 win32_unload_font (dpyinfo
, font
)
3797 struct win32_display_info
*dpyinfo
;
3802 if (font
->hfont
) DeleteObject(font
->hfont
);
3807 /* The font conversion stuff between x and win32 */
3809 /* X font string is as follows (from faces.el)
3813 * (weight "\\(bold\\|demibold\\|medium\\)") ; 1
3814 * (weight\? "\\([^-]*\\)") ; 1
3815 * (slant "\\([ior]\\)") ; 2
3816 * (slant\? "\\([^-]?\\)") ; 2
3817 * (swidth "\\([^-]*\\)") ; 3
3818 * (adstyle "[^-]*") ; 4
3819 * (pixelsize "[0-9]+")
3820 * (pointsize "[0-9][0-9]+")
3821 * (resx "[0-9][0-9]+")
3822 * (resy "[0-9][0-9]+")
3823 * (spacing "[cmp?*]")
3824 * (avgwidth "[0-9]+")
3825 * (registry "[^-]+")
3826 * (encoding "[^-]+")
3828 * (setq x-font-regexp
3829 * (concat "\\`\\*?[-?*]"
3830 * foundry - family - weight\? - slant\? - swidth - adstyle -
3831 * pixelsize - pointsize - resx - resy - spacing - registry -
3832 * encoding "[-?*]\\*?\\'"
3834 * (setq x-font-regexp-head
3835 * (concat "\\`[-?*]" foundry - family - weight\? - slant\?
3836 * "\\([-*?]\\|\\'\\)"))
3837 * (setq x-font-regexp-slant (concat - slant -))
3838 * (setq x-font-regexp-weight (concat - weight -))
3842 #define FONT_START "[-?]"
3843 #define FONT_FOUNDRY "[^-]+"
3844 #define FONT_FAMILY "\\([^-]+\\)" /* 1 */
3845 #define FONT_WEIGHT "\\(bold\\|demibold\\|medium\\)" /* 2 */
3846 #define FONT_WEIGHT_Q "\\([^-]*\\)" /* 2 */
3847 #define FONT_SLANT "\\([ior]\\)" /* 3 */
3848 #define FONT_SLANT_Q "\\([^-]?\\)" /* 3 */
3849 #define FONT_SWIDTH "\\([^-]*\\)" /* 4 */
3850 #define FONT_ADSTYLE "[^-]*"
3851 #define FONT_PIXELSIZE "[^-]*"
3852 #define FONT_POINTSIZE "\\([0-9][0-9]+\\|\\*\\)" /* 5 */
3853 #define FONT_RESX "[0-9][0-9]+"
3854 #define FONT_RESY "[0-9][0-9]+"
3855 #define FONT_SPACING "[cmp?*]"
3856 #define FONT_AVGWIDTH "[0-9]+"
3857 #define FONT_REGISTRY "[^-]+"
3858 #define FONT_ENCODING "[^-]+"
3860 #define FONT_REGEXP ("\\`\\*?[-?*]" \
3867 FONT_PIXELSIZE "-" \
3868 FONT_POINTSIZE "-" \
3871 #define FONT_REGEXP_HEAD ("\\`[-?*]" \
3876 "\\([-*?]\\|\\'\\)")
3878 #define FONT_REGEXP_SLANT "-" FONT_SLANT "-"
3879 #define FONT_REGEXP_WEIGHT "-" FONT_WEIGHT "-"
3882 x_to_win32_weight (lpw
)
3885 if (!lpw
) return (FW_DONTCARE
);
3887 if (stricmp (lpw
,"heavy") == 0) return FW_HEAVY
;
3888 else if (stricmp (lpw
,"extrabold") == 0) return FW_EXTRABOLD
;
3889 else if (stricmp (lpw
,"bold") == 0) return FW_BOLD
;
3890 else if (stricmp (lpw
,"demibold") == 0) return FW_SEMIBOLD
;
3891 else if (stricmp (lpw
,"medium") == 0) return FW_MEDIUM
;
3892 else if (stricmp (lpw
,"normal") == 0) return FW_NORMAL
;
3893 else if (stricmp (lpw
,"light") == 0) return FW_LIGHT
;
3894 else if (stricmp (lpw
,"extralight") == 0) return FW_EXTRALIGHT
;
3895 else if (stricmp (lpw
,"thin") == 0) return FW_THIN
;
3902 win32_to_x_weight (fnweight
)
3905 if (fnweight
>= FW_HEAVY
) return "heavy";
3906 if (fnweight
>= FW_EXTRABOLD
) return "extrabold";
3907 if (fnweight
>= FW_BOLD
) return "bold";
3908 if (fnweight
>= FW_SEMIBOLD
) return "semibold";
3909 if (fnweight
>= FW_MEDIUM
) return "medium";
3910 if (fnweight
>= FW_NORMAL
) return "normal";
3911 if (fnweight
>= FW_LIGHT
) return "light";
3912 if (fnweight
>= FW_EXTRALIGHT
) return "extralight";
3913 if (fnweight
>= FW_THIN
) return "thin";
3919 x_to_win32_charset (lpcs
)
3922 if (!lpcs
) return (0);
3924 if (stricmp (lpcs
,"ansi") == 0) return ANSI_CHARSET
;
3925 else if (stricmp (lpcs
,"iso8859-1") == 0) return ANSI_CHARSET
;
3926 else if (stricmp (lpcs
,"iso8859") == 0) return ANSI_CHARSET
;
3927 else if (stricmp (lpcs
,"oem") == 0) return OEM_CHARSET
;
3928 #ifdef UNICODE_CHARSET
3929 else if (stricmp (lpcs
,"unicode") == 0) return UNICODE_CHARSET
;
3930 else if (stricmp (lpcs
,"iso10646") == 0) return UNICODE_CHARSET
;
3937 win32_to_x_charset (fncharset
)
3942 case ANSI_CHARSET
: return "ansi";
3943 case OEM_CHARSET
: return "oem";
3944 case SYMBOL_CHARSET
: return "symbol";
3945 #ifdef UNICODE_CHARSET
3946 case UNICODE_CHARSET
: return "unicode";
3953 win32_to_x_font (lplogfont
, lpxstr
, len
)
3954 LOGFONT
* lplogfont
;
3958 char height_pixels
[8];
3960 char width_pixels
[8];
3962 if (!lpxstr
) abort ();
3967 if (lplogfont
->lfHeight
)
3969 sprintf (height_pixels
, "%u", abs (lplogfont
->lfHeight
));
3970 sprintf (height_dpi
, "%u",
3971 (abs (lplogfont
->lfHeight
) * 720) / one_win32_display_info
.height_in
);
3975 strcpy (height_pixels
, "*");
3976 strcpy (height_dpi
, "*");
3978 if (lplogfont
->lfWidth
)
3979 sprintf (width_pixels
, "%u", lplogfont
->lfWidth
* 10);
3981 strcpy (width_pixels
, "*");
3983 _snprintf (lpxstr
, len
- 1,
3984 "-*-%s-%s-%c-*-*-%s-%s-*-*-%c-%s-*-%s-",
3985 lplogfont
->lfFaceName
,
3986 win32_to_x_weight (lplogfont
->lfWeight
),
3987 lplogfont
->lfItalic
?'i':'r',
3990 ((lplogfont
->lfPitchAndFamily
& 0x3) == VARIABLE_PITCH
) ? 'p' : 'c',
3992 win32_to_x_charset (lplogfont
->lfCharSet
)
3995 lpxstr
[len
- 1] = 0; /* just to be sure */
4000 x_to_win32_font (lpxstr
, lplogfont
)
4002 LOGFONT
* lplogfont
;
4004 if (!lplogfont
) return (FALSE
);
4006 memset (lplogfont
, 0, sizeof (*lplogfont
));
4009 lplogfont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
4010 lplogfont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
4011 lplogfont
->lfQuality
= DEFAULT_QUALITY
;
4013 /* go for maximum quality */
4014 lplogfont
->lfOutPrecision
= OUT_STROKE_PRECIS
;
4015 lplogfont
->lfClipPrecision
= CLIP_STROKE_PRECIS
;
4016 lplogfont
->lfQuality
= PROOF_QUALITY
;
4022 /* Provide a simple escape mechanism for specifying Windows font names
4023 * directly -- if font spec does not beginning with '-', assume this
4025 * "<font name>[:height in pixels[:width in pixels[:weight]]]"
4031 char name
[50], weight
[20], slant
, pitch
, pixels
[10], height
[10], width
[10], remainder
[20];
4034 fields
= sscanf (lpxstr
,
4035 "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%*[^-]-%c-%9[^-]-%19s",
4036 name
, weight
, &slant
, pixels
, height
, &pitch
, width
, remainder
);
4038 if (fields
== EOF
) return (FALSE
);
4040 if (fields
> 0 && name
[0] != '*')
4042 strncpy (lplogfont
->lfFaceName
,name
, LF_FACESIZE
);
4043 lplogfont
->lfFaceName
[LF_FACESIZE
-1] = 0;
4047 lplogfont
->lfFaceName
[0] = 0;
4052 lplogfont
->lfWeight
= x_to_win32_weight ((fields
> 0 ? weight
: ""));
4056 if (!NILP (Vwin32_enable_italics
))
4057 lplogfont
->lfItalic
= (fields
> 0 && slant
== 'i');
4061 if (fields
> 0 && pixels
[0] != '*')
4062 lplogfont
->lfHeight
= atoi (pixels
);
4066 if (fields
> 0 && lplogfont
->lfHeight
== 0 && height
[0] != '*')
4067 lplogfont
->lfHeight
= (atoi (height
)
4068 * one_win32_display_info
.height_in
) / 720;
4072 lplogfont
->lfPitchAndFamily
=
4073 (fields
> 0 && pitch
== 'p') ? VARIABLE_PITCH
: FIXED_PITCH
;
4077 if (fields
> 0 && width
[0] != '*')
4078 lplogfont
->lfWidth
= atoi (width
) / 10;
4082 /* Not all font specs include the registry field, so we allow for an
4083 optional registry field before the encoding when parsing
4084 remainder. Also we strip the trailing '-' if present. */
4086 int len
= strlen (remainder
);
4087 if (len
> 0 && remainder
[len
-1] == '-')
4088 remainder
[len
-1] = 0;
4090 encoding
= remainder
;
4091 if (strncmp (encoding
, "*-", 2) == 0)
4093 lplogfont
->lfCharSet
= x_to_win32_charset (fields
> 0 ? encoding
: "");
4098 char name
[100], height
[10], width
[10], weight
[20];
4100 fields
= sscanf (lpxstr
,
4101 "%99[^:]:%9[^:]:%9[^:]:%19s",
4102 name
, height
, width
, weight
);
4104 if (fields
== EOF
) return (FALSE
);
4108 strncpy (lplogfont
->lfFaceName
,name
, LF_FACESIZE
);
4109 lplogfont
->lfFaceName
[LF_FACESIZE
-1] = 0;
4113 lplogfont
->lfFaceName
[0] = 0;
4119 lplogfont
->lfHeight
= atoi (height
);
4124 lplogfont
->lfWidth
= atoi (width
);
4128 lplogfont
->lfWeight
= x_to_win32_weight ((fields
> 0 ? weight
: ""));
4131 /* This makes TrueType fonts work better. */
4132 lplogfont
->lfHeight
= - abs (lplogfont
->lfHeight
);
4138 win32_font_match (lpszfont1
, lpszfont2
)
4142 char * s1
= lpszfont1
, *e1
;
4143 char * s2
= lpszfont2
, *e2
;
4145 if (s1
== NULL
|| s2
== NULL
) return (FALSE
);
4147 if (*s1
== '-') s1
++;
4148 if (*s2
== '-') s2
++;
4154 e1
= strchr (s1
, '-');
4155 e2
= strchr (s2
, '-');
4157 if (e1
== NULL
|| e2
== NULL
) return (TRUE
);
4162 if (*s1
!= '*' && *s2
!= '*'
4163 && (len1
!= len2
|| strnicmp (s1
, s2
, len1
) != 0))
4171 typedef struct enumfont_t
4176 XFontStruct
*size_ref
;
4177 Lisp_Object
*pattern
;
4183 enum_font_cb2 (lplf
, lptm
, FontType
, lpef
)
4185 NEWTEXTMETRIC
* lptm
;
4189 if (lplf
->elfLogFont
.lfStrikeOut
|| lplf
->elfLogFont
.lfUnderline
4190 || (lplf
->elfLogFont
.lfCharSet
!= ANSI_CHARSET
&& lplf
->elfLogFont
.lfCharSet
!= OEM_CHARSET
))
4193 /* if (!lpef->size_ref || lptm->tmMaxCharWidth == FONT_WIDTH (lpef->size_ref)) */
4197 if (!NILP (*(lpef
->pattern
)) && FontType
== TRUETYPE_FONTTYPE
)
4199 lplf
->elfLogFont
.lfHeight
= lpef
->logfont
.lfHeight
;
4200 lplf
->elfLogFont
.lfWidth
= lpef
->logfont
.lfWidth
;
4203 if (!win32_to_x_font (lplf
, buf
, 100)) return (0);
4205 if (NILP (*(lpef
->pattern
)) || win32_font_match (buf
, XSTRING (*(lpef
->pattern
))->data
))
4207 *lpef
->tail
= Fcons (build_string (buf
), Qnil
);
4208 lpef
->tail
= &XCONS (*lpef
->tail
)->cdr
;
4217 enum_font_cb1 (lplf
, lptm
, FontType
, lpef
)
4219 NEWTEXTMETRIC
* lptm
;
4223 return EnumFontFamilies (lpef
->hdc
,
4224 lplf
->elfLogFont
.lfFaceName
,
4225 (FONTENUMPROC
) enum_font_cb2
,
4230 DEFUN ("x-list-fonts", Fx_list_fonts
, Sx_list_fonts
, 1, 3, 0,
4231 "Return a list of the names of available fonts matching PATTERN.\n\
4232 If optional arguments FACE and FRAME are specified, return only fonts\n\
4233 the same size as FACE on FRAME.\n\
4235 PATTERN is a string, perhaps with wildcard characters;\n\
4236 the * character matches any substring, and\n\
4237 the ? character matches any single character.\n\
4238 PATTERN is case-insensitive.\n\
4239 FACE is a face name--a symbol.\n\
4241 The return value is a list of strings, suitable as arguments to\n\
4244 Fonts Emacs can't use (i.e. proportional fonts) may or may not be excluded\n\
4245 even if they match PATTERN and FACE.")
4246 (pattern
, face
, frame
)
4247 Lisp_Object pattern
, face
, frame
;
4252 XFontStruct
*size_ref
;
4253 Lisp_Object namelist
;
4258 CHECK_STRING (pattern
, 0);
4260 CHECK_SYMBOL (face
, 1);
4262 f
= check_x_frame (frame
);
4264 /* Determine the width standard for comparison with the fonts we find. */
4272 /* Don't die if we get called with a terminal frame. */
4273 if (! FRAME_WIN32_P (f
))
4274 error ("non-win32 frame used in `x-list-fonts'");
4276 face_id
= face_name_id_number (f
, face
);
4278 if (face_id
< 0 || face_id
>= FRAME_N_PARAM_FACES (f
)
4279 || FRAME_PARAM_FACES (f
) [face_id
] == 0)
4280 size_ref
= f
->output_data
.win32
->font
;
4283 size_ref
= FRAME_PARAM_FACES (f
) [face_id
]->font
;
4284 if (size_ref
== (XFontStruct
*) (~0))
4285 size_ref
= f
->output_data
.win32
->font
;
4289 /* See if we cached the result for this particular query. */
4290 list
= Fassoc (pattern
,
4291 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
);
4293 /* We have info in the cache for this PATTERN. */
4296 Lisp_Object tem
, newlist
;
4298 /* We have info about this pattern. */
4299 list
= XCONS (list
)->cdr
;
4306 /* Filter the cached info and return just the fonts that match FACE. */
4308 for (tem
= list
; CONSP (tem
); tem
= XCONS (tem
)->cdr
)
4310 XFontStruct
*thisinfo
;
4312 thisinfo
= win32_load_font (FRAME_WIN32_DISPLAY_INFO (f
), XSTRING (XCONS (tem
)->car
)->data
);
4314 if (thisinfo
&& same_size_fonts (thisinfo
, size_ref
))
4315 newlist
= Fcons (XCONS (tem
)->car
, newlist
);
4317 win32_unload_font (FRAME_WIN32_DISPLAY_INFO (f
), thisinfo
);
4328 ef
.pattern
= &pattern
;
4329 ef
.tail
= ef
.head
= &namelist
;
4331 x_to_win32_font (STRINGP (pattern
) ? XSTRING (pattern
)->data
: NULL
, &ef
.logfont
);
4334 ef
.hdc
= GetDC (FRAME_WIN32_WINDOW (f
));
4336 EnumFontFamilies (ef
.hdc
, NULL
, (FONTENUMPROC
) enum_font_cb1
, (LPARAM
)&ef
);
4338 ReleaseDC (FRAME_WIN32_WINDOW (f
), ef
.hdc
);
4348 /* Make a list of all the fonts we got back.
4349 Store that in the font cache for the display. */
4350 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
4351 = Fcons (Fcons (pattern
, namelist
),
4352 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
);
4354 /* Make a list of the fonts that have the right width. */
4357 for (i
= 0; i
< ef
.numFonts
; i
++)
4365 XFontStruct
*thisinfo
;
4368 thisinfo
= win32_load_font (FRAME_WIN32_DISPLAY_INFO (f
), XSTRING (Fcar (cur
))->data
);
4370 keeper
= thisinfo
&& same_size_fonts (thisinfo
, size_ref
);
4372 win32_unload_font (FRAME_WIN32_DISPLAY_INFO (f
), thisinfo
);
4377 list
= Fcons (build_string (XSTRING (Fcar (cur
))->data
), list
);
4381 list
= Fnreverse (list
);
4387 DEFUN ("x-color-defined-p", Fx_color_defined_p
, Sx_color_defined_p
, 1, 2, 0,
4388 "Return non-nil if color COLOR is supported on frame FRAME.\n\
4389 If FRAME is omitted or nil, use the selected frame.")
4391 Lisp_Object color
, frame
;
4394 FRAME_PTR f
= check_x_frame (frame
);
4396 CHECK_STRING (color
, 1);
4398 if (defined_color (f
, XSTRING (color
)->data
, &foo
, 0))
4404 DEFUN ("x-color-values", Fx_color_values
, Sx_color_values
, 1, 2, 0,
4405 "Return a description of the color named COLOR on frame FRAME.\n\
4406 The value is a list of integer RGB values--(RED GREEN BLUE).\n\
4407 These values appear to range from 0 to 65280 or 65535, depending\n\
4408 on the system; white is (65280 65280 65280) or (65535 65535 65535).\n\
4409 If FRAME is omitted or nil, use the selected frame.")
4411 Lisp_Object color
, frame
;
4414 FRAME_PTR f
= check_x_frame (frame
);
4416 CHECK_STRING (color
, 1);
4418 if (defined_color (f
, XSTRING (color
)->data
, &foo
, 0))
4422 rgb
[0] = make_number (GetRValue (foo
));
4423 rgb
[1] = make_number (GetGValue (foo
));
4424 rgb
[2] = make_number (GetBValue (foo
));
4425 return Flist (3, rgb
);
4431 DEFUN ("x-display-color-p", Fx_display_color_p
, Sx_display_color_p
, 0, 1, 0,
4432 "Return t if the X display supports color.\n\
4433 The optional argument DISPLAY specifies which display to ask about.\n\
4434 DISPLAY should be either a frame or a display name (a string).\n\
4435 If omitted or nil, that stands for the selected frame's display.")
4437 Lisp_Object display
;
4439 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4441 if ((dpyinfo
->n_planes
* dpyinfo
->n_cbits
) <= 2)
4447 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p
, Sx_display_grayscale_p
,
4449 "Return t if the X display supports shades of gray.\n\
4450 Note that color displays do support shades of gray.\n\
4451 The optional argument DISPLAY specifies which display to ask about.\n\
4452 DISPLAY should be either a frame or a display name (a string).\n\
4453 If omitted or nil, that stands for the selected frame's display.")
4455 Lisp_Object display
;
4457 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4459 if ((dpyinfo
->n_planes
* dpyinfo
->n_cbits
) <= 1)
4465 DEFUN ("x-display-pixel-width", Fx_display_pixel_width
, Sx_display_pixel_width
,
4467 "Returns the width in pixels of the X display DISPLAY.\n\
4468 The optional argument DISPLAY specifies which display to ask about.\n\
4469 DISPLAY should be either a frame or a display name (a string).\n\
4470 If omitted or nil, that stands for the selected frame's display.")
4472 Lisp_Object display
;
4474 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4476 return make_number (dpyinfo
->width
);
4479 DEFUN ("x-display-pixel-height", Fx_display_pixel_height
,
4480 Sx_display_pixel_height
, 0, 1, 0,
4481 "Returns the height in pixels of the X display DISPLAY.\n\
4482 The optional argument DISPLAY specifies which display to ask about.\n\
4483 DISPLAY should be either a frame or a display name (a string).\n\
4484 If omitted or nil, that stands for the selected frame's display.")
4486 Lisp_Object display
;
4488 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4490 return make_number (dpyinfo
->height
);
4493 DEFUN ("x-display-planes", Fx_display_planes
, Sx_display_planes
,
4495 "Returns the number of bitplanes of the display DISPLAY.\n\
4496 The optional argument DISPLAY specifies which display to ask about.\n\
4497 DISPLAY should be either a frame or a display name (a string).\n\
4498 If omitted or nil, that stands for the selected frame's display.")
4500 Lisp_Object display
;
4502 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4504 return make_number (dpyinfo
->n_planes
* dpyinfo
->n_cbits
);
4507 DEFUN ("x-display-color-cells", Fx_display_color_cells
, Sx_display_color_cells
,
4509 "Returns the number of color cells of the display DISPLAY.\n\
4510 The optional argument DISPLAY specifies which display to ask about.\n\
4511 DISPLAY should be either a frame or a display name (a string).\n\
4512 If omitted or nil, that stands for the selected frame's display.")
4514 Lisp_Object display
;
4516 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4520 hdc
= GetDC (dpyinfo
->root_window
);
4521 if (dpyinfo
->has_palette
)
4522 cap
= GetDeviceCaps (hdc
,SIZEPALETTE
);
4524 cap
= GetDeviceCaps (hdc
,NUMCOLORS
);
4526 ReleaseDC (dpyinfo
->root_window
, hdc
);
4528 return make_number (cap
);
4531 DEFUN ("x-server-max-request-size", Fx_server_max_request_size
,
4532 Sx_server_max_request_size
,
4534 "Returns the maximum request size of the server of display DISPLAY.\n\
4535 The optional argument DISPLAY specifies which display to ask about.\n\
4536 DISPLAY should be either a frame or a display name (a string).\n\
4537 If omitted or nil, that stands for the selected frame's display.")
4539 Lisp_Object display
;
4541 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4543 return make_number (1);
4546 DEFUN ("x-server-vendor", Fx_server_vendor
, Sx_server_vendor
, 0, 1, 0,
4547 "Returns the vendor ID string of the Win32 system (Microsoft).\n\
4548 The optional argument DISPLAY specifies which display to ask about.\n\
4549 DISPLAY should be either a frame or a display name (a string).\n\
4550 If omitted or nil, that stands for the selected frame's display.")
4552 Lisp_Object display
;
4554 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4555 char *vendor
= "Microsoft Corp.";
4557 if (! vendor
) vendor
= "";
4558 return build_string (vendor
);
4561 DEFUN ("x-server-version", Fx_server_version
, Sx_server_version
, 0, 1, 0,
4562 "Returns the version numbers of the server of display DISPLAY.\n\
4563 The value is a list of three integers: the major and minor\n\
4564 version numbers, and the vendor-specific release\n\
4565 number. See also the function `x-server-vendor'.\n\n\
4566 The optional argument DISPLAY specifies which display to ask about.\n\
4567 DISPLAY should be either a frame or a display name (a string).\n\
4568 If omitted or nil, that stands for the selected frame's display.")
4570 Lisp_Object display
;
4572 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4574 return Fcons (make_number (nt_major_version
),
4575 Fcons (make_number (nt_minor_version
), Qnil
));
4578 DEFUN ("x-display-screens", Fx_display_screens
, Sx_display_screens
, 0, 1, 0,
4579 "Returns the number of screens on the server of display DISPLAY.\n\
4580 The optional argument DISPLAY specifies which display to ask about.\n\
4581 DISPLAY should be either a frame or a display name (a string).\n\
4582 If omitted or nil, that stands for the selected frame's display.")
4584 Lisp_Object display
;
4586 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4588 return make_number (1);
4591 DEFUN ("x-display-mm-height", Fx_display_mm_height
, Sx_display_mm_height
, 0, 1, 0,
4592 "Returns the height in millimeters of the X display DISPLAY.\n\
4593 The optional argument DISPLAY specifies which display to ask about.\n\
4594 DISPLAY should be either a frame or a display name (a string).\n\
4595 If omitted or nil, that stands for the selected frame's display.")
4597 Lisp_Object display
;
4599 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4603 hdc
= GetDC (dpyinfo
->root_window
);
4605 cap
= GetDeviceCaps (hdc
, VERTSIZE
);
4607 ReleaseDC (dpyinfo
->root_window
, hdc
);
4609 return make_number (cap
);
4612 DEFUN ("x-display-mm-width", Fx_display_mm_width
, Sx_display_mm_width
, 0, 1, 0,
4613 "Returns the width in millimeters of the X display DISPLAY.\n\
4614 The optional argument DISPLAY specifies which display to ask about.\n\
4615 DISPLAY should be either a frame or a display name (a string).\n\
4616 If omitted or nil, that stands for the selected frame's display.")
4618 Lisp_Object display
;
4620 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4625 hdc
= GetDC (dpyinfo
->root_window
);
4627 cap
= GetDeviceCaps (hdc
, HORZSIZE
);
4629 ReleaseDC (dpyinfo
->root_window
, hdc
);
4631 return make_number (cap
);
4634 DEFUN ("x-display-backing-store", Fx_display_backing_store
,
4635 Sx_display_backing_store
, 0, 1, 0,
4636 "Returns an indication of whether display DISPLAY does backing store.\n\
4637 The value may be `always', `when-mapped', or `not-useful'.\n\
4638 The optional argument DISPLAY specifies which display to ask about.\n\
4639 DISPLAY should be either a frame or a display name (a string).\n\
4640 If omitted or nil, that stands for the selected frame's display.")
4642 Lisp_Object display
;
4644 return intern ("not-useful");
4647 DEFUN ("x-display-visual-class", Fx_display_visual_class
,
4648 Sx_display_visual_class
, 0, 1, 0,
4649 "Returns the visual class of the display DISPLAY.\n\
4650 The value is one of the symbols `static-gray', `gray-scale',\n\
4651 `static-color', `pseudo-color', `true-color', or `direct-color'.\n\n\
4652 The optional argument DISPLAY specifies which display to ask about.\n\
4653 DISPLAY should be either a frame or a display name (a string).\n\
4654 If omitted or nil, that stands for the selected frame's display.")
4656 Lisp_Object display
;
4658 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4661 switch (dpyinfo
->visual
->class)
4663 case StaticGray
: return (intern ("static-gray"));
4664 case GrayScale
: return (intern ("gray-scale"));
4665 case StaticColor
: return (intern ("static-color"));
4666 case PseudoColor
: return (intern ("pseudo-color"));
4667 case TrueColor
: return (intern ("true-color"));
4668 case DirectColor
: return (intern ("direct-color"));
4670 error ("Display has an unknown visual class");
4674 error ("Display has an unknown visual class");
4677 DEFUN ("x-display-save-under", Fx_display_save_under
,
4678 Sx_display_save_under
, 0, 1, 0,
4679 "Returns t if the display DISPLAY supports the save-under feature.\n\
4680 The optional argument DISPLAY specifies which display to ask about.\n\
4681 DISPLAY should be either a frame or a display name (a string).\n\
4682 If omitted or nil, that stands for the selected frame's display.")
4684 Lisp_Object display
;
4686 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4693 register struct frame
*f
;
4695 return PIXEL_WIDTH (f
);
4700 register struct frame
*f
;
4702 return PIXEL_HEIGHT (f
);
4707 register struct frame
*f
;
4709 return FONT_WIDTH (f
->output_data
.win32
->font
);
4714 register struct frame
*f
;
4716 return f
->output_data
.win32
->line_height
;
4720 x_screen_planes (frame
)
4723 return (FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_planes
*
4724 FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_cbits
);
4727 /* Return the display structure for the display named NAME.
4728 Open a new connection if necessary. */
4730 struct win32_display_info
*
4731 x_display_info_for_name (name
)
4735 struct win32_display_info
*dpyinfo
;
4737 CHECK_STRING (name
, 0);
4739 for (dpyinfo
= &one_win32_display_info
, names
= win32_display_name_list
;
4741 dpyinfo
= dpyinfo
->next
, names
= XCONS (names
)->cdr
)
4744 tem
= Fstring_equal (XCONS (XCONS (names
)->car
)->car
, name
);
4749 /* Use this general default value to start with. */
4750 Vx_resource_name
= Vinvocation_name
;
4752 validate_x_resource_name ();
4754 dpyinfo
= win32_term_init (name
, (unsigned char *)0,
4755 (char *) XSTRING (Vx_resource_name
)->data
);
4758 error ("Cannot connect to server %s", XSTRING (name
)->data
);
4760 XSETFASTINT (Vwindow_system_version
, 3);
4765 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
4766 1, 3, 0, "Open a connection to a server.\n\
4767 DISPLAY is the name of the display to connect to.\n\
4768 Optional second arg XRM-STRING is a string of resources in xrdb format.\n\
4769 If the optional third arg MUST-SUCCEED is non-nil,\n\
4770 terminate Emacs if we can't open the connection.")
4771 (display
, xrm_string
, must_succeed
)
4772 Lisp_Object display
, xrm_string
, must_succeed
;
4774 unsigned int n_planes
;
4775 unsigned char *xrm_option
;
4776 struct win32_display_info
*dpyinfo
;
4778 CHECK_STRING (display
, 0);
4779 if (! NILP (xrm_string
))
4780 CHECK_STRING (xrm_string
, 1);
4782 /* Allow color mapping to be defined externally; first look in user's
4783 HOME directory, then in Emacs etc dir for a file called rgb.txt. */
4785 Lisp_Object color_file
;
4786 struct gcpro gcpro1
;
4788 color_file
= build_string("~/rgb.txt");
4790 GCPRO1 (color_file
);
4792 if (NILP (Ffile_readable_p (color_file
)))
4794 Fexpand_file_name (build_string ("rgb.txt"),
4795 Fsymbol_value (intern ("data-directory")));
4797 Vwin32_color_map
= Fwin32_load_color_file (color_file
);
4801 if (NILP (Vwin32_color_map
))
4802 Vwin32_color_map
= Fwin32_default_color_map ();
4804 if (! NILP (xrm_string
))
4805 xrm_option
= (unsigned char *) XSTRING (xrm_string
)->data
;
4807 xrm_option
= (unsigned char *) 0;
4809 /* Use this general default value to start with. */
4810 /* First remove .exe suffix from invocation-name - it looks ugly. */
4812 char basename
[ MAX_PATH
], *str
;
4814 strcpy (basename
, XSTRING (Vinvocation_name
)->data
);
4815 str
= strrchr (basename
, '.');
4817 Vinvocation_name
= build_string (basename
);
4819 Vx_resource_name
= Vinvocation_name
;
4821 validate_x_resource_name ();
4823 /* This is what opens the connection and sets x_current_display.
4824 This also initializes many symbols, such as those used for input. */
4825 dpyinfo
= win32_term_init (display
, xrm_option
,
4826 (char *) XSTRING (Vx_resource_name
)->data
);
4830 if (!NILP (must_succeed
))
4831 fatal ("Cannot connect to server %s.\n",
4832 XSTRING (display
)->data
);
4834 error ("Cannot connect to server %s", XSTRING (display
)->data
);
4837 XSETFASTINT (Vwindow_system_version
, 3);
4841 DEFUN ("x-close-connection", Fx_close_connection
,
4842 Sx_close_connection
, 1, 1, 0,
4843 "Close the connection to DISPLAY's server.\n\
4844 For DISPLAY, specify either a frame or a display name (a string).\n\
4845 If DISPLAY is nil, that stands for the selected frame's display.")
4847 Lisp_Object display
;
4849 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4850 struct win32_display_info
*tail
;
4853 if (dpyinfo
->reference_count
> 0)
4854 error ("Display still has frames on it");
4857 /* Free the fonts in the font table. */
4858 for (i
= 0; i
< dpyinfo
->n_fonts
; i
++)
4860 if (dpyinfo
->font_table
[i
].name
)
4861 free (dpyinfo
->font_table
[i
].name
);
4862 /* Don't free the full_name string;
4863 it is always shared with something else. */
4864 win32_unload_font (dpyinfo
, dpyinfo
->font_table
[i
].font
);
4866 x_destroy_all_bitmaps (dpyinfo
);
4868 x_delete_display (dpyinfo
);
4874 DEFUN ("x-display-list", Fx_display_list
, Sx_display_list
, 0, 0, 0,
4875 "Return the list of display names that Emacs has connections to.")
4878 Lisp_Object tail
, result
;
4881 for (tail
= win32_display_name_list
; ! NILP (tail
); tail
= XCONS (tail
)->cdr
)
4882 result
= Fcons (XCONS (XCONS (tail
)->car
)->car
, result
);
4887 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
, 1, 2, 0,
4888 "If ON is non-nil, report errors as soon as the erring request is made.\n\
4889 If ON is nil, allow buffering of requests.\n\
4890 This is a noop on Win32 systems.\n\
4891 The optional second argument DISPLAY specifies which display to act on.\n\
4892 DISPLAY should be either a frame or a display name (a string).\n\
4893 If DISPLAY is omitted or nil, that stands for the selected frame's display.")
4895 Lisp_Object display
, on
;
4897 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4903 /* These are the win32 specialized functions */
4905 DEFUN ("win32-select-font", Fwin32_select_font
, Swin32_select_font
, 0, 1, 0,
4906 "This will display the Win32 font dialog and return an X font string corresponding to the selection.")
4910 FRAME_PTR f
= check_x_frame (frame
);
4915 bzero (&cf
, sizeof (cf
));
4917 cf
.lStructSize
= sizeof (cf
);
4918 cf
.hwndOwner
= FRAME_WIN32_WINDOW (f
);
4919 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
| CF_SCREENFONTS
;
4922 if (!ChooseFont (&cf
) || !win32_to_x_font (&lf
, buf
, 100))
4925 return build_string (buf
);
4931 /* The section below is built by the lisp expression at the top of the file,
4932 just above where these variables are declared. */
4933 /*&&& init symbols here &&&*/
4934 Qauto_raise
= intern ("auto-raise");
4935 staticpro (&Qauto_raise
);
4936 Qauto_lower
= intern ("auto-lower");
4937 staticpro (&Qauto_lower
);
4938 Qbackground_color
= intern ("background-color");
4939 staticpro (&Qbackground_color
);
4940 Qbar
= intern ("bar");
4942 Qborder_color
= intern ("border-color");
4943 staticpro (&Qborder_color
);
4944 Qborder_width
= intern ("border-width");
4945 staticpro (&Qborder_width
);
4946 Qbox
= intern ("box");
4948 Qcursor_color
= intern ("cursor-color");
4949 staticpro (&Qcursor_color
);
4950 Qcursor_type
= intern ("cursor-type");
4951 staticpro (&Qcursor_type
);
4952 Qforeground_color
= intern ("foreground-color");
4953 staticpro (&Qforeground_color
);
4954 Qgeometry
= intern ("geometry");
4955 staticpro (&Qgeometry
);
4956 Qicon_left
= intern ("icon-left");
4957 staticpro (&Qicon_left
);
4958 Qicon_top
= intern ("icon-top");
4959 staticpro (&Qicon_top
);
4960 Qicon_type
= intern ("icon-type");
4961 staticpro (&Qicon_type
);
4962 Qicon_name
= intern ("icon-name");
4963 staticpro (&Qicon_name
);
4964 Qinternal_border_width
= intern ("internal-border-width");
4965 staticpro (&Qinternal_border_width
);
4966 Qleft
= intern ("left");
4968 Qright
= intern ("right");
4969 staticpro (&Qright
);
4970 Qmouse_color
= intern ("mouse-color");
4971 staticpro (&Qmouse_color
);
4972 Qnone
= intern ("none");
4974 Qparent_id
= intern ("parent-id");
4975 staticpro (&Qparent_id
);
4976 Qscroll_bar_width
= intern ("scroll-bar-width");
4977 staticpro (&Qscroll_bar_width
);
4978 Qsuppress_icon
= intern ("suppress-icon");
4979 staticpro (&Qsuppress_icon
);
4980 Qtop
= intern ("top");
4982 Qundefined_color
= intern ("undefined-color");
4983 staticpro (&Qundefined_color
);
4984 Qvertical_scroll_bars
= intern ("vertical-scroll-bars");
4985 staticpro (&Qvertical_scroll_bars
);
4986 Qvisibility
= intern ("visibility");
4987 staticpro (&Qvisibility
);
4988 Qwindow_id
= intern ("window-id");
4989 staticpro (&Qwindow_id
);
4990 Qx_frame_parameter
= intern ("x-frame-parameter");
4991 staticpro (&Qx_frame_parameter
);
4992 Qx_resource_name
= intern ("x-resource-name");
4993 staticpro (&Qx_resource_name
);
4994 Quser_position
= intern ("user-position");
4995 staticpro (&Quser_position
);
4996 Quser_size
= intern ("user-size");
4997 staticpro (&Quser_size
);
4998 Qdisplay
= intern ("display");
4999 staticpro (&Qdisplay
);
5000 /* This is the end of symbol initialization. */
5002 Fput (Qundefined_color
, Qerror_conditions
,
5003 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
5004 Fput (Qundefined_color
, Qerror_message
,
5005 build_string ("Undefined color"));
5007 DEFVAR_LISP ("win32-color-map", &Vwin32_color_map
,
5008 "A array of color name mappings for windows.");
5009 Vwin32_color_map
= Qnil
;
5011 DEFVAR_LISP ("win32-pass-alt-to-system", &Vwin32_pass_alt_to_system
,
5012 "Non-nil if alt key presses are passed on to Windows.\n\
5013 When non-nil, for example, alt pressed and released and then space will\n\
5014 open the System menu. When nil, Emacs silently swallows alt key events.");
5015 Vwin32_pass_alt_to_system
= Qnil
;
5017 DEFVAR_LISP ("win32-alt-is-meta", &Vwin32_alt_is_meta
,
5018 "Non-nil if the alt key is to be considered the same as the meta key.\n\
5019 When nil, Emacs will translate the alt key to the Alt modifier, and not Meta.");
5020 Vwin32_alt_is_meta
= Qt
;
5022 DEFVAR_LISP ("win32-pass-optional-keys-to-system",
5023 &Vwin32_pass_optional_keys_to_system
,
5024 "Non-nil if the 'optional' keys (left window, right window,\n\
5025 and application keys) are passed on to Windows.");
5026 Vwin32_pass_optional_keys_to_system
= Qnil
;
5028 DEFVAR_LISP ("win32-enable-italics", &Vwin32_enable_italics
,
5029 "Non-nil enables selection of artificially italicized fonts.");
5030 Vwin32_enable_italics
= Qnil
;
5032 DEFVAR_LISP ("win32-enable-palette", &Vwin32_enable_palette
,
5033 "Non-nil enables Windows palette management to map colors exactly.");
5034 Vwin32_enable_palette
= Qt
;
5036 DEFVAR_INT ("win32-mouse-button-tolerance",
5037 &Vwin32_mouse_button_tolerance
,
5038 "Analogue of double click interval for faking middle mouse events.\n\
5039 The value is the minimum time in milliseconds that must elapse between\n\
5040 left/right button down events before they are considered distinct events.\n\
5041 If both mouse buttons are depressed within this interval, a middle mouse\n\
5042 button down event is generated instead.");
5043 XSETINT (Vwin32_mouse_button_tolerance
, GetDoubleClickTime () / 2);
5045 DEFVAR_INT ("win32-mouse-move-interval",
5046 &Vwin32_mouse_move_interval
,
5047 "Minimum interval between mouse move events.\n\
5048 The value is the minimum time in milliseconds that must elapse between\n\
5049 successive mouse move (or scroll bar drag) events before they are\n\
5050 reported as lisp events.");
5051 XSETINT (Vwin32_mouse_move_interval
, 50);
5053 init_x_parm_symbols ();
5055 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path
,
5056 "List of directories to search for bitmap files for win32.");
5057 Vx_bitmap_file_path
= decode_env_path ((char *) 0, "PATH");
5059 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape
,
5060 "The shape of the pointer when over text.\n\
5061 Changing the value does not affect existing frames\n\
5062 unless you set the mouse color.");
5063 Vx_pointer_shape
= Qnil
;
5065 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
5066 "The name Emacs uses to look up resources; for internal use only.\n\
5067 `x-get-resource' uses this as the first component of the instance name\n\
5068 when requesting resource values.\n\
5069 Emacs initially sets `x-resource-name' to the name under which Emacs\n\
5070 was invoked, or to the value specified with the `-name' or `-rn'\n\
5071 switches, if present.");
5072 Vx_resource_name
= Qnil
;
5074 Vx_nontext_pointer_shape
= Qnil
;
5076 Vx_mode_pointer_shape
= Qnil
;
5078 DEFVAR_INT ("x-sensitive-text-pointer-shape",
5079 &Vx_sensitive_text_pointer_shape
,
5080 "The shape of the pointer when over mouse-sensitive text.\n\
5081 This variable takes effect when you create a new frame\n\
5082 or when you set the mouse color.");
5083 Vx_sensitive_text_pointer_shape
= Qnil
;
5085 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
5086 "A string indicating the foreground color of the cursor box.");
5087 Vx_cursor_fore_pixel
= Qnil
;
5089 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
5090 "Non-nil if no window manager is in use.\n\
5091 Emacs doesn't try to figure this out; this is always nil\n\
5092 unless you set it to something else.");
5093 /* We don't have any way to find this out, so set it to nil
5094 and maybe the user would like to set it to t. */
5095 Vx_no_window_manager
= Qnil
;
5097 defsubr (&Sx_get_resource
);
5098 defsubr (&Sx_list_fonts
);
5099 defsubr (&Sx_display_color_p
);
5100 defsubr (&Sx_display_grayscale_p
);
5101 defsubr (&Sx_color_defined_p
);
5102 defsubr (&Sx_color_values
);
5103 defsubr (&Sx_server_max_request_size
);
5104 defsubr (&Sx_server_vendor
);
5105 defsubr (&Sx_server_version
);
5106 defsubr (&Sx_display_pixel_width
);
5107 defsubr (&Sx_display_pixel_height
);
5108 defsubr (&Sx_display_mm_width
);
5109 defsubr (&Sx_display_mm_height
);
5110 defsubr (&Sx_display_screens
);
5111 defsubr (&Sx_display_planes
);
5112 defsubr (&Sx_display_color_cells
);
5113 defsubr (&Sx_display_visual_class
);
5114 defsubr (&Sx_display_backing_store
);
5115 defsubr (&Sx_display_save_under
);
5116 defsubr (&Sx_parse_geometry
);
5117 defsubr (&Sx_create_frame
);
5118 defsubr (&Sfocus_frame
);
5119 defsubr (&Sunfocus_frame
);
5120 defsubr (&Sx_open_connection
);
5121 defsubr (&Sx_close_connection
);
5122 defsubr (&Sx_display_list
);
5123 defsubr (&Sx_synchronize
);
5125 /* Win32 specific functions */
5127 defsubr (&Swin32_select_font
);
5128 defsubr (&Swin32_define_rgb_color
);
5129 defsubr (&Swin32_default_color_map
);
5130 defsubr (&Swin32_load_color_file
);
5139 button
= MessageBox (NULL
,
5140 "A fatal error has occurred!\n\n"
5141 "Select Abort to exit, Retry to debug, Ignore to continue",
5142 "Emacs Abort Dialog",
5143 MB_ICONEXCLAMATION
| MB_TASKMODAL
5144 | MB_SETFOREGROUND
| MB_ABORTRETRYIGNORE
);