1 /* Functions for the Win32 window system.
2 Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation.
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* Added by Kevin Gallo */
31 #include "dispextern.h"
33 #include "blockinput.h"
36 #include "termhooks.h"
41 extern void free_frame_menubar ();
42 extern struct scroll_bar
*x_window_to_scroll_bar ();
44 /* The colormap for converting color names to RGB values */
45 Lisp_Object Vwin32_color_map
;
47 /* The name we're using in resource queries. */
48 Lisp_Object Vx_resource_name
;
50 /* Non nil if no window manager is in use. */
51 Lisp_Object Vx_no_window_manager
;
53 /* The background and shape of the mouse pointer, and shape when not
54 over text or in the modeline. */
55 Lisp_Object Vx_pointer_shape
, Vx_nontext_pointer_shape
, Vx_mode_pointer_shape
;
56 /* The shape when over mouse-sensitive text. */
57 Lisp_Object Vx_sensitive_text_pointer_shape
;
59 /* Color of chars displayed in cursor box. */
60 Lisp_Object Vx_cursor_fore_pixel
;
62 /* Search path for bitmap files. */
63 Lisp_Object Vx_bitmap_file_path
;
65 /* Evaluate this expression to rebuild the section of syms_of_w32fns
66 that initializes and staticpros the symbols declared below. Note
67 that Emacs 18 has a bug that keeps C-x C-e from being able to
68 evaluate this expression.
71 ;; Accumulate a list of the symbols we want to initialize from the
72 ;; declarations at the top of the file.
73 (goto-char (point-min))
74 (search-forward "/\*&&& symbols declared here &&&*\/\n")
76 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
78 (cons (buffer-substring (match-beginning 1) (match-end 1))
81 (setq symbol-list (nreverse symbol-list))
82 ;; Delete the section of syms_of_... where we initialize the symbols.
83 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
84 (let ((start (point)))
85 (while (looking-at "^ Q")
87 (kill-region start (point)))
88 ;; Write a new symbol initialization section.
90 (insert (format " %s = intern (\"" (car symbol-list)))
91 (let ((start (point)))
92 (insert (substring (car symbol-list) 1))
93 (subst-char-in-region start (point) ?_ ?-))
94 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
95 (setq symbol-list (cdr symbol-list)))))
99 /*&&& symbols declared here &&&*/
100 Lisp_Object Qauto_raise
;
101 Lisp_Object Qauto_lower
;
102 Lisp_Object Qbackground_color
;
104 Lisp_Object Qborder_color
;
105 Lisp_Object Qborder_width
;
107 Lisp_Object Qcursor_color
;
108 Lisp_Object Qcursor_type
;
110 Lisp_Object Qforeground_color
;
111 Lisp_Object Qgeometry
;
112 Lisp_Object Qicon_left
;
113 Lisp_Object Qicon_top
;
114 Lisp_Object Qicon_type
;
115 Lisp_Object Qicon_name
;
116 Lisp_Object Qinternal_border_width
;
118 Lisp_Object Qmouse_color
;
120 Lisp_Object Qparent_id
;
121 Lisp_Object Qscroll_bar_width
;
122 Lisp_Object Qsuppress_icon
;
124 Lisp_Object Qundefined_color
;
125 Lisp_Object Qvertical_scroll_bars
;
126 Lisp_Object Qvisibility
;
127 Lisp_Object Qwindow_id
;
128 Lisp_Object Qx_frame_parameter
;
129 Lisp_Object Qx_resource_name
;
130 Lisp_Object Quser_position
;
131 Lisp_Object Quser_size
;
132 Lisp_Object Qdisplay
;
134 /* The below are defined in frame.c. */
135 extern Lisp_Object Qheight
, Qminibuffer
, Qname
, Qonly
, Qwidth
;
136 extern Lisp_Object Qunsplittable
, Qmenu_bar_lines
;
138 extern Lisp_Object Vwindow_system_version
;
140 extern Lisp_Object last_mouse_scroll_bar
;
141 extern int last_mouse_scroll_bar_pos
;
142 Time last_mouse_movement_time
;
145 /* Extract a frame as a FRAME_PTR, defaulting to the selected frame
146 and checking validity for Win32. */
149 check_x_frame (frame
)
158 CHECK_LIVE_FRAME (frame
, 0);
161 if (! FRAME_WIN32_P (f
))
162 error ("non-win32 frame used");
166 /* Let the user specify an display with a frame.
167 nil stands for the selected frame--or, if that is not a win32 frame,
168 the first display on the list. */
170 static struct win32_display_info
*
171 check_x_display_info (frame
)
176 if (FRAME_WIN32_P (selected_frame
))
177 return FRAME_WIN32_DISPLAY_INFO (selected_frame
);
179 return &one_win32_display_info
;
181 else if (STRINGP (frame
))
182 return x_display_info_for_name (frame
);
187 CHECK_LIVE_FRAME (frame
, 0);
189 if (! FRAME_WIN32_P (f
))
190 error ("non-win32 frame used");
191 return FRAME_WIN32_DISPLAY_INFO (f
);
195 /* Return the Emacs frame-object corresponding to an win32 window.
196 It could be the frame's main window or an icon window. */
198 /* This function can be called during GC, so use GC_xxx type test macros. */
201 x_window_to_frame (dpyinfo
, wdesc
)
202 struct win32_display_info
*dpyinfo
;
205 Lisp_Object tail
, frame
;
208 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCONS (tail
)->cdr
)
210 frame
= XCONS (tail
)->car
;
211 if (!GC_FRAMEP (frame
))
214 if (f
->output_data
.nothing
== 1
215 || FRAME_WIN32_DISPLAY_INFO (f
) != dpyinfo
)
217 if (FRAME_WIN32_WINDOW (f
) == wdesc
)
225 /* Code to deal with bitmaps. Bitmaps are referenced by their bitmap
226 id, which is just an int that this section returns. Bitmaps are
227 reference counted so they can be shared among frames.
229 Bitmap indices are guaranteed to be > 0, so a negative number can
230 be used to indicate no bitmap.
232 If you use x_create_bitmap_from_data, then you must keep track of
233 the bitmaps yourself. That is, creating a bitmap from the same
234 data more than once will not be caught. */
237 /* Functions to access the contents of a bitmap, given an id. */
240 x_bitmap_height (f
, id
)
244 return FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].height
;
248 x_bitmap_width (f
, id
)
252 return FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].width
;
256 x_bitmap_pixmap (f
, id
)
260 return (int) FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].pixmap
;
264 /* Allocate a new bitmap record. Returns index of new record. */
267 x_allocate_bitmap_record (f
)
270 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
273 if (dpyinfo
->bitmaps
== NULL
)
275 dpyinfo
->bitmaps_size
= 10;
277 = (struct win32_bitmap_record
*) xmalloc (dpyinfo
->bitmaps_size
* sizeof (struct win32_bitmap_record
));
278 dpyinfo
->bitmaps_last
= 1;
282 if (dpyinfo
->bitmaps_last
< dpyinfo
->bitmaps_size
)
283 return ++dpyinfo
->bitmaps_last
;
285 for (i
= 0; i
< dpyinfo
->bitmaps_size
; ++i
)
286 if (dpyinfo
->bitmaps
[i
].refcount
== 0)
289 dpyinfo
->bitmaps_size
*= 2;
291 = (struct win32_bitmap_record
*) xrealloc (dpyinfo
->bitmaps
,
292 dpyinfo
->bitmaps_size
* sizeof (struct win32_bitmap_record
));
293 return ++dpyinfo
->bitmaps_last
;
296 /* Add one reference to the reference count of the bitmap with id ID. */
299 x_reference_bitmap (f
, id
)
303 ++FRAME_WIN32_DISPLAY_INFO (f
)->bitmaps
[id
- 1].refcount
;
306 /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */
309 x_create_bitmap_from_data (f
, bits
, width
, height
)
312 unsigned int width
, height
;
314 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
318 bitmap
= CreateBitmap (width
, height
,
319 FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_planes
,
320 FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_cbits
,
326 id
= x_allocate_bitmap_record (f
);
327 dpyinfo
->bitmaps
[id
- 1].pixmap
= bitmap
;
328 dpyinfo
->bitmaps
[id
- 1].file
= NULL
;
329 dpyinfo
->bitmaps
[id
- 1].hinst
= NULL
;
330 dpyinfo
->bitmaps
[id
- 1].refcount
= 1;
331 dpyinfo
->bitmaps
[id
- 1].depth
= 1;
332 dpyinfo
->bitmaps
[id
- 1].height
= height
;
333 dpyinfo
->bitmaps
[id
- 1].width
= width
;
338 /* Create bitmap from file FILE for frame F. */
341 x_create_bitmap_from_file (f
, file
)
347 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
348 unsigned int width
, height
;
350 int xhot
, yhot
, result
, id
;
356 /* Look for an existing bitmap with the same name. */
357 for (id
= 0; id
< dpyinfo
->bitmaps_last
; ++id
)
359 if (dpyinfo
->bitmaps
[id
].refcount
360 && dpyinfo
->bitmaps
[id
].file
361 && !strcmp (dpyinfo
->bitmaps
[id
].file
, (char *) XSTRING (file
)->data
))
363 ++dpyinfo
->bitmaps
[id
].refcount
;
368 /* Search bitmap-file-path for the file, if appropriate. */
369 fd
= openp (Vx_bitmap_file_path
, file
, "", &found
, 0);
374 filename
= (char *) XSTRING (found
)->data
;
376 hinst
= LoadLibraryEx (filename
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
382 result
= XReadBitmapFile (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
),
383 filename
, &width
, &height
, &bitmap
, &xhot
, &yhot
);
384 if (result
!= BitmapSuccess
)
387 id
= x_allocate_bitmap_record (f
);
388 dpyinfo
->bitmaps
[id
- 1].pixmap
= bitmap
;
389 dpyinfo
->bitmaps
[id
- 1].refcount
= 1;
390 dpyinfo
->bitmaps
[id
- 1].file
= (char *) xmalloc (XSTRING (file
)->size
+ 1);
391 dpyinfo
->bitmaps
[id
- 1].depth
= 1;
392 dpyinfo
->bitmaps
[id
- 1].height
= height
;
393 dpyinfo
->bitmaps
[id
- 1].width
= width
;
394 strcpy (dpyinfo
->bitmaps
[id
- 1].file
, XSTRING (file
)->data
);
400 /* Remove reference to bitmap with id number ID. */
403 x_destroy_bitmap (f
, id
)
407 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (f
);
411 --dpyinfo
->bitmaps
[id
- 1].refcount
;
412 if (dpyinfo
->bitmaps
[id
- 1].refcount
== 0)
415 DeleteObject (dpyinfo
->bitmaps
[id
- 1].pixmap
);
416 if (dpyinfo
->bitmaps
[id
- 1].file
)
418 free (dpyinfo
->bitmaps
[id
- 1].file
);
419 dpyinfo
->bitmaps
[id
- 1].file
= NULL
;
426 /* Free all the bitmaps for the display specified by DPYINFO. */
429 x_destroy_all_bitmaps (dpyinfo
)
430 struct win32_display_info
*dpyinfo
;
433 for (i
= 0; i
< dpyinfo
->bitmaps_last
; i
++)
434 if (dpyinfo
->bitmaps
[i
].refcount
> 0)
436 DeleteObject (dpyinfo
->bitmaps
[i
].pixmap
);
437 if (dpyinfo
->bitmaps
[i
].file
)
438 free (dpyinfo
->bitmaps
[i
].file
);
440 dpyinfo
->bitmaps_last
= 0;
443 /* Connect the frame-parameter names for Win32 frames
444 to the ways of passing the parameter values to the window system.
446 The name of a parameter, as a Lisp symbol,
447 has an `x-frame-parameter' property which is an integer in Lisp
448 but can be interpreted as an `enum x_frame_parm' in C. */
452 X_PARM_FOREGROUND_COLOR
,
453 X_PARM_BACKGROUND_COLOR
,
460 X_PARM_INTERNAL_BORDER_WIDTH
,
464 X_PARM_VERT_SCROLL_BAR
,
466 X_PARM_MENU_BAR_LINES
470 struct x_frame_parm_table
473 void (*setter
)( /* struct frame *frame, Lisp_Object val, oldval */ );
476 void x_set_foreground_color ();
477 void x_set_background_color ();
478 void x_set_mouse_color ();
479 void x_set_cursor_color ();
480 void x_set_border_color ();
481 void x_set_cursor_type ();
482 void x_set_icon_type ();
483 void x_set_icon_name ();
485 void x_set_border_width ();
486 void x_set_internal_border_width ();
487 void x_explicitly_set_name ();
488 void x_set_autoraise ();
489 void x_set_autolower ();
490 void x_set_vertical_scroll_bars ();
491 void x_set_visibility ();
492 void x_set_menu_bar_lines ();
493 void x_set_scroll_bar_width ();
494 void x_set_unsplittable ();
496 static struct x_frame_parm_table x_frame_parms
[] =
498 "foreground-color", x_set_foreground_color
,
499 "background-color", x_set_background_color
,
500 "mouse-color", x_set_mouse_color
,
501 "cursor-color", x_set_cursor_color
,
502 "border-color", x_set_border_color
,
503 "cursor-type", x_set_cursor_type
,
504 "icon-type", x_set_icon_type
,
505 "icon-name", x_set_icon_name
,
507 "border-width", x_set_border_width
,
508 "internal-border-width", x_set_internal_border_width
,
509 "name", x_explicitly_set_name
,
510 "auto-raise", x_set_autoraise
,
511 "auto-lower", x_set_autolower
,
512 "vertical-scroll-bars", x_set_vertical_scroll_bars
,
513 "visibility", x_set_visibility
,
514 "menu-bar-lines", x_set_menu_bar_lines
,
515 "scroll-bar-width", x_set_scroll_bar_width
,
516 "unsplittable", x_set_unsplittable
,
519 /* Attach the `x-frame-parameter' properties to
520 the Lisp symbol names of parameters relevant to Win32. */
522 init_x_parm_symbols ()
526 for (i
= 0; i
< sizeof (x_frame_parms
) / sizeof (x_frame_parms
[0]); i
++)
527 Fput (intern (x_frame_parms
[i
].name
), Qx_frame_parameter
,
531 /* Change the parameters of FRAME as specified by ALIST.
532 If a parameter is not specially recognized, do nothing;
533 otherwise call the `x_set_...' function for that parameter. */
536 x_set_frame_parameters (f
, alist
)
542 /* If both of these parameters are present, it's more efficient to
543 set them both at once. So we wait until we've looked at the
544 entire list before we set them. */
545 Lisp_Object width
, height
;
548 Lisp_Object left
, top
;
550 /* Same with these. */
551 Lisp_Object icon_left
, icon_top
;
553 /* Record in these vectors all the parms specified. */
557 int left_no_change
= 0, top_no_change
= 0;
558 int icon_left_no_change
= 0, icon_top_no_change
= 0;
561 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
564 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
565 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
567 /* Extract parm names and values into those vectors. */
570 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
572 Lisp_Object elt
, prop
, val
;
575 parms
[i
] = Fcar (elt
);
576 values
[i
] = Fcdr (elt
);
580 width
= height
= top
= left
= Qunbound
;
581 icon_left
= icon_top
= Qunbound
;
583 /* Now process them in reverse of specified order. */
584 for (i
--; i
>= 0; i
--)
586 Lisp_Object prop
, val
;
591 if (EQ (prop
, Qwidth
))
593 else if (EQ (prop
, Qheight
))
595 else if (EQ (prop
, Qtop
))
597 else if (EQ (prop
, Qleft
))
599 else if (EQ (prop
, Qicon_top
))
601 else if (EQ (prop
, Qicon_left
))
605 register Lisp_Object param_index
, old_value
;
607 param_index
= Fget (prop
, Qx_frame_parameter
);
608 old_value
= get_frame_param (f
, prop
);
609 store_frame_param (f
, prop
, val
);
610 if (NATNUMP (param_index
)
611 && (XFASTINT (param_index
)
612 < sizeof (x_frame_parms
)/sizeof (x_frame_parms
[0])))
613 (*x_frame_parms
[XINT (param_index
)].setter
)(f
, val
, old_value
);
617 /* Don't die if just one of these was set. */
618 if (EQ (left
, Qunbound
))
621 if (f
->output_data
.win32
->left_pos
< 0)
622 left
= Fcons (Qplus
, Fcons (make_number (f
->output_data
.win32
->left_pos
), Qnil
));
624 XSETINT (left
, f
->output_data
.win32
->left_pos
);
626 if (EQ (top
, Qunbound
))
629 if (f
->output_data
.win32
->top_pos
< 0)
630 top
= Fcons (Qplus
, Fcons (make_number (f
->output_data
.win32
->top_pos
), Qnil
));
632 XSETINT (top
, f
->output_data
.win32
->top_pos
);
635 /* If one of the icon positions was not set, preserve or default it. */
636 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
638 icon_left_no_change
= 1;
639 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
640 if (NILP (icon_left
))
641 XSETINT (icon_left
, 0);
643 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
645 icon_top_no_change
= 1;
646 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
648 XSETINT (icon_top
, 0);
651 /* Don't die if just one of these was set. */
652 if (EQ (width
, Qunbound
))
653 XSETINT (width
, FRAME_WIDTH (f
));
654 if (EQ (height
, Qunbound
))
655 XSETINT (height
, FRAME_HEIGHT (f
));
657 /* Don't set these parameters unless they've been explicitly
658 specified. The window might be mapped or resized while we're in
659 this function, and we don't want to override that unless the lisp
660 code has asked for it.
662 Don't set these parameters unless they actually differ from the
663 window's current parameters; the window may not actually exist
668 check_frame_size (f
, &height
, &width
);
670 XSETFRAME (frame
, f
);
672 if ((NUMBERP (width
) && XINT (width
) != FRAME_WIDTH (f
))
673 || (NUMBERP (height
) && XINT (height
) != FRAME_HEIGHT (f
)))
674 Fset_frame_size (frame
, width
, height
);
676 if ((!NILP (left
) || !NILP (top
))
677 && ! (left_no_change
&& top_no_change
)
678 && ! (NUMBERP (left
) && XINT (left
) == f
->output_data
.win32
->left_pos
679 && NUMBERP (top
) && XINT (top
) == f
->output_data
.win32
->top_pos
))
684 /* Record the signs. */
685 f
->output_data
.win32
->size_hint_flags
&= ~ (XNegative
| YNegative
);
686 if (EQ (left
, Qminus
))
687 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
688 else if (INTEGERP (left
))
690 leftpos
= XINT (left
);
692 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
694 else if (CONSP (left
) && EQ (XCONS (left
)->car
, Qminus
)
695 && CONSP (XCONS (left
)->cdr
)
696 && INTEGERP (XCONS (XCONS (left
)->cdr
)->car
))
698 leftpos
= - XINT (XCONS (XCONS (left
)->cdr
)->car
);
699 f
->output_data
.win32
->size_hint_flags
|= XNegative
;
701 else if (CONSP (left
) && EQ (XCONS (left
)->car
, Qplus
)
702 && CONSP (XCONS (left
)->cdr
)
703 && INTEGERP (XCONS (XCONS (left
)->cdr
)->car
))
705 leftpos
= XINT (XCONS (XCONS (left
)->cdr
)->car
);
708 if (EQ (top
, Qminus
))
709 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
710 else if (INTEGERP (top
))
714 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
716 else if (CONSP (top
) && EQ (XCONS (top
)->car
, Qminus
)
717 && CONSP (XCONS (top
)->cdr
)
718 && INTEGERP (XCONS (XCONS (top
)->cdr
)->car
))
720 toppos
= - XINT (XCONS (XCONS (top
)->cdr
)->car
);
721 f
->output_data
.win32
->size_hint_flags
|= YNegative
;
723 else if (CONSP (top
) && EQ (XCONS (top
)->car
, Qplus
)
724 && CONSP (XCONS (top
)->cdr
)
725 && INTEGERP (XCONS (XCONS (top
)->cdr
)->car
))
727 toppos
= XINT (XCONS (XCONS (top
)->cdr
)->car
);
731 /* Store the numeric value of the position. */
732 f
->output_data
.win32
->top_pos
= toppos
;
733 f
->output_data
.win32
->left_pos
= leftpos
;
735 f
->output_data
.win32
->win_gravity
= NorthWestGravity
;
737 /* Actually set that position, and convert to absolute. */
738 x_set_offset (f
, leftpos
, toppos
, -1);
741 if ((!NILP (icon_left
) || !NILP (icon_top
))
742 && ! (icon_left_no_change
&& icon_top_no_change
))
743 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
747 /* Store the screen positions of frame F into XPTR and YPTR.
748 These are the positions of the containing window manager window,
749 not Emacs's own window. */
752 x_real_positions (f
, xptr
, yptr
)
761 GetClientRect(FRAME_WIN32_WINDOW(f
), &rect
);
762 AdjustWindowRect(&rect
, f
->output_data
.win32
->dwStyle
, FRAME_EXTERNAL_MENU_BAR(f
));
768 ClientToScreen (FRAME_WIN32_WINDOW(f
), &pt
);
774 /* Insert a description of internally-recorded parameters of frame X
775 into the parameter alist *ALISTPTR that is to be given to the user.
776 Only parameters that are specific to Win32
777 and whose values are not correctly recorded in the frame's
778 param_alist need to be considered here. */
780 x_report_frame_params (f
, alistptr
)
782 Lisp_Object
*alistptr
;
787 /* Represent negative positions (off the top or left screen edge)
788 in a way that Fmodify_frame_parameters will understand correctly. */
789 XSETINT (tem
, f
->output_data
.win32
->left_pos
);
790 if (f
->output_data
.win32
->left_pos
>= 0)
791 store_in_alist (alistptr
, Qleft
, tem
);
793 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
795 XSETINT (tem
, f
->output_data
.win32
->top_pos
);
796 if (f
->output_data
.win32
->top_pos
>= 0)
797 store_in_alist (alistptr
, Qtop
, tem
);
799 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
801 store_in_alist (alistptr
, Qborder_width
,
802 make_number (f
->output_data
.win32
->border_width
));
803 store_in_alist (alistptr
, Qinternal_border_width
,
804 make_number (f
->output_data
.win32
->internal_border_width
));
805 sprintf (buf
, "%ld", (long) FRAME_WIN32_WINDOW (f
));
806 store_in_alist (alistptr
, Qwindow_id
,
808 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
809 FRAME_SAMPLE_VISIBILITY (f
);
810 store_in_alist (alistptr
, Qvisibility
,
811 (FRAME_VISIBLE_P (f
) ? Qt
812 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
813 store_in_alist (alistptr
, Qdisplay
,
814 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->car
);
819 DEFUN ("win32-rgb", Fwin32_rgb
, Swin32_rgb
, 3, 3, 0,
820 "Convert RGB numbers to a windows color reference.")
822 Lisp_Object red
, green
, blue
;
826 CHECK_NUMBER (red
, 0);
827 CHECK_NUMBER (green
, 0);
828 CHECK_NUMBER (blue
, 0);
830 XSET (rgb
, Lisp_Int
, RGB(XUINT(red
), XUINT(green
), XUINT(blue
)));
837 /* The default colors for the win32 color map */
838 typedef struct colormap_t
844 colormap_t win32_color_map
[] =
846 {"snow" , RGB (255,250,250)},
847 {"ghost white" , RGB (248,248,255)},
848 {"GhostWhite" , RGB (248,248,255)},
849 {"white smoke" , RGB (245,245,245)},
850 {"WhiteSmoke" , RGB (245,245,245)},
851 {"gainsboro" , RGB (220,220,220)},
852 {"floral white" , RGB (255,250,240)},
853 {"FloralWhite" , RGB (255,250,240)},
854 {"old lace" , RGB (253,245,230)},
855 {"OldLace" , RGB (253,245,230)},
856 {"linen" , RGB (250,240,230)},
857 {"antique white" , RGB (250,235,215)},
858 {"AntiqueWhite" , RGB (250,235,215)},
859 {"papaya whip" , RGB (255,239,213)},
860 {"PapayaWhip" , RGB (255,239,213)},
861 {"blanched almond" , RGB (255,235,205)},
862 {"BlanchedAlmond" , RGB (255,235,205)},
863 {"bisque" , RGB (255,228,196)},
864 {"peach puff" , RGB (255,218,185)},
865 {"PeachPuff" , RGB (255,218,185)},
866 {"navajo white" , RGB (255,222,173)},
867 {"NavajoWhite" , RGB (255,222,173)},
868 {"moccasin" , RGB (255,228,181)},
869 {"cornsilk" , RGB (255,248,220)},
870 {"ivory" , RGB (255,255,240)},
871 {"lemon chiffon" , RGB (255,250,205)},
872 {"LemonChiffon" , RGB (255,250,205)},
873 {"seashell" , RGB (255,245,238)},
874 {"honeydew" , RGB (240,255,240)},
875 {"mint cream" , RGB (245,255,250)},
876 {"MintCream" , RGB (245,255,250)},
877 {"azure" , RGB (240,255,255)},
878 {"alice blue" , RGB (240,248,255)},
879 {"AliceBlue" , RGB (240,248,255)},
880 {"lavender" , RGB (230,230,250)},
881 {"lavender blush" , RGB (255,240,245)},
882 {"LavenderBlush" , RGB (255,240,245)},
883 {"misty rose" , RGB (255,228,225)},
884 {"MistyRose" , RGB (255,228,225)},
885 {"white" , RGB (255,255,255)},
886 {"black" , RGB ( 0, 0, 0)},
887 {"dark slate gray" , RGB ( 47, 79, 79)},
888 {"DarkSlateGray" , RGB ( 47, 79, 79)},
889 {"dark slate grey" , RGB ( 47, 79, 79)},
890 {"DarkSlateGrey" , RGB ( 47, 79, 79)},
891 {"dim gray" , RGB (105,105,105)},
892 {"DimGray" , RGB (105,105,105)},
893 {"dim grey" , RGB (105,105,105)},
894 {"DimGrey" , RGB (105,105,105)},
895 {"slate gray" , RGB (112,128,144)},
896 {"SlateGray" , RGB (112,128,144)},
897 {"slate grey" , RGB (112,128,144)},
898 {"SlateGrey" , RGB (112,128,144)},
899 {"light slate gray" , RGB (119,136,153)},
900 {"LightSlateGray" , RGB (119,136,153)},
901 {"light slate grey" , RGB (119,136,153)},
902 {"LightSlateGrey" , RGB (119,136,153)},
903 {"gray" , RGB (190,190,190)},
904 {"grey" , RGB (190,190,190)},
905 {"light grey" , RGB (211,211,211)},
906 {"LightGrey" , RGB (211,211,211)},
907 {"light gray" , RGB (211,211,211)},
908 {"LightGray" , RGB (211,211,211)},
909 {"midnight blue" , RGB ( 25, 25,112)},
910 {"MidnightBlue" , RGB ( 25, 25,112)},
911 {"navy" , RGB ( 0, 0,128)},
912 {"navy blue" , RGB ( 0, 0,128)},
913 {"NavyBlue" , RGB ( 0, 0,128)},
914 {"cornflower blue" , RGB (100,149,237)},
915 {"CornflowerBlue" , RGB (100,149,237)},
916 {"dark slate blue" , RGB ( 72, 61,139)},
917 {"DarkSlateBlue" , RGB ( 72, 61,139)},
918 {"slate blue" , RGB (106, 90,205)},
919 {"SlateBlue" , RGB (106, 90,205)},
920 {"medium slate blue" , RGB (123,104,238)},
921 {"MediumSlateBlue" , RGB (123,104,238)},
922 {"light slate blue" , RGB (132,112,255)},
923 {"LightSlateBlue" , RGB (132,112,255)},
924 {"medium blue" , RGB ( 0, 0,205)},
925 {"MediumBlue" , RGB ( 0, 0,205)},
926 {"royal blue" , RGB ( 65,105,225)},
927 {"RoyalBlue" , RGB ( 65,105,225)},
928 {"blue" , RGB ( 0, 0,255)},
929 {"dodger blue" , RGB ( 30,144,255)},
930 {"DodgerBlue" , RGB ( 30,144,255)},
931 {"deep sky blue" , RGB ( 0,191,255)},
932 {"DeepSkyBlue" , RGB ( 0,191,255)},
933 {"sky blue" , RGB (135,206,235)},
934 {"SkyBlue" , RGB (135,206,235)},
935 {"light sky blue" , RGB (135,206,250)},
936 {"LightSkyBlue" , RGB (135,206,250)},
937 {"steel blue" , RGB ( 70,130,180)},
938 {"SteelBlue" , RGB ( 70,130,180)},
939 {"light steel blue" , RGB (176,196,222)},
940 {"LightSteelBlue" , RGB (176,196,222)},
941 {"light blue" , RGB (173,216,230)},
942 {"LightBlue" , RGB (173,216,230)},
943 {"powder blue" , RGB (176,224,230)},
944 {"PowderBlue" , RGB (176,224,230)},
945 {"pale turquoise" , RGB (175,238,238)},
946 {"PaleTurquoise" , RGB (175,238,238)},
947 {"dark turquoise" , RGB ( 0,206,209)},
948 {"DarkTurquoise" , RGB ( 0,206,209)},
949 {"medium turquoise" , RGB ( 72,209,204)},
950 {"MediumTurquoise" , RGB ( 72,209,204)},
951 {"turquoise" , RGB ( 64,224,208)},
952 {"cyan" , RGB ( 0,255,255)},
953 {"light cyan" , RGB (224,255,255)},
954 {"LightCyan" , RGB (224,255,255)},
955 {"cadet blue" , RGB ( 95,158,160)},
956 {"CadetBlue" , RGB ( 95,158,160)},
957 {"medium aquamarine" , RGB (102,205,170)},
958 {"MediumAquamarine" , RGB (102,205,170)},
959 {"aquamarine" , RGB (127,255,212)},
960 {"dark green" , RGB ( 0,100, 0)},
961 {"DarkGreen" , RGB ( 0,100, 0)},
962 {"dark olive green" , RGB ( 85,107, 47)},
963 {"DarkOliveGreen" , RGB ( 85,107, 47)},
964 {"dark sea green" , RGB (143,188,143)},
965 {"DarkSeaGreen" , RGB (143,188,143)},
966 {"sea green" , RGB ( 46,139, 87)},
967 {"SeaGreen" , RGB ( 46,139, 87)},
968 {"medium sea green" , RGB ( 60,179,113)},
969 {"MediumSeaGreen" , RGB ( 60,179,113)},
970 {"light sea green" , RGB ( 32,178,170)},
971 {"LightSeaGreen" , RGB ( 32,178,170)},
972 {"pale green" , RGB (152,251,152)},
973 {"PaleGreen" , RGB (152,251,152)},
974 {"spring green" , RGB ( 0,255,127)},
975 {"SpringGreen" , RGB ( 0,255,127)},
976 {"lawn green" , RGB (124,252, 0)},
977 {"LawnGreen" , RGB (124,252, 0)},
978 {"green" , RGB ( 0,255, 0)},
979 {"chartreuse" , RGB (127,255, 0)},
980 {"medium spring green" , RGB ( 0,250,154)},
981 {"MediumSpringGreen" , RGB ( 0,250,154)},
982 {"green yellow" , RGB (173,255, 47)},
983 {"GreenYellow" , RGB (173,255, 47)},
984 {"lime green" , RGB ( 50,205, 50)},
985 {"LimeGreen" , RGB ( 50,205, 50)},
986 {"yellow green" , RGB (154,205, 50)},
987 {"YellowGreen" , RGB (154,205, 50)},
988 {"forest green" , RGB ( 34,139, 34)},
989 {"ForestGreen" , RGB ( 34,139, 34)},
990 {"olive drab" , RGB (107,142, 35)},
991 {"OliveDrab" , RGB (107,142, 35)},
992 {"dark khaki" , RGB (189,183,107)},
993 {"DarkKhaki" , RGB (189,183,107)},
994 {"khaki" , RGB (240,230,140)},
995 {"pale goldenrod" , RGB (238,232,170)},
996 {"PaleGoldenrod" , RGB (238,232,170)},
997 {"light goldenrod yellow" , RGB (250,250,210)},
998 {"LightGoldenrodYellow" , RGB (250,250,210)},
999 {"light yellow" , RGB (255,255,224)},
1000 {"LightYellow" , RGB (255,255,224)},
1001 {"yellow" , RGB (255,255, 0)},
1002 {"gold" , RGB (255,215, 0)},
1003 {"light goldenrod" , RGB (238,221,130)},
1004 {"LightGoldenrod" , RGB (238,221,130)},
1005 {"goldenrod" , RGB (218,165, 32)},
1006 {"dark goldenrod" , RGB (184,134, 11)},
1007 {"DarkGoldenrod" , RGB (184,134, 11)},
1008 {"rosy brown" , RGB (188,143,143)},
1009 {"RosyBrown" , RGB (188,143,143)},
1010 {"indian red" , RGB (205, 92, 92)},
1011 {"IndianRed" , RGB (205, 92, 92)},
1012 {"saddle brown" , RGB (139, 69, 19)},
1013 {"SaddleBrown" , RGB (139, 69, 19)},
1014 {"sienna" , RGB (160, 82, 45)},
1015 {"peru" , RGB (205,133, 63)},
1016 {"burlywood" , RGB (222,184,135)},
1017 {"beige" , RGB (245,245,220)},
1018 {"wheat" , RGB (245,222,179)},
1019 {"sandy brown" , RGB (244,164, 96)},
1020 {"SandyBrown" , RGB (244,164, 96)},
1021 {"tan" , RGB (210,180,140)},
1022 {"chocolate" , RGB (210,105, 30)},
1023 {"firebrick" , RGB (178,34, 34)},
1024 {"brown" , RGB (165,42, 42)},
1025 {"dark salmon" , RGB (233,150,122)},
1026 {"DarkSalmon" , RGB (233,150,122)},
1027 {"salmon" , RGB (250,128,114)},
1028 {"light salmon" , RGB (255,160,122)},
1029 {"LightSalmon" , RGB (255,160,122)},
1030 {"orange" , RGB (255,165, 0)},
1031 {"dark orange" , RGB (255,140, 0)},
1032 {"DarkOrange" , RGB (255,140, 0)},
1033 {"coral" , RGB (255,127, 80)},
1034 {"light coral" , RGB (240,128,128)},
1035 {"LightCoral" , RGB (240,128,128)},
1036 {"tomato" , RGB (255, 99, 71)},
1037 {"orange red" , RGB (255, 69, 0)},
1038 {"OrangeRed" , RGB (255, 69, 0)},
1039 {"red" , RGB (255, 0, 0)},
1040 {"hot pink" , RGB (255,105,180)},
1041 {"HotPink" , RGB (255,105,180)},
1042 {"deep pink" , RGB (255, 20,147)},
1043 {"DeepPink" , RGB (255, 20,147)},
1044 {"pink" , RGB (255,192,203)},
1045 {"light pink" , RGB (255,182,193)},
1046 {"LightPink" , RGB (255,182,193)},
1047 {"pale violet red" , RGB (219,112,147)},
1048 {"PaleVioletRed" , RGB (219,112,147)},
1049 {"maroon" , RGB (176, 48, 96)},
1050 {"medium violet red" , RGB (199, 21,133)},
1051 {"MediumVioletRed" , RGB (199, 21,133)},
1052 {"violet red" , RGB (208, 32,144)},
1053 {"VioletRed" , RGB (208, 32,144)},
1054 {"magenta" , RGB (255, 0,255)},
1055 {"violet" , RGB (238,130,238)},
1056 {"plum" , RGB (221,160,221)},
1057 {"orchid" , RGB (218,112,214)},
1058 {"medium orchid" , RGB (186, 85,211)},
1059 {"MediumOrchid" , RGB (186, 85,211)},
1060 {"dark orchid" , RGB (153, 50,204)},
1061 {"DarkOrchid" , RGB (153, 50,204)},
1062 {"dark violet" , RGB (148, 0,211)},
1063 {"DarkViolet" , RGB (148, 0,211)},
1064 {"blue violet" , RGB (138, 43,226)},
1065 {"BlueViolet" , RGB (138, 43,226)},
1066 {"purple" , RGB (160, 32,240)},
1067 {"medium purple" , RGB (147,112,219)},
1068 {"MediumPurple" , RGB (147,112,219)},
1069 {"thistle" , RGB (216,191,216)},
1070 {"gray0" , RGB ( 0, 0, 0)},
1071 {"grey0" , RGB ( 0, 0, 0)},
1072 {"dark grey" , RGB (169,169,169)},
1073 {"DarkGrey" , RGB (169,169,169)},
1074 {"dark gray" , RGB (169,169,169)},
1075 {"DarkGray" , RGB (169,169,169)},
1076 {"dark blue" , RGB ( 0, 0,139)},
1077 {"DarkBlue" , RGB ( 0, 0,139)},
1078 {"dark cyan" , RGB ( 0,139,139)},
1079 {"DarkCyan" , RGB ( 0,139,139)},
1080 {"dark magenta" , RGB (139, 0,139)},
1081 {"DarkMagenta" , RGB (139, 0,139)},
1082 {"dark red" , RGB (139, 0, 0)},
1083 {"DarkRed" , RGB (139, 0, 0)},
1084 {"light green" , RGB (144,238,144)},
1085 {"LightGreen" , RGB (144,238,144)},
1088 DEFUN ("win32-default-color-map", Fwin32_default_color_map
, Swin32_default_color_map
,
1089 0, 0, 0, "Return the default color map.")
1093 colormap_t
*pc
= win32_color_map
;
1100 for (i
= 0; i
< sizeof (win32_color_map
) / sizeof (win32_color_map
[0]);
1102 cmap
= Fcons (Fcons (build_string (pc
->name
),
1103 make_number (pc
->colorref
)),
1113 win32_to_x_color (rgb
)
1118 CHECK_NUMBER (rgb
, 0);
1122 color
= Frassq (rgb
, Vwin32_color_map
);
1127 return (Fcar (color
));
1133 x_to_win32_color (colorname
)
1136 register Lisp_Object tail
, ret
= Qnil
;
1140 for (tail
= Vwin32_color_map
; !NILP (tail
); tail
= Fcdr (tail
))
1142 register Lisp_Object elt
, tem
;
1145 if (!CONSP (elt
)) continue;
1149 if (lstrcmpi (XSTRING (tem
)->data
, colorname
) == 0)
1151 ret
= XUINT(Fcdr (elt
));
1163 /* Decide if color named COLOR is valid for the display associated with
1164 the selected frame; if so, return the rgb values in COLOR_DEF.
1165 If ALLOC is nonzero, allocate a new colormap cell. */
1168 defined_color (f
, color
, color_def
, alloc
)
1171 COLORREF
*color_def
;
1174 register Lisp_Object tem
;
1176 tem
= x_to_win32_color (color
);
1180 *color_def
= XUINT (tem
);
1189 /* Given a string ARG naming a color, compute a pixel value from it
1190 suitable for screen F.
1191 If F is not a color screen, return DEF (default) regardless of what
1195 x_decode_color (f
, arg
, def
)
1202 CHECK_STRING (arg
, 0);
1204 if (strcmp (XSTRING (arg
)->data
, "black") == 0)
1205 return BLACK_PIX_DEFAULT (f
);
1206 else if (strcmp (XSTRING (arg
)->data
, "white") == 0)
1207 return WHITE_PIX_DEFAULT (f
);
1209 if ((FRAME_WIN32_DISPLAY_INFO (f
)->n_planes
* FRAME_WIN32_DISPLAY_INFO (f
)->n_cbits
) == 1)
1212 /* defined_color is responsible for coping with failures
1213 by looking for a near-miss. */
1214 if (defined_color (f
, XSTRING (arg
)->data
, &cdef
, 1))
1217 /* defined_color failed; return an ultimate default. */
1221 /* Functions called only from `x_set_frame_param'
1222 to set individual parameters.
1224 If FRAME_WIN32_WINDOW (f) is 0,
1225 the frame is being created and its window does not exist yet.
1226 In that case, just record the parameter's new value
1227 in the standard place; do not attempt to change the window. */
1230 x_set_foreground_color (f
, arg
, oldval
)
1232 Lisp_Object arg
, oldval
;
1234 f
->output_data
.win32
->foreground_pixel
1235 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1236 if (FRAME_WIN32_WINDOW (f
) != 0)
1238 recompute_basic_faces (f
);
1239 if (FRAME_VISIBLE_P (f
))
1245 x_set_background_color (f
, arg
, oldval
)
1247 Lisp_Object arg
, oldval
;
1252 f
->output_data
.win32
->background_pixel
1253 = x_decode_color (f
, arg
, WHITE_PIX_DEFAULT (f
));
1255 if (FRAME_WIN32_WINDOW (f
) != 0)
1257 SetWindowLong (FRAME_WIN32_WINDOW (f
), WND_BACKGROUND_INDEX
, f
->output_data
.win32
->background_pixel
);
1259 recompute_basic_faces (f
);
1261 if (FRAME_VISIBLE_P (f
))
1267 x_set_mouse_color (f
, arg
, oldval
)
1269 Lisp_Object arg
, oldval
;
1272 Cursor cursor
, nontext_cursor
, mode_cursor
, cross_cursor
;
1276 if (!EQ (Qnil
, arg
))
1277 f
->output_data
.win32
->mouse_pixel
1278 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1279 mask_color
= f
->output_data
.win32
->background_pixel
;
1280 /* No invisible pointers. */
1281 if (mask_color
== f
->output_data
.win32
->mouse_pixel
1282 && mask_color
== f
->output_data
.win32
->background_pixel
)
1283 f
->output_data
.win32
->mouse_pixel
= f
->output_data
.win32
->foreground_pixel
;
1288 /* It's not okay to crash if the user selects a screwy cursor. */
1289 x_catch_errors (FRAME_WIN32_DISPLAY (f
));
1291 if (!EQ (Qnil
, Vx_pointer_shape
))
1293 CHECK_NUMBER (Vx_pointer_shape
, 0);
1294 cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XINT (Vx_pointer_shape
));
1297 cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_xterm
);
1298 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad text pointer cursor: %s");
1300 if (!EQ (Qnil
, Vx_nontext_pointer_shape
))
1302 CHECK_NUMBER (Vx_nontext_pointer_shape
, 0);
1303 nontext_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1304 XINT (Vx_nontext_pointer_shape
));
1307 nontext_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_left_ptr
);
1308 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad nontext pointer cursor: %s");
1310 if (!EQ (Qnil
, Vx_mode_pointer_shape
))
1312 CHECK_NUMBER (Vx_mode_pointer_shape
, 0);
1313 mode_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1314 XINT (Vx_mode_pointer_shape
));
1317 mode_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_xterm
);
1318 x_check_errors (FRAME_WIN32_DISPLAY (f
), "bad modeline pointer cursor: %s");
1320 if (!EQ (Qnil
, Vx_sensitive_text_pointer_shape
))
1322 CHECK_NUMBER (Vx_sensitive_text_pointer_shape
, 0);
1324 = XCreateFontCursor (FRAME_WIN32_DISPLAY (f
),
1325 XINT (Vx_sensitive_text_pointer_shape
));
1328 cross_cursor
= XCreateFontCursor (FRAME_WIN32_DISPLAY (f
), XC_crosshair
);
1330 /* Check and report errors with the above calls. */
1331 x_check_errors (FRAME_WIN32_DISPLAY (f
), "can't set cursor shape: %s");
1332 x_uncatch_errors (FRAME_WIN32_DISPLAY (f
));
1335 XColor fore_color
, back_color
;
1337 fore_color
.pixel
= f
->output_data
.win32
->mouse_pixel
;
1338 back_color
.pixel
= mask_color
;
1339 XQueryColor (FRAME_WIN32_DISPLAY (f
),
1340 DefaultColormap (FRAME_WIN32_DISPLAY (f
),
1341 DefaultScreen (FRAME_WIN32_DISPLAY (f
))),
1343 XQueryColor (FRAME_WIN32_DISPLAY (f
),
1344 DefaultColormap (FRAME_WIN32_DISPLAY (f
),
1345 DefaultScreen (FRAME_WIN32_DISPLAY (f
))),
1347 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), cursor
,
1348 &fore_color
, &back_color
);
1349 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), nontext_cursor
,
1350 &fore_color
, &back_color
);
1351 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), mode_cursor
,
1352 &fore_color
, &back_color
);
1353 XRecolorCursor (FRAME_WIN32_DISPLAY (f
), cross_cursor
,
1354 &fore_color
, &back_color
);
1357 if (FRAME_WIN32_WINDOW (f
) != 0)
1359 XDefineCursor (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
), cursor
);
1362 if (cursor
!= f
->output_data
.win32
->text_cursor
&& f
->output_data
.win32
->text_cursor
!= 0)
1363 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->text_cursor
);
1364 f
->output_data
.win32
->text_cursor
= cursor
;
1366 if (nontext_cursor
!= f
->output_data
.win32
->nontext_cursor
1367 && f
->output_data
.win32
->nontext_cursor
!= 0)
1368 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->nontext_cursor
);
1369 f
->output_data
.win32
->nontext_cursor
= nontext_cursor
;
1371 if (mode_cursor
!= f
->output_data
.win32
->modeline_cursor
1372 && f
->output_data
.win32
->modeline_cursor
!= 0)
1373 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->modeline_cursor
);
1374 f
->output_data
.win32
->modeline_cursor
= mode_cursor
;
1375 if (cross_cursor
!= f
->output_data
.win32
->cross_cursor
1376 && f
->output_data
.win32
->cross_cursor
!= 0)
1377 XFreeCursor (FRAME_WIN32_DISPLAY (f
), f
->output_data
.win32
->cross_cursor
);
1378 f
->output_data
.win32
->cross_cursor
= cross_cursor
;
1380 XFlush (FRAME_WIN32_DISPLAY (f
));
1386 x_set_cursor_color (f
, arg
, oldval
)
1388 Lisp_Object arg
, oldval
;
1390 unsigned long fore_pixel
;
1392 if (!EQ (Vx_cursor_fore_pixel
, Qnil
))
1393 fore_pixel
= x_decode_color (f
, Vx_cursor_fore_pixel
,
1394 WHITE_PIX_DEFAULT (f
));
1396 fore_pixel
= f
->output_data
.win32
->background_pixel
;
1397 f
->output_data
.win32
->cursor_pixel
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1399 /* Make sure that the cursor color differs from the background color. */
1400 if (f
->output_data
.win32
->cursor_pixel
== f
->output_data
.win32
->background_pixel
)
1402 f
->output_data
.win32
->cursor_pixel
= f
->output_data
.win32
->mouse_pixel
;
1403 if (f
->output_data
.win32
->cursor_pixel
== fore_pixel
)
1404 fore_pixel
= f
->output_data
.win32
->background_pixel
;
1406 f
->output_data
.win32
->cursor_foreground_pixel
= fore_pixel
;
1408 if (FRAME_WIN32_WINDOW (f
) != 0)
1410 if (FRAME_VISIBLE_P (f
))
1412 x_display_cursor (f
, 0);
1413 x_display_cursor (f
, 1);
1418 /* Set the border-color of frame F to value described by ARG.
1419 ARG can be a string naming a color.
1420 The border-color is used for the border that is drawn by the server.
1421 Note that this does not fully take effect if done before
1422 F has a window; it must be redone when the window is created. */
1425 x_set_border_color (f
, arg
, oldval
)
1427 Lisp_Object arg
, oldval
;
1432 CHECK_STRING (arg
, 0);
1433 str
= XSTRING (arg
)->data
;
1435 pix
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1437 x_set_border_pixel (f
, pix
);
1440 /* Set the border-color of frame F to pixel value PIX.
1441 Note that this does not fully take effect if done before
1444 x_set_border_pixel (f
, pix
)
1448 f
->output_data
.win32
->border_pixel
= pix
;
1450 if (FRAME_WIN32_WINDOW (f
) != 0 && f
->output_data
.win32
->border_width
> 0)
1452 if (FRAME_VISIBLE_P (f
))
1458 x_set_cursor_type (f
, arg
, oldval
)
1460 Lisp_Object arg
, oldval
;
1464 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
1465 f
->output_data
.win32
->cursor_width
= 2;
1467 else if (CONSP (arg
) && EQ (XCONS (arg
)->car
, Qbar
)
1468 && INTEGERP (XCONS (arg
)->cdr
))
1470 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
1471 f
->output_data
.win32
->cursor_width
= XINT (XCONS (arg
)->cdr
);
1474 /* Treat anything unknown as "box cursor".
1475 It was bad to signal an error; people have trouble fixing
1476 .Xdefaults with Emacs, when it has something bad in it. */
1477 FRAME_DESIRED_CURSOR (f
) = filled_box_cursor
;
1479 /* Make sure the cursor gets redrawn. This is overkill, but how
1480 often do people change cursor types? */
1481 update_mode_lines
++;
1485 x_set_icon_type (f
, arg
, oldval
)
1487 Lisp_Object arg
, oldval
;
1495 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1498 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1503 result
= x_text_icon (f
,
1504 (char *) XSTRING ((!NILP (f
->icon_name
)
1508 result
= x_bitmap_icon (f
, arg
);
1513 error ("No icon window available");
1516 /* If the window was unmapped (and its icon was mapped),
1517 the new icon is not mapped, so map the window in its stead. */
1518 if (FRAME_VISIBLE_P (f
))
1520 #ifdef USE_X_TOOLKIT
1521 XtPopup (f
->output_data
.win32
->widget
, XtGrabNone
);
1523 XMapWindow (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
));
1526 XFlush (FRAME_WIN32_DISPLAY (f
));
1531 /* Return non-nil if frame F wants a bitmap icon. */
1539 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
1541 return XCONS (tem
)->cdr
;
1547 x_set_icon_name (f
, arg
, oldval
)
1549 Lisp_Object arg
, oldval
;
1556 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1559 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1565 if (f
->output_data
.win32
->icon_bitmap
!= 0)
1570 result
= x_text_icon (f
,
1571 (char *) XSTRING ((!NILP (f
->icon_name
)
1578 error ("No icon window available");
1581 /* If the window was unmapped (and its icon was mapped),
1582 the new icon is not mapped, so map the window in its stead. */
1583 if (FRAME_VISIBLE_P (f
))
1585 #ifdef USE_X_TOOLKIT
1586 XtPopup (f
->output_data
.win32
->widget
, XtGrabNone
);
1588 XMapWindow (FRAME_WIN32_DISPLAY (f
), FRAME_WIN32_WINDOW (f
));
1591 XFlush (FRAME_WIN32_DISPLAY (f
));
1596 extern Lisp_Object
x_new_font ();
1599 x_set_font (f
, arg
, oldval
)
1601 Lisp_Object arg
, oldval
;
1605 CHECK_STRING (arg
, 1);
1608 result
= x_new_font (f
, XSTRING (arg
)->data
);
1611 if (EQ (result
, Qnil
))
1612 error ("Font \"%s\" is not defined", XSTRING (arg
)->data
);
1613 else if (EQ (result
, Qt
))
1614 error ("the characters of the given font have varying widths");
1615 else if (STRINGP (result
))
1617 recompute_basic_faces (f
);
1618 store_frame_param (f
, Qfont
, result
);
1625 x_set_border_width (f
, arg
, oldval
)
1627 Lisp_Object arg
, oldval
;
1629 CHECK_NUMBER (arg
, 0);
1631 if (XINT (arg
) == f
->output_data
.win32
->border_width
)
1634 if (FRAME_WIN32_WINDOW (f
) != 0)
1635 error ("Cannot change the border width of a window");
1637 f
->output_data
.win32
->border_width
= XINT (arg
);
1641 x_set_internal_border_width (f
, arg
, oldval
)
1643 Lisp_Object arg
, oldval
;
1646 int old
= f
->output_data
.win32
->internal_border_width
;
1648 CHECK_NUMBER (arg
, 0);
1649 f
->output_data
.win32
->internal_border_width
= XINT (arg
);
1650 if (f
->output_data
.win32
->internal_border_width
< 0)
1651 f
->output_data
.win32
->internal_border_width
= 0;
1653 if (f
->output_data
.win32
->internal_border_width
== old
)
1656 if (FRAME_WIN32_WINDOW (f
) != 0)
1659 x_set_window_size (f
, 0, f
->width
, f
->height
);
1661 SET_FRAME_GARBAGED (f
);
1666 x_set_visibility (f
, value
, oldval
)
1668 Lisp_Object value
, oldval
;
1671 XSETFRAME (frame
, f
);
1674 Fmake_frame_invisible (frame
, Qt
);
1675 else if (EQ (value
, Qicon
))
1676 Ficonify_frame (frame
);
1678 Fmake_frame_visible (frame
);
1682 x_set_menu_bar_lines (f
, value
, oldval
)
1684 Lisp_Object value
, oldval
;
1687 int olines
= FRAME_MENU_BAR_LINES (f
);
1689 /* Right now, menu bars don't work properly in minibuf-only frames;
1690 most of the commands try to apply themselves to the minibuffer
1691 frame itslef, and get an error because you can't switch buffers
1692 in or split the minibuffer window. */
1693 if (FRAME_MINIBUF_ONLY_P (f
))
1696 if (INTEGERP (value
))
1697 nlines
= XINT (value
);
1701 FRAME_MENU_BAR_LINES (f
) = 0;
1703 FRAME_EXTERNAL_MENU_BAR (f
) = 1;
1706 if (FRAME_EXTERNAL_MENU_BAR (f
) == 1)
1707 free_frame_menubar (f
);
1708 FRAME_EXTERNAL_MENU_BAR (f
) = 0;
1712 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
1715 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1716 name; if NAME is a string, set F's name to NAME and set
1717 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1719 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1720 suggesting a new name, which lisp code should override; if
1721 F->explicit_name is set, ignore the new name; otherwise, set it. */
1724 x_set_name (f
, name
, explicit)
1729 /* Make sure that requests from lisp code override requests from
1730 Emacs redisplay code. */
1733 /* If we're switching from explicit to implicit, we had better
1734 update the mode lines and thereby update the title. */
1735 if (f
->explicit_name
&& NILP (name
))
1736 update_mode_lines
= 1;
1738 f
->explicit_name
= ! NILP (name
);
1740 else if (f
->explicit_name
)
1743 /* If NAME is nil, set the name to the win32_id_name. */
1746 /* Check for no change needed in this very common case
1747 before we do any consing. */
1748 if (!strcmp (FRAME_WIN32_DISPLAY_INFO (f
)->win32_id_name
,
1749 XSTRING (f
->name
)->data
))
1751 name
= build_string (FRAME_WIN32_DISPLAY_INFO (f
)->win32_id_name
);
1754 CHECK_STRING (name
, 0);
1756 /* Don't change the name if it's already NAME. */
1757 if (! NILP (Fstring_equal (name
, f
->name
)))
1760 if (FRAME_WIN32_WINDOW (f
))
1763 SetWindowText(FRAME_WIN32_WINDOW (f
), XSTRING (name
)->data
);
1770 /* This function should be called when the user's lisp code has
1771 specified a name for the frame; the name will override any set by the
1774 x_explicitly_set_name (f
, arg
, oldval
)
1776 Lisp_Object arg
, oldval
;
1778 x_set_name (f
, arg
, 1);
1781 /* This function should be called by Emacs redisplay code to set the
1782 name; names set this way will never override names set by the user's
1785 x_implicitly_set_name (f
, arg
, oldval
)
1787 Lisp_Object arg
, oldval
;
1789 x_set_name (f
, arg
, 0);
1793 x_set_autoraise (f
, arg
, oldval
)
1795 Lisp_Object arg
, oldval
;
1797 f
->auto_raise
= !EQ (Qnil
, arg
);
1801 x_set_autolower (f
, arg
, oldval
)
1803 Lisp_Object arg
, oldval
;
1805 f
->auto_lower
= !EQ (Qnil
, arg
);
1809 x_set_unsplittable (f
, arg
, oldval
)
1811 Lisp_Object arg
, oldval
;
1813 f
->no_split
= !NILP (arg
);
1817 x_set_vertical_scroll_bars (f
, arg
, oldval
)
1819 Lisp_Object arg
, oldval
;
1821 if (NILP (arg
) != ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
1823 FRAME_HAS_VERTICAL_SCROLL_BARS (f
) = ! NILP (arg
);
1825 /* We set this parameter before creating the window for the
1826 frame, so we can get the geometry right from the start.
1827 However, if the window hasn't been created yet, we shouldn't
1828 call x_set_window_size. */
1829 if (FRAME_WIN32_WINDOW (f
))
1830 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
1835 x_set_scroll_bar_width (f
, arg
, oldval
)
1837 Lisp_Object arg
, oldval
;
1841 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = 0;
1842 FRAME_SCROLL_BAR_COLS (f
) = 2;
1844 else if (INTEGERP (arg
) && XINT (arg
) > 0
1845 && XFASTINT (arg
) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f
))
1847 int wid
= FONT_WIDTH (f
->output_data
.win32
->font
);
1848 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = XFASTINT (arg
);
1849 FRAME_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
1850 if (FRAME_WIN32_WINDOW (f
))
1851 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
1855 /* Subroutines of creating an frame. */
1857 /* Make sure that Vx_resource_name is set to a reasonable value.
1858 Fix it up, or set it to `emacs' if it is too hopeless. */
1861 validate_x_resource_name ()
1864 /* Number of valid characters in the resource name. */
1866 /* Number of invalid characters in the resource name. */
1871 if (STRINGP (Vx_resource_name
))
1873 unsigned char *p
= XSTRING (Vx_resource_name
)->data
;
1876 len
= XSTRING (Vx_resource_name
)->size
;
1878 /* Only letters, digits, - and _ are valid in resource names.
1879 Count the valid characters and count the invalid ones. */
1880 for (i
= 0; i
< len
; i
++)
1883 if (! ((c
>= 'a' && c
<= 'z')
1884 || (c
>= 'A' && c
<= 'Z')
1885 || (c
>= '0' && c
<= '9')
1886 || c
== '-' || c
== '_'))
1893 /* Not a string => completely invalid. */
1894 bad_count
= 5, good_count
= 0;
1896 /* If name is valid already, return. */
1900 /* If name is entirely invalid, or nearly so, use `emacs'. */
1902 || (good_count
== 1 && bad_count
> 0))
1904 Vx_resource_name
= build_string ("emacs");
1908 /* Name is partly valid. Copy it and replace the invalid characters
1909 with underscores. */
1911 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
1913 for (i
= 0; i
< len
; i
++)
1915 int c
= XSTRING (new)->data
[i
];
1916 if (! ((c
>= 'a' && c
<= 'z')
1917 || (c
>= 'A' && c
<= 'Z')
1918 || (c
>= '0' && c
<= '9')
1919 || c
== '-' || c
== '_'))
1920 XSTRING (new)->data
[i
] = '_';
1925 extern char *x_get_string_resource ();
1927 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
1928 "Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.\n\
1929 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the\n\
1930 class, where INSTANCE is the name under which Emacs was invoked, or\n\
1931 the name specified by the `-name' or `-rn' command-line arguments.\n\
1933 The optional arguments COMPONENT and SUBCLASS add to the key and the\n\
1934 class, respectively. You must specify both of them or neither.\n\
1935 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'\n\
1936 and the class is `Emacs.CLASS.SUBCLASS'.")
1937 (attribute
, class, component
, subclass
)
1938 Lisp_Object attribute
, class, component
, subclass
;
1940 register char *value
;
1944 CHECK_STRING (attribute
, 0);
1945 CHECK_STRING (class, 0);
1947 if (!NILP (component
))
1948 CHECK_STRING (component
, 1);
1949 if (!NILP (subclass
))
1950 CHECK_STRING (subclass
, 2);
1951 if (NILP (component
) != NILP (subclass
))
1952 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
1954 validate_x_resource_name ();
1956 /* Allocate space for the components, the dots which separate them,
1957 and the final '\0'. Make them big enough for the worst case. */
1958 name_key
= (char *) alloca (XSTRING (Vx_resource_name
)->size
1959 + (STRINGP (component
)
1960 ? XSTRING (component
)->size
: 0)
1961 + XSTRING (attribute
)->size
1964 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
1965 + XSTRING (class)->size
1966 + (STRINGP (subclass
)
1967 ? XSTRING (subclass
)->size
: 0)
1970 /* Start with emacs.FRAMENAME for the name (the specific one)
1971 and with `Emacs' for the class key (the general one). */
1972 strcpy (name_key
, XSTRING (Vx_resource_name
)->data
);
1973 strcpy (class_key
, EMACS_CLASS
);
1975 strcat (class_key
, ".");
1976 strcat (class_key
, XSTRING (class)->data
);
1978 if (!NILP (component
))
1980 strcat (class_key
, ".");
1981 strcat (class_key
, XSTRING (subclass
)->data
);
1983 strcat (name_key
, ".");
1984 strcat (name_key
, XSTRING (component
)->data
);
1987 strcat (name_key
, ".");
1988 strcat (name_key
, XSTRING (attribute
)->data
);
1990 value
= x_get_string_resource (Qnil
,
1991 name_key
, class_key
);
1993 if (value
!= (char *) 0)
1994 return build_string (value
);
1999 /* Used when C code wants a resource value. */
2002 x_get_resource_string (attribute
, class)
2003 char *attribute
, *class;
2005 register char *value
;
2009 /* Allocate space for the components, the dots which separate them,
2010 and the final '\0'. */
2011 name_key
= (char *) alloca (XSTRING (Vinvocation_name
)->size
2012 + strlen (attribute
) + 2);
2013 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
2014 + strlen (class) + 2);
2016 sprintf (name_key
, "%s.%s",
2017 XSTRING (Vinvocation_name
)->data
,
2019 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
2021 return x_get_string_resource (selected_frame
,
2022 name_key
, class_key
);
2025 /* Types we might convert a resource string into. */
2028 number
, boolean
, string
, symbol
2031 /* Return the value of parameter PARAM.
2033 First search ALIST, then Vdefault_frame_alist, then the X defaults
2034 database, using ATTRIBUTE as the attribute name and CLASS as its class.
2036 Convert the resource to the type specified by desired_type.
2038 If no default is specified, return Qunbound. If you call
2039 x_get_arg, make sure you deal with Qunbound in a reasonable way,
2040 and don't let it get stored in any Lisp-visible variables! */
2043 x_get_arg (alist
, param
, attribute
, class, type
)
2044 Lisp_Object alist
, param
;
2047 enum resource_types type
;
2049 register Lisp_Object tem
;
2051 tem
= Fassq (param
, alist
);
2053 tem
= Fassq (param
, Vdefault_frame_alist
);
2059 tem
= Fx_get_resource (build_string (attribute
),
2060 build_string (class),
2069 return make_number (atoi (XSTRING (tem
)->data
));
2072 tem
= Fdowncase (tem
);
2073 if (!strcmp (XSTRING (tem
)->data
, "on")
2074 || !strcmp (XSTRING (tem
)->data
, "true"))
2083 /* As a special case, we map the values `true' and `on'
2084 to Qt, and `false' and `off' to Qnil. */
2087 lower
= Fdowncase (tem
);
2088 if (!strcmp (XSTRING (lower
)->data
, "on")
2089 || !strcmp (XSTRING (lower
)->data
, "true"))
2091 else if (!strcmp (XSTRING (lower
)->data
, "off")
2092 || !strcmp (XSTRING (lower
)->data
, "false"))
2095 return Fintern (tem
, Qnil
);
2108 /* Record in frame F the specified or default value according to ALIST
2109 of the parameter named PARAM (a Lisp symbol).
2110 If no value is specified for PARAM, look for an X default for XPROP
2111 on the frame named NAME.
2112 If that is not found either, use the value DEFLT. */
2115 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
2122 enum resource_types type
;
2126 tem
= x_get_arg (alist
, prop
, xprop
, xclass
, type
);
2127 if (EQ (tem
, Qunbound
))
2129 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
2133 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
2134 "Parse an X-style geometry string STRING.\n\
2135 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).\n\
2136 The properties returned may include `top', `left', `height', and `width'.\n\
2137 The value of `left' or `top' may be an integer,\n\
2138 or a list (+ N) meaning N pixels relative to top/left corner,\n\
2139 or a list (- N) meaning -N pixels relative to bottom/right corner.")
2144 unsigned int width
, height
;
2147 CHECK_STRING (string
, 0);
2149 geometry
= XParseGeometry ((char *) XSTRING (string
)->data
,
2150 &x
, &y
, &width
, &height
);
2153 if (geometry
& XValue
)
2155 Lisp_Object element
;
2157 if (x
>= 0 && (geometry
& XNegative
))
2158 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
2159 else if (x
< 0 && ! (geometry
& XNegative
))
2160 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
2162 element
= Fcons (Qleft
, make_number (x
));
2163 result
= Fcons (element
, result
);
2166 if (geometry
& YValue
)
2168 Lisp_Object element
;
2170 if (y
>= 0 && (geometry
& YNegative
))
2171 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
2172 else if (y
< 0 && ! (geometry
& YNegative
))
2173 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
2175 element
= Fcons (Qtop
, make_number (y
));
2176 result
= Fcons (element
, result
);
2179 if (geometry
& WidthValue
)
2180 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
2181 if (geometry
& HeightValue
)
2182 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
2187 /* Calculate the desired size and position of this window,
2188 and return the flags saying which aspects were specified.
2190 This function does not make the coordinates positive. */
2192 #define DEFAULT_ROWS 40
2193 #define DEFAULT_COLS 80
2196 x_figure_window_size (f
, parms
)
2200 register Lisp_Object tem0
, tem1
, tem2
;
2201 int height
, width
, left
, top
;
2202 register int geometry
;
2203 long window_prompting
= 0;
2205 /* Default values if we fall through.
2206 Actually, if that happens we should get
2207 window manager prompting. */
2208 f
->width
= DEFAULT_COLS
;
2209 f
->height
= DEFAULT_ROWS
;
2210 /* Window managers expect that if program-specified
2211 positions are not (0,0), they're intentional, not defaults. */
2212 f
->output_data
.win32
->top_pos
= 0;
2213 f
->output_data
.win32
->left_pos
= 0;
2215 tem0
= x_get_arg (parms
, Qheight
, 0, 0, number
);
2216 tem1
= x_get_arg (parms
, Qwidth
, 0, 0, number
);
2217 tem2
= x_get_arg (parms
, Quser_size
, 0, 0, number
);
2218 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
2220 if (!EQ (tem0
, Qunbound
))
2222 CHECK_NUMBER (tem0
, 0);
2223 f
->height
= XINT (tem0
);
2225 if (!EQ (tem1
, Qunbound
))
2227 CHECK_NUMBER (tem1
, 0);
2228 f
->width
= XINT (tem1
);
2230 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
2231 window_prompting
|= USSize
;
2233 window_prompting
|= PSize
;
2236 f
->output_data
.win32
->vertical_scroll_bar_extra
2237 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2239 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) > 0
2240 ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f
)
2241 : (FRAME_SCROLL_BAR_COLS (f
) * FONT_WIDTH (f
->output_data
.win32
->font
)));
2242 f
->output_data
.win32
->pixel_width
= CHAR_TO_PIXEL_WIDTH (f
, f
->width
);
2243 f
->output_data
.win32
->pixel_height
= CHAR_TO_PIXEL_HEIGHT (f
, f
->height
);
2245 tem0
= x_get_arg (parms
, Qtop
, 0, 0, number
);
2246 tem1
= x_get_arg (parms
, Qleft
, 0, 0, number
);
2247 tem2
= x_get_arg (parms
, Quser_position
, 0, 0, number
);
2248 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
2250 if (EQ (tem0
, Qminus
))
2252 f
->output_data
.win32
->top_pos
= 0;
2253 window_prompting
|= YNegative
;
2255 else if (CONSP (tem0
) && EQ (XCONS (tem0
)->car
, Qminus
)
2256 && CONSP (XCONS (tem0
)->cdr
)
2257 && INTEGERP (XCONS (XCONS (tem0
)->cdr
)->car
))
2259 f
->output_data
.win32
->top_pos
= - XINT (XCONS (XCONS (tem0
)->cdr
)->car
);
2260 window_prompting
|= YNegative
;
2262 else if (CONSP (tem0
) && EQ (XCONS (tem0
)->car
, Qplus
)
2263 && CONSP (XCONS (tem0
)->cdr
)
2264 && INTEGERP (XCONS (XCONS (tem0
)->cdr
)->car
))
2266 f
->output_data
.win32
->top_pos
= XINT (XCONS (XCONS (tem0
)->cdr
)->car
);
2268 else if (EQ (tem0
, Qunbound
))
2269 f
->output_data
.win32
->top_pos
= 0;
2272 CHECK_NUMBER (tem0
, 0);
2273 f
->output_data
.win32
->top_pos
= XINT (tem0
);
2274 if (f
->output_data
.win32
->top_pos
< 0)
2275 window_prompting
|= YNegative
;
2278 if (EQ (tem1
, Qminus
))
2280 f
->output_data
.win32
->left_pos
= 0;
2281 window_prompting
|= XNegative
;
2283 else if (CONSP (tem1
) && EQ (XCONS (tem1
)->car
, Qminus
)
2284 && CONSP (XCONS (tem1
)->cdr
)
2285 && INTEGERP (XCONS (XCONS (tem1
)->cdr
)->car
))
2287 f
->output_data
.win32
->left_pos
= - XINT (XCONS (XCONS (tem1
)->cdr
)->car
);
2288 window_prompting
|= XNegative
;
2290 else if (CONSP (tem1
) && EQ (XCONS (tem1
)->car
, Qplus
)
2291 && CONSP (XCONS (tem1
)->cdr
)
2292 && INTEGERP (XCONS (XCONS (tem1
)->cdr
)->car
))
2294 f
->output_data
.win32
->left_pos
= XINT (XCONS (XCONS (tem1
)->cdr
)->car
);
2296 else if (EQ (tem1
, Qunbound
))
2297 f
->output_data
.win32
->left_pos
= 0;
2300 CHECK_NUMBER (tem1
, 0);
2301 f
->output_data
.win32
->left_pos
= XINT (tem1
);
2302 if (f
->output_data
.win32
->left_pos
< 0)
2303 window_prompting
|= XNegative
;
2306 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
2307 window_prompting
|= USPosition
;
2309 window_prompting
|= PPosition
;
2312 return window_prompting
;
2317 extern LRESULT CALLBACK
win32_wnd_proc ();
2320 win32_init_class (hinst
)
2325 wc
.style
= CS_HREDRAW
| CS_VREDRAW
| CS_OWNDC
;
2326 wc
.lpfnWndProc
= (WNDPROC
) win32_wnd_proc
;
2328 wc
.cbWndExtra
= WND_EXTRA_BYTES
;
2329 wc
.hInstance
= hinst
;
2330 wc
.hIcon
= LoadIcon (hinst
, EMACS_CLASS
);
2331 wc
.hCursor
= LoadCursor (NULL
, IDC_ARROW
);
2332 wc
.hbrBackground
= NULL
; // GetStockObject (WHITE_BRUSH);
2333 wc
.lpszMenuName
= NULL
;
2334 wc
.lpszClassName
= EMACS_CLASS
;
2336 return (RegisterClass (&wc
));
2340 win32_createscrollbar (f
, bar
)
2342 struct scroll_bar
* bar
;
2344 return (CreateWindow ("SCROLLBAR", "", SBS_VERT
| WS_CHILD
| WS_VISIBLE
,
2345 /* Position and size of scroll bar. */
2346 XINT(bar
->left
), XINT(bar
->top
),
2347 XINT(bar
->width
), XINT(bar
->height
),
2348 FRAME_WIN32_WINDOW (f
),
2355 win32_createwindow (f
)
2360 /* Do first time app init */
2364 win32_init_class (hinst
);
2367 FRAME_WIN32_WINDOW (f
) = hwnd
= CreateWindow (EMACS_CLASS
,
2369 f
->output_data
.win32
->dwStyle
| WS_CLIPCHILDREN
,
2370 f
->output_data
.win32
->left_pos
,
2371 f
->output_data
.win32
->top_pos
,
2381 SetWindowLong (hwnd
, WND_X_UNITS_INDEX
, FONT_WIDTH (f
->output_data
.win32
->font
));
2382 SetWindowLong (hwnd
, WND_Y_UNITS_INDEX
, f
->output_data
.win32
->line_height
);
2383 SetWindowLong (hwnd
, WND_BACKGROUND_INDEX
, f
->output_data
.win32
->background_pixel
);
2393 /* Ensure our message queue is created */
2395 PeekMessage (&msg
, NULL
, 0, 0, PM_NOREMOVE
);
2397 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, 0, 0);
2399 while (GetMessage (&msg
, NULL
, 0, 0))
2401 if (msg
.hwnd
== NULL
)
2403 switch (msg
.message
)
2405 case WM_EMACS_CREATEWINDOW
:
2406 win32_createwindow ((struct frame
*) msg
.wParam
);
2407 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, 0, 0);
2409 case WM_EMACS_CREATESCROLLBAR
:
2411 HWND hwnd
= win32_createscrollbar ((struct frame
*) msg
.wParam
,
2412 (struct scroll_bar
*) msg
.lParam
);
2413 PostThreadMessage (dwMainThreadId
, WM_EMACS_DONE
, (WPARAM
)hwnd
, 0);
2422 DispatchMessage (&msg
);
2436 /* Make mapping mode be in 1/20 of point */
2438 SetMapMode (hdc
, MM_ANISOTROPIC
);
2439 SetWindowExtEx (hdc
, 1440, 1440, NULL
);
2440 SetViewportExtEx (hdc
,
2441 GetDeviceCaps (hdc
, LOGPIXELSX
),
2442 GetDeviceCaps (hdc
, LOGPIXELSY
),
2449 /* Convert between the modifier bits Win32 uses and the modifier bits
2452 win32_get_modifiers ()
2454 return (((GetKeyState (VK_SHIFT
)&0x8000) ? shift_modifier
: 0) |
2455 ((GetKeyState (VK_CONTROL
)&0x8000) ? ctrl_modifier
: 0) |
2456 ((GetKeyState (VK_MENU
)&0x8000) ? meta_modifier
: 0));
2460 my_post_msg (wmsg
, hwnd
, msg
, wParam
, lParam
)
2467 wmsg
->msg
.hwnd
= hwnd
;
2468 wmsg
->msg
.message
= msg
;
2469 wmsg
->msg
.wParam
= wParam
;
2470 wmsg
->msg
.lParam
= lParam
;
2471 wmsg
->msg
.time
= GetMessageTime ();
2476 /* Main window procedure */
2478 extern char *lispy_function_keys
[];
2481 win32_wnd_proc (hwnd
, msg
, wParam
, lParam
)
2489 struct win32_display_info
*dpyinfo
= &one_win32_display_info
;
2500 GetClientRect (hwnd
, &rect
);
2502 hb
= CreateSolidBrush (GetWindowLong (hwnd
, WND_BACKGROUND_INDEX
));
2504 oldobj
= SelectObject ((HDC
)wParam
, hb
);
2506 FillRect((HDC
)wParam
, &rect
, hb
);
2508 SelectObject((HDC
)wParam
, oldobj
);
2516 PAINTSTRUCT paintStruct
;
2518 BeginPaint (hwnd
, &paintStruct
);
2519 wmsg
.rect
= paintStruct
.rcPaint
;
2520 EndPaint (hwnd
, &paintStruct
);
2522 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
2529 HDC hdc
= my_get_dc (hwnd
);
2531 /* Make mapping mode be in 1/20 of point */
2535 ReleaseDC (hwnd
, hdc
);
2542 if (! ((wParam
>= VK_BACK
&& wParam
<= VK_TAB
)
2543 || (wParam
>= VK_CLEAR
&& wParam
<= VK_RETURN
)
2544 || (wParam
== VK_ESCAPE
)
2545 || (wParam
>= VK_PRIOR
&& wParam
<= VK_HELP
)
2546 || (wParam
>= VK_LWIN
&& wParam
<= VK_APPS
)
2547 || (wParam
>= VK_NUMPAD0
&& wParam
<= VK_F24
)
2548 || (wParam
>= VK_NUMLOCK
&& wParam
<= VK_SCROLL
)
2549 || (wParam
>= VK_ATTN
&& wParam
<= VK_OEM_CLEAR
)
2550 || !TranslateMessage (&msg1
)))
2556 /* Check for special characters since translate message
2557 seems to always indicate true. */
2559 if (wParam
== VK_MENU
2560 || wParam
== VK_SHIFT
2561 || wParam
== VK_CONTROL
2562 || wParam
== VK_CAPITAL
)
2565 /* Anything we do not have a name for needs to be translated or
2566 returned as ascii keystroke. */
2568 if (lispy_function_keys
[wParam
] == 0)
2574 msg1
.wParam
= wParam
;
2575 msg1
.lParam
= lParam
;
2577 if (TranslateMessage (&msg1
))
2587 wmsg
.dwModifiers
= win32_get_modifiers ();
2589 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
2591 case WM_LBUTTONDOWN
:
2593 case WM_MBUTTONDOWN
:
2595 case WM_RBUTTONDOWN
:
2600 if (parse_button (msg
, NULL
, &up
))
2602 if (up
) ReleaseCapture ();
2603 else SetCapture (hwnd
);
2607 wmsg
.dwModifiers
= win32_get_modifiers ();
2609 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
2620 my_post_msg (&wmsg
, hwnd
, msg
, wParam
, lParam
);
2622 case WM_WINDOWPOSCHANGING
:
2625 LPWINDOWPOS lppos
= (WINDOWPOS
*) lParam
;
2627 GetWindowPlacement (hwnd
, &wp
);
2629 if (wp
.showCmd
!= SW_SHOWMINIMIZED
&& ! (lppos
->flags
& SWP_NOSIZE
))
2638 GetWindowRect (hwnd
, &wr
);
2642 dwXUnits
= GetWindowLong (hwnd
, WND_X_UNITS_INDEX
);
2643 dwYUnits
= GetWindowLong (hwnd
, WND_Y_UNITS_INDEX
);
2647 memset (&rect
, 0, sizeof (rect
));
2648 AdjustWindowRect (&rect
, GetWindowLong (hwnd
, GWL_STYLE
),
2649 GetMenu (hwnd
) != NULL
);
2651 /* All windows have an extra pixel so subtract 1 */
2653 wdiff
= (lppos
->cx
- (rect
.right
- rect
.left
) - 0) % dwXUnits
;
2654 hdiff
= (lppos
->cy
- (rect
.bottom
- rect
.top
) - 0) % dwYUnits
;
2658 /* For right/bottom sizing we can just fix the sizes.
2659 However for top/left sizing we will need to fix the X
2660 and Y positions as well. */
2665 if (wp
.showCmd
!= SW_SHOWMAXIMIZED
2666 && ! (lppos
->flags
& SWP_NOMOVE
))
2668 if (lppos
->x
!= wr
.left
|| lppos
->y
!= wr
.top
)
2675 lppos
->flags
|= SWP_NOMOVE
;
2684 if (ret
== 0) return (0);
2687 case WM_EMACS_DESTROYWINDOW
:
2688 DestroyWindow ((HWND
) wParam
);
2692 return DefWindowProc (hwnd
, msg
, wParam
, lParam
);
2699 my_create_window (f
)
2704 PostThreadMessage (dwWinThreadId
, WM_EMACS_CREATEWINDOW
, (WPARAM
)f
, 0);
2705 GetMessage (&msg
, NULL
, WM_EMACS_DONE
, WM_EMACS_DONE
);
2708 /* Create and set up the win32 window for frame F. */
2711 win32_window (f
, window_prompting
, minibuffer_only
)
2713 long window_prompting
;
2714 int minibuffer_only
;
2718 /* Use the resource name as the top-level window name
2719 for looking up resources. Make a non-Lisp copy
2720 for the window manager, so GC relocation won't bother it.
2722 Elsewhere we specify the window name for the window manager. */
2725 char *str
= (char *) XSTRING (Vx_resource_name
)->data
;
2726 f
->namebuf
= (char *) xmalloc (strlen (str
) + 1);
2727 strcpy (f
->namebuf
, str
);
2730 my_create_window (f
);
2732 validate_x_resource_name ();
2734 /* x_set_name normally ignores requests to set the name if the
2735 requested name is the same as the current name. This is the one
2736 place where that assumption isn't correct; f->name is set, but
2737 the server hasn't been told. */
2740 int explicit = f
->explicit_name
;
2742 f
->explicit_name
= 0;
2745 x_set_name (f
, name
, explicit);
2750 if (!minibuffer_only
&& FRAME_EXTERNAL_MENU_BAR (f
))
2751 initialize_frame_menubar (f
);
2753 if (FRAME_WIN32_WINDOW (f
) == 0)
2754 error ("Unable to create window");
2757 /* Handle the icon stuff for this window. Perhaps later we might
2758 want an x_set_icon_position which can be called interactively as
2766 Lisp_Object icon_x
, icon_y
;
2768 /* Set the position of the icon. Note that win95 groups all
2769 icons in the tray. */
2770 icon_x
= x_get_arg (parms
, Qicon_left
, 0, 0, number
);
2771 icon_y
= x_get_arg (parms
, Qicon_top
, 0, 0, number
);
2772 if (!EQ (icon_x
, Qunbound
) && !EQ (icon_y
, Qunbound
))
2774 CHECK_NUMBER (icon_x
, 0);
2775 CHECK_NUMBER (icon_y
, 0);
2777 else if (!EQ (icon_x
, Qunbound
) || !EQ (icon_y
, Qunbound
))
2778 error ("Both left and top icon corners of icon must be specified");
2782 if (! EQ (icon_x
, Qunbound
))
2783 x_wm_set_icon_position (f
, XINT (icon_x
), XINT (icon_y
));
2788 DEFUN ("x-create-frame", Fx_create_frame
, Sx_create_frame
,
2790 "Make a new window, which is called a \"frame\" in Emacs terms.\n\
2791 Returns an Emacs frame object.\n\
2792 ALIST is an alist of frame parameters.\n\
2793 If the parameters specify that the frame should not have a minibuffer,\n\
2794 and do not specify a specific minibuffer window to use,\n\
2795 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
2796 be shared by the new frame.\n\
2798 This function is an internal primitive--use `make-frame' instead.")
2803 Lisp_Object frame
, tem
;
2805 int minibuffer_only
= 0;
2806 long window_prompting
= 0;
2808 int count
= specpdl_ptr
- specpdl
;
2809 struct gcpro gcpro1
;
2810 Lisp_Object display
;
2811 struct win32_display_info
*dpyinfo
;
2815 /* Use this general default value to start with
2816 until we know if this frame has a specified name. */
2817 Vx_resource_name
= Vinvocation_name
;
2819 display
= x_get_arg (parms
, Qdisplay
, 0, 0, string
);
2820 if (EQ (display
, Qunbound
))
2822 dpyinfo
= check_x_display_info (display
);
2824 kb
= dpyinfo
->kboard
;
2826 kb
= &the_only_kboard
;
2829 name
= x_get_arg (parms
, Qname
, "title", "Title", string
);
2831 && ! EQ (name
, Qunbound
)
2833 error ("Invalid frame name--not a string or nil");
2836 Vx_resource_name
= name
;
2838 /* See if parent window is specified. */
2839 parent
= x_get_arg (parms
, Qparent_id
, NULL
, NULL
, number
);
2840 if (EQ (parent
, Qunbound
))
2842 if (! NILP (parent
))
2843 CHECK_NUMBER (parent
, 0);
2845 tem
= x_get_arg (parms
, Qminibuffer
, 0, 0, symbol
);
2846 if (EQ (tem
, Qnone
) || NILP (tem
))
2847 f
= make_frame_without_minibuffer (Qnil
, kb
, display
);
2848 else if (EQ (tem
, Qonly
))
2850 f
= make_minibuffer_frame ();
2851 minibuffer_only
= 1;
2853 else if (WINDOWP (tem
))
2854 f
= make_frame_without_minibuffer (tem
, kb
, display
);
2858 /* Note that Windows does support scroll bars. */
2859 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 1;
2861 XSETFRAME (frame
, f
);
2864 f
->output_method
= output_win32
;
2865 f
->output_data
.win32
= (struct win32_output
*) xmalloc (sizeof (struct win32_output
));
2866 bzero (f
->output_data
.win32
, sizeof (struct win32_output
));
2868 /* FRAME_WIN32_DISPLAY_INFO (f) = dpyinfo; */
2870 FRAME_KBOARD (f
) = kb
;
2873 /* Specify the parent under which to make this window. */
2877 f
->output_data
.win32
->parent_desc
= (Window
) parent
;
2878 f
->output_data
.win32
->explicit_parent
= 1;
2882 f
->output_data
.win32
->parent_desc
= FRAME_WIN32_DISPLAY_INFO (f
)->root_window
;
2883 f
->output_data
.win32
->explicit_parent
= 0;
2886 /* Note that the frame has no physical cursor right now. */
2887 f
->phys_cursor_x
= -1;
2889 /* Set the name; the functions to which we pass f expect the name to
2891 if (EQ (name
, Qunbound
) || NILP (name
))
2893 f
->name
= build_string (dpyinfo
->win32_id_name
);
2894 f
->explicit_name
= 0;
2899 f
->explicit_name
= 1;
2900 /* use the frame's title when getting resources for this frame. */
2901 specbind (Qx_resource_name
, name
);
2904 /* Extract the window parameters from the supplied values
2905 that are needed to determine window geometry. */
2909 font
= x_get_arg (parms
, Qfont
, "font", "Font", string
);
2911 /* First, try whatever font the caller has specified. */
2913 font
= x_new_font (f
, XSTRING (font
)->data
);
2915 /* Try out a font which we hope has bold and italic variations. */
2916 if (!STRINGP (font
))
2917 font
= x_new_font (f
, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
2918 if (! STRINGP (font
))
2919 font
= x_new_font (f
, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
2920 if (! STRINGP (font
))
2921 /* This was formerly the first thing tried, but it finds too many fonts
2922 and takes too long. */
2923 font
= x_new_font (f
, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
2924 /* If those didn't work, look for something which will at least work. */
2925 if (! STRINGP (font
))
2926 font
= x_new_font (f
, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
2927 if (! STRINGP (font
))
2928 font
= x_new_font (f
, "-*-system-medium-r-normal-*-*-200-*-*-c-120-*-*");
2930 if (! STRINGP (font
))
2931 font
= x_new_font (f
, "-*-terminal-medium-r-normal-*-*-180-*-*-c-120-*-*");
2933 if (! STRINGP (font
))
2934 font
= build_string ("-*-system");
2936 x_default_parameter (f
, parms
, Qfont
, font
,
2937 "font", "Font", string
);
2940 x_default_parameter (f
, parms
, Qborder_width
, make_number (2),
2941 "borderwidth", "BorderWidth", number
);
2942 /* This defaults to 2 in order to match xterm. We recognize either
2943 internalBorderWidth or internalBorder (which is what xterm calls
2945 if (NILP (Fassq (Qinternal_border_width
, parms
)))
2949 value
= x_get_arg (parms
, Qinternal_border_width
,
2950 "internalBorder", "BorderWidth", number
);
2951 if (! EQ (value
, Qunbound
))
2952 parms
= Fcons (Fcons (Qinternal_border_width
, value
),
2955 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (0),
2956 "internalBorderWidth", "BorderWidth", number
);
2957 x_default_parameter (f
, parms
, Qvertical_scroll_bars
, Qt
,
2958 "verticalScrollBars", "ScrollBars", boolean
);
2960 /* Also do the stuff which must be set before the window exists. */
2961 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
2962 "foreground", "Foreground", string
);
2963 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
2964 "background", "Background", string
);
2965 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
2966 "pointerColor", "Foreground", string
);
2967 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
2968 "cursorColor", "Foreground", string
);
2969 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
2970 "borderColor", "BorderColor", string
);
2972 x_default_parameter (f
, parms
, Qmenu_bar_lines
, make_number (1),
2973 "menuBar", "MenuBar", number
);
2974 x_default_parameter (f
, parms
, Qscroll_bar_width
, Qnil
,
2975 "scrollBarWidth", "ScrollBarWidth", number
);
2977 f
->output_data
.win32
->dwStyle
= WS_OVERLAPPEDWINDOW
;
2978 f
->output_data
.win32
->parent_desc
= FRAME_WIN32_DISPLAY_INFO (f
)->root_window
;
2979 window_prompting
= x_figure_window_size (f
, parms
);
2981 if (window_prompting
& XNegative
)
2983 if (window_prompting
& YNegative
)
2984 f
->output_data
.win32
->win_gravity
= SouthEastGravity
;
2986 f
->output_data
.win32
->win_gravity
= NorthEastGravity
;
2990 if (window_prompting
& YNegative
)
2991 f
->output_data
.win32
->win_gravity
= SouthWestGravity
;
2993 f
->output_data
.win32
->win_gravity
= NorthWestGravity
;
2996 f
->output_data
.win32
->size_hint_flags
= window_prompting
;
2998 win32_window (f
, window_prompting
, minibuffer_only
);
3000 init_frame_faces (f
);
3002 /* We need to do this after creating the window, so that the
3003 icon-creation functions can say whose icon they're describing. */
3004 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
3005 "bitmapIcon", "BitmapIcon", symbol
);
3007 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
3008 "autoRaise", "AutoRaiseLower", boolean
);
3009 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
3010 "autoLower", "AutoRaiseLower", boolean
);
3011 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
3012 "cursorType", "CursorType", symbol
);
3014 /* Dimensions, especially f->height, must be done via change_frame_size.
3015 Change will not be effected unless different from the current
3019 f
->height
= f
->width
= 0;
3020 change_frame_size (f
, height
, width
, 1, 0);
3022 /* Tell the server what size and position, etc, we want,
3023 and how badly we want them. */
3025 x_wm_set_size_hint (f
, window_prompting
, 0);
3028 tem
= x_get_arg (parms
, Qunsplittable
, 0, 0, boolean
);
3029 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
3033 /* It is now ok to make the frame official
3034 even if we get an error below.
3035 And the frame needs to be on Vframe_list
3036 or making it visible won't work. */
3037 Vframe_list
= Fcons (frame
, Vframe_list
);
3039 /* Now that the frame is official, it counts as a reference to
3041 FRAME_WIN32_DISPLAY_INFO (f
)->reference_count
++;
3043 /* Make the window appear on the frame and enable display,
3044 unless the caller says not to. However, with explicit parent,
3045 Emacs cannot control visibility, so don't try. */
3046 if (! f
->output_data
.win32
->explicit_parent
)
3048 Lisp_Object visibility
;
3050 visibility
= x_get_arg (parms
, Qvisibility
, 0, 0, symbol
);
3051 if (EQ (visibility
, Qunbound
))
3054 if (EQ (visibility
, Qicon
))
3055 x_iconify_frame (f
);
3056 else if (! NILP (visibility
))
3057 x_make_frame_visible (f
);
3059 /* Must have been Qnil. */
3063 return unbind_to (count
, frame
);
3066 /* FRAME is used only to get a handle on the X display. We don't pass the
3067 display info directly because we're called from frame.c, which doesn't
3068 know about that structure. */
3070 x_get_focus_frame (frame
)
3071 struct frame
*frame
;
3073 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (frame
);
3075 if (! dpyinfo
->win32_focus_frame
)
3078 XSETFRAME (xfocus
, dpyinfo
->win32_focus_frame
);
3082 DEFUN ("focus-frame", Ffocus_frame
, Sfocus_frame
, 1, 1, 0,
3083 "Set the focus on FRAME.")
3087 CHECK_LIVE_FRAME (frame
, 0);
3089 if (FRAME_WIN32_P (XFRAME (frame
)))
3092 x_focus_on_frame (XFRAME (frame
));
3100 DEFUN ("unfocus-frame", Funfocus_frame
, Sunfocus_frame
, 0, 0, 0,
3101 "If a frame has been focused, release it.")
3104 if (FRAME_WIN32_P (selected_frame
))
3106 struct win32_display_info
*dpyinfo
= FRAME_WIN32_DISPLAY_INFO (selected_frame
);
3108 if (dpyinfo
->win32_focus_frame
)
3111 x_unfocus_frame (dpyinfo
->win32_focus_frame
);
3120 *win32_load_font (dpyinfo
,name
)
3121 struct win32_display_info
*dpyinfo
;
3124 XFontStruct
* font
= NULL
;
3130 if (!name
|| !x_to_win32_font(name
, &lf
))
3133 font
= (XFontStruct
*) xmalloc (sizeof (XFontStruct
));
3135 if (!font
) return (NULL
);
3139 font
->hfont
= CreateFontIndirect(&lf
);
3142 if (font
->hfont
== NULL
)
3151 hdc
= my_get_dc (dpyinfo
->root_window
);
3153 oldobj
= SelectObject (hdc
, font
->hfont
);
3155 ok
= GetTextMetrics (hdc
, &font
->tm
);
3157 SelectObject (hdc
, oldobj
);
3159 ReleaseDC (dpyinfo
->root_window
, hdc
);
3164 if (ok
) return (font
);
3166 win32_unload_font(dpyinfo
, font
);
3171 win32_unload_font (dpyinfo
, font
)
3172 struct win32_display_info
*dpyinfo
;
3177 if (font
->hfont
) DeleteObject(font
->hfont
);
3182 /* The font conversion stuff between x and win32 */
3184 /* X font string is as follows (from faces.el)
3188 * (weight "\\(bold\\|demibold\\|medium\\)") ; 1
3189 * (weight\? "\\([^-]*\\)") ; 1
3190 * (slant "\\([ior]\\)") ; 2
3191 * (slant\? "\\([^-]?\\)") ; 2
3192 * (swidth "\\([^-]*\\)") ; 3
3193 * (adstyle "[^-]*") ; 4
3194 * (pixelsize "[0-9]+")
3195 * (pointsize "[0-9][0-9]+")
3196 * (resx "[0-9][0-9]+")
3197 * (resy "[0-9][0-9]+")
3198 * (spacing "[cmp?*]")
3199 * (avgwidth "[0-9]+")
3200 * (registry "[^-]+")
3201 * (encoding "[^-]+")
3203 * (setq x-font-regexp
3204 * (concat "\\`\\*?[-?*]"
3205 * foundry - family - weight\? - slant\? - swidth - adstyle -
3206 * pixelsize - pointsize - resx - resy - spacing - registry -
3207 * encoding "[-?*]\\*?\\'"
3209 * (setq x-font-regexp-head
3210 * (concat "\\`[-?*]" foundry - family - weight\? - slant\?
3211 * "\\([-*?]\\|\\'\\)"))
3212 * (setq x-font-regexp-slant (concat - slant -))
3213 * (setq x-font-regexp-weight (concat - weight -))
3217 #define FONT_START "[-?]"
3218 #define FONT_FOUNDRY "[^-]+"
3219 #define FONT_FAMILY "\\([^-]+\\)" /* 1 */
3220 #define FONT_WEIGHT "\\(bold\\|demibold\\|medium\\)" /* 2 */
3221 #define FONT_WEIGHT_Q "\\([^-]*\\)" /* 2 */
3222 #define FONT_SLANT "\\([ior]\\)" /* 3 */
3223 #define FONT_SLANT_Q "\\([^-]?\\)" /* 3 */
3224 #define FONT_SWIDTH "\\([^-]*\\)" /* 4 */
3225 #define FONT_ADSTYLE "[^-]*"
3226 #define FONT_PIXELSIZE "[^-]*"
3227 #define FONT_POINTSIZE "\\([0-9][0-9]+\\|\\*\\)" /* 5 */
3228 #define FONT_RESX "[0-9][0-9]+"
3229 #define FONT_RESY "[0-9][0-9]+"
3230 #define FONT_SPACING "[cmp?*]"
3231 #define FONT_AVGWIDTH "[0-9]+"
3232 #define FONT_REGISTRY "[^-]+"
3233 #define FONT_ENCODING "[^-]+"
3235 #define FONT_REGEXP ("\\`\\*?[-?*]" \
3242 FONT_PIXELSIZE "-" \
3243 FONT_POINTSIZE "-" \
3246 #define FONT_REGEXP_HEAD ("\\`[-?*]" \
3251 "\\([-*?]\\|\\'\\)")
3253 #define FONT_REGEXP_SLANT "-" FONT_SLANT "-"
3254 #define FONT_REGEXP_WEIGHT "-" FONT_WEIGHT "-"
3257 x_to_win32_weight (lpw
)
3260 if (!lpw
) return (FW_DONTCARE
);
3262 if (stricmp (lpw
, "bold") == 0)
3264 else if (stricmp (lpw
, "demibold") == 0)
3265 return (FW_SEMIBOLD
);
3266 else if (stricmp (lpw
, "medium") == 0)
3268 else if (stricmp (lpw
, "normal") == 0)
3271 return (FW_DONTCARE
);
3275 win32_to_x_weight (fnweight
)
3278 if (fnweight
>= FW_BOLD
)
3280 else if (fnweight
>= FW_SEMIBOLD
)
3281 return ("demibold");
3282 else if (fnweight
>= FW_MEDIUM
)
3289 win32_to_x_font (lplogfont
, lpxstr
, len
)
3290 LOGFONT
* lplogfont
;
3294 if (!lpxstr
) return (FALSE
);
3298 int height
= (lplogfont
->lfHeight
* 1440)
3299 / one_win32_display_info
.height_in
;
3300 int width
= (lplogfont
->lfWidth
* 1440)
3301 / one_win32_display_info
.width_in
;
3303 height
= abs (height
);
3304 _snprintf (lpxstr
, len
- 1,
3305 "-*-%s-%s-%c-%s-%s-*-%d-*-*-%c-%d-*-*-",
3306 lplogfont
->lfFaceName
,
3307 win32_to_x_weight (lplogfont
->lfWeight
),
3308 lplogfont
->lfItalic
? 'i' : 'r',
3311 ((lplogfont
->lfPitchAndFamily
& 0x3) == VARIABLE_PITCH
) ? 'p' : 'c',
3316 strncpy (lpxstr
, "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-", len
- 1);
3319 lpxstr
[len
- 1] = 0; /* just to be sure */
3324 x_to_win32_font (lpxstr
, lplogfont
)
3326 LOGFONT
* lplogfont
;
3328 if (!lplogfont
) return (FALSE
);
3330 memset (lplogfont
, 0, sizeof (*lplogfont
));
3332 lplogfont
->lfCharSet
= OEM_CHARSET
;
3333 lplogfont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
3334 lplogfont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
3335 lplogfont
->lfQuality
= DEFAULT_QUALITY
;
3337 if (lpxstr
&& *lpxstr
== '-') lpxstr
++;
3341 char name
[50], weight
[20], slant
, pitch
, height
[10], width
[10];
3345 "%*[^-]-%[^-]-%[^-]-%c-%*[^-]-%*[^-]-%*[^-]-%[^-]-%*[^-]-%*[^-]-%c-%[^-]",
3346 name
, weight
, &slant
, height
, &pitch
, width
)
3349 if (fields
== EOF
) return (FALSE
);
3351 if (fields
> 0 && name
[0] != '*')
3353 strncpy (lplogfont
->lfFaceName
, name
, LF_FACESIZE
);
3357 lplogfont
->lfFaceName
[0] = 0;
3362 lplogfont
->lfWeight
= x_to_win32_weight((fields
> 0 ? weight
: ""));
3366 lplogfont
->lfItalic
= (fields
> 0 && slant
== 'i');
3370 if (fields
> 0 && height
[0] != '*')
3371 lplogfont
->lfHeight
= (atoi (height
) * one_win32_display_info
.height_in
) / 1440;
3375 lplogfont
->lfPitchAndFamily
= (fields
> 0 && pitch
== 'p') ? VARIABLE_PITCH
: FIXED_PITCH
;
3379 if (fields
> 0 && width
[0] != '*')
3380 lplogfont
->lfWidth
= (atoi (width
) * one_win32_display_info
.width_in
) / 1440;
3387 win32_font_match (lpszfont1
, lpszfont2
)
3391 char * s1
= lpszfont1
, *e1
;
3392 char * s2
= lpszfont2
, *e2
;
3394 if (s1
== NULL
|| s2
== NULL
) return (FALSE
);
3396 if (*s1
== '-') s1
++;
3397 if (*s2
== '-') s2
++;
3403 e1
= strchr (s1
, '-');
3404 e2
= strchr (s2
, '-');
3406 if (e1
== NULL
|| e2
== NULL
) return (TRUE
);
3411 if (*s1
!= '*' && *s2
!= '*'
3412 && (len1
!= len2
|| strnicmp (s1
, s2
, len1
) != 0))
3420 typedef struct enumfont_t
3424 XFontStruct
*size_ref
;
3425 Lisp_Object
*pattern
;
3431 enum_font_cb2 (lplf
, lptm
, FontType
, lpef
)
3433 NEWTEXTMETRIC
* lptm
;
3437 if (lplf
->elfLogFont
.lfStrikeOut
|| lplf
->elfLogFont
.lfUnderline
3438 || (lplf
->elfLogFont
.lfCharSet
!= ANSI_CHARSET
&& lplf
->elfLogFont
.lfCharSet
!= OEM_CHARSET
))
3441 /* if (!lpef->size_ref || lptm->tmMaxCharWidth == FONT_WIDTH (lpef->size_ref)) */
3445 if (!win32_to_x_font (lplf
, buf
, 100)) return (0);
3447 if (NILP (*(lpef
->pattern
)) || win32_font_match (buf
, XSTRING (*(lpef
->pattern
))->data
))
3449 *lpef
->tail
= Fcons (build_string (buf
), Qnil
);
3450 lpef
->tail
= &XCONS (*lpef
->tail
)->cdr
;
3459 enum_font_cb1 (lplf
, lptm
, FontType
, lpef
)
3461 NEWTEXTMETRIC
* lptm
;
3465 return EnumFontFamilies (lpef
->hdc
,
3466 lplf
->elfLogFont
.lfFaceName
,
3467 (FONTENUMPROC
) enum_font_cb2
,
3472 DEFUN ("x-list-fonts", Fx_list_fonts
, Sx_list_fonts
, 1, 3, 0,
3473 "Return a list of the names of available fonts matching PATTERN.\n\
3474 If optional arguments FACE and FRAME are specified, return only fonts\n\
3475 the same size as FACE on FRAME.\n\
3477 PATTERN is a string, perhaps with wildcard characters;\n\
3478 the * character matches any substring, and\n\
3479 the ? character matches any single character.\n\
3480 PATTERN is case-insensitive.\n\
3481 FACE is a face name--a symbol.\n\
3483 The return value is a list of strings, suitable as arguments to\n\
3486 Fonts Emacs can't use (i.e. proportional fonts) may or may not be excluded\n\
3487 even if they match PATTERN and FACE.")
3488 (pattern
, face
, frame
)
3489 Lisp_Object pattern
, face
, frame
;
3494 XFontStruct
*size_ref
;
3495 Lisp_Object namelist
;
3500 CHECK_STRING (pattern
, 0);
3502 CHECK_SYMBOL (face
, 1);
3504 f
= check_x_frame (frame
);
3506 /* Determine the width standard for comparison with the fonts we find. */
3514 /* Don't die if we get called with a terminal frame. */
3515 if (! FRAME_WIN32_P (f
))
3516 error ("non-win32 frame used in `x-list-fonts'");
3518 face_id
= face_name_id_number (f
, face
);
3520 if (face_id
< 0 || face_id
>= FRAME_N_PARAM_FACES (f
)
3521 || FRAME_PARAM_FACES (f
) [face_id
] == 0)
3522 size_ref
= f
->output_data
.win32
->font
;
3525 size_ref
= FRAME_PARAM_FACES (f
) [face_id
]->font
;
3526 if (size_ref
== (XFontStruct
*) (~0))
3527 size_ref
= f
->output_data
.win32
->font
;
3531 /* See if we cached the result for this particular query. */
3532 list
= Fassoc (pattern
,
3533 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
);
3535 /* We have info in the cache for this PATTERN. */
3538 Lisp_Object tem
, newlist
;
3540 /* We have info about this pattern. */
3541 list
= XCONS (list
)->cdr
;
3548 /* Filter the cached info and return just the fonts that match FACE. */
3550 for (tem
= list
; CONSP (tem
); tem
= XCONS (tem
)->cdr
)
3552 XFontStruct
*thisinfo
;
3554 thisinfo
= win32_load_font (FRAME_WIN32_DISPLAY_INFO (f
), XSTRING (XCONS (tem
)->car
)->data
);
3556 if (thisinfo
&& same_size_fonts (thisinfo
, size_ref
))
3557 newlist
= Fcons (XCONS (tem
)->car
, newlist
);
3559 win32_unload_font (FRAME_WIN32_DISPLAY_INFO (f
), thisinfo
);
3570 ef
.pattern
= &pattern
;
3571 ef
.tail
= ef
.head
= &namelist
;
3575 ef
.hdc
= my_get_dc (FRAME_WIN32_WINDOW (f
));
3577 EnumFontFamilies (ef
.hdc
, NULL
, (FONTENUMPROC
) enum_font_cb1
, (LPARAM
)&ef
);
3579 ReleaseDC (FRAME_WIN32_WINDOW (f
), ef
.hdc
);
3589 /* Make a list of all the fonts we got back.
3590 Store that in the font cache for the display. */
3591 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
3592 = Fcons (Fcons (pattern
, namelist
),
3593 XCONS (FRAME_WIN32_DISPLAY_INFO (f
)->name_list_element
)->cdr
);
3595 /* Make a list of the fonts that have the right width. */
3598 for (i
= 0; i
< ef
.numFonts
; i
++)
3606 XFontStruct
*thisinfo
;
3609 thisinfo
= win32_load_font (FRAME_WIN32_DISPLAY_INFO (f
), XSTRING (Fcar (cur
))->data
);
3611 keeper
= thisinfo
&& same_size_fonts (thisinfo
, size_ref
);
3613 win32_unload_font (FRAME_WIN32_DISPLAY_INFO (f
), thisinfo
);
3618 list
= Fcons (build_string (XSTRING (Fcar (cur
))->data
), list
);
3622 list
= Fnreverse (list
);
3628 DEFUN ("x-color-defined-p", Fx_color_defined_p
, Sx_color_defined_p
, 1, 2, 0,
3629 "Return non-nil if color COLOR is supported on frame FRAME.\n\
3630 If FRAME is omitted or nil, use the selected frame.")
3632 Lisp_Object color
, frame
;
3635 FRAME_PTR f
= check_x_frame (frame
);
3637 CHECK_STRING (color
, 1);
3639 if (defined_color (f
, XSTRING (color
)->data
, &foo
, 0))
3645 DEFUN ("x-color-values", Fx_color_values
, Sx_color_values
, 1, 2, 0,
3646 "Return a description of the color named COLOR on frame FRAME.\n\
3647 The value is a list of integer RGB values--(RED GREEN BLUE).\n\
3648 These values appear to range from 0 to 65280 or 65535, depending\n\
3649 on the system; white is (65280 65280 65280) or (65535 65535 65535).\n\
3650 If FRAME is omitted or nil, use the selected frame.")
3652 Lisp_Object color
, frame
;
3655 FRAME_PTR f
= check_x_frame (frame
);
3657 CHECK_STRING (color
, 1);
3659 if (defined_color (f
, XSTRING (color
)->data
, &foo
, 0))
3663 rgb
[0] = make_number (GetRValue (foo
));
3664 rgb
[1] = make_number (GetGValue (foo
));
3665 rgb
[2] = make_number (GetBValue (foo
));
3666 return Flist (3, rgb
);
3672 DEFUN ("x-display-color-p", Fx_display_color_p
, Sx_display_color_p
, 0, 1, 0,
3673 "Return t if the X display supports color.\n\
3674 The optional argument DISPLAY specifies which display to ask about.\n\
3675 DISPLAY should be either a frame or a display name (a string).\n\
3676 If omitted or nil, that stands for the selected frame's display.")
3678 Lisp_Object display
;
3680 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3682 if ((dpyinfo
->n_planes
* dpyinfo
->n_cbits
) <= 2)
3688 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p
, Sx_display_grayscale_p
,
3690 "Return t if the X display supports shades of gray.\n\
3691 Note that color displays do support shades of gray.\n\
3692 The optional argument DISPLAY specifies which display to ask about.\n\
3693 DISPLAY should be either a frame or a display name (a string).\n\
3694 If omitted or nil, that stands for the selected frame's display.")
3696 Lisp_Object display
;
3698 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3700 if ((dpyinfo
->n_planes
* dpyinfo
->n_cbits
) <= 1)
3706 DEFUN ("x-display-pixel-width", Fx_display_pixel_width
, Sx_display_pixel_width
,
3708 "Returns the width in pixels of the X display DISPLAY.\n\
3709 The optional argument DISPLAY specifies which display to ask about.\n\
3710 DISPLAY should be either a frame or a display name (a string).\n\
3711 If omitted or nil, that stands for the selected frame's display.")
3713 Lisp_Object display
;
3715 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3717 return make_number (dpyinfo
->width
);
3720 DEFUN ("x-display-pixel-height", Fx_display_pixel_height
,
3721 Sx_display_pixel_height
, 0, 1, 0,
3722 "Returns the height in pixels of the X display DISPLAY.\n\
3723 The optional argument DISPLAY specifies which display to ask about.\n\
3724 DISPLAY should be either a frame or a display name (a string).\n\
3725 If omitted or nil, that stands for the selected frame's display.")
3727 Lisp_Object display
;
3729 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3731 return make_number (dpyinfo
->height
);
3734 DEFUN ("x-display-planes", Fx_display_planes
, Sx_display_planes
,
3736 "Returns the number of bitplanes of the display DISPLAY.\n\
3737 The optional argument DISPLAY specifies which display to ask about.\n\
3738 DISPLAY should be either a frame or a display name (a string).\n\
3739 If omitted or nil, that stands for the selected frame's display.")
3741 Lisp_Object display
;
3743 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3745 return make_number (dpyinfo
->n_planes
* dpyinfo
->n_cbits
);
3748 DEFUN ("x-display-color-cells", Fx_display_color_cells
, Sx_display_color_cells
,
3750 "Returns the number of color cells of the display DISPLAY.\n\
3751 The optional argument DISPLAY specifies which display to ask about.\n\
3752 DISPLAY should be either a frame or a display name (a string).\n\
3753 If omitted or nil, that stands for the selected frame's display.")
3755 Lisp_Object display
;
3757 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3761 hdc
= my_get_dc (dpyinfo
->root_window
);
3763 cap
= GetDeviceCaps (hdc
,NUMCOLORS
);
3765 ReleaseDC (dpyinfo
->root_window
, hdc
);
3767 return make_number (cap
);
3770 DEFUN ("x-server-max-request-size", Fx_server_max_request_size
,
3771 Sx_server_max_request_size
,
3773 "Returns the maximum request size of the server of display DISPLAY.\n\
3774 The optional argument DISPLAY specifies which display to ask about.\n\
3775 DISPLAY should be either a frame or a display name (a string).\n\
3776 If omitted or nil, that stands for the selected frame's display.")
3778 Lisp_Object display
;
3780 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3782 return make_number (1);
3785 DEFUN ("x-server-vendor", Fx_server_vendor
, Sx_server_vendor
, 0, 1, 0,
3786 "Returns the vendor ID string of the Win32 system (Microsoft).\n\
3787 The optional argument DISPLAY specifies which display to ask about.\n\
3788 DISPLAY should be either a frame or a display name (a string).\n\
3789 If omitted or nil, that stands for the selected frame's display.")
3791 Lisp_Object display
;
3793 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3794 char *vendor
= "Microsoft Corp.";
3796 if (! vendor
) vendor
= "";
3797 return build_string (vendor
);
3800 DEFUN ("x-server-version", Fx_server_version
, Sx_server_version
, 0, 1, 0,
3801 "Returns the version numbers of the server of display DISPLAY.\n\
3802 The value is a list of three integers: the major and minor\n\
3803 version numbers, and the vendor-specific release\n\
3804 number. See also the function `x-server-vendor'.\n\n\
3805 The optional argument DISPLAY specifies which display to ask about.\n\
3806 DISPLAY should be either a frame or a display name (a string).\n\
3807 If omitted or nil, that stands for the selected frame's display.")
3809 Lisp_Object display
;
3811 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3813 return Fcons (make_number (nt_major_version
),
3814 Fcons (make_number (nt_minor_version
), Qnil
));
3817 DEFUN ("x-display-screens", Fx_display_screens
, Sx_display_screens
, 0, 1, 0,
3818 "Returns the number of screens on the server of display DISPLAY.\n\
3819 The optional argument DISPLAY specifies which display to ask about.\n\
3820 DISPLAY should be either a frame or a display name (a string).\n\
3821 If omitted or nil, that stands for the selected frame's display.")
3823 Lisp_Object display
;
3825 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3827 return make_number (1);
3830 DEFUN ("x-display-mm-height", Fx_display_mm_height
, Sx_display_mm_height
, 0, 1, 0,
3831 "Returns the height in millimeters of the X display DISPLAY.\n\
3832 The optional argument DISPLAY specifies which display to ask about.\n\
3833 DISPLAY should be either a frame or a display name (a string).\n\
3834 If omitted or nil, that stands for the selected frame's display.")
3836 Lisp_Object display
;
3838 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3842 hdc
= my_get_dc (dpyinfo
->root_window
);
3844 cap
= GetDeviceCaps (hdc
, VERTSIZE
);
3846 ReleaseDC (dpyinfo
->root_window
, hdc
);
3848 return make_number (cap
);
3851 DEFUN ("x-display-mm-width", Fx_display_mm_width
, Sx_display_mm_width
, 0, 1, 0,
3852 "Returns the width in millimeters of the X display DISPLAY.\n\
3853 The optional argument DISPLAY specifies which display to ask about.\n\
3854 DISPLAY should be either a frame or a display name (a string).\n\
3855 If omitted or nil, that stands for the selected frame's display.")
3857 Lisp_Object display
;
3859 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3864 hdc
= my_get_dc (dpyinfo
->root_window
);
3866 cap
= GetDeviceCaps (hdc
, HORZSIZE
);
3868 ReleaseDC (dpyinfo
->root_window
, hdc
);
3870 return make_number (cap
);
3873 DEFUN ("x-display-backing-store", Fx_display_backing_store
,
3874 Sx_display_backing_store
, 0, 1, 0,
3875 "Returns an indication of whether display DISPLAY does backing store.\n\
3876 The value may be `always', `when-mapped', or `not-useful'.\n\
3877 The optional argument DISPLAY specifies which display to ask about.\n\
3878 DISPLAY should be either a frame or a display name (a string).\n\
3879 If omitted or nil, that stands for the selected frame's display.")
3881 Lisp_Object display
;
3883 return intern ("not-useful");
3886 DEFUN ("x-display-visual-class", Fx_display_visual_class
,
3887 Sx_display_visual_class
, 0, 1, 0,
3888 "Returns the visual class of the display DISPLAY.\n\
3889 The value is one of the symbols `static-gray', `gray-scale',\n\
3890 `static-color', `pseudo-color', `true-color', or `direct-color'.\n\n\
3891 The optional argument DISPLAY specifies which display to ask about.\n\
3892 DISPLAY should be either a frame or a display name (a string).\n\
3893 If omitted or nil, that stands for the selected frame's display.")
3895 Lisp_Object display
;
3897 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3900 switch (dpyinfo
->visual
->class)
3902 case StaticGray
: return (intern ("static-gray"));
3903 case GrayScale
: return (intern ("gray-scale"));
3904 case StaticColor
: return (intern ("static-color"));
3905 case PseudoColor
: return (intern ("pseudo-color"));
3906 case TrueColor
: return (intern ("true-color"));
3907 case DirectColor
: return (intern ("direct-color"));
3909 error ("Display has an unknown visual class");
3913 error ("Display has an unknown visual class");
3916 DEFUN ("x-display-save-under", Fx_display_save_under
,
3917 Sx_display_save_under
, 0, 1, 0,
3918 "Returns t if the display DISPLAY supports the save-under feature.\n\
3919 The optional argument DISPLAY specifies which display to ask about.\n\
3920 DISPLAY should be either a frame or a display name (a string).\n\
3921 If omitted or nil, that stands for the selected frame's display.")
3923 Lisp_Object display
;
3925 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
3932 register struct frame
*f
;
3934 return PIXEL_WIDTH (f
);
3939 register struct frame
*f
;
3941 return PIXEL_HEIGHT (f
);
3946 register struct frame
*f
;
3948 return FONT_WIDTH (f
->output_data
.win32
->font
);
3953 register struct frame
*f
;
3955 return f
->output_data
.win32
->line_height
;
3959 x_screen_planes (frame
)
3962 return (FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_planes
*
3963 FRAME_WIN32_DISPLAY_INFO (XFRAME (frame
))->n_cbits
);
3966 /* Return the display structure for the display named NAME.
3967 Open a new connection if necessary. */
3969 struct win32_display_info
*
3970 x_display_info_for_name (name
)
3974 struct win32_display_info
*dpyinfo
;
3976 CHECK_STRING (name
, 0);
3978 for (dpyinfo
= &one_win32_display_info
, names
= win32_display_name_list
;
3980 dpyinfo
= dpyinfo
->next
, names
= XCONS (names
)->cdr
)
3983 tem
= Fstring_equal (XCONS (XCONS (names
)->car
)->car
, name
);
3988 /* Use this general default value to start with. */
3989 Vx_resource_name
= Vinvocation_name
;
3991 validate_x_resource_name ();
3993 dpyinfo
= win32_term_init (name
, (unsigned char *)0,
3994 (char *) XSTRING (Vx_resource_name
)->data
);
3997 error ("Cannot connect to server %s", XSTRING (name
)->data
);
3999 XSETFASTINT (Vwindow_system_version
, 3);
4004 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
4005 1, 3, 0, "Open a connection to a server.\n\
4006 DISPLAY is the name of the display to connect to.\n\
4007 Optional second arg XRM-STRING is a string of resources in xrdb format.\n\
4008 If the optional third arg MUST-SUCCEED is non-nil,\n\
4009 terminate Emacs if we can't open the connection.")
4010 (display
, xrm_string
, must_succeed
)
4011 Lisp_Object display
, xrm_string
, must_succeed
;
4013 unsigned int n_planes
;
4014 unsigned char *xrm_option
;
4015 struct win32_display_info
*dpyinfo
;
4017 CHECK_STRING (display
, 0);
4018 if (! NILP (xrm_string
))
4019 CHECK_STRING (xrm_string
, 1);
4021 Vwin32_color_map
= Fwin32_default_color_map ();
4023 if (! NILP (xrm_string
))
4024 xrm_option
= (unsigned char *) XSTRING (xrm_string
)->data
;
4026 xrm_option
= (unsigned char *) 0;
4028 /* Use this general default value to start with. */
4029 Vx_resource_name
= Vinvocation_name
;
4031 validate_x_resource_name ();
4033 /* This is what opens the connection and sets x_current_display.
4034 This also initializes many symbols, such as those used for input. */
4035 dpyinfo
= win32_term_init (display
, xrm_option
,
4036 (char *) XSTRING (Vx_resource_name
)->data
);
4040 if (!NILP (must_succeed
))
4041 fatal ("Cannot connect to server %s.\n",
4042 XSTRING (display
)->data
);
4044 error ("Cannot connect to server %s", XSTRING (display
)->data
);
4047 XSETFASTINT (Vwindow_system_version
, 3);
4051 DEFUN ("x-close-connection", Fx_close_connection
,
4052 Sx_close_connection
, 1, 1, 0,
4053 "Close the connection to DISPLAY's server.\n\
4054 For DISPLAY, specify either a frame or a display name (a string).\n\
4055 If DISPLAY is nil, that stands for the selected frame's display.")
4057 Lisp_Object display
;
4059 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4060 struct win32_display_info
*tail
;
4063 if (dpyinfo
->reference_count
> 0)
4064 error ("Display still has frames on it");
4067 /* Free the fonts in the font table. */
4068 for (i
= 0; i
< dpyinfo
->n_fonts
; i
++)
4070 if (dpyinfo
->font_table
[i
].name
)
4071 free (dpyinfo
->font_table
[i
].name
);
4072 /* Don't free the full_name string;
4073 it is always shared with something else. */
4074 win32_unload_font (dpyinfo
, dpyinfo
->font_table
[i
].font
);
4076 x_destroy_all_bitmaps (dpyinfo
);
4078 x_delete_display (dpyinfo
);
4084 DEFUN ("x-display-list", Fx_display_list
, Sx_display_list
, 0, 0, 0,
4085 "Return the list of display names that Emacs has connections to.")
4088 Lisp_Object tail
, result
;
4091 for (tail
= win32_display_name_list
; ! NILP (tail
); tail
= XCONS (tail
)->cdr
)
4092 result
= Fcons (XCONS (XCONS (tail
)->car
)->car
, result
);
4097 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
, 1, 2, 0,
4098 "If ON is non-nil, report errors as soon as the erring request is made.\n\
4099 If ON is nil, allow buffering of requests.\n\
4100 This is a noop on Win32 systems.\n\
4101 The optional second argument DISPLAY specifies which display to act on.\n\
4102 DISPLAY should be either a frame or a display name (a string).\n\
4103 If DISPLAY is omitted or nil, that stands for the selected frame's display.")
4105 Lisp_Object display
, on
;
4107 struct win32_display_info
*dpyinfo
= check_x_display_info (display
);
4113 /* These are the win32 specialized functions */
4115 DEFUN ("win32-select-font", Fwin32_select_font
, Swin32_select_font
, 0, 1, 0,
4116 "This will display the Win32 font dialog and return an X font string corresponding to the selection.")
4120 FRAME_PTR f
= check_x_frame (frame
);
4125 bzero (&cf
, sizeof (cf
));
4127 cf
.lStructSize
= sizeof (cf
);
4128 cf
.hwndOwner
= FRAME_WIN32_WINDOW (f
);
4129 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
| CF_SCREENFONTS
;
4132 if (!ChooseFont (&cf
) || !win32_to_x_font (&lf
, buf
, 100))
4135 return build_string (buf
);
4141 /* The section below is built by the lisp expression at the top of the file,
4142 just above where these variables are declared. */
4143 /*&&& init symbols here &&&*/
4144 Qauto_raise
= intern ("auto-raise");
4145 staticpro (&Qauto_raise
);
4146 Qauto_lower
= intern ("auto-lower");
4147 staticpro (&Qauto_lower
);
4148 Qbackground_color
= intern ("background-color");
4149 staticpro (&Qbackground_color
);
4150 Qbar
= intern ("bar");
4152 Qborder_color
= intern ("border-color");
4153 staticpro (&Qborder_color
);
4154 Qborder_width
= intern ("border-width");
4155 staticpro (&Qborder_width
);
4156 Qbox
= intern ("box");
4158 Qcursor_color
= intern ("cursor-color");
4159 staticpro (&Qcursor_color
);
4160 Qcursor_type
= intern ("cursor-type");
4161 staticpro (&Qcursor_type
);
4162 Qfont
= intern ("font");
4164 Qforeground_color
= intern ("foreground-color");
4165 staticpro (&Qforeground_color
);
4166 Qgeometry
= intern ("geometry");
4167 staticpro (&Qgeometry
);
4168 Qicon_left
= intern ("icon-left");
4169 staticpro (&Qicon_left
);
4170 Qicon_top
= intern ("icon-top");
4171 staticpro (&Qicon_top
);
4172 Qicon_type
= intern ("icon-type");
4173 staticpro (&Qicon_type
);
4174 Qicon_name
= intern ("icon-name");
4175 staticpro (&Qicon_name
);
4176 Qinternal_border_width
= intern ("internal-border-width");
4177 staticpro (&Qinternal_border_width
);
4178 Qleft
= intern ("left");
4180 Qmouse_color
= intern ("mouse-color");
4181 staticpro (&Qmouse_color
);
4182 Qnone
= intern ("none");
4184 Qparent_id
= intern ("parent-id");
4185 staticpro (&Qparent_id
);
4186 Qscroll_bar_width
= intern ("scroll-bar-width");
4187 staticpro (&Qscroll_bar_width
);
4188 Qsuppress_icon
= intern ("suppress-icon");
4189 staticpro (&Qsuppress_icon
);
4190 Qtop
= intern ("top");
4192 Qundefined_color
= intern ("undefined-color");
4193 staticpro (&Qundefined_color
);
4194 Qvertical_scroll_bars
= intern ("vertical-scroll-bars");
4195 staticpro (&Qvertical_scroll_bars
);
4196 Qvisibility
= intern ("visibility");
4197 staticpro (&Qvisibility
);
4198 Qwindow_id
= intern ("window-id");
4199 staticpro (&Qwindow_id
);
4200 Qx_frame_parameter
= intern ("x-frame-parameter");
4201 staticpro (&Qx_frame_parameter
);
4202 Qx_resource_name
= intern ("x-resource-name");
4203 staticpro (&Qx_resource_name
);
4204 Quser_position
= intern ("user-position");
4205 staticpro (&Quser_position
);
4206 Quser_size
= intern ("user-size");
4207 staticpro (&Quser_size
);
4208 Qdisplay
= intern ("display");
4209 staticpro (&Qdisplay
);
4210 /* This is the end of symbol initialization. */
4212 Fput (Qundefined_color
, Qerror_conditions
,
4213 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
4214 Fput (Qundefined_color
, Qerror_message
,
4215 build_string ("Undefined color"));
4217 DEFVAR_LISP ("win32-color-map", &Vwin32_color_map
,
4218 "A array of color name mappings for windows.");
4219 Vwin32_color_map
= Qnil
;
4221 init_x_parm_symbols ();
4223 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path
,
4224 "List of directories to search for bitmap files for win32.");
4225 Vx_bitmap_file_path
= decode_env_path ((char *) 0, "PATH");
4227 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape
,
4228 "The shape of the pointer when over text.\n\
4229 Changing the value does not affect existing frames\n\
4230 unless you set the mouse color.");
4231 Vx_pointer_shape
= Qnil
;
4233 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4234 "The name Emacs uses to look up resources; for internal use only.\n\
4235 `x-get-resource' uses this as the first component of the instance name\n\
4236 when requesting resource values.\n\
4237 Emacs initially sets `x-resource-name' to the name under which Emacs\n\
4238 was invoked, or to the value specified with the `-name' or `-rn'\n\
4239 switches, if present.");
4240 Vx_resource_name
= Qnil
;
4242 Vx_nontext_pointer_shape
= Qnil
;
4244 Vx_mode_pointer_shape
= Qnil
;
4246 DEFVAR_INT ("x-sensitive-text-pointer-shape",
4247 &Vx_sensitive_text_pointer_shape
,
4248 "The shape of the pointer when over mouse-sensitive text.\n\
4249 This variable takes effect when you create a new frame\n\
4250 or when you set the mouse color.");
4251 Vx_sensitive_text_pointer_shape
= Qnil
;
4253 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
4254 "A string indicating the foreground color of the cursor box.");
4255 Vx_cursor_fore_pixel
= Qnil
;
4257 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
4258 "Non-nil if no window manager is in use.\n\
4259 Emacs doesn't try to figure this out; this is always nil\n\
4260 unless you set it to something else.");
4261 /* We don't have any way to find this out, so set it to nil
4262 and maybe the user would like to set it to t. */
4263 Vx_no_window_manager
= Qnil
;
4265 defsubr (&Sx_get_resource
);
4266 defsubr (&Sx_list_fonts
);
4267 defsubr (&Sx_display_color_p
);
4268 defsubr (&Sx_display_grayscale_p
);
4269 defsubr (&Sx_color_defined_p
);
4270 defsubr (&Sx_color_values
);
4271 defsubr (&Sx_server_max_request_size
);
4272 defsubr (&Sx_server_vendor
);
4273 defsubr (&Sx_server_version
);
4274 defsubr (&Sx_display_pixel_width
);
4275 defsubr (&Sx_display_pixel_height
);
4276 defsubr (&Sx_display_mm_width
);
4277 defsubr (&Sx_display_mm_height
);
4278 defsubr (&Sx_display_screens
);
4279 defsubr (&Sx_display_planes
);
4280 defsubr (&Sx_display_color_cells
);
4281 defsubr (&Sx_display_visual_class
);
4282 defsubr (&Sx_display_backing_store
);
4283 defsubr (&Sx_display_save_under
);
4284 defsubr (&Sx_parse_geometry
);
4285 defsubr (&Sx_create_frame
);
4286 defsubr (&Sfocus_frame
);
4287 defsubr (&Sunfocus_frame
);
4288 defsubr (&Sx_open_connection
);
4289 defsubr (&Sx_close_connection
);
4290 defsubr (&Sx_display_list
);
4291 defsubr (&Sx_synchronize
);
4293 /* Win32 specific functions */
4295 defsubr (&Swin32_select_font
);
4304 "A fatal error has occurred - aborting!",
4305 "Emacs Abort Dialog",
4306 MB_OK
|MB_ICONEXCLAMATION
);