aboutsummaryrefslogtreecommitdiffstats
path: root/src/nsfns.m
diff options
context:
space:
mode:
Diffstat (limited to 'src/nsfns.m')
-rw-r--r--src/nsfns.m53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/nsfns.m b/src/nsfns.m
index f320a909497..ccefec1e34f 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1076,7 +1076,41 @@ unwind_create_frame (Lisp_Object frame)
1076 return Qnil; 1076 return Qnil;
1077} 1077}
1078 1078
1079/*
1080 * Read geometry related parameters from preferences if not in PARMS.
1081 * Returns the union of parms and any preferences read.
1082 */
1083
1084static Lisp_Object
1085get_geometry_from_preferences (struct ns_display_info *dpyinfo,
1086 Lisp_Object parms)
1087{
1088 struct {
1089 const char *val;
1090 const char *cls;
1091 Lisp_Object tem;
1092 } r[] = {
1093 { "width", "Width", Qwidth },
1094 { "height", "Height", Qheight },
1095 { "left", "Left", Qleft },
1096 { "top", "Top", Qtop },
1097 };
1098
1099 int i;
1100 for (i = 0; i < sizeof (r)/sizeof (r[0]); ++i)
1101 {
1102 if (NILP (Fassq (r[i].tem, parms)))
1103 {
1104 Lisp_Object value
1105 = x_get_arg (dpyinfo, parms, r[i].tem, r[i].val, r[i].cls,
1106 RES_TYPE_NUMBER);
1107 if (! EQ (value, Qunbound))
1108 parms = Fcons (Fcons (r[i].tem, value), parms);
1109 }
1110 }
1079 1111
1112 return parms;
1113}
1080 1114
1081/* ========================================================================== 1115/* ==========================================================================
1082 1116
@@ -1285,6 +1319,7 @@ This function is an internal primitive--use `make-frame' instead. */)
1285 x_default_parameter (f, parms, Qtitle, Qnil, "title", "Title", 1319 x_default_parameter (f, parms, Qtitle, Qnil, "title", "Title",
1286 RES_TYPE_STRING); 1320 RES_TYPE_STRING);
1287 1321
1322 parms = get_geometry_from_preferences (dpyinfo, parms);
1288 window_prompting = x_figure_window_size (f, parms, 1); 1323 window_prompting = x_figure_window_size (f, parms, 1);
1289 1324
1290 tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); 1325 tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
@@ -1511,6 +1546,17 @@ Optional arg INIT, if non-nil, provides a default file name to use. */)
1511 return ret ? fname : Qnil; 1546 return ret ? fname : Qnil;
1512} 1547}
1513 1548
1549const char *
1550ns_get_defaults_value (const char *key)
1551{
1552 NSObject *obj = [[NSUserDefaults standardUserDefaults]
1553 objectForKey: [NSString stringWithUTF8String: key]];
1554
1555 if (!obj) return NULL;
1556
1557 return [[NSString stringWithFormat: @"%@", obj] UTF8String];
1558}
1559
1514 1560
1515DEFUN ("ns-get-resource", Fns_get_resource, Sns_get_resource, 2, 2, 0, 1561DEFUN ("ns-get-resource", Fns_get_resource, Sns_get_resource, 2, 2, 0,
1516 doc: /* Return the value of the property NAME of OWNER from the defaults database. 1562 doc: /* Return the value of the property NAME of OWNER from the defaults database.
@@ -1525,9 +1571,7 @@ If OWNER is nil, Emacs is assumed. */)
1525 CHECK_STRING (name); 1571 CHECK_STRING (name);
1526/*fprintf (stderr, "ns-get-resource checking resource '%s'\n", SDATA (name)); */ 1572/*fprintf (stderr, "ns-get-resource checking resource '%s'\n", SDATA (name)); */
1527 1573
1528 value =[[[NSUserDefaults standardUserDefaults] 1574 value = ns_get_defaults_value (SDATA (name));
1529 objectForKey: [NSString stringWithUTF8String: SDATA (name)]]
1530 UTF8String];
1531 1575
1532 if (value) 1576 if (value)
1533 return build_string (value); 1577 return build_string (value);
@@ -2182,8 +2226,7 @@ x_get_string_resource (XrmDatabase rdb, char *name, char *class)
2182 /* --quick was passed, so this is a no-op. */ 2226 /* --quick was passed, so this is a no-op. */
2183 return NULL; 2227 return NULL;
2184 2228
2185 res = [[[NSUserDefaults standardUserDefaults] objectForKey: 2229 res = ns_get_defaults_value (toCheck);
2186 [NSString stringWithUTF8String: toCheck]] UTF8String];
2187 return !res ? NULL : 2230 return !res ? NULL :
2188 (!strncasecmp (res, "YES", 3) ? "true" : 2231 (!strncasecmp (res, "YES", 3) ? "true" :
2189 (!strncasecmp (res, "NO", 2) ? "false" : res)); 2232 (!strncasecmp (res, "NO", 2) ? "false" : res));