aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2003-03-31 20:34:30 +0000
committerKim F. Storm2003-03-31 20:34:30 +0000
commit42556ca4fcda7bab7c0a2f126b582a5bcdafad24 (patch)
tree6222b69ec6d1ccdb781b832eb61d6f8bb5cee5cd /src
parent5e02ce11875499ca3ad7561123ba52427ee9e562 (diff)
downloademacs-42556ca4fcda7bab7c0a2f126b582a5bcdafad24.tar.gz
emacs-42556ca4fcda7bab7c0a2f126b582a5bcdafad24.zip
(Qauto_raise, Qauto_lower, ...): Remove vars for frame
parameters now defined in frame.h and frame.c. (Vx_resource_name): Remove. Use generic var. (check_x_display_info): Make non-static (for frame.c). (struct x_frame_parm_table, x_frame_parms): Remove. (init_x_parm_symbols, x_set_frame_parameters, x_report_frame_params) (x_set_line_spacing, x_set_screen_gamma, x_icon_type, x_set_font) (x_set_border_width, x_set_internal_border_width, x_set_visibility) (x_change_window_heights, x_set_autoraise, x_set_autolower) (x_set_vertical_scroll_bars, x_set_scroll_bar_width) (validate_x_resource_name, Fx_get_resource, x_get_resource_string) (x_default_parameter, Fx_parse_geometry, x_figure_window_size): Remove. Use generic functions instead. (enum resource_types): Remove. (x_set_scroll_bar_default_width): New global function (for frame.c). (mac_frame_parm_handlers): New table for redisplay_interface. (syms_of_macfns): Don't intern/staticpro removed vars.
Diffstat (limited to 'src')
-rw-r--r--src/macfns.c1314
1 files changed, 64 insertions, 1250 deletions
diff --git a/src/macfns.c b/src/macfns.c
index 10d8a5f7eb2..5a3651a9dfa 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -109,10 +109,6 @@ int gray_bitmap_width = gray_width;
109int gray_bitmap_height = gray_height; 109int gray_bitmap_height = gray_height;
110unsigned char *gray_bitmap_bits = gray_bits; 110unsigned char *gray_bitmap_bits = gray_bits;
111 111
112/* The name we're using in resource queries. */
113
114Lisp_Object Vx_resource_name;
115
116/* Non-zero means we're allowed to display an hourglass cursor. */ 112/* Non-zero means we're allowed to display an hourglass cursor. */
117 113
118int display_hourglass_p; 114int display_hourglass_p;
@@ -187,35 +183,9 @@ Lisp_Object Vx_pixel_size_width_font_regexp;
187 */ 183 */
188 184
189/*&&& symbols declared here &&&*/ 185/*&&& symbols declared here &&&*/
190Lisp_Object Qauto_raise;
191Lisp_Object Qauto_lower;
192Lisp_Object Qborder_color;
193Lisp_Object Qborder_width;
194Lisp_Object Qcursor_color;
195Lisp_Object Qcursor_type;
196Lisp_Object Qgeometry;
197Lisp_Object Qicon_left;
198Lisp_Object Qicon_top;
199Lisp_Object Qicon_type;
200Lisp_Object Qicon_name;
201Lisp_Object Qinternal_border_width;
202Lisp_Object Qleft;
203Lisp_Object Qright;
204Lisp_Object Qmouse_color;
205Lisp_Object Qnone; 186Lisp_Object Qnone;
206Lisp_Object Qparent_id;
207Lisp_Object Qscroll_bar_width;
208Lisp_Object Qsuppress_icon; 187Lisp_Object Qsuppress_icon;
209Lisp_Object Qundefined_color; 188Lisp_Object Qundefined_color;
210Lisp_Object Qvertical_scroll_bars;
211Lisp_Object Qvisibility;
212Lisp_Object Qwindow_id;
213Lisp_Object Qx_frame_parameter;
214Lisp_Object Qx_resource_name;
215Lisp_Object Quser_position;
216Lisp_Object Quser_size;
217Lisp_Object Qscreen_gamma;
218Lisp_Object Qline_spacing;
219Lisp_Object Qcenter; 189Lisp_Object Qcenter;
220Lisp_Object Qcancel_timer; 190Lisp_Object Qcancel_timer;
221Lisp_Object Qhyper; 191Lisp_Object Qhyper;
@@ -226,27 +196,11 @@ Lisp_Object Qctrl;
226Lisp_Object Qcontrol; 196Lisp_Object Qcontrol;
227Lisp_Object Qshift; 197Lisp_Object Qshift;
228 198
229extern Lisp_Object Qtop;
230extern Lisp_Object Qdisplay;
231Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
232extern Lisp_Object Qtool_bar_lines;
233
234/* These are defined in frame.c. */
235extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
236extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle;
237extern Lisp_Object Qtool_bar_lines;
238
239extern Lisp_Object Vwindow_system_version; 199extern Lisp_Object Vwindow_system_version;
240 200
241extern Lisp_Object Qbox;
242
243Lisp_Object Qface_set_after_frame_default;
244
245extern int mac_initialized; 201extern int mac_initialized;
246 202
247/* Functions in macterm.c. */ 203/* Functions in macterm.c. */
248extern void x_set_offset (struct frame *, int, int, int);
249extern void x_wm_set_icon_position (struct frame *, int, int);
250extern void x_set_window_size (struct frame *, int, int, int); 204extern void x_set_window_size (struct frame *, int, int, int);
251extern void x_make_frame_visible (struct frame *); 205extern void x_make_frame_visible (struct frame *);
252extern struct mac_display_info *mac_term_init (Lisp_Object, char *, char *); 206extern struct mac_display_info *mac_term_init (Lisp_Object, char *, char *);
@@ -319,7 +273,7 @@ check_x_frame (frame)
319 nil stands for the selected frame--or, if that is not a mac frame, 273 nil stands for the selected frame--or, if that is not a mac frame,
320 the first display on the list. */ 274 the first display on the list. */
321 275
322static struct mac_display_info * 276struct mac_display_info *
323check_x_display_info (frame) 277check_x_display_info (frame)
324 Lisp_Object frame; 278 Lisp_Object frame;
325{ 279{
@@ -606,14 +560,7 @@ x_destroy_all_bitmaps (dpyinfo)
606 has an `x-frame-parameter' property which is an integer in Lisp 560 has an `x-frame-parameter' property which is an integer in Lisp
607 but can be interpreted as an `enum x_frame_parm' in C. */ 561 but can be interpreted as an `enum x_frame_parm' in C. */
608 562
609struct x_frame_parm_table
610{
611 char *name;
612 void (*setter) P_ ((struct frame *, Lisp_Object, Lisp_Object));
613};
614
615void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); 563void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
616static void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object));
617void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); 564void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
618void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); 565void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
619void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); 566void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
@@ -621,20 +568,9 @@ void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
621void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object)); 568void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
622void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object)); 569void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
623void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); 570void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
624void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));
625void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
626void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,
627 Lisp_Object));
628void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); 571void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
629void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object));
630void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object));
631void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object,
632 Lisp_Object));
633void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object));
634void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); 572void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
635void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
636void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object)); 573void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object));
637void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));
638void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); 574void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
639void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object, 575void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object,
640 Lisp_Object)); 576 Lisp_Object));
@@ -645,316 +581,6 @@ static Lisp_Object x_default_scroll_bar_color_parameter P_ ((struct frame *,
645 Lisp_Object, 581 Lisp_Object,
646 char *, char *, 582 char *, char *,
647 int)); 583 int));
648static void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object));
649
650static struct x_frame_parm_table x_frame_parms[] =
651{
652 "auto-raise", x_set_autoraise,
653 "auto-lower", x_set_autolower,
654 "background-color", x_set_background_color,
655 "border-color", x_set_border_color,
656 "border-width", x_set_border_width,
657 "cursor-color", x_set_cursor_color,
658 "cursor-type", x_set_cursor_type,
659 "font", x_set_font,
660 "foreground-color", x_set_foreground_color,
661 "icon-name", x_set_icon_name,
662#if 0 /* MAC_TODO: no icons for Mac */
663 "icon-type", x_set_icon_type,
664#endif
665 "internal-border-width", x_set_internal_border_width,
666 "menu-bar-lines", x_set_menu_bar_lines,
667 "mouse-color", x_set_mouse_color,
668 "name", x_explicitly_set_name,
669 "scroll-bar-width", x_set_scroll_bar_width,
670 "title", x_set_title,
671 "unsplittable", x_set_unsplittable,
672 "vertical-scroll-bars", x_set_vertical_scroll_bars,
673 "visibility", x_set_visibility,
674 "tool-bar-lines", x_set_tool_bar_lines,
675#if 0 /* MAC_TODO: cannot set color of scroll bar on the Mac? */
676 "scroll-bar-foreground", x_set_scroll_bar_foreground,
677 "scroll-bar-background", x_set_scroll_bar_background,
678#endif
679 "screen-gamma", x_set_screen_gamma,
680 "line-spacing", x_set_line_spacing
681};
682
683/* Attach the `x-frame-parameter' properties to
684 the Lisp symbol names of parameters relevant to Mac. */
685
686void
687init_x_parm_symbols ()
688{
689 int i;
690
691 for (i = 0; i < sizeof (x_frame_parms) / sizeof (x_frame_parms[0]); i++)
692 Fput (intern (x_frame_parms[i].name), Qx_frame_parameter,
693 make_number (i));
694}
695
696/* Change the parameters of frame F as specified by ALIST.
697 If a parameter is not specially recognized, do nothing;
698 otherwise call the `x_set_...' function for that parameter. */
699
700void
701x_set_frame_parameters (f, alist)
702 FRAME_PTR f;
703 Lisp_Object alist;
704{
705 Lisp_Object tail;
706
707 /* If both of these parameters are present, it's more efficient to
708 set them both at once. So we wait until we've looked at the
709 entire list before we set them. */
710 int width, height;
711
712 /* Same here. */
713 Lisp_Object left, top;
714
715 /* Same with these. */
716 Lisp_Object icon_left, icon_top;
717
718 /* Record in these vectors all the parms specified. */
719 Lisp_Object *parms;
720 Lisp_Object *values;
721 int i, p;
722 int left_no_change = 0, top_no_change = 0;
723 int icon_left_no_change = 0, icon_top_no_change = 0;
724
725 struct gcpro gcpro1, gcpro2;
726
727 i = 0;
728 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
729 i++;
730
731 parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
732 values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
733
734 /* Extract parm names and values into those vectors. */
735
736 i = 0;
737 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
738 {
739 Lisp_Object elt;
740
741 elt = Fcar (tail);
742 parms[i] = Fcar (elt);
743 values[i] = Fcdr (elt);
744 i++;
745 }
746 /* TAIL and ALIST are not used again below here. */
747 alist = tail = Qnil;
748
749 GCPRO2 (*parms, *values);
750 gcpro1.nvars = i;
751 gcpro2.nvars = i;
752
753 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
754 because their values appear in VALUES and strings are not valid. */
755 top = left = Qunbound;
756 icon_left = icon_top = Qunbound;
757
758 /* Provide default values for HEIGHT and WIDTH. */
759 if (FRAME_NEW_WIDTH (f))
760 width = FRAME_NEW_WIDTH (f);
761 else
762 width = FRAME_WIDTH (f);
763
764 if (FRAME_NEW_HEIGHT (f))
765 height = FRAME_NEW_HEIGHT (f);
766 else
767 height = FRAME_HEIGHT (f);
768
769 /* Process foreground_color and background_color before anything else.
770 They are independent of other properties, but other properties (e.g.,
771 cursor_color) are dependent upon them. */
772 for (p = 0; p < i; p++)
773 {
774 Lisp_Object prop, val;
775
776 prop = parms[p];
777 val = values[p];
778 if (EQ (prop, Qforeground_color) || EQ (prop, Qbackground_color))
779 {
780 register Lisp_Object param_index, old_value;
781
782 param_index = Fget (prop, Qx_frame_parameter);
783 old_value = get_frame_param (f, prop);
784 store_frame_param (f, prop, val);
785 if (NATNUMP (param_index)
786 && (XFASTINT (param_index)
787 < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))
788 (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);
789 }
790 }
791
792 /* Now process them in reverse of specified order. */
793 for (i--; i >= 0; i--)
794 {
795 Lisp_Object prop, val;
796
797 prop = parms[i];
798 val = values[i];
799
800 if (EQ (prop, Qwidth) && NUMBERP (val))
801 width = XFASTINT (val);
802 else if (EQ (prop, Qheight) && NUMBERP (val))
803 height = XFASTINT (val);
804 else if (EQ (prop, Qtop))
805 top = val;
806 else if (EQ (prop, Qleft))
807 left = val;
808 else if (EQ (prop, Qicon_top))
809 icon_top = val;
810 else if (EQ (prop, Qicon_left))
811 icon_left = val;
812 else if (EQ (prop, Qforeground_color) || EQ (prop, Qbackground_color))
813 /* Processed above. */
814 continue;
815 else
816 {
817 register Lisp_Object param_index, old_value;
818
819 param_index = Fget (prop, Qx_frame_parameter);
820 old_value = get_frame_param (f, prop);
821 store_frame_param (f, prop, val);
822 if (NATNUMP (param_index)
823 && (XFASTINT (param_index)
824 < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))
825 (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);
826 }
827 }
828
829 /* Don't die if just one of these was set. */
830 if (EQ (left, Qunbound))
831 {
832 left_no_change = 1;
833 if (f->output_data.mac->left_pos < 0)
834 left = Fcons (Qplus,
835 Fcons (make_number (f->output_data.mac->left_pos),
836 Qnil));
837 else
838 XSETINT (left, f->output_data.mac->left_pos);
839 }
840 if (EQ (top, Qunbound))
841 {
842 top_no_change = 1;
843 if (f->output_data.mac->top_pos < 0)
844 top = Fcons (Qplus,
845 Fcons (make_number (f->output_data.mac->top_pos), Qnil));
846 else
847 XSETINT (top, f->output_data.mac->top_pos);
848 }
849
850 /* If one of the icon positions was not set, preserve or default it. */
851 if (EQ (icon_left, Qunbound) || ! INTEGERP (icon_left))
852 {
853 icon_left_no_change = 1;
854 icon_left = Fcdr (Fassq (Qicon_left, f->param_alist));
855 if (NILP (icon_left))
856 XSETINT (icon_left, 0);
857 }
858 if (EQ (icon_top, Qunbound) || ! INTEGERP (icon_top))
859 {
860 icon_top_no_change = 1;
861 icon_top = Fcdr (Fassq (Qicon_top, f->param_alist));
862 if (NILP (icon_top))
863 XSETINT (icon_top, 0);
864 }
865
866 /* Don't set these parameters unless they've been explicitly
867 specified. The window might be mapped or resized while we're in
868 this function, and we don't want to override that unless the lisp
869 code has asked for it.
870
871 Don't set these parameters unless they actually differ from the
872 window's current parameters; the window may not actually exist
873 yet. */
874 {
875 Lisp_Object frame;
876
877 check_frame_size (f, &height, &width);
878
879 XSETFRAME (frame, f);
880
881 if (width != FRAME_WIDTH (f)
882 || height != FRAME_HEIGHT (f)
883 || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f))
884 Fset_frame_size (frame, make_number (width), make_number (height));
885
886 if ((!NILP (left) || !NILP (top))
887 && ! (left_no_change && top_no_change)
888 && ! (NUMBERP (left) && XINT (left) == f->output_data.mac->left_pos
889 && NUMBERP (top) && XINT (top) == f->output_data.mac->top_pos))
890 {
891 int leftpos = 0;
892 int toppos = 0;
893
894 /* Record the signs. */
895 f->output_data.mac->size_hint_flags &= ~ (XNegative | YNegative);
896 if (EQ (left, Qminus))
897 f->output_data.mac->size_hint_flags |= XNegative;
898 else if (INTEGERP (left))
899 {
900 leftpos = XINT (left);
901 if (leftpos < 0)
902 f->output_data.mac->size_hint_flags |= XNegative;
903 }
904 else if (CONSP (left) && EQ (XCAR (left), Qminus)
905 && CONSP (XCDR (left))
906 && INTEGERP (XCAR (XCDR (left))))
907 {
908 leftpos = - XINT (XCAR (XCDR (left)));
909 f->output_data.mac->size_hint_flags |= XNegative;
910 }
911 else if (CONSP (left) && EQ (XCAR (left), Qplus)
912 && CONSP (XCDR (left))
913 && INTEGERP (XCAR (XCDR (left))))
914 {
915 leftpos = XINT (XCAR (XCDR (left)));
916 }
917
918 if (EQ (top, Qminus))
919 f->output_data.mac->size_hint_flags |= YNegative;
920 else if (INTEGERP (top))
921 {
922 toppos = XINT (top);
923 if (toppos < 0)
924 f->output_data.mac->size_hint_flags |= YNegative;
925 }
926 else if (CONSP (top) && EQ (XCAR (top), Qminus)
927 && CONSP (XCDR (top))
928 && INTEGERP (XCAR (XCDR (top))))
929 {
930 toppos = - XINT (XCAR (XCDR (top)));
931 f->output_data.mac->size_hint_flags |= YNegative;
932 }
933 else if (CONSP (top) && EQ (XCAR (top), Qplus)
934 && CONSP (XCDR (top))
935 && INTEGERP (XCAR (XCDR (top))))
936 {
937 toppos = XINT (XCAR (XCDR (top)));
938 }
939
940
941 /* Store the numeric value of the position. */
942 f->output_data.mac->top_pos = toppos;
943 f->output_data.mac->left_pos = leftpos;
944
945 f->output_data.mac->win_gravity = NorthWestGravity;
946
947 /* Actually set that position, and convert to absolute. */
948 x_set_offset (f, leftpos, toppos, -1);
949 }
950
951 if ((!NILP (icon_left) || !NILP (icon_top))
952 && ! (icon_left_no_change && icon_top_no_change))
953 x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top));
954 }
955
956 UNGCPRO;
957}
958 584
959/* Store the screen positions of frame F into XPTR and YPTR. 585/* Store the screen positions of frame F into XPTR and YPTR.
960 These are the positions of the containing window manager window, 586 These are the positions of the containing window manager window,
@@ -988,49 +614,6 @@ x_real_positions (f, xptr, yptr)
988 *yptr = pt.v; 614 *yptr = pt.v;
989} 615}
990 616
991/* Insert a description of internally-recorded parameters of frame X
992 into the parameter alist *ALISTPTR that is to be given to the user.
993 Only parameters that are specific to Mac and whose values are not
994 correctly recorded in the frame's param_alist need to be considered
995 here. */
996
997void
998x_report_frame_params (f, alistptr)
999 struct frame *f;
1000 Lisp_Object *alistptr;
1001{
1002 char buf[16];
1003 Lisp_Object tem;
1004
1005 /* Represent negative positions (off the top or left screen edge)
1006 in a way that Fmodify_frame_parameters will understand correctly. */
1007 XSETINT (tem, f->output_data.mac->left_pos);
1008 if (f->output_data.mac->left_pos >= 0)
1009 store_in_alist (alistptr, Qleft, tem);
1010 else
1011 store_in_alist (alistptr, Qleft, Fcons (Qplus, Fcons (tem, Qnil)));
1012
1013 XSETINT (tem, f->output_data.mac->top_pos);
1014 if (f->output_data.mac->top_pos >= 0)
1015 store_in_alist (alistptr, Qtop, tem);
1016 else
1017 store_in_alist (alistptr, Qtop, Fcons (Qplus, Fcons (tem, Qnil)));
1018
1019 store_in_alist (alistptr, Qborder_width,
1020 make_number (f->output_data.mac->border_width));
1021 store_in_alist (alistptr, Qinternal_border_width,
1022 make_number (f->output_data.mac->internal_border_width));
1023 sprintf (buf, "%ld", (long) FRAME_MAC_WINDOW (f));
1024 store_in_alist (alistptr, Qwindow_id,
1025 build_string (buf));
1026 store_in_alist (alistptr, Qicon_name, f->icon_name);
1027 FRAME_SAMPLE_VISIBILITY (f);
1028 store_in_alist (alistptr, Qvisibility,
1029 (FRAME_VISIBLE_P (f) ? Qt
1030 : FRAME_ICONIFIED_P (f) ? Qicon : Qnil));
1031 store_in_alist (alistptr, Qdisplay,
1032 XCAR (FRAME_MAC_DISPLAY_INFO (f)->name_list_element));
1033}
1034 617
1035/* The default colors for the Mac color map */ 618/* The default colors for the Mac color map */
1036typedef struct colormap_t 619typedef struct colormap_t
@@ -2074,47 +1657,6 @@ x_decode_color (f, arg, def)
2074 return def; 1657 return def;
2075} 1658}
2076 1659
2077/* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
2078 the previous value of that parameter, NEW_VALUE is the new value. */
2079
2080static void
2081x_set_line_spacing (f, new_value, old_value)
2082 struct frame *f;
2083 Lisp_Object new_value, old_value;
2084{
2085 if (NILP (new_value))
2086 f->extra_line_spacing = 0;
2087 else if (NATNUMP (new_value))
2088 f->extra_line_spacing = XFASTINT (new_value);
2089 else
2090 Fsignal (Qerror, Fcons (build_string ("Illegal line-spacing"),
2091 Fcons (new_value, Qnil)));
2092 if (FRAME_VISIBLE_P (f))
2093 redraw_frame (f);
2094}
2095
2096
2097/* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
2098 the previous value of that parameter, NEW_VALUE is the new value. */
2099
2100static void
2101x_set_screen_gamma (f, new_value, old_value)
2102 struct frame *f;
2103 Lisp_Object new_value, old_value;
2104{
2105 if (NILP (new_value))
2106 f->gamma = 0;
2107 else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0)
2108 /* The value 0.4545 is the normal viewing gamma. */
2109 f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value));
2110 else
2111 Fsignal (Qerror, Fcons (build_string ("Illegal screen-gamma"),
2112 Fcons (new_value, Qnil)));
2113
2114 clear_face_cache (0);
2115}
2116
2117
2118/* Functions called only from `x_set_frame_param' 1660/* Functions called only from `x_set_frame_param'
2119 to set individual parameters. 1661 to set individual parameters.
2120 1662
@@ -2423,21 +1965,6 @@ x_set_icon_type (f, arg, oldval)
2423} 1965}
2424#endif /* MAC_TODO */ 1966#endif /* MAC_TODO */
2425 1967
2426/* Return non-nil if frame F wants a bitmap icon. */
2427
2428Lisp_Object
2429x_icon_type (f)
2430 FRAME_PTR f;
2431{
2432 Lisp_Object tem;
2433
2434 tem = assq_no_quit (Qicon_type, f->param_alist);
2435 if (CONSP (tem))
2436 return XCDR (tem);
2437 else
2438 return Qnil;
2439}
2440
2441void 1968void
2442x_set_icon_name (f, arg, oldval) 1969x_set_icon_name (f, arg, oldval)
2443 struct frame *f; 1970 struct frame *f;
@@ -2489,154 +2016,7 @@ x_set_icon_name (f, arg, oldval)
2489#endif /* MAC_TODO */ 2016#endif /* MAC_TODO */
2490} 2017}
2491 2018
2492extern Lisp_Object x_new_font ();
2493extern Lisp_Object x_new_fontset();
2494
2495void
2496x_set_font (f, arg, oldval)
2497 struct frame *f;
2498 Lisp_Object arg, oldval;
2499{
2500 Lisp_Object result;
2501 Lisp_Object fontset_name;
2502 Lisp_Object frame;
2503 int old_fontset = FRAME_FONTSET(f);
2504
2505 CHECK_STRING (arg);
2506
2507 fontset_name = Fquery_fontset (arg, Qnil);
2508
2509 BLOCK_INPUT;
2510 result = (STRINGP (fontset_name)
2511 ? x_new_fontset (f, SDATA (fontset_name))
2512 : x_new_font (f, SDATA (arg)));
2513 UNBLOCK_INPUT;
2514
2515 if (EQ (result, Qnil))
2516 error ("Font `%s' is not defined", SDATA (arg));
2517 else if (EQ (result, Qt))
2518 error ("The characters of the given font have varying widths");
2519 else if (STRINGP (result))
2520 {
2521 if (STRINGP (fontset_name))
2522 {
2523 /* Fontset names are built from ASCII font names, so the
2524 names may be equal despite there was a change. */
2525 if (old_fontset == FRAME_FONTSET (f))
2526 return;
2527 }
2528 else if (!NILP (Fequal (result, oldval)))
2529 return;
2530
2531 store_frame_param (f, Qfont, result);
2532 recompute_basic_faces (f);
2533 }
2534 else
2535 abort ();
2536
2537 do_pending_window_change (0);
2538
2539 /* Don't call `face-set-after-frame-default' when faces haven't been
2540 initialized yet. This is the case when called from
2541 Fx_create_frame. In that case, the X widget or window doesn't
2542 exist either, and we can end up in x_report_frame_params with a
2543 null widget which gives a segfault. */
2544 if (FRAME_FACE_CACHE (f))
2545 {
2546 XSETFRAME (frame, f);
2547 call1 (Qface_set_after_frame_default, frame);
2548 }
2549}
2550
2551void
2552x_set_border_width (f, arg, oldval)
2553 struct frame *f;
2554 Lisp_Object arg, oldval;
2555{
2556 CHECK_NUMBER (arg);
2557
2558 if (XINT (arg) == f->output_data.mac->border_width)
2559 return;
2560
2561#if 0 /* MAC_TODO */
2562 if (FRAME_MAC_WINDOW (f) != 0)
2563 error ("Cannot change the border width of a window");
2564#endif
2565
2566 f->output_data.mac->border_width = XINT (arg);
2567}
2568
2569void
2570x_set_internal_border_width (f, arg, oldval)
2571 struct frame *f;
2572 Lisp_Object arg, oldval;
2573{
2574 int old = f->output_data.mac->internal_border_width;
2575
2576 CHECK_NUMBER (arg);
2577 f->output_data.mac->internal_border_width = XINT (arg);
2578 if (f->output_data.mac->internal_border_width < 0)
2579 f->output_data.mac->internal_border_width = 0;
2580
2581 if (f->output_data.mac->internal_border_width == old)
2582 return;
2583
2584 if (FRAME_MAC_WINDOW (f) != 0)
2585 {
2586 x_set_window_size (f, 0, f->width, f->height);
2587 SET_FRAME_GARBAGED (f);
2588 do_pending_window_change (0);
2589 }
2590 else
2591 SET_FRAME_GARBAGED (f);
2592}
2593
2594void
2595x_set_visibility (f, value, oldval)
2596 struct frame *f;
2597 Lisp_Object value, oldval;
2598{
2599 Lisp_Object frame;
2600 XSETFRAME (frame, f);
2601
2602 if (NILP (value))
2603 Fmake_frame_invisible (frame, Qt);
2604 else if (EQ (value, Qicon))
2605 Ficonify_frame (frame);
2606 else
2607 Fmake_frame_visible (frame);
2608}
2609
2610 2019
2611/* Change window heights in windows rooted in WINDOW by N lines. */
2612
2613static void
2614x_change_window_heights (window, n)
2615 Lisp_Object window;
2616 int n;
2617{
2618 struct window *w = XWINDOW (window);
2619
2620 XSETFASTINT (w->top, XFASTINT (w->top) + n);
2621 XSETFASTINT (w->height, XFASTINT (w->height) - n);
2622
2623 if (INTEGERP (w->orig_top))
2624 XSETFASTINT (w->orig_top, XFASTINT (w->orig_top) + n);
2625 if (INTEGERP (w->orig_height))
2626 XSETFASTINT (w->orig_height, XFASTINT (w->orig_height) - n);
2627
2628 /* Handle just the top child in a vertical split. */
2629 if (!NILP (w->vchild))
2630 x_change_window_heights (w->vchild, n);
2631
2632 /* Adjust all children in a horizontal split. */
2633 for (window = w->hchild; !NILP (window); window = w->next)
2634 {
2635 w = XWINDOW (window);
2636 x_change_window_heights (window, n);
2637 }
2638}
2639
2640void 2020void
2641x_set_menu_bar_lines (f, value, oldval) 2021x_set_menu_bar_lines (f, value, oldval)
2642 struct frame *f; 2022 struct frame *f;
@@ -2715,7 +2095,7 @@ x_set_tool_bar_lines (f, value, oldval)
2715 } 2095 }
2716 2096
2717 FRAME_TOOL_BAR_LINES (f) = nlines; 2097 FRAME_TOOL_BAR_LINES (f) = nlines;
2718 x_change_window_heights (root_window, delta); 2098 change_window_heights (root_window, delta);
2719 adjust_glyphs (f); 2099 adjust_glyphs (f);
2720 2100
2721 /* We also have to make sure that the internal border at the top of 2101 /* We also have to make sure that the internal border at the top of
@@ -2905,283 +2285,41 @@ x_set_title (f, name, old_name)
2905 UNBLOCK_INPUT; 2285 UNBLOCK_INPUT;
2906 } 2286 }
2907} 2287}
2908
2909void
2910x_set_autoraise (f, arg, oldval)
2911 struct frame *f;
2912 Lisp_Object arg, oldval;
2913{
2914 f->auto_raise = !EQ (Qnil, arg);
2915}
2916
2917void
2918x_set_autolower (f, arg, oldval)
2919 struct frame *f;
2920 Lisp_Object arg, oldval;
2921{
2922 f->auto_lower = !EQ (Qnil, arg);
2923}
2924
2925void
2926x_set_unsplittable (f, arg, oldval)
2927 struct frame *f;
2928 Lisp_Object arg, oldval;
2929{
2930 f->no_split = !NILP (arg);
2931}
2932
2933void
2934x_set_vertical_scroll_bars (f, arg, oldval)
2935 struct frame *f;
2936 Lisp_Object arg, oldval;
2937{
2938 if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
2939 || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
2940 || (NILP (arg) && FRAME_HAS_VERTICAL_SCROLL_BARS (f))
2941 || (!NILP (arg) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f)))
2942 {
2943 FRAME_VERTICAL_SCROLL_BAR_TYPE (f)
2944 = (NILP (arg)
2945 ? vertical_scroll_bar_none
2946 : EQ (Qright, arg)
2947 ? vertical_scroll_bar_right
2948 : vertical_scroll_bar_left);
2949
2950 /* We set this parameter before creating the window for the
2951 frame, so we can get the geometry right from the start.
2952 However, if the window hasn't been created yet, we shouldn't
2953 call x_set_window_size. */
2954 if (FRAME_MAC_WINDOW (f))
2955 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
2956 do_pending_window_change (0);
2957 }
2958}
2959 2288
2960void 2289void
2961x_set_scroll_bar_width (f, arg, oldval) 2290x_set_scroll_bar_default_width (f)
2962 struct frame *f; 2291 struct frame *f;
2963 Lisp_Object arg, oldval;
2964{ 2292{
2965 /* Imitate X without X Toolkit */ 2293 /* Imitate X without X Toolkit */
2966 2294
2967 int wid = FONT_WIDTH (f->output_data.mac->font); 2295 int wid = FONT_WIDTH (f->output_data.mac->font);
2968 2296
2969 if (NILP (arg))
2970 {
2971#ifdef MAC_OSX 2297#ifdef MAC_OSX
2972 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 16; /* Aqua scroll bars. */ 2298 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 16; /* Aqua scroll bars. */
2973 FRAME_SCROLL_BAR_COLS (f) = (FRAME_SCROLL_BAR_PIXEL_WIDTH (f) + 2299 FRAME_SCROLL_BAR_COLS (f) = (FRAME_SCROLL_BAR_PIXEL_WIDTH (f) +
2974 wid - 1) / wid; 2300 wid - 1) / wid;
2975#else /* not MAC_OSX */ 2301#else /* not MAC_OSX */
2976 /* Make the actual width at least 14 pixels and a multiple of a 2302 /* Make the actual width at least 14 pixels and a multiple of a
2977 character width. */ 2303 character width. */
2978 FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid; 2304 FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
2979 2305
2980 /* Use all of that space (aside from required margins) for the 2306 /* Use all of that space (aside from required margins) for the
2981 scroll bar. */ 2307 scroll bar. */
2982 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0; 2308 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;
2983#endif /* not MAC_OSX */ 2309#endif /* not MAC_OSX */
2984 if (FRAME_MAC_WINDOW (f))
2985 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
2986 do_pending_window_change (0);
2987 }
2988 else if (INTEGERP (arg) && XINT (arg) > 0
2989 && XFASTINT (arg) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
2990 {
2991 if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
2992 XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1);
2993
2994 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = XFASTINT (arg);
2995 FRAME_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid;
2996 if (FRAME_MAC_WINDOW (f))
2997 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
2998 do_pending_window_change (0);
2999 }
3000 change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0);
3001 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
3002 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
3003} 2310}
2311
3004 2312
3005/* Subroutines of creating a frame. */ 2313/* Subroutines of creating a frame. */
3006 2314
3007/* Make sure that Vx_resource_name is set to a reasonable value.
3008 Fix it up, or set it to `emacs' if it is too hopeless. */
3009
3010static void
3011validate_x_resource_name ()
3012{
3013 int len = 0;
3014 /* Number of valid characters in the resource name. */
3015 int good_count = 0;
3016 /* Number of invalid characters in the resource name. */
3017 int bad_count = 0;
3018 Lisp_Object new;
3019 int i;
3020
3021 if (STRINGP (Vx_resource_name))
3022 {
3023 unsigned char *p = SDATA (Vx_resource_name);
3024 int i;
3025
3026 len = SBYTES (Vx_resource_name);
3027
3028 /* Only letters, digits, - and _ are valid in resource names.
3029 Count the valid characters and count the invalid ones. */
3030 for (i = 0; i < len; i++)
3031 {
3032 int c = p[i];
3033 if (! ((c >= 'a' && c <= 'z')
3034 || (c >= 'A' && c <= 'Z')
3035 || (c >= '0' && c <= '9')
3036 || c == '-' || c == '_'))
3037 bad_count++;
3038 else
3039 good_count++;
3040 }
3041 }
3042 else
3043 /* Not a string => completely invalid. */
3044 bad_count = 5, good_count = 0;
3045
3046 /* If name is valid already, return. */
3047 if (bad_count == 0)
3048 return;
3049
3050 /* If name is entirely invalid, or nearly so, use `emacs'. */
3051 if (good_count == 0
3052 || (good_count == 1 && bad_count > 0))
3053 {
3054 Vx_resource_name = build_string ("emacs");
3055 return;
3056 }
3057
3058 /* Name is partly valid. Copy it and replace the invalid characters
3059 with underscores. */
3060
3061 Vx_resource_name = new = Fcopy_sequence (Vx_resource_name);
3062
3063 for (i = 0; i < len; i++)
3064 {
3065 int c = SREF (new, i);
3066 if (! ((c >= 'a' && c <= 'z')
3067 || (c >= 'A' && c <= 'Z')
3068 || (c >= '0' && c <= '9')
3069 || c == '-' || c == '_'))
3070 SSET (new, i, '_');
3071 }
3072}
3073
3074
3075#if 0 /* MAC_TODO: implement resource strings */
3076extern char *x_get_string_resource ();
3077
3078DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0,
3079 doc: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3080This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3081class, where INSTANCE is the name under which Emacs was invoked, or
3082the name specified by the `-name' or `-rn' command-line arguments.
3083
3084The optional arguments COMPONENT and SUBCLASS add to the key and the
3085class, respectively. You must specify both of them or neither.
3086If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3087and the class is `Emacs.CLASS.SUBCLASS'. */)
3088 (attribute, class, component, subclass)
3089 Lisp_Object attribute, class, component, subclass;
3090{
3091 register char *value;
3092 char *name_key;
3093 char *class_key;
3094
3095 CHECK_STRING (attribute);
3096 CHECK_STRING (class);
3097
3098 if (!NILP (component))
3099 CHECK_STRING (component);
3100 if (!NILP (subclass))
3101 CHECK_STRING (subclass);
3102 if (NILP (component) != NILP (subclass))
3103 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3104
3105 validate_x_resource_name ();
3106
3107 /* Allocate space for the components, the dots which separate them,
3108 and the final '\0'. Make them big enough for the worst case. */
3109 name_key = (char *) alloca (SBYTES (Vx_resource_name)
3110 + (STRINGP (component)
3111 ? SBYTES (component) : 0)
3112 + SBYTES (attribute)
3113 + 3);
3114
3115 class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
3116 + SBYTES (class)
3117 + (STRINGP (subclass)
3118 ? SBYTES (subclass) : 0)
3119 + 3);
3120
3121 /* Start with emacs.FRAMENAME for the name (the specific one)
3122 and with `Emacs' for the class key (the general one). */
3123 strcpy (name_key, SDATA (Vx_resource_name));
3124 strcpy (class_key, EMACS_CLASS);
3125
3126 strcat (class_key, ".");
3127 strcat (class_key, SDATA (class));
3128
3129 if (!NILP (component))
3130 {
3131 strcat (class_key, ".");
3132 strcat (class_key, SDATA (subclass));
3133
3134 strcat (name_key, ".");
3135 strcat (name_key, SDATA (component));
3136 }
3137
3138 strcat (name_key, ".");
3139 strcat (name_key, SDATA (attribute));
3140
3141 value = x_get_string_resource (Qnil,
3142 name_key, class_key);
3143
3144 if (value != (char *) 0)
3145 return build_string (value);
3146 else
3147 return Qnil;
3148}
3149
3150/* Used when C code wants a resource value. */
3151
3152char * 2315char *
3153x_get_resource_string (attribute, class) 2316x_get_string_resource (rdb, name, class)
3154 char *attribute, *class; 2317 XrmDatabase rdb;
2318 char *name, *class;
3155{ 2319{
3156 char *name_key; 2320 /* MAC_TODO: implement resource strings */
3157 char *class_key; 2321 return (char *)0;
3158 struct frame *sf = SELECTED_FRAME ();
3159
3160 /* Allocate space for the components, the dots which separate them,
3161 and the final '\0'. */
3162 name_key = (char *) alloca (SBYTES (Vinvocation_name)
3163 + strlen (attribute) + 2);
3164 class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
3165 + strlen (class) + 2);
3166
3167 sprintf (name_key, "%s.%s",
3168 SDATA (Vinvocation_name),
3169 attribute);
3170 sprintf (class_key, "%s.%s", EMACS_CLASS, class);
3171
3172 return x_get_string_resource (sf, name_key, class_key);
3173} 2322}
3174#endif /* MAC_TODO */
3175
3176/* Types we might convert a resource string into. */
3177enum resource_types
3178{
3179 RES_TYPE_NUMBER,
3180 RES_TYPE_FLOAT,
3181 RES_TYPE_BOOLEAN,
3182 RES_TYPE_STRING,
3183 RES_TYPE_SYMBOL
3184};
3185 2323
3186/* Return the value of parameter PARAM. 2324/* Return the value of parameter PARAM.
3187 2325
@@ -3191,7 +2329,7 @@ enum resource_types
3191 Convert the resource to the type specified by desired_type. 2329 Convert the resource to the type specified by desired_type.
3192 2330
3193 If no default is specified, return Qunbound. If you call 2331 If no default is specified, return Qunbound. If you call
3194 w32_get_arg, make sure you deal with Qunbound in a reasonable way, 2332 mac_get_arg, make sure you deal with Qunbound in a reasonable way,
3195 and don't let it get stored in any Lisp-visible variables! */ 2333 and don't let it get stored in any Lisp-visible variables! */
3196 2334
3197static Lisp_Object 2335static Lisp_Object
@@ -3201,94 +2339,10 @@ mac_get_arg (alist, param, attribute, class, type)
3201 char *class; 2339 char *class;
3202 enum resource_types type; 2340 enum resource_types type;
3203{ 2341{
3204 register Lisp_Object tem; 2342 return x_get_arg (check_x_display_info (Qnil),
3205 2343 alist, param, attribute, class, type);
3206 tem = Fassq (param, alist);
3207 if (EQ (tem, Qnil))
3208 tem = Fassq (param, Vdefault_frame_alist);
3209 if (EQ (tem, Qnil))
3210 {
3211
3212#if 0 /* MAC_TODO: search resource also */
3213 if (attribute)
3214 {
3215 tem = Fx_get_resource (build_string (attribute),
3216 build_string (class),
3217 Qnil, Qnil);
3218
3219 if (NILP (tem))
3220 return Qunbound;
3221
3222 switch (type)
3223 {
3224 case RES_TYPE_NUMBER:
3225 return make_number (atoi (SDATA (tem)));
3226
3227 case RES_TYPE_FLOAT:
3228 return make_float (atof (SDATA (tem)));
3229
3230 case RES_TYPE_BOOLEAN:
3231 tem = Fdowncase (tem);
3232 if (!strcmp (SDATA (tem), "on")
3233 || !strcmp (SDATA (tem), "true"))
3234 return Qt;
3235 else
3236 return Qnil;
3237
3238 case RES_TYPE_STRING:
3239 return tem;
3240
3241 case RES_TYPE_SYMBOL:
3242 /* As a special case, we map the values `true' and `on'
3243 to Qt, and `false' and `off' to Qnil. */
3244 {
3245 Lisp_Object lower;
3246 lower = Fdowncase (tem);
3247 if (!strcmp (SDATA (lower), "on")
3248 || !strcmp (SDATA (lower), "true"))
3249 return Qt;
3250 else if (!strcmp (SDATA (lower), "off")
3251 || !strcmp (SDATA (lower), "false"))
3252 return Qnil;
3253 else
3254 return Fintern (tem, Qnil);
3255 }
3256
3257 default:
3258 abort ();
3259 }
3260 }
3261 else
3262#endif /* MAC_TODO */
3263 return Qunbound;
3264 }
3265 return Fcdr (tem);
3266} 2344}
3267 2345
3268/* Record in frame F the specified or default value according to ALIST
3269 of the parameter named PROP (a Lisp symbol).
3270 If no value is specified for PROP, look for an X default for XPROP
3271 on the frame named NAME.
3272 If that is not found either, use the value DEFLT. */
3273
3274static Lisp_Object
3275x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)
3276 struct frame *f;
3277 Lisp_Object alist;
3278 Lisp_Object prop;
3279 Lisp_Object deflt;
3280 char *xprop;
3281 char *xclass;
3282 enum resource_types type;
3283{
3284 Lisp_Object tem;
3285
3286 tem = mac_get_arg (alist, prop, xprop, xclass, type);
3287 if (EQ (tem, Qunbound))
3288 tem = deflt;
3289 x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil));
3290 return tem;
3291}
3292 2346
3293/* XParseGeometry copied from w32xfns.c */ 2347/* XParseGeometry copied from w32xfns.c */
3294 2348
@@ -3427,189 +2481,6 @@ XParseGeometry (string, x, y, width, height)
3427 return (mask); 2481 return (mask);
3428} 2482}
3429 2483
3430DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,
3431 doc: /* Parse an X-style geometry string STRING.
3432Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3433The properties returned may include `top', `left', `height', and `width'.
3434The value of `left' or `top' may be an integer,
3435or a list (+ N) meaning N pixels relative to top/left corner,
3436or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3437 (string)
3438 Lisp_Object string;
3439{
3440 int geometry, x, y;
3441 unsigned int width, height;
3442 Lisp_Object result;
3443
3444 CHECK_STRING (string);
3445
3446 geometry = XParseGeometry ((char *) SDATA (string),
3447 &x, &y, &width, &height);
3448
3449 result = Qnil;
3450 if (geometry & XValue)
3451 {
3452 Lisp_Object element;
3453
3454 if (x >= 0 && (geometry & XNegative))
3455 element = Fcons (Qleft, Fcons (Qminus, Fcons (make_number (-x), Qnil)));
3456 else if (x < 0 && ! (geometry & XNegative))
3457 element = Fcons (Qleft, Fcons (Qplus, Fcons (make_number (x), Qnil)));
3458 else
3459 element = Fcons (Qleft, make_number (x));
3460 result = Fcons (element, result);
3461 }
3462
3463 if (geometry & YValue)
3464 {
3465 Lisp_Object element;
3466
3467 if (y >= 0 && (geometry & YNegative))
3468 element = Fcons (Qtop, Fcons (Qminus, Fcons (make_number (-y), Qnil)));
3469 else if (y < 0 && ! (geometry & YNegative))
3470 element = Fcons (Qtop, Fcons (Qplus, Fcons (make_number (y), Qnil)));
3471 else
3472 element = Fcons (Qtop, make_number (y));
3473 result = Fcons (element, result);
3474 }
3475
3476 if (geometry & WidthValue)
3477 result = Fcons (Fcons (Qwidth, make_number (width)), result);
3478 if (geometry & HeightValue)
3479 result = Fcons (Fcons (Qheight, make_number (height)), result);
3480
3481 return result;
3482}
3483
3484/* Calculate the desired size and position of this window,
3485 and return the flags saying which aspects were specified.
3486
3487 This function does not make the coordinates positive. */
3488
3489#define DEFAULT_ROWS 40
3490#define DEFAULT_COLS 80
3491
3492static int
3493x_figure_window_size (f, parms)
3494 struct frame *f;
3495 Lisp_Object parms;
3496{
3497 register Lisp_Object tem0, tem1, tem2;
3498 long window_prompting = 0;
3499
3500 /* Default values if we fall through.
3501 Actually, if that happens we should get
3502 window manager prompting. */
3503 SET_FRAME_WIDTH (f, DEFAULT_COLS);
3504 f->height = DEFAULT_ROWS;
3505 /* Window managers expect that if program-specified
3506 positions are not (0,0), they're intentional, not defaults. */
3507 f->output_data.mac->top_pos = 0;
3508 f->output_data.mac->left_pos = 0;
3509
3510 tem0 = mac_get_arg (parms, Qheight, 0, 0, RES_TYPE_NUMBER);
3511 tem1 = mac_get_arg (parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
3512 tem2 = mac_get_arg (parms, Quser_size, 0, 0, RES_TYPE_NUMBER);
3513 if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
3514 {
3515 if (!EQ (tem0, Qunbound))
3516 {
3517 CHECK_NUMBER (tem0);
3518 f->height = XINT (tem0);
3519 }
3520 if (!EQ (tem1, Qunbound))
3521 {
3522 CHECK_NUMBER (tem1);
3523 SET_FRAME_WIDTH (f, XINT (tem1));
3524 }
3525 if (!NILP (tem2) && !EQ (tem2, Qunbound))
3526 window_prompting |= USSize;
3527 else
3528 window_prompting |= PSize;
3529 }
3530
3531 f->output_data.mac->vertical_scroll_bar_extra
3532 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
3533 ? 0
3534 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
3535 ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f)
3536 : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.mac->font)));
3537
3538 compute_fringe_widths (f, 0);
3539
3540 f->output_data.mac->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
3541 f->output_data.mac->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
3542
3543 tem0 = mac_get_arg (parms, Qtop, 0, 0, RES_TYPE_NUMBER);
3544 tem1 = mac_get_arg (parms, Qleft, 0, 0, RES_TYPE_NUMBER);
3545 tem2 = mac_get_arg (parms, Quser_position, 0, 0, RES_TYPE_NUMBER);
3546 if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
3547 {
3548 if (EQ (tem0, Qminus))
3549 {
3550 f->output_data.mac->top_pos = 0;
3551 window_prompting |= YNegative;
3552 }
3553 else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
3554 && CONSP (XCDR (tem0))
3555 && INTEGERP (XCAR (XCDR (tem0))))
3556 {
3557 f->output_data.mac->top_pos = - XINT (XCAR (XCDR (tem0)));
3558 window_prompting |= YNegative;
3559 }
3560 else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
3561 && CONSP (XCDR (tem0))
3562 && INTEGERP (XCAR (XCDR (tem0))))
3563 {
3564 f->output_data.mac->top_pos = XINT (XCAR (XCDR (tem0)));
3565 }
3566 else if (EQ (tem0, Qunbound))
3567 f->output_data.mac->top_pos = 0;
3568 else
3569 {
3570 CHECK_NUMBER (tem0);
3571 f->output_data.mac->top_pos = XINT (tem0);
3572 if (f->output_data.mac->top_pos < 0)
3573 window_prompting |= YNegative;
3574 }
3575
3576 if (EQ (tem1, Qminus))
3577 {
3578 f->output_data.mac->left_pos = 0;
3579 window_prompting |= XNegative;
3580 }
3581 else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
3582 && CONSP (XCDR (tem1))
3583 && INTEGERP (XCAR (XCDR (tem1))))
3584 {
3585 f->output_data.mac->left_pos = - XINT (XCAR (XCDR (tem1)));
3586 window_prompting |= XNegative;
3587 }
3588 else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
3589 && CONSP (XCDR (tem1))
3590 && INTEGERP (XCAR (XCDR (tem1))))
3591 {
3592 f->output_data.mac->left_pos = XINT (XCAR (XCDR (tem1)));
3593 }
3594 else if (EQ (tem1, Qunbound))
3595 f->output_data.mac->left_pos = 0;
3596 else
3597 {
3598 CHECK_NUMBER (tem1);
3599 f->output_data.mac->left_pos = XINT (tem1);
3600 if (f->output_data.mac->left_pos < 0)
3601 window_prompting |= XNegative;
3602 }
3603
3604 if (!NILP (tem2) && ! EQ (tem2, Qunbound))
3605 window_prompting |= USPosition;
3606 else
3607 window_prompting |= PPosition;
3608 }
3609
3610 return window_prompting;
3611}
3612
3613 2484
3614#if 0 /* MAC_TODO */ 2485#if 0 /* MAC_TODO */
3615/* Create and set up the Mac window for frame F. */ 2486/* Create and set up the Mac window for frame F. */
@@ -3997,24 +2868,9 @@ This function is an internal primitive--use `make-frame' instead. */)
3997 "title", "Title", RES_TYPE_STRING); 2868 "title", "Title", RES_TYPE_STRING);
3998 2869
3999 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; 2870 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
4000 window_prompting = x_figure_window_size (f, parms);
4001 2871
4002 if (window_prompting & XNegative) 2872 /* MAC_TODO: specify 1 below when toolbars are implemented. */
4003 { 2873 window_prompting = x_figure_window_size (f, parms, 0);
4004 if (window_prompting & YNegative)
4005 f->output_data.mac->win_gravity = SouthEastGravity;
4006 else
4007 f->output_data.mac->win_gravity = NorthEastGravity;
4008 }
4009 else
4010 {
4011 if (window_prompting & YNegative)
4012 f->output_data.mac->win_gravity = SouthWestGravity;
4013 else
4014 f->output_data.mac->win_gravity = NorthWestGravity;
4015 }
4016
4017 f->output_data.mac->size_hint_flags = window_prompting;
4018 2874
4019 tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); 2875 tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
4020 f->no_split = minibuffer_only || EQ (tem, Qt); 2876 f->no_split = minibuffer_only || EQ (tem, Qt);
@@ -9400,24 +8256,9 @@ x_create_tip_frame (dpyinfo, parms)
9400 init_frame_faces (f); 8256 init_frame_faces (f);
9401 8257
9402 f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window; 8258 f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window;
9403 window_prompting = x_figure_window_size (f, parms);
9404 8259
9405 if (window_prompting & XNegative) 8260 window_prompting = x_figure_window_size (f, parms, 0);
9406 {
9407 if (window_prompting & YNegative)
9408 f->output_data.w32->win_gravity = SouthEastGravity;
9409 else
9410 f->output_data.w32->win_gravity = NorthEastGravity;
9411 }
9412 else
9413 {
9414 if (window_prompting & YNegative)
9415 f->output_data.w32->win_gravity = SouthWestGravity;
9416 else
9417 f->output_data.w32->win_gravity = NorthWestGravity;
9418 }
9419 8261
9420 f->output_data.w32->size_hint_flags = window_prompting;
9421 { 8262 {
9422 XSetWindowAttributes attrs; 8263 XSetWindowAttributes attrs;
9423 unsigned long mask; 8264 unsigned long mask;
@@ -9872,6 +8713,46 @@ DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "")
9872 8713
9873 8714
9874 8715
8716/***********************************************************************
8717 Initialization
8718 ***********************************************************************/
8719
8720/* Keep this list in the same order as frame_parms in frame.c.
8721 Use 0 for unsupported frame parameters. */
8722
8723frame_parm_handler mac_frame_parm_handlers[] =
8724{
8725 x_set_autoraise,
8726 x_set_autolower,
8727 x_set_background_color,
8728 x_set_border_color,
8729 x_set_border_width,
8730 x_set_cursor_color,
8731 x_set_cursor_type,
8732 x_set_font,
8733 x_set_foreground_color,
8734 x_set_icon_name,
8735 0, /* MAC_TODO: x_set_icon_type, */
8736 x_set_internal_border_width,
8737 x_set_menu_bar_lines,
8738 x_set_mouse_color,
8739 x_explicitly_set_name,
8740 x_set_scroll_bar_width,
8741 x_set_title,
8742 x_set_unsplittable,
8743 x_set_vertical_scroll_bars,
8744 x_set_visibility,
8745 x_set_tool_bar_lines,
8746 0, /* MAC_TODO: x_set_scroll_bar_foreground, */
8747 0, /* MAC_TODO: x_set_scroll_bar_background, */
8748 x_set_screen_gamma,
8749 x_set_line_spacing,
8750 0, /* MAC_TODO: x_set_fringe_width, */
8751 0, /* MAC_TODO: x_set_fringe_width, */
8752 0, /* x_set_wait_for_wm, */
8753 0, /* MAC_TODO: x_set_fullscreen, */
8754};
8755
9875void 8756void
9876syms_of_macfns () 8757syms_of_macfns ()
9877{ 8758{
@@ -9881,64 +8762,12 @@ syms_of_macfns ()
9881 /* The section below is built by the lisp expression at the top of the file, 8762 /* The section below is built by the lisp expression at the top of the file,
9882 just above where these variables are declared. */ 8763 just above where these variables are declared. */
9883 /*&&& init symbols here &&&*/ 8764 /*&&& init symbols here &&&*/
9884 Qauto_raise = intern ("auto-raise");
9885 staticpro (&Qauto_raise);
9886 Qauto_lower = intern ("auto-lower");
9887 staticpro (&Qauto_lower);
9888 Qborder_color = intern ("border-color");
9889 staticpro (&Qborder_color);
9890 Qborder_width = intern ("border-width");
9891 staticpro (&Qborder_width);
9892 Qcursor_color = intern ("cursor-color");
9893 staticpro (&Qcursor_color);
9894 Qcursor_type = intern ("cursor-type");
9895 staticpro (&Qcursor_type);
9896 Qgeometry = intern ("geometry");
9897 staticpro (&Qgeometry);
9898 Qicon_left = intern ("icon-left");
9899 staticpro (&Qicon_left);
9900 Qicon_top = intern ("icon-top");
9901 staticpro (&Qicon_top);
9902 Qicon_type = intern ("icon-type");
9903 staticpro (&Qicon_type);
9904 Qicon_name = intern ("icon-name");
9905 staticpro (&Qicon_name);
9906 Qinternal_border_width = intern ("internal-border-width");
9907 staticpro (&Qinternal_border_width);
9908 Qleft = intern ("left");
9909 staticpro (&Qleft);
9910 Qright = intern ("right");
9911 staticpro (&Qright);
9912 Qmouse_color = intern ("mouse-color");
9913 staticpro (&Qmouse_color);
9914 Qnone = intern ("none"); 8765 Qnone = intern ("none");
9915 staticpro (&Qnone); 8766 staticpro (&Qnone);
9916 Qparent_id = intern ("parent-id");
9917 staticpro (&Qparent_id);
9918 Qscroll_bar_width = intern ("scroll-bar-width");
9919 staticpro (&Qscroll_bar_width);
9920 Qsuppress_icon = intern ("suppress-icon"); 8767 Qsuppress_icon = intern ("suppress-icon");
9921 staticpro (&Qsuppress_icon); 8768 staticpro (&Qsuppress_icon);
9922 Qundefined_color = intern ("undefined-color"); 8769 Qundefined_color = intern ("undefined-color");
9923 staticpro (&Qundefined_color); 8770 staticpro (&Qundefined_color);
9924 Qvertical_scroll_bars = intern ("vertical-scroll-bars");
9925 staticpro (&Qvertical_scroll_bars);
9926 Qvisibility = intern ("visibility");
9927 staticpro (&Qvisibility);
9928 Qwindow_id = intern ("window-id");
9929 staticpro (&Qwindow_id);
9930 Qx_frame_parameter = intern ("x-frame-parameter");
9931 staticpro (&Qx_frame_parameter);
9932 Qx_resource_name = intern ("x-resource-name");
9933 staticpro (&Qx_resource_name);
9934 Quser_position = intern ("user-position");
9935 staticpro (&Quser_position);
9936 Quser_size = intern ("user-size");
9937 staticpro (&Quser_size);
9938 Qscreen_gamma = intern ("screen-gamma");
9939 staticpro (&Qscreen_gamma);
9940 Qline_spacing = intern ("line-spacing");
9941 staticpro (&Qline_spacing);
9942 Qcenter = intern ("center"); 8771 Qcenter = intern ("center");
9943 staticpro (&Qcenter); 8772 staticpro (&Qcenter);
9944 /* This is the end of symbol initialization. */ 8773 /* This is the end of symbol initialization. */
@@ -9986,15 +8815,6 @@ Changing the value does not affect existing frames
9986unless you set the mouse color. */); 8815unless you set the mouse color. */);
9987 Vx_pointer_shape = Qnil; 8816 Vx_pointer_shape = Qnil;
9988 8817
9989 DEFVAR_LISP ("x-resource-name", &Vx_resource_name,
9990 doc: /* The name Emacs uses to look up resources; for internal use only.
9991`x-get-resource' uses this as the first component of the instance name
9992when requesting resource values.
9993Emacs initially sets `x-resource-name' to the name under which Emacs
9994was invoked, or to the value specified with the `-name' or `-rn'
9995switches, if present. */);
9996 Vx_resource_name = Qnil;
9997
9998 Vx_nontext_pointer_shape = Qnil; 8818 Vx_nontext_pointer_shape = Qnil;
9999 8819
10000 Vx_mode_pointer_shape = Qnil; 8820 Vx_mode_pointer_shape = Qnil;
@@ -10050,9 +8870,6 @@ from the image cache. Value must be an integer or nil with nil
10050meaning don't clear the cache. */); 8870meaning don't clear the cache. */);
10051 Vimage_cache_eviction_delay = make_number (30 * 60); 8871 Vimage_cache_eviction_delay = make_number (30 * 60);
10052 8872
10053#if 0 /* MAC_TODO: implement get X resource */
10054 defsubr (&Sx_get_resource);
10055#endif
10056 defsubr (&Sx_change_window_property); 8873 defsubr (&Sx_change_window_property);
10057 defsubr (&Sx_delete_window_property); 8874 defsubr (&Sx_delete_window_property);
10058 defsubr (&Sx_window_property); 8875 defsubr (&Sx_window_property);
@@ -10073,9 +8890,6 @@ meaning don't clear the cache. */);
10073 defsubr (&Sx_display_visual_class); 8890 defsubr (&Sx_display_visual_class);
10074 defsubr (&Sx_display_backing_store); 8891 defsubr (&Sx_display_backing_store);
10075 defsubr (&Sx_display_save_under); 8892 defsubr (&Sx_display_save_under);
10076#if 0 /* MAC_TODO: implement XParseGeometry */
10077 defsubr (&Sx_parse_geometry);
10078#endif
10079 defsubr (&Sx_create_frame); 8893 defsubr (&Sx_create_frame);
10080#if 0 /* MAC_TODO: implement network support */ 8894#if 0 /* MAC_TODO: implement network support */
10081 defsubr (&Sx_open_connection); 8895 defsubr (&Sx_open_connection);