aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2013-04-07 08:41:19 +0400
committerDmitry Antipov2013-04-07 08:41:19 +0400
commit7452b7bd70f01fb96f13269250bda32507ce0cf1 (patch)
tree7751bfa41bc66b5516fb734cb44c98c2b74c5a5b /src
parent6096db2e0067715c06573c924214385a2c0a1baf (diff)
downloademacs-7452b7bd70f01fb96f13269250bda32507ce0cf1.tar.gz
emacs-7452b7bd70f01fb96f13269250bda32507ce0cf1.zip
Get rid of some platform-specific functions examining window
system and its capabilities. This is a partial rework of the 2013-04-05 change. * lisp.h (have_menus_p): Remove prototype. This function is replaced with platform-independent window_system_available. (check_window_system): Move to... * frame.h (decode_window_system_frame, window_system_available): ...here, add new prototypes. * frame.c (window_system_available, decode_window_system_frame): New functions. (check_window_system): Platform-independent now. * xterm.h (x_in_use): Remove declaration. (check_x_frame): * w32term.h (check_x_frame): * nsterm.h (check_x_frame): Remove prototypes. This function is replaced with platform-independent decode_window_system_frame. * msdos.c (have_menus_p): Remove. * nsfns.m (check_window_system, have_menus_p, check_ns_frame): Remove platform-specific functions. Use check_window_system, decode_window_system_frame and check_ns_display_info where appropriate. Minor style and comment tweaks. * w32fns.c (w32_in_use, check_window_system, have_menus_p) (check_x_frame): Likewise. * xfns.c (x_in_use, check_window_system, have_menus_p, check_x_frame): Likewise. * fileio.c, fns.c, font.c, fontset.c, image.c, menu.c, nsmenu.m: * nsselect.m, nsterm.m, w32font.c, w32menu.c, xfaces.c, xgselect.c: * xmenu.c, xselect.c: All related users changed.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog31
-rw-r--r--src/fileio.c2
-rw-r--r--src/fns.c5
-rw-r--r--src/font.c4
-rw-r--r--src/fontset.c5
-rw-r--r--src/frame.c33
-rw-r--r--src/frame.h3
-rw-r--r--src/image.c10
-rw-r--r--src/lisp.h10
-rw-r--r--src/menu.c2
-rw-r--r--src/msdos.c5
-rw-r--r--src/nsfns.m142
-rw-r--r--src/nsmenu.m4
-rw-r--r--src/nsselect.m15
-rw-r--r--src/nsterm.h2
-rw-r--r--src/nsterm.m38
-rw-r--r--src/w32fns.c60
-rw-r--r--src/w32font.c2
-rw-r--r--src/w32menu.c4
-rw-r--r--src/w32term.h1
-rw-r--r--src/xfaces.c10
-rw-r--r--src/xfns.c74
-rw-r--r--src/xgselect.c3
-rw-r--r--src/xmenu.c9
-rw-r--r--src/xselect.c8
-rw-r--r--src/xterm.h2
26 files changed, 187 insertions, 297 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 70e342dfb2f..e39a104e135 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,34 @@
12013-04-07 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Get rid of some platform-specific functions examining window
4 system and its capabilities. This is a partial rework of the
5 2013-04-05 change.
6 * lisp.h (have_menus_p): Remove prototype. This function is
7 replaced with platform-independent window_system_available.
8 (check_window_system): Move to...
9 * frame.h (decode_window_system_frame, window_system_available):
10 ...here, add new prototypes.
11 * frame.c (window_system_available, decode_window_system_frame):
12 New functions.
13 (check_window_system): Platform-independent now.
14 * xterm.h (x_in_use): Remove declaration.
15 (check_x_frame):
16 * w32term.h (check_x_frame):
17 * nsterm.h (check_x_frame): Remove prototypes. This function
18 is replaced with platform-independent decode_window_system_frame.
19 * msdos.c (have_menus_p): Remove.
20 * nsfns.m (check_window_system, have_menus_p, check_ns_frame):
21 Remove platform-specific functions. Use check_window_system,
22 decode_window_system_frame and check_ns_display_info where
23 appropriate. Minor style and comment tweaks.
24 * w32fns.c (w32_in_use, check_window_system, have_menus_p)
25 (check_x_frame): Likewise.
26 * xfns.c (x_in_use, check_window_system, have_menus_p, check_x_frame):
27 Likewise.
28 * fileio.c, fns.c, font.c, fontset.c, image.c, menu.c, nsmenu.m:
29 * nsselect.m, nsterm.m, w32font.c, w32menu.c, xfaces.c, xgselect.c:
30 * xmenu.c, xselect.c: All related users changed.
31
12013-04-03 Kenichi Handa <handa@gnu.org> 322013-04-03 Kenichi Handa <handa@gnu.org>
2 33
3 The following changes is to optimize the code for reading UTF-8 34 The following changes is to optimize the code for reading UTF-8
diff --git a/src/fileio.c b/src/fileio.c
index 2047338f03e..bffaff0609d 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5816,7 +5816,7 @@ before any other event (mouse or keypress) is handled. */)
5816 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) 5816 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
5817 && use_dialog_box 5817 && use_dialog_box
5818 && use_file_dialog 5818 && use_file_dialog
5819 && have_menus_p ()) 5819 && window_system_available (SELECTED_FRAME ()))
5820 return Qt; 5820 return Qt;
5821#endif 5821#endif
5822 return Qnil; 5822 return Qnil;
diff --git a/src/fns.c b/src/fns.c
index b3a1dc2317a..86bdc0250dc 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2443,10 +2443,9 @@ is nil, and `use-dialog-box' is non-nil. */)
2443 CHECK_STRING (prompt); 2443 CHECK_STRING (prompt);
2444 2444
2445#ifdef HAVE_MENUS 2445#ifdef HAVE_MENUS
2446 if (FRAME_WINDOW_P (SELECTED_FRAME ()) 2446 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
2447 && (NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
2448 && use_dialog_box 2447 && use_dialog_box
2449 && have_menus_p ()) 2448 && window_system_available (SELECTED_FRAME ()))
2450 { 2449 {
2451 Lisp_Object pane, menu, obj; 2450 Lisp_Object pane, menu, obj;
2452 redisplay_preserve_echo_area (4); 2451 redisplay_preserve_echo_area (4);
diff --git a/src/font.c b/src/font.c
index 17573cdc264..6247eeca948 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4844,11 +4844,9 @@ If the named font is not yet loaded, return nil. */)
4844 Lisp_Object info; 4844 Lisp_Object info;
4845 Lisp_Object font_object; 4845 Lisp_Object font_object;
4846 4846
4847 check_window_system ();
4848
4849 if (! FONTP (name)) 4847 if (! FONTP (name))
4850 CHECK_STRING (name); 4848 CHECK_STRING (name);
4851 f = decode_live_frame (frame); 4849 f = decode_window_system_frame (frame);
4852 4850
4853 if (STRINGP (name)) 4851 if (STRINGP (name))
4854 { 4852 {
diff --git a/src/fontset.c b/src/fontset.c
index 7aec26bbb5b..2f6313c4214 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1209,7 +1209,7 @@ If REGEXPP is non-nil, PATTERN is a regular expression. */)
1209 Lisp_Object fontset; 1209 Lisp_Object fontset;
1210 int id; 1210 int id;
1211 1211
1212 check_window_system (); 1212 check_window_system (NULL);
1213 1213
1214 CHECK_STRING (pattern); 1214 CHECK_STRING (pattern);
1215 1215
@@ -1915,8 +1915,7 @@ format is the same as above. */)
1915 Lisp_Object val, elt; 1915 Lisp_Object val, elt;
1916 int c, i, j, k; 1916 int c, i, j, k;
1917 1917
1918 check_window_system (); 1918 check_window_system (NULL);
1919
1920 fontset = check_fontset_name (fontset, &frame); 1919 fontset = check_fontset_name (fontset, &frame);
1921 1920
1922 /* Recode fontsets realized on FRAME from the base fontset FONTSET 1921 /* Recode fontsets realized on FRAME from the base fontset FONTSET
diff --git a/src/frame.c b/src/frame.c
index 5d5876ed097..2fe398296ed 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -149,6 +149,37 @@ decode_any_frame (register Lisp_Object frame)
149 return XFRAME (frame); 149 return XFRAME (frame);
150} 150}
151 151
152bool
153window_system_available (struct frame *f)
154{
155 if (f)
156 return FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f);
157 else
158#ifdef HAVE_WINDOW_SYSTEM
159 return x_display_list != NULL;
160#else
161 return 0;
162#endif
163}
164
165struct frame *
166decode_window_system_frame (Lisp_Object frame)
167{
168 struct frame *f = decode_live_frame (frame);
169
170 if (!window_system_available (f))
171 error ("Window system frame should be used");
172 return f;
173}
174
175void
176check_window_system (struct frame *f)
177{
178 if (!window_system_available (f))
179 error (f ? "Window system frame should be used"
180 : "Window system is not in use or not initialized");
181}
182
152static void 183static void
153set_menu_bar_lines_1 (Lisp_Object window, int n) 184set_menu_bar_lines_1 (Lisp_Object window, int n)
154{ 185{
@@ -3493,7 +3524,7 @@ and the class is `Emacs.CLASS.SUBCLASS'. */)
3493 (Lisp_Object attribute, Lisp_Object class, Lisp_Object component, 3524 (Lisp_Object attribute, Lisp_Object class, Lisp_Object component,
3494 Lisp_Object subclass) 3525 Lisp_Object subclass)
3495{ 3526{
3496 check_window_system (); 3527 check_window_system (NULL);
3497 3528
3498 return xrdb_get_resource (check_x_display_info (Qnil)->xrdb, 3529 return xrdb_get_resource (check_x_display_info (Qnil)->xrdb,
3499 attribute, class, component, subclass); 3530 attribute, class, component, subclass);
diff --git a/src/frame.h b/src/frame.h
index 46e18dd8ddb..b69f19b7ef8 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -958,6 +958,7 @@ extern Lisp_Object Qnoelisp;
958extern struct frame *last_nonminibuf_frame; 958extern struct frame *last_nonminibuf_frame;
959 959
960extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); 960extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
961extern struct frame *decode_window_system_frame (Lisp_Object);
961extern struct frame *decode_live_frame (Lisp_Object); 962extern struct frame *decode_live_frame (Lisp_Object);
962extern struct frame *decode_any_frame (Lisp_Object); 963extern struct frame *decode_any_frame (Lisp_Object);
963extern struct frame *make_initial_frame (void); 964extern struct frame *make_initial_frame (void);
@@ -968,6 +969,8 @@ extern struct frame *make_frame_without_minibuffer (Lisp_Object,
968 struct kboard *, 969 struct kboard *,
969 Lisp_Object); 970 Lisp_Object);
970#endif /* HAVE_WINDOW_SYSTEM */ 971#endif /* HAVE_WINDOW_SYSTEM */
972extern bool window_system_available (struct frame *);
973extern void check_window_system (struct frame *);
971extern void frame_make_pointer_invisible (void); 974extern void frame_make_pointer_invisible (void);
972extern void frame_make_pointer_visible (void); 975extern void frame_make_pointer_visible (void);
973extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object); 976extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
diff --git a/src/image.c b/src/image.c
index cac23b7fa87..2dae63a294f 100644
--- a/src/image.c
+++ b/src/image.c
@@ -889,7 +889,7 @@ or omitted means use the selected frame. */)
889 size = Qnil; 889 size = Qnil;
890 if (valid_image_p (spec)) 890 if (valid_image_p (spec))
891 { 891 {
892 struct frame *f = check_x_frame (frame); 892 struct frame *f = decode_window_system_frame (frame);
893 ptrdiff_t id = lookup_image (f, spec); 893 ptrdiff_t id = lookup_image (f, spec);
894 struct image *img = IMAGE_FROM_ID (f, id); 894 struct image *img = IMAGE_FROM_ID (f, id);
895 int width = img->width + 2 * img->hmargin; 895 int width = img->width + 2 * img->hmargin;
@@ -919,7 +919,7 @@ or omitted means use the selected frame. */)
919 mask = Qnil; 919 mask = Qnil;
920 if (valid_image_p (spec)) 920 if (valid_image_p (spec))
921 { 921 {
922 struct frame *f = check_x_frame (frame); 922 struct frame *f = decode_window_system_frame (frame);
923 ptrdiff_t id = lookup_image (f, spec); 923 ptrdiff_t id = lookup_image (f, spec);
924 struct image *img = IMAGE_FROM_ID (f, id); 924 struct image *img = IMAGE_FROM_ID (f, id);
925 if (img->mask) 925 if (img->mask)
@@ -942,7 +942,7 @@ or omitted means use the selected frame. */)
942 ext = Qnil; 942 ext = Qnil;
943 if (valid_image_p (spec)) 943 if (valid_image_p (spec))
944 { 944 {
945 struct frame *f = check_x_frame (frame); 945 struct frame *f = decode_window_system_frame (frame);
946 ptrdiff_t id = lookup_image (f, spec); 946 ptrdiff_t id = lookup_image (f, spec);
947 struct image *img = IMAGE_FROM_ID (f, id); 947 struct image *img = IMAGE_FROM_ID (f, id);
948 ext = img->lisp_data; 948 ext = img->lisp_data;
@@ -1550,7 +1550,7 @@ which is then usually a filename. */)
1550 if (!(EQ (filter, Qnil) || FRAMEP (filter))) 1550 if (!(EQ (filter, Qnil) || FRAMEP (filter)))
1551 clear_image_caches (filter); 1551 clear_image_caches (filter);
1552 else 1552 else
1553 clear_image_cache (check_x_frame (filter), Qt); 1553 clear_image_cache (decode_window_system_frame (filter), Qt);
1554 1554
1555 return Qnil; 1555 return Qnil;
1556} 1556}
@@ -1581,7 +1581,7 @@ FRAME t means refresh the image on all frames. */)
1581 } 1581 }
1582 } 1582 }
1583 else 1583 else
1584 uncache_image (check_x_frame (frame), spec); 1584 uncache_image (decode_window_system_frame (frame), spec);
1585 1585
1586 return Qnil; 1586 return Qnil;
1587} 1587}
diff --git a/src/lisp.h b/src/lisp.h
index 2e1d20a5109..bcb866b4cc4 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3765,22 +3765,12 @@ extern void syms_of_xterm (void);
3765extern char *x_get_keysym_name (int); 3765extern char *x_get_keysym_name (int);
3766#endif /* HAVE_WINDOW_SYSTEM */ 3766#endif /* HAVE_WINDOW_SYSTEM */
3767 3767
3768#if defined(HAVE_WINDOW_SYSTEM) || defined (MSDOS)
3769/* Defined in (x|w32)fns.c, nsfns.m, msdos.c. */
3770extern void check_window_system (void);
3771#endif
3772
3773#ifdef HAVE_LIBXML2 3768#ifdef HAVE_LIBXML2
3774/* Defined in xml.c. */ 3769/* Defined in xml.c. */
3775extern void syms_of_xml (void); 3770extern void syms_of_xml (void);
3776extern void xml_cleanup_parser (void); 3771extern void xml_cleanup_parser (void);
3777#endif 3772#endif
3778 3773
3779#ifdef HAVE_MENUS
3780/* Defined in (x|w32)fns.c, nsfns.m, msdos.c. */
3781extern int have_menus_p (void);
3782#endif
3783
3784#ifdef HAVE_DBUS 3774#ifdef HAVE_DBUS
3785/* Defined in dbusbind.c. */ 3775/* Defined in dbusbind.c. */
3786void syms_of_dbusbind (void); 3776void syms_of_dbusbind (void);
diff --git a/src/menu.c b/src/menu.c
index ec9c681a3a9..58558d5aedd 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1086,7 +1086,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
1086 { 1086 {
1087 bool get_current_pos_p = 0; 1087 bool get_current_pos_p = 0;
1088 1088
1089 check_window_system (); 1089 check_window_system (SELECTED_FRAME ());
1090 1090
1091 /* Decode the first argument: find the window and the coordinates. */ 1091 /* Decode the first argument: find the window and the coordinates. */
1092 if (EQ (position, Qt) 1092 if (EQ (position, Qt)
diff --git a/src/msdos.c b/src/msdos.c
index dc79b66e0b1..a2bcc06ac17 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -2983,11 +2983,6 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
2983 2983
2984/* --------------------------- X Menu emulation ---------------------- */ 2984/* --------------------------- X Menu emulation ---------------------- */
2985 2985
2986/* Report availability of menus. */
2987
2988int
2989have_menus_p (void) { return 1; }
2990
2991/* Create a brand new menu structure. */ 2986/* Create a brand new menu structure. */
2992 2987
2993XMenu * 2988XMenu *
diff --git a/src/nsfns.m b/src/nsfns.m
index f7cf898c7a9..a483f847dec 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -107,43 +107,6 @@ static ptrdiff_t image_cache_refcount;
107 107
108 ========================================================================== */ 108 ========================================================================== */
109 109
110
111void
112check_window_system (void)
113{
114 if (NSApp == nil)
115 error ("OpenStep is not in use or not initialized");
116}
117
118
119/* Nonzero if we can use mouse menus. */
120int
121have_menus_p (void)
122{
123 return NSApp != nil;
124}
125
126
127/* Extract a frame as a FRAME_PTR, defaulting to the selected frame
128 and checking validity for NS. */
129static FRAME_PTR
130check_ns_frame (Lisp_Object frame)
131{
132 FRAME_PTR f;
133
134 if (NILP (frame))
135 f = SELECTED_FRAME ();
136 else
137 {
138 CHECK_LIVE_FRAME (frame);
139 f = XFRAME (frame);
140 }
141 if (! FRAME_NS_P (f))
142 error ("non-Nextstep frame used");
143 return f;
144}
145
146
147/* Let the user specify an Nextstep display with a frame. 110/* Let the user specify an Nextstep display with a frame.
148 nil stands for the selected frame--or, if that is not an Nextstep frame, 111 nil stands for the selected frame--or, if that is not an Nextstep frame,
149 the first Nextstep display on the list. */ 112 the first Nextstep display on the list. */
@@ -1145,8 +1108,6 @@ This function is an internal primitive--use `make-frame' instead. */)
1145 Lisp_Object tfont, tfontsize; 1108 Lisp_Object tfont, tfontsize;
1146 static int desc_ctr = 1; 1109 static int desc_ctr = 1;
1147 1110
1148 check_window_system ();
1149
1150 /* x_get_arg modifies parms. */ 1111 /* x_get_arg modifies parms. */
1151 parms = Fcopy_alist (parms); 1112 parms = Fcopy_alist (parms);
1152 1113
@@ -1418,7 +1379,7 @@ DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
1418FRAME nil means use the selected frame. */) 1379FRAME nil means use the selected frame. */)
1419 (Lisp_Object frame) 1380 (Lisp_Object frame)
1420{ 1381{
1421 struct frame *f = check_ns_frame (frame); 1382 struct frame *f = decode_window_system_frame (frame);
1422 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); 1383 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
1423 1384
1424 if (dpyinfo->x_focus_frame != f) 1385 if (dpyinfo->x_focus_frame != f)
@@ -1439,18 +1400,8 @@ DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel,
1439 doc: /* Pop up the font panel. */) 1400 doc: /* Pop up the font panel. */)
1440 (Lisp_Object frame) 1401 (Lisp_Object frame)
1441{ 1402{
1442 id fm; 1403 struct frame *f = decode_window_system_frame (frame);
1443 struct frame *f; 1404 id fm = [NSFontManager sharedFontManager];
1444
1445 check_window_system ();
1446 fm = [NSFontManager sharedFontManager];
1447 if (NILP (frame))
1448 f = SELECTED_FRAME ();
1449 else
1450 {
1451 CHECK_FRAME (frame);
1452 f = XFRAME (frame);
1453 }
1454 1405
1455 [fm setSelectedFont: ((struct nsfont_info *)f->output_data.ns->font)->nsfont 1406 [fm setSelectedFont: ((struct nsfont_info *)f->output_data.ns->font)->nsfont
1456 isMultiple: NO]; 1407 isMultiple: NO];
@@ -1464,17 +1415,7 @@ DEFUN ("ns-popup-color-panel", Fns_popup_color_panel, Sns_popup_color_panel,
1464 doc: /* Pop up the color panel. */) 1415 doc: /* Pop up the color panel. */)
1465 (Lisp_Object frame) 1416 (Lisp_Object frame)
1466{ 1417{
1467 struct frame *f; 1418 check_window_system (NULL);
1468
1469 check_window_system ();
1470 if (NILP (frame))
1471 f = SELECTED_FRAME ();
1472 else
1473 {
1474 CHECK_FRAME (frame);
1475 f = XFRAME (frame);
1476 }
1477
1478 [NSApp orderFrontColorPanel: NSApp]; 1419 [NSApp orderFrontColorPanel: NSApp];
1479 return Qnil; 1420 return Qnil;
1480} 1421}
@@ -1503,7 +1444,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
1503 NSString *initS = NILP (init) || !STRINGP (init) ? nil : 1444 NSString *initS = NILP (init) || !STRINGP (init) ? nil :
1504 [NSString stringWithUTF8String: SSDATA (init)]; 1445 [NSString stringWithUTF8String: SSDATA (init)];
1505 1446
1506 check_window_system (); 1447 check_window_system (NULL);
1507 1448
1508 if (fileDelegate == nil) 1449 if (fileDelegate == nil)
1509 fileDelegate = [EmacsFileDelegate new]; 1450 fileDelegate = [EmacsFileDelegate new];
@@ -1594,11 +1535,10 @@ If OWNER is nil, Emacs is assumed. */)
1594{ 1535{
1595 const char *value; 1536 const char *value;
1596 1537
1597 check_window_system (); 1538 check_window_system (NULL);
1598 if (NILP (owner)) 1539 if (NILP (owner))
1599 owner = build_string([ns_app_name UTF8String]); 1540 owner = build_string([ns_app_name UTF8String]);
1600 CHECK_STRING (name); 1541 CHECK_STRING (name);
1601/*fprintf (stderr, "ns-get-resource checking resource '%s'\n", SSDATA (name)); */
1602 1542
1603 value = ns_get_defaults_value (SSDATA (name)); 1543 value = ns_get_defaults_value (SSDATA (name));
1604 1544
@@ -1614,7 +1554,7 @@ If OWNER is nil, Emacs is assumed.
1614If VALUE is nil, the default is removed. */) 1554If VALUE is nil, the default is removed. */)
1615 (Lisp_Object owner, Lisp_Object name, Lisp_Object value) 1555 (Lisp_Object owner, Lisp_Object name, Lisp_Object value)
1616{ 1556{
1617 check_window_system (); 1557 check_window_system (NULL);
1618 if (NILP (owner)) 1558 if (NILP (owner))
1619 owner = build_string ([ns_app_name UTF8String]); 1559 owner = build_string ([ns_app_name UTF8String]);
1620 CHECK_STRING (name); 1560 CHECK_STRING (name);
@@ -1642,7 +1582,7 @@ DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
1642 doc: /* This function is a no-op. It is only present for completeness. */) 1582 doc: /* This function is a no-op. It is only present for completeness. */)
1643 (Lisp_Object display) 1583 (Lisp_Object display)
1644{ 1584{
1645 check_window_system (); 1585 check_ns_display_info (display);
1646 /* This function has no real equivalent under NeXTstep. Return nil to 1586 /* This function has no real equivalent under NeXTstep. Return nil to
1647 indicate this. */ 1587 indicate this. */
1648 return Qnil; 1588 return Qnil;
@@ -1692,7 +1632,7 @@ If omitted or nil, the selected frame's display is used. */)
1692{ 1632{
1693 int num; 1633 int num;
1694 1634
1695 check_window_system (); 1635 check_ns_display_info (display);
1696 num = [[NSScreen screens] count]; 1636 num = [[NSScreen screens] count];
1697 1637
1698 return (num != 0) ? make_number (num) : Qnil; 1638 return (num != 0) ? make_number (num) : Qnil;
@@ -1706,7 +1646,7 @@ DISPLAY should be a frame, the display name as a string, or a terminal ID.
1706If omitted or nil, the selected frame's display is used. */) 1646If omitted or nil, the selected frame's display is used. */)
1707 (Lisp_Object display) 1647 (Lisp_Object display)
1708{ 1648{
1709 check_window_system (); 1649 check_ns_display_info (display);
1710 return make_number ((int) 1650 return make_number ((int)
1711 ([ns_get_screen (display) frame].size.height/(92.0/25.4))); 1651 ([ns_get_screen (display) frame].size.height/(92.0/25.4)));
1712} 1652}
@@ -1719,7 +1659,7 @@ DISPLAY should be a frame, the display name as a string, or a terminal ID.
1719If omitted or nil, the selected frame's display is used. */) 1659If omitted or nil, the selected frame's display is used. */)
1720 (Lisp_Object display) 1660 (Lisp_Object display)
1721{ 1661{
1722 check_window_system (); 1662 check_ns_display_info (display);
1723 return make_number ((int) 1663 return make_number ((int)
1724 ([ns_get_screen (display) frame].size.width/(92.0/25.4))); 1664 ([ns_get_screen (display) frame].size.width/(92.0/25.4)));
1725} 1665}
@@ -1733,7 +1673,7 @@ DISPLAY should be a frame, the display name as a string, or a terminal ID.
1733If omitted or nil, the selected frame's display is used. */) 1673If omitted or nil, the selected frame's display is used. */)
1734 (Lisp_Object display) 1674 (Lisp_Object display)
1735{ 1675{
1736 check_window_system (); 1676 check_ns_display_info (display);
1737 switch ([ns_get_window (display) backingType]) 1677 switch ([ns_get_window (display) backingType])
1738 { 1678 {
1739 case NSBackingStoreBuffered: 1679 case NSBackingStoreBuffered:
@@ -1759,7 +1699,8 @@ If omitted or nil, the selected frame's display is used. */)
1759 (Lisp_Object display) 1699 (Lisp_Object display)
1760{ 1700{
1761 NSWindowDepth depth; 1701 NSWindowDepth depth;
1762 check_window_system (); 1702
1703 check_ns_display_info (display);
1763 depth = [ns_get_screen (display) depth]; 1704 depth = [ns_get_screen (display) depth];
1764 1705
1765 if ( depth == NSBestDepth (NSCalibratedWhiteColorSpace, 2, 2, YES, NULL)) 1706 if ( depth == NSBestDepth (NSCalibratedWhiteColorSpace, 2, 2, YES, NULL))
@@ -1786,7 +1727,7 @@ DISPLAY should be a frame, the display name as a string, or a terminal ID.
1786If omitted or nil, the selected frame's display is used. */) 1727If omitted or nil, the selected frame's display is used. */)
1787 (Lisp_Object display) 1728 (Lisp_Object display)
1788{ 1729{
1789 check_window_system (); 1730 check_ns_display_info (display);
1790 switch ([ns_get_window (display) backingType]) 1731 switch ([ns_get_window (display) backingType])
1791 { 1732 {
1792 case NSBackingStoreBuffered: 1733 case NSBackingStoreBuffered:
@@ -1836,11 +1777,10 @@ terminate Emacs if we can't open the connection.
1836DEFUN ("x-close-connection", Fx_close_connection, Sx_close_connection, 1777DEFUN ("x-close-connection", Fx_close_connection, Sx_close_connection,
1837 1, 1, 0, 1778 1, 1, 0,
1838 doc: /* Close the connection to the current Nextstep display server. 1779 doc: /* Close the connection to the current Nextstep display server.
1839The argument DISPLAY is currently ignored. */) 1780DISPLAY should be a frame, the display name as a string, or a terminal ID. */)
1840 (Lisp_Object display) 1781 (Lisp_Object display)
1841{ 1782{
1842 check_window_system (); 1783 check_ns_display_info (display);
1843 /*ns_delete_terminal (dpyinfo->terminal); */
1844 [NSApp terminate: NSApp]; 1784 [NSApp terminate: NSApp];
1845 return Qnil; 1785 return Qnil;
1846} 1786}
@@ -1865,7 +1805,7 @@ DEFUN ("ns-hide-others", Fns_hide_others, Sns_hide_others,
1865 doc: /* Hides all applications other than Emacs. */) 1805 doc: /* Hides all applications other than Emacs. */)
1866 (void) 1806 (void)
1867{ 1807{
1868 check_window_system (); 1808 check_window_system (NULL);
1869 [NSApp hideOtherApplications: NSApp]; 1809 [NSApp hideOtherApplications: NSApp];
1870 return Qnil; 1810 return Qnil;
1871} 1811}
@@ -1878,7 +1818,7 @@ If ON is equal to `activate', Emacs is unhidden and becomes
1878the active application. */) 1818the active application. */)
1879 (Lisp_Object on) 1819 (Lisp_Object on)
1880{ 1820{
1881 check_window_system (); 1821 check_window_system (NULL);
1882 if (EQ (on, intern ("activate"))) 1822 if (EQ (on, intern ("activate")))
1883 { 1823 {
1884 [NSApp unhide: NSApp]; 1824 [NSApp unhide: NSApp];
@@ -1897,7 +1837,7 @@ DEFUN ("ns-emacs-info-panel", Fns_emacs_info_panel, Sns_emacs_info_panel,
1897 doc: /* Shows the 'Info' or 'About' panel for Emacs. */) 1837 doc: /* Shows the 'Info' or 'About' panel for Emacs. */)
1898 (void) 1838 (void)
1899{ 1839{
1900 check_window_system (); 1840 check_window_system (NULL);
1901 [NSApp orderFrontStandardAboutPanel: nil]; 1841 [NSApp orderFrontStandardAboutPanel: nil];
1902 return Qnil; 1842 return Qnil;
1903} 1843}
@@ -1975,7 +1915,7 @@ DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0,
1975 NSMenu *svcs; 1915 NSMenu *svcs;
1976 id delegate; 1916 id delegate;
1977 1917
1978 check_window_system (); 1918 check_window_system (NULL);
1979 svcs = [[NSMenu alloc] initWithTitle: @"Services"]; 1919 svcs = [[NSMenu alloc] initWithTitle: @"Services"];
1980 [NSApp setServicesMenu: svcs]; 1920 [NSApp setServicesMenu: svcs];
1981 [NSApp registerServicesMenuSendTypes: ns_send_types 1921 [NSApp registerServicesMenuSendTypes: ns_send_types
@@ -2028,7 +1968,7 @@ there was no result. */)
2028 char *utfStr; 1968 char *utfStr;
2029 1969
2030 CHECK_STRING (service); 1970 CHECK_STRING (service);
2031 check_window_system (); 1971 check_window_system (NULL);
2032 1972
2033 utfStr = SSDATA (service); 1973 utfStr = SSDATA (service);
2034 svcName = [NSString stringWithUTF8String: utfStr]; 1974 svcName = [NSString stringWithUTF8String: utfStr];
@@ -2152,7 +2092,7 @@ In case the execution fails, an error is signaled. */)
2152 NSEvent *nxev; 2092 NSEvent *nxev;
2153 2093
2154 CHECK_STRING (script); 2094 CHECK_STRING (script);
2155 check_window_system (); 2095 check_window_system (NULL);
2156 2096
2157 block_input (); 2097 block_input ();
2158 2098
@@ -2201,15 +2141,6 @@ In case the execution fails, an error is signaled. */)
2201 2141
2202 ========================================================================== */ 2142 ========================================================================== */
2203 2143
2204
2205/* called from image.c */
2206FRAME_PTR
2207check_x_frame (Lisp_Object frame)
2208{
2209 return check_ns_frame (frame);
2210}
2211
2212
2213/* called from frame.c */ 2144/* called from frame.c */
2214struct ns_display_info * 2145struct ns_display_info *
2215check_x_display_info (Lisp_Object frame) 2146check_x_display_info (Lisp_Object frame)
@@ -2235,7 +2166,7 @@ x_get_string_resource (XrmDatabase rdb, char *name, char *class)
2235 /* remove appname prefix; TODO: allow for !="Emacs" */ 2166 /* remove appname prefix; TODO: allow for !="Emacs" */
2236 char *toCheck = class + (!strncmp (class, "Emacs.", 6) ? 6 : 0); 2167 char *toCheck = class + (!strncmp (class, "Emacs.", 6) ? 6 : 0);
2237 const char *res; 2168 const char *res;
2238 check_window_system (); 2169 check_window_system (NULL);
2239 2170
2240 if (inhibit_x_resources) 2171 if (inhibit_x_resources)
2241 /* --quick was passed, so this is a no-op. */ 2172 /* --quick was passed, so this is a no-op. */
@@ -2305,7 +2236,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
2305 (Lisp_Object color, Lisp_Object frame) 2236 (Lisp_Object color, Lisp_Object frame)
2306{ 2237{
2307 NSColor * col; 2238 NSColor * col;
2308 check_window_system (); 2239 check_window_system (NULL);
2309 return ns_lisp_to_color (color, &col) ? Qnil : Qt; 2240 return ns_lisp_to_color (color, &col) ? Qnil : Qt;
2310} 2241}
2311 2242
@@ -2317,7 +2248,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
2317 NSColor * col; 2248 NSColor * col;
2318 CGFloat red, green, blue, alpha; 2249 CGFloat red, green, blue, alpha;
2319 2250
2320 check_window_system (); 2251 check_window_system (NULL);
2321 CHECK_STRING (color); 2252 CHECK_STRING (color);
2322 2253
2323 if (ns_lisp_to_color (color, &col)) 2254 if (ns_lisp_to_color (color, &col))
@@ -2336,7 +2267,8 @@ DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
2336{ 2267{
2337 NSWindowDepth depth; 2268 NSWindowDepth depth;
2338 NSString *colorSpace; 2269 NSString *colorSpace;
2339 check_window_system (); 2270
2271 check_ns_display_info (display);
2340 depth = [ns_get_screen (display) depth]; 2272 depth = [ns_get_screen (display) depth];
2341 colorSpace = NSColorSpaceFromDepth (depth); 2273 colorSpace = NSColorSpaceFromDepth (depth);
2342 2274
@@ -2356,7 +2288,8 @@ If omitted or nil, that stands for the selected frame's display. */)
2356 (Lisp_Object display) 2288 (Lisp_Object display)
2357{ 2289{
2358 NSWindowDepth depth; 2290 NSWindowDepth depth;
2359 check_window_system (); 2291
2292 check_ns_display_info (display);
2360 depth = [ns_get_screen (display) depth]; 2293 depth = [ns_get_screen (display) depth];
2361 2294
2362 return NSBitsPerPixelFromDepth (depth) > 1 ? Qt : Qnil; 2295 return NSBitsPerPixelFromDepth (depth) > 1 ? Qt : Qnil;
@@ -2371,7 +2304,7 @@ DISPLAY should be either a frame, a display name (a string), or terminal ID.
2371If omitted or nil, that stands for the selected frame's display. */) 2304If omitted or nil, that stands for the selected frame's display. */)
2372 (Lisp_Object display) 2305 (Lisp_Object display)
2373{ 2306{
2374 check_window_system (); 2307 check_ns_display_info (display);
2375 return make_number ((int) [ns_get_screen (display) frame].size.width); 2308 return make_number ((int) [ns_get_screen (display) frame].size.width);
2376} 2309}
2377 2310
@@ -2384,7 +2317,7 @@ DISPLAY should be either a frame, a display name (a string), or terminal ID.
2384If omitted or nil, that stands for the selected frame's display. */) 2317If omitted or nil, that stands for the selected frame's display. */)
2385 (Lisp_Object display) 2318 (Lisp_Object display)
2386{ 2319{
2387 check_window_system (); 2320 check_ns_display_info (display);
2388 return make_number ((int) [ns_get_screen (display) frame].size.height); 2321 return make_number ((int) [ns_get_screen (display) frame].size.height);
2389} 2322}
2390 2323
@@ -2404,7 +2337,7 @@ that stands for the selected frame's display. */)
2404 NSScreen *screen; 2337 NSScreen *screen;
2405 NSRect vScreen; 2338 NSRect vScreen;
2406 2339
2407 check_window_system (); 2340 check_ns_display_info (display);
2408 screen = ns_get_screen (display); 2341 screen = ns_get_screen (display);
2409 if (!screen) 2342 if (!screen)
2410 return Qnil; 2343 return Qnil;
@@ -2428,7 +2361,7 @@ DISPLAY should be either a frame, a display name (a string), or terminal ID.
2428If omitted or nil, that stands for the selected frame's display. */) 2361If omitted or nil, that stands for the selected frame's display. */)
2429 (Lisp_Object display) 2362 (Lisp_Object display)
2430{ 2363{
2431 check_window_system (); 2364 check_ns_display_info (display);
2432 return make_number 2365 return make_number
2433 (NSBitsPerPixelFromDepth ([ns_get_screen (display) depth])); 2366 (NSBitsPerPixelFromDepth ([ns_get_screen (display) depth]));
2434} 2367}
@@ -2442,10 +2375,7 @@ DISPLAY should be either a frame, a display name (a string), or terminal ID.
2442If omitted or nil, that stands for the selected frame's display. */) 2375If omitted or nil, that stands for the selected frame's display. */)
2443 (Lisp_Object display) 2376 (Lisp_Object display)
2444{ 2377{
2445 struct ns_display_info *dpyinfo; 2378 struct ns_display_info *dpyinfo = check_ns_display_info (display);
2446 check_window_system ();
2447
2448 dpyinfo = check_ns_display_info (display);
2449 /* We force 24+ bit depths to 24-bit to prevent an overflow. */ 2379 /* We force 24+ bit depths to 24-bit to prevent an overflow. */
2450 return make_number (1 << min (dpyinfo->n_planes, 24)); 2380 return make_number (1 << min (dpyinfo->n_planes, 24));
2451} 2381}
@@ -2558,7 +2488,7 @@ Text larger than the specified size is clipped. */)
2558 2488
2559 CHECK_STRING (string); 2489 CHECK_STRING (string);
2560 str = SSDATA (string); 2490 str = SSDATA (string);
2561 f = check_x_frame (frame); 2491 f = decode_window_system_frame (frame);
2562 if (NILP (timeout)) 2492 if (NILP (timeout))
2563 timeout = make_number (5); 2493 timeout = make_number (5);
2564 else 2494 else
diff --git a/src/nsmenu.m b/src/nsmenu.m
index d364639b0bc..648b568d180 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1409,8 +1409,6 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1409 1409
1410 NSTRACE (x-popup-dialog); 1410 NSTRACE (x-popup-dialog);
1411 1411
1412 check_window_system ();
1413
1414 isQ = NILP (header); 1412 isQ = NILP (header);
1415 1413
1416 if (EQ (position, Qt) 1414 if (EQ (position, Qt)
@@ -1448,6 +1446,8 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1448 else 1446 else
1449 CHECK_WINDOW (window); 1447 CHECK_WINDOW (window);
1450 1448
1449 check_window_system (f);
1450
1451 p.x = (int)f->left_pos + ((int)FRAME_COLUMN_WIDTH (f) * f->text_cols)/2; 1451 p.x = (int)f->left_pos + ((int)FRAME_COLUMN_WIDTH (f) * f->text_cols)/2;
1452 p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2; 1452 p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2;
1453 1453
diff --git a/src/nsselect.m b/src/nsselect.m
index 2f539a16406..bb9eacd23cd 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -354,8 +354,7 @@ On Nextstep, FRAME is unused. */)
354 Lisp_Object successful_p = Qnil, rest; 354 Lisp_Object successful_p = Qnil, rest;
355 Lisp_Object target_symbol, data; 355 Lisp_Object target_symbol, data;
356 356
357 357 check_window_system (NULL);
358 check_window_system ();
359 CHECK_SYMBOL (selection); 358 CHECK_SYMBOL (selection);
360 if (NILP (value)) 359 if (NILP (value))
361 error ("selection value may not be nil."); 360 error ("selection value may not be nil.");
@@ -409,7 +408,7 @@ On MS-DOS, all this does is return non-nil if we own the selection. */)
409 (Lisp_Object selection, Lisp_Object time_object, Lisp_Object terminal) 408 (Lisp_Object selection, Lisp_Object time_object, Lisp_Object terminal)
410{ 409{
411 id pb; 410 id pb;
412 check_window_system (); 411 check_window_system (NULL);
413 CHECK_SYMBOL (selection); 412 CHECK_SYMBOL (selection);
414 if (NILP (assq_no_quit (selection, Vselection_alist))) return Qnil; 413 if (NILP (assq_no_quit (selection, Vselection_alist))) return Qnil;
415 414
@@ -436,7 +435,7 @@ On Nextstep, TERMINAL is unused. */)
436 id pb; 435 id pb;
437 NSArray *types; 436 NSArray *types;
438 437
439 check_window_system (); 438 check_window_system (NULL);
440 CHECK_SYMBOL (selection); 439 CHECK_SYMBOL (selection);
441 if (EQ (selection, Qnil)) selection = QPRIMARY; 440 if (EQ (selection, Qnil)) selection = QPRIMARY;
442 if (EQ (selection, Qt)) selection = QSECONDARY; 441 if (EQ (selection, Qt)) selection = QSECONDARY;
@@ -464,7 +463,7 @@ frame's display, or the first available X display.
464On Nextstep, TERMINAL is unused. */) 463On Nextstep, TERMINAL is unused. */)
465 (Lisp_Object selection, Lisp_Object terminal) 464 (Lisp_Object selection, Lisp_Object terminal)
466{ 465{
467 check_window_system (); 466 check_window_system (NULL);
468 CHECK_SYMBOL (selection); 467 CHECK_SYMBOL (selection);
469 if (EQ (selection, Qnil)) selection = QPRIMARY; 468 if (EQ (selection, Qnil)) selection = QPRIMARY;
470 if (EQ (selection, Qt)) selection = QSECONDARY; 469 if (EQ (selection, Qt)) selection = QSECONDARY;
@@ -492,7 +491,7 @@ On Nextstep, TIME-STAMP and TERMINAL are unused. */)
492{ 491{
493 Lisp_Object val; 492 Lisp_Object val;
494 493
495 check_window_system (); 494 check_window_system (NULL);
496 CHECK_SYMBOL (selection_name); 495 CHECK_SYMBOL (selection_name);
497 CHECK_SYMBOL (target_type); 496 CHECK_SYMBOL (target_type);
498 val = ns_get_local_selection (selection_name, target_type); 497 val = ns_get_local_selection (selection_name, target_type);
@@ -516,7 +515,7 @@ SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */)
516 (Lisp_Object selection) 515 (Lisp_Object selection)
517{ 516{
518 id pb; 517 id pb;
519 check_window_system (); 518 check_window_system (NULL);
520 pb = ns_symbol_to_pb (selection); 519 pb = ns_symbol_to_pb (selection);
521 return pb != nil ? ns_string_from_pasteboard (pb) : Qnil; 520 return pb != nil ? ns_string_from_pasteboard (pb) : Qnil;
522} 521}
@@ -529,7 +528,7 @@ SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */)
529 (Lisp_Object selection, Lisp_Object string) 528 (Lisp_Object selection, Lisp_Object string)
530{ 529{
531 id pb; 530 id pb;
532 check_window_system (); 531 check_window_system (NULL);
533 pb = ns_symbol_to_pb (selection); 532 pb = ns_symbol_to_pb (selection);
534 if (pb != nil) ns_string_to_pasteboard (pb, string); 533 if (pb != nil) ns_string_to_pasteboard (pb, string);
535 return Qnil; 534 return Qnil;
diff --git a/src/nsterm.h b/src/nsterm.h
index 59cac34773a..07cfc2e022e 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -577,8 +577,6 @@ extern Lisp_Object ns_display_name_list;
577extern struct ns_display_info *ns_display_info_for_name (Lisp_Object name); 577extern struct ns_display_info *ns_display_info_for_name (Lisp_Object name);
578 578
579struct ns_display_info *check_x_display_info (Lisp_Object frame); 579struct ns_display_info *check_x_display_info (Lisp_Object frame);
580FRAME_PTR check_x_frame (Lisp_Object frame);
581
582 580
583struct ns_output 581struct ns_output
584{ 582{
diff --git a/src/nsterm.m b/src/nsterm.m
index fb1b0aa327c..bc3150c0a07 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1012,8 +1012,9 @@ ns_raise_frame (struct frame *f)
1012 Bring window to foreground and make it active 1012 Bring window to foreground and make it active
1013 -------------------------------------------------------------------------- */ 1013 -------------------------------------------------------------------------- */
1014{ 1014{
1015 NSView *view = FRAME_NS_VIEW (f); 1015 NSView *view;
1016 check_window_system (); 1016 check_window_system (f);
1017 view = FRAME_NS_VIEW (f);
1017 block_input (); 1018 block_input ();
1018 if (FRAME_VISIBLE_P (f)) 1019 if (FRAME_VISIBLE_P (f))
1019 [[view window] makeKeyAndOrderFront: NSApp]; 1020 [[view window] makeKeyAndOrderFront: NSApp];
@@ -1027,8 +1028,9 @@ ns_lower_frame (struct frame *f)
1027 Send window to back 1028 Send window to back
1028 -------------------------------------------------------------------------- */ 1029 -------------------------------------------------------------------------- */
1029{ 1030{
1030 NSView *view = FRAME_NS_VIEW (f); 1031 NSView *view;
1031 check_window_system (); 1032 check_window_system (f);
1033 view = FRAME_NS_VIEW (f);
1032 block_input (); 1034 block_input ();
1033 [[view window] orderBack: NSApp]; 1035 [[view window] orderBack: NSApp];
1034 unblock_input (); 1036 unblock_input ();
@@ -1131,9 +1133,10 @@ x_make_frame_invisible (struct frame *f)
1131 External: Hide the window (X11 semantics) 1133 External: Hide the window (X11 semantics)
1132 -------------------------------------------------------------------------- */ 1134 -------------------------------------------------------------------------- */
1133{ 1135{
1134 NSView * view = FRAME_NS_VIEW (f); 1136 NSView *view;
1135 NSTRACE (x_make_frame_invisible); 1137 NSTRACE (x_make_frame_invisible);
1136 check_window_system (); 1138 check_window_system (f);
1139 view = FRAME_NS_VIEW (f);
1137 [[view window] orderOut: NSApp]; 1140 [[view window] orderOut: NSApp];
1138 SET_FRAME_VISIBLE (f, 0); 1141 SET_FRAME_VISIBLE (f, 0);
1139 SET_FRAME_ICONIFIED (f, 0); 1142 SET_FRAME_ICONIFIED (f, 0);
@@ -1146,10 +1149,13 @@ x_iconify_frame (struct frame *f)
1146 External: Iconify window 1149 External: Iconify window
1147 -------------------------------------------------------------------------- */ 1150 -------------------------------------------------------------------------- */
1148{ 1151{
1149 NSView * view = FRAME_NS_VIEW (f); 1152 NSView *view;
1150 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); 1153 struct ns_display_info *dpyinfo;
1154
1151 NSTRACE (x_iconify_frame); 1155 NSTRACE (x_iconify_frame);
1152 check_window_system (); 1156 check_window_system (f);
1157 view = FRAME_NS_VIEW (f);
1158 dpyinfo = FRAME_NS_DISPLAY_INFO (f);
1153 1159
1154 if (dpyinfo->x_highlight_frame == f) 1160 if (dpyinfo->x_highlight_frame == f)
1155 dpyinfo->x_highlight_frame = 0; 1161 dpyinfo->x_highlight_frame = 0;
@@ -1174,11 +1180,15 @@ x_iconify_frame (struct frame *f)
1174void 1180void
1175x_free_frame_resources (struct frame *f) 1181x_free_frame_resources (struct frame *f)
1176{ 1182{
1177 NSView *view = FRAME_NS_VIEW (f); 1183 NSView *view;
1178 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); 1184 struct ns_display_info *dpyinfo;
1179 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); 1185 Mouse_HLInfo *hlinfo;
1186
1180 NSTRACE (x_free_frame_resources); 1187 NSTRACE (x_free_frame_resources);
1181 check_window_system (); 1188 check_window_system (f);
1189 view = FRAME_NS_VIEW (f);
1190 dpyinfo = FRAME_NS_DISPLAY_INFO (f);
1191 hlinfo = MOUSE_HL_INFO (f);
1182 1192
1183 [(EmacsView *)view setWindowClosing: YES]; /* may not have been informed */ 1193 [(EmacsView *)view setWindowClosing: YES]; /* may not have been informed */
1184 1194
@@ -1219,7 +1229,7 @@ x_destroy_window (struct frame *f)
1219 -------------------------------------------------------------------------- */ 1229 -------------------------------------------------------------------------- */
1220{ 1230{
1221 NSTRACE (x_destroy_window); 1231 NSTRACE (x_destroy_window);
1222 check_window_system (); 1232 check_window_system (f);
1223 x_free_frame_resources (f); 1233 x_free_frame_resources (f);
1224 ns_window_num--; 1234 ns_window_num--;
1225} 1235}
diff --git a/src/w32fns.c b/src/w32fns.c
index 2bc1042e126..5d3a78f8b95 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -95,10 +95,6 @@ static HWND hourglass_hwnd = NULL;
95#define IDC_HAND MAKEINTRESOURCE(32649) 95#define IDC_HAND MAKEINTRESOURCE(32649)
96#endif 96#endif
97 97
98/* Nonzero if using Windows. */
99
100static int w32_in_use;
101
102Lisp_Object Qsuppress_icon; 98Lisp_Object Qsuppress_icon;
103Lisp_Object Qundefined_color; 99Lisp_Object Qundefined_color;
104Lisp_Object Qcancel_timer; 100Lisp_Object Qcancel_timer;
@@ -239,37 +235,6 @@ HINSTANCE hinst = NULL;
239static unsigned int sound_type = 0xFFFFFFFF; 235static unsigned int sound_type = 0xFFFFFFFF;
240#define MB_EMACS_SILENT (0xFFFFFFFF - 1) 236#define MB_EMACS_SILENT (0xFFFFFFFF - 1)
241 237
242
243/* Error if we are not connected to MS-Windows. */
244void
245check_window_system (void)
246{
247 if (! w32_in_use)
248 error ("MS-Windows not in use or not initialized");
249}
250
251/* Nonzero if we can use mouse menus.
252 You should not call this unless HAVE_MENUS is defined. */
253
254int
255have_menus_p (void)
256{
257 return w32_in_use;
258}
259
260/* Extract a frame as a FRAME_PTR, defaulting to the selected frame
261 and checking validity for W32. */
262
263FRAME_PTR
264check_x_frame (Lisp_Object frame)
265{
266 struct frame *f = decode_live_frame (frame);
267
268 if (! FRAME_W32_P (f))
269 error ("Non-W32 frame used");
270 return f;
271}
272
273/* Let the user specify a display with a frame. 238/* Let the user specify a display with a frame.
274 nil stands for the selected frame--or, if that is not a w32 frame, 239 nil stands for the selected frame--or, if that is not a w32 frame,
275 the first display on the list. */ 240 the first display on the list. */
@@ -4567,7 +4532,7 @@ DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
4567 doc: /* Give FRAME input focus, raising to foreground if necessary. */) 4532 doc: /* Give FRAME input focus, raising to foreground if necessary. */)
4568 (Lisp_Object frame) 4533 (Lisp_Object frame)
4569{ 4534{
4570 x_focus_on_frame (check_x_frame (frame)); 4535 x_focus_on_frame (decode_window_system_frame (frame));
4571 return Qnil; 4536 return Qnil;
4572} 4537}
4573 4538
@@ -4578,7 +4543,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
4578 (Lisp_Object color, Lisp_Object frame) 4543 (Lisp_Object color, Lisp_Object frame)
4579{ 4544{
4580 XColor foo; 4545 XColor foo;
4581 FRAME_PTR f = check_x_frame (frame); 4546 FRAME_PTR f = decode_window_system_frame (frame);
4582 4547
4583 CHECK_STRING (color); 4548 CHECK_STRING (color);
4584 4549
@@ -4593,7 +4558,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
4593 (Lisp_Object color, Lisp_Object frame) 4558 (Lisp_Object color, Lisp_Object frame)
4594{ 4559{
4595 XColor foo; 4560 XColor foo;
4596 FRAME_PTR f = check_x_frame (frame); 4561 FRAME_PTR f = decode_window_system_frame (frame);
4597 4562
4598 CHECK_STRING (color); 4563 CHECK_STRING (color);
4599 4564
@@ -4911,7 +4876,6 @@ x_display_info_for_name (Lisp_Object name)
4911 if (dpyinfo == 0) 4876 if (dpyinfo == 0)
4912 error ("Cannot connect to server %s", SDATA (name)); 4877 error ("Cannot connect to server %s", SDATA (name));
4913 4878
4914 w32_in_use = 1;
4915 XSETFASTINT (Vwindow_system_version, w32_major_version); 4879 XSETFASTINT (Vwindow_system_version, w32_major_version);
4916 4880
4917 return dpyinfo; 4881 return dpyinfo;
@@ -4941,7 +4905,7 @@ terminate Emacs if we can't open the connection.
4941 4905
4942 /* If initialization has already been done, return now to avoid 4906 /* If initialization has already been done, return now to avoid
4943 overwriting critical parts of one_w32_display_info. */ 4907 overwriting critical parts of one_w32_display_info. */
4944 if (w32_in_use) 4908 if (window_system_available (NULL))
4945 return Qnil; 4909 return Qnil;
4946 4910
4947 if (! NILP (xrm_string)) 4911 if (! NILP (xrm_string))
@@ -5010,8 +4974,6 @@ terminate Emacs if we can't open the connection.
5010 error ("Cannot connect to server %s", SDATA (display)); 4974 error ("Cannot connect to server %s", SDATA (display));
5011 } 4975 }
5012 4976
5013 w32_in_use = 1;
5014
5015 XSETFASTINT (Vwindow_system_version, w32_major_version); 4977 XSETFASTINT (Vwindow_system_version, w32_major_version);
5016 return Qnil; 4978 return Qnil;
5017} 4979}
@@ -5095,7 +5057,7 @@ FRAME. Default is to change on the edit X window. */)
5095 (Lisp_Object prop, Lisp_Object value, Lisp_Object frame, 5057 (Lisp_Object prop, Lisp_Object value, Lisp_Object frame,
5096 Lisp_Object type, Lisp_Object format, Lisp_Object outer_p) 5058 Lisp_Object type, Lisp_Object format, Lisp_Object outer_p)
5097{ 5059{
5098 struct frame *f = check_x_frame (frame); 5060 struct frame *f = decode_window_system_frame (frame);
5099 Atom prop_atom; 5061 Atom prop_atom;
5100 5062
5101 CHECK_STRING (prop); 5063 CHECK_STRING (prop);
@@ -5121,7 +5083,7 @@ DEFUN ("x-delete-window-property", Fx_delete_window_property,
5121FRAME nil or omitted means use the selected frame. Value is PROP. */) 5083FRAME nil or omitted means use the selected frame. Value is PROP. */)
5122 (Lisp_Object prop, Lisp_Object frame) 5084 (Lisp_Object prop, Lisp_Object frame)
5123{ 5085{
5124 struct frame *f = check_x_frame (frame); 5086 struct frame *f = decode_window_system_frame (frame);
5125 Atom prop_atom; 5087 Atom prop_atom;
5126 5088
5127 CHECK_STRING (prop); 5089 CHECK_STRING (prop);
@@ -5157,7 +5119,7 @@ no value of TYPE (always string in the MS Windows case). */)
5157 (Lisp_Object prop, Lisp_Object frame, Lisp_Object type, 5119 (Lisp_Object prop, Lisp_Object frame, Lisp_Object type,
5158 Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p) 5120 Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p)
5159{ 5121{
5160 struct frame *f = check_x_frame (frame); 5122 struct frame *f = decode_window_system_frame (frame);
5161 Atom prop_atom; 5123 Atom prop_atom;
5162 int rc; 5124 int rc;
5163 Lisp_Object prop_value = Qnil; 5125 Lisp_Object prop_value = Qnil;
@@ -5358,8 +5320,6 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
5358 Lisp_Object buffer; 5320 Lisp_Object buffer;
5359 struct buffer *old_buffer; 5321 struct buffer *old_buffer;
5360 5322
5361 check_window_system ();
5362
5363 /* Use this general default value to start with until we know if 5323 /* Use this general default value to start with until we know if
5364 this frame has a specified name. */ 5324 this frame has a specified name. */
5365 Vx_resource_name = Vinvocation_name; 5325 Vx_resource_name = Vinvocation_name;
@@ -5703,7 +5663,7 @@ Text larger than the specified size is clipped. */)
5703 GCPRO4 (string, parms, frame, timeout); 5663 GCPRO4 (string, parms, frame, timeout);
5704 5664
5705 CHECK_STRING (string); 5665 CHECK_STRING (string);
5706 f = check_x_frame (frame); 5666 f = decode_window_system_frame (frame);
5707 if (NILP (timeout)) 5667 if (NILP (timeout))
5708 timeout = make_number (5); 5668 timeout = make_number (5);
5709 else 5669 else
@@ -6354,7 +6314,7 @@ screen saver if defined.
6354If optional parameter FRAME is not specified, use selected frame. */) 6314If optional parameter FRAME is not specified, use selected frame. */)
6355 (Lisp_Object command, Lisp_Object frame) 6315 (Lisp_Object command, Lisp_Object frame)
6356{ 6316{
6357 FRAME_PTR f = check_x_frame (frame); 6317 FRAME_PTR f = decode_window_system_frame (frame);
6358 6318
6359 CHECK_NUMBER (command); 6319 CHECK_NUMBER (command);
6360 6320
@@ -7312,8 +7272,6 @@ void
7312syms_of_w32fns (void) 7272syms_of_w32fns (void)
7313{ 7273{
7314 globals_of_w32fns (); 7274 globals_of_w32fns ();
7315 /* This is zero if not using MS-Windows. */
7316 w32_in_use = 0;
7317 track_mouse_window = NULL; 7275 track_mouse_window = NULL;
7318 7276
7319 w32_visible_system_caret_hwnd = NULL; 7277 w32_visible_system_caret_hwnd = NULL;
diff --git a/src/w32font.c b/src/w32font.c
index fb52376b9e1..105daa06365 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -2467,7 +2467,7 @@ If EXCLUDE-PROPORTIONAL is non-nil, exclude proportional fonts
2467in the font selection dialog. */) 2467in the font selection dialog. */)
2468 (Lisp_Object frame, Lisp_Object exclude_proportional) 2468 (Lisp_Object frame, Lisp_Object exclude_proportional)
2469{ 2469{
2470 FRAME_PTR f = check_x_frame (frame); 2470 FRAME_PTR f = decode_window_system_frame (frame);
2471 CHOOSEFONT cf; 2471 CHOOSEFONT cf;
2472 LOGFONT lf; 2472 LOGFONT lf;
2473 TEXTMETRIC tm; 2473 TEXTMETRIC tm;
diff --git a/src/w32menu.c b/src/w32menu.c
index 0c8d5ca06c5..346402b7c6b 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -140,8 +140,6 @@ otherwise it is "Question". */)
140 FRAME_PTR f = NULL; 140 FRAME_PTR f = NULL;
141 Lisp_Object window; 141 Lisp_Object window;
142 142
143 check_window_system ();
144
145 /* Decode the first argument: find the window or frame to use. */ 143 /* Decode the first argument: find the window or frame to use. */
146 if (EQ (position, Qt) 144 if (EQ (position, Qt)
147 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar) 145 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
@@ -194,6 +192,8 @@ otherwise it is "Question". */)
194 but I don't want to make one now. */ 192 but I don't want to make one now. */
195 CHECK_WINDOW (window); 193 CHECK_WINDOW (window);
196 194
195 check_window_system (f);
196
197#ifndef HAVE_DIALOGS 197#ifndef HAVE_DIALOGS
198 198
199 { 199 {
diff --git a/src/w32term.h b/src/w32term.h
index e85ee7790d5..9bb37b31ef5 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -739,7 +739,6 @@ struct image;
739struct face; 739struct face;
740 740
741XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *); 741XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *);
742struct frame * check_x_frame (Lisp_Object);
743 742
744typedef DWORD (WINAPI * ClipboardSequence_Proc) (void); 743typedef DWORD (WINAPI * ClipboardSequence_Proc) (void);
745typedef BOOL (WINAPI * AppendMenuW_Proc) ( 744typedef BOOL (WINAPI * AppendMenuW_Proc) (
diff --git a/src/xfaces.c b/src/xfaces.c
index 9acaf6d6f52..b2ace1be14e 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1634,7 +1634,7 @@ the WIDTH times as wide as FACE on FRAME. */)
1634 struct frame *f; 1634 struct frame *f;
1635 int size, avgwidth IF_LINT (= 0); 1635 int size, avgwidth IF_LINT (= 0);
1636 1636
1637 check_window_system (); 1637 check_window_system (NULL);
1638 CHECK_STRING (pattern); 1638 CHECK_STRING (pattern);
1639 1639
1640 if (! NILP (maximum)) 1640 if (! NILP (maximum))
@@ -1643,8 +1643,8 @@ the WIDTH times as wide as FACE on FRAME. */)
1643 if (!NILP (width)) 1643 if (!NILP (width))
1644 CHECK_NUMBER (width); 1644 CHECK_NUMBER (width);
1645 1645
1646 /* We can't simply call check_x_frame because this function may be 1646 /* We can't simply call decode_window_system_frame because
1647 called before any frame is created. */ 1647 this function may be called before any frame is created. */
1648 f = decode_live_frame (frame); 1648 f = decode_live_frame (frame);
1649 if (! FRAME_WINDOW_P (f)) 1649 if (! FRAME_WINDOW_P (f))
1650 { 1650 {
@@ -3923,8 +3923,8 @@ If FRAME is omitted or nil, use the selected frame. */)
3923 struct frame *f; 3923 struct frame *f;
3924 Lisp_Object lface1, lface2; 3924 Lisp_Object lface1, lface2;
3925 3925
3926 /* Don't use check_x_frame here because this function is called 3926 /* Don't use decode_window_system_frame here because this function
3927 before X frames exist. At that time, if FRAME is nil, 3927 is called before X frames exist. At that time, if FRAME is nil,
3928 selected_frame will be used which is the frame dumped with 3928 selected_frame will be used which is the frame dumped with
3929 Emacs. That frame is not an X frame. */ 3929 Emacs. That frame is not an X frame. */
3930 f = EQ (frame, Qt) ? NULL : decode_live_frame (frame); 3930 f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
diff --git a/src/xfns.c b/src/xfns.c
index 8b8d94d4779..f4c24cb09a0 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -123,10 +123,6 @@ extern LWLIB_ID widget_id_tick;
123 123
124#define MAXREQUEST(dpy) (XMaxRequestSize (dpy)) 124#define MAXREQUEST(dpy) (XMaxRequestSize (dpy))
125 125
126/* Nonzero if using X. */
127
128int x_in_use;
129
130static Lisp_Object Qsuppress_icon; 126static Lisp_Object Qsuppress_icon;
131static Lisp_Object Qundefined_color; 127static Lisp_Object Qundefined_color;
132static Lisp_Object Qcompound_text, Qcancel_timer; 128static Lisp_Object Qcompound_text, Qcancel_timer;
@@ -139,38 +135,6 @@ static int dpyinfo_refcount;
139 135
140static struct x_display_info *x_display_info_for_name (Lisp_Object); 136static struct x_display_info *x_display_info_for_name (Lisp_Object);
141 137
142
143/* Error if we are not connected to X. */
144
145void
146check_window_system (void)
147{
148 if (! x_in_use)
149 error ("X windows are not in use or not initialized");
150}
151
152/* Nonzero if we can use mouse menus.
153 You should not call this unless HAVE_MENUS is defined. */
154
155int
156have_menus_p (void)
157{
158 return x_in_use;
159}
160
161/* Extract a frame as a FRAME_PTR, defaulting to the selected frame
162 and checking validity for X. */
163
164FRAME_PTR
165check_x_frame (Lisp_Object frame)
166{
167 struct frame *f = decode_live_frame (frame);
168
169 if (! FRAME_X_P (f))
170 error ("Non-X frame used");
171 return f;
172}
173
174/* Let the user specify an X display with a Lisp object. 138/* Let the user specify an X display with a Lisp object.
175 OBJECT may be nil, a frame or a terminal object. 139 OBJECT may be nil, a frame or a terminal object.
176 nil stands for the selected frame--or, if that is not an X frame, 140 nil stands for the selected frame--or, if that is not an X frame,
@@ -205,7 +169,7 @@ check_x_display_info (Lisp_Object object)
205 dpyinfo = x_display_info_for_name (object); 169 dpyinfo = x_display_info_for_name (object);
206 else 170 else
207 { 171 {
208 FRAME_PTR f = check_x_frame (object); 172 FRAME_PTR f = decode_window_system_frame (object);
209 dpyinfo = FRAME_X_DISPLAY_INFO (f); 173 dpyinfo = FRAME_X_DISPLAY_INFO (f);
210 } 174 }
211 175
@@ -2992,7 +2956,7 @@ If FRAME is omitted or nil, use the selected frame.
2992Signal error if FRAME is not an X frame. */) 2956Signal error if FRAME is not an X frame. */)
2993 (Lisp_Object frame) 2957 (Lisp_Object frame)
2994{ 2958{
2995 struct frame *f = check_x_frame (frame); 2959 struct frame *f = decode_window_system_frame (frame);
2996 2960
2997 block_input (); 2961 block_input ();
2998 x_wm_set_size_hint (f, 0, 0); 2962 x_wm_set_size_hint (f, 0, 0);
@@ -3483,7 +3447,7 @@ DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
3483FRAME nil means use the selected frame. */) 3447FRAME nil means use the selected frame. */)
3484 (Lisp_Object frame) 3448 (Lisp_Object frame)
3485{ 3449{
3486 struct frame *f = check_x_frame (frame); 3450 struct frame *f = decode_window_system_frame (frame);
3487 Display *dpy = FRAME_X_DISPLAY (f); 3451 Display *dpy = FRAME_X_DISPLAY (f);
3488 3452
3489 block_input (); 3453 block_input ();
@@ -3516,7 +3480,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
3516 (Lisp_Object color, Lisp_Object frame) 3480 (Lisp_Object color, Lisp_Object frame)
3517{ 3481{
3518 XColor foo; 3482 XColor foo;
3519 FRAME_PTR f = check_x_frame (frame); 3483 FRAME_PTR f = decode_window_system_frame (frame);
3520 3484
3521 CHECK_STRING (color); 3485 CHECK_STRING (color);
3522 3486
@@ -3531,7 +3495,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
3531 (Lisp_Object color, Lisp_Object frame) 3495 (Lisp_Object color, Lisp_Object frame)
3532{ 3496{
3533 XColor foo; 3497 XColor foo;
3534 FRAME_PTR f = check_x_frame (frame); 3498 FRAME_PTR f = decode_window_system_frame (frame);
3535 3499
3536 CHECK_STRING (color); 3500 CHECK_STRING (color);
3537 3501
@@ -3996,7 +3960,6 @@ x_display_info_for_name (Lisp_Object name)
3996 if (dpyinfo == 0) 3960 if (dpyinfo == 0)
3997 error ("Cannot connect to X server %s", SDATA (name)); 3961 error ("Cannot connect to X server %s", SDATA (name));
3998 3962
3999 x_in_use = 1;
4000 XSETFASTINT (Vwindow_system_version, 11); 3963 XSETFASTINT (Vwindow_system_version, 11);
4001 3964
4002 return dpyinfo; 3965 return dpyinfo;
@@ -4050,8 +4013,6 @@ An insecure way to solve the problem may be to use `xhost'.\n",
4050 error ("Cannot connect to X server %s", SDATA (display)); 4013 error ("Cannot connect to X server %s", SDATA (display));
4051 } 4014 }
4052 4015
4053 x_in_use = 1;
4054
4055 XSETFASTINT (Vwindow_system_version, 11); 4016 XSETFASTINT (Vwindow_system_version, 11);
4056 return Qnil; 4017 return Qnil;
4057} 4018}
@@ -4143,7 +4104,7 @@ FRAME. Default is to change on the edit X window. */)
4143 (Lisp_Object prop, Lisp_Object value, Lisp_Object frame, 4104 (Lisp_Object prop, Lisp_Object value, Lisp_Object frame,
4144 Lisp_Object type, Lisp_Object format, Lisp_Object outer_p) 4105 Lisp_Object type, Lisp_Object format, Lisp_Object outer_p)
4145{ 4106{
4146 struct frame *f = check_x_frame (frame); 4107 struct frame *f = decode_window_system_frame (frame);
4147 Atom prop_atom; 4108 Atom prop_atom;
4148 Atom target_type = XA_STRING; 4109 Atom target_type = XA_STRING;
4149 int element_format = 8; 4110 int element_format = 8;
@@ -4221,7 +4182,7 @@ DEFUN ("x-delete-window-property", Fx_delete_window_property,
4221FRAME nil or omitted means use the selected frame. Value is PROP. */) 4182FRAME nil or omitted means use the selected frame. Value is PROP. */)
4222 (Lisp_Object prop, Lisp_Object frame) 4183 (Lisp_Object prop, Lisp_Object frame)
4223{ 4184{
4224 struct frame *f = check_x_frame (frame); 4185 struct frame *f = decode_window_system_frame (frame);
4225 Atom prop_atom; 4186 Atom prop_atom;
4226 4187
4227 CHECK_STRING (prop); 4188 CHECK_STRING (prop);
@@ -4257,7 +4218,7 @@ no value of TYPE (always string in the MS Windows case). */)
4257 (Lisp_Object prop, Lisp_Object frame, Lisp_Object type, 4218 (Lisp_Object prop, Lisp_Object frame, Lisp_Object type,
4258 Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p) 4219 Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p)
4259{ 4220{
4260 struct frame *f = check_x_frame (frame); 4221 struct frame *f = decode_window_system_frame (frame);
4261 Atom prop_atom; 4222 Atom prop_atom;
4262 int rc; 4223 int rc;
4263 Lisp_Object prop_value = Qnil; 4224 Lisp_Object prop_value = Qnil;
@@ -4525,8 +4486,6 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4525 Lisp_Object buffer; 4486 Lisp_Object buffer;
4526 struct buffer *old_buffer; 4487 struct buffer *old_buffer;
4527 4488
4528 check_window_system ();
4529
4530 if (!dpyinfo->terminal->name) 4489 if (!dpyinfo->terminal->name)
4531 error ("Terminal is not live, can't create new frames on it"); 4490 error ("Terminal is not live, can't create new frames on it");
4532 4491
@@ -4923,7 +4882,7 @@ Text larger than the specified size is clipped. */)
4923 if (SCHARS (string) == 0) 4882 if (SCHARS (string) == 0)
4924 string = make_unibyte_string (" ", 1); 4883 string = make_unibyte_string (" ", 1);
4925 4884
4926 f = check_x_frame (frame); 4885 f = decode_window_system_frame (frame);
4927 if (NILP (timeout)) 4886 if (NILP (timeout))
4928 timeout = make_number (5); 4887 timeout = make_number (5);
4929 else 4888 else
@@ -5246,7 +5205,7 @@ DEFUN ("x-uses-old-gtk-dialog", Fx_uses_old_gtk_dialog,
5246#ifdef USE_GTK 5205#ifdef USE_GTK
5247 if (use_dialog_box 5206 if (use_dialog_box
5248 && use_file_dialog 5207 && use_file_dialog
5249 && have_menus_p () 5208 && window_system_available (SELECTED_FRAME ())
5250 && xg_uses_old_file_dialog ()) 5209 && xg_uses_old_file_dialog ())
5251 return Qt; 5210 return Qt;
5252#endif 5211#endif
@@ -5316,7 +5275,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5316 ptrdiff_t count = SPECPDL_INDEX (); 5275 ptrdiff_t count = SPECPDL_INDEX ();
5317 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 5276 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
5318 5277
5319 check_window_system (); 5278 check_window_system (f);
5320 5279
5321 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); 5280 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
5322 5281
@@ -5486,7 +5445,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5486 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 5445 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
5487 char *cdef_file; 5446 char *cdef_file;
5488 5447
5489 check_window_system (); 5448 check_window_system (f);
5490 5449
5491 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); 5450 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
5492 5451
@@ -5541,15 +5500,13 @@ FRAME is the frame on which to pop up the font chooser. If omitted or
5541nil, it defaults to the selected frame. */) 5500nil, it defaults to the selected frame. */)
5542 (Lisp_Object frame, Lisp_Object ignored) 5501 (Lisp_Object frame, Lisp_Object ignored)
5543{ 5502{
5544 FRAME_PTR f = check_x_frame (frame); 5503 FRAME_PTR f = decode_window_system_frame (frame);
5545 Lisp_Object font; 5504 Lisp_Object font;
5546 Lisp_Object font_param; 5505 Lisp_Object font_param;
5547 char *default_name = NULL; 5506 char *default_name = NULL;
5548 struct gcpro gcpro1, gcpro2; 5507 struct gcpro gcpro1, gcpro2;
5549 ptrdiff_t count = SPECPDL_INDEX (); 5508 ptrdiff_t count = SPECPDL_INDEX ();
5550 5509
5551 check_window_system ();
5552
5553 if (popup_activated ()) 5510 if (popup_activated ())
5554 error ("Trying to use a menu from within a menu-entry"); 5511 error ("Trying to use a menu from within a menu-entry");
5555 5512
@@ -5609,7 +5566,7 @@ present and mapped to the usual X keysyms. */)
5609 return Qlambda; 5566 return Qlambda;
5610#else 5567#else
5611 XkbDescPtr kb; 5568 XkbDescPtr kb;
5612 struct frame *f = check_x_frame (frame); 5569 struct frame *f = decode_window_system_frame (frame);
5613 Display *dpy = FRAME_X_DISPLAY (f); 5570 Display *dpy = FRAME_X_DISPLAY (f);
5614 Lisp_Object have_keys; 5571 Lisp_Object have_keys;
5615 int major, minor, op, event, error_code; 5572 int major, minor, op, event, error_code;
@@ -5737,9 +5694,6 @@ frame_parm_handler x_frame_parm_handlers[] =
5737void 5694void
5738syms_of_xfns (void) 5695syms_of_xfns (void)
5739{ 5696{
5740 /* This is zero if not using X windows. */
5741 x_in_use = 0;
5742
5743 /* The section below is built by the lisp expression at the top of the file, 5697 /* The section below is built by the lisp expression at the top of the file,
5744 just above where these variables are declared. */ 5698 just above where these variables are declared. */
5745 /*&&& init symbols here &&&*/ 5699 /*&&& init symbols here &&&*/
diff --git a/src/xgselect.c b/src/xgselect.c
index 2c8e9671abb..0b5ad6ae70d 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -26,6 +26,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#include <glib.h> 26#include <glib.h>
27#include <errno.h> 27#include <errno.h>
28#include "xterm.h" 28#include "xterm.h"
29#include "frame.h"
29 30
30int 31int
31xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 32xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
@@ -43,7 +44,7 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
43 int i, nfds, tmo_in_millisec; 44 int i, nfds, tmo_in_millisec;
44 USE_SAFE_ALLOCA; 45 USE_SAFE_ALLOCA;
45 46
46 if (! (x_in_use 47 if (! (window_system_available (NULL)
47 && g_main_context_pending (context = g_main_context_default ()))) 48 && g_main_context_pending (context = g_main_context_default ())))
48 return pselect (fds_lim, rfds, wfds, efds, timeout, sigmask); 49 return pselect (fds_lim, rfds, wfds, efds, timeout, sigmask);
49 50
diff --git a/src/xmenu.c b/src/xmenu.c
index e6291edf7d6..9993bd87d5b 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -223,8 +223,6 @@ for instance using the window manager, then this produces a quit and
223 FRAME_PTR f = NULL; 223 FRAME_PTR f = NULL;
224 Lisp_Object window; 224 Lisp_Object window;
225 225
226 check_window_system ();
227
228 /* Decode the first argument: find the window or frame to use. */ 226 /* Decode the first argument: find the window or frame to use. */
229 if (EQ (position, Qt) 227 if (EQ (position, Qt)
230 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar) 228 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
@@ -277,8 +275,7 @@ for instance using the window manager, then this produces a quit and
277 but I don't want to make one now. */ 275 but I don't want to make one now. */
278 CHECK_WINDOW (window); 276 CHECK_WINDOW (window);
279 277
280 if (! FRAME_X_P (f) && ! FRAME_MSDOS_P (f)) 278 check_window_system (f);
281 error ("Can not put X dialog on this terminal");
282 279
283 /* Force a redisplay before showing the dialog. If a frame is created 280 /* Force a redisplay before showing the dialog. If a frame is created
284 just before showing the dialog, its contents may not have been fully 281 just before showing the dialog, its contents may not have been fully
@@ -485,7 +482,7 @@ If FRAME is nil or not given, use the selected frame. */)
485 (Lisp_Object frame) 482 (Lisp_Object frame)
486{ 483{
487 XEvent ev; 484 XEvent ev;
488 FRAME_PTR f = check_x_frame (frame); 485 FRAME_PTR f = decode_window_system_frame (frame);
489 Widget menubar; 486 Widget menubar;
490 block_input (); 487 block_input ();
491 488
@@ -569,7 +566,7 @@ If FRAME is nil or not given, use the selected frame. */)
569 block_input (). */ 566 block_input (). */
570 567
571 block_input (); 568 block_input ();
572 f = check_x_frame (frame); 569 f = decode_window_system_frame (frame);
573 570
574 if (FRAME_EXTERNAL_MENU_BAR (f)) 571 if (FRAME_EXTERNAL_MENU_BAR (f))
575 set_frame_menubar (f, 0, 1); 572 set_frame_menubar (f, 0, 1);
diff --git a/src/xselect.c b/src/xselect.c
index cca1a47212b..b422a22d68b 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2450,7 +2450,7 @@ Use the display for FRAME or the current frame if FRAME is not given or nil.
2450If the value is 0 or the atom is not known, return the empty string. */) 2450If the value is 0 or the atom is not known, return the empty string. */)
2451 (Lisp_Object value, Lisp_Object frame) 2451 (Lisp_Object value, Lisp_Object frame)
2452{ 2452{
2453 struct frame *f = check_x_frame (frame); 2453 struct frame *f = decode_window_system_frame (frame);
2454 char *name = 0; 2454 char *name = 0;
2455 char empty[] = ""; 2455 char empty[] = "";
2456 Lisp_Object ret = Qnil; 2456 Lisp_Object ret = Qnil;
@@ -2485,7 +2485,7 @@ FRAME is on. If FRAME is nil, the selected frame is used. */)
2485 (Lisp_Object atom, Lisp_Object frame) 2485 (Lisp_Object atom, Lisp_Object frame)
2486{ 2486{
2487 Atom x_atom; 2487 Atom x_atom;
2488 struct frame *f = check_x_frame (frame); 2488 struct frame *f = decode_window_system_frame (frame);
2489 ptrdiff_t i; 2489 ptrdiff_t i;
2490 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 2490 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
2491 2491
@@ -2618,7 +2618,7 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from,
2618 struct x_display_info *dpyinfo = check_x_display_info (display); 2618 struct x_display_info *dpyinfo = check_x_display_info (display);
2619 Window wdest; 2619 Window wdest;
2620 XEvent event; 2620 XEvent event;
2621 struct frame *f = check_x_frame (from); 2621 struct frame *f = decode_window_system_frame (from);
2622 int to_root; 2622 int to_root;
2623 2623
2624 CHECK_NUMBER (format); 2624 CHECK_NUMBER (format);
@@ -2635,7 +2635,7 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from,
2635 2635
2636 if (FRAMEP (dest) || NILP (dest)) 2636 if (FRAMEP (dest) || NILP (dest))
2637 { 2637 {
2638 struct frame *fdest = check_x_frame (dest); 2638 struct frame *fdest = decode_window_system_frame (dest);
2639 wdest = FRAME_OUTER_WINDOW (fdest); 2639 wdest = FRAME_OUTER_WINDOW (fdest);
2640 } 2640 }
2641 else if (STRINGP (dest)) 2641 else if (STRINGP (dest))
diff --git a/src/xterm.h b/src/xterm.h
index 6b64135927e..16effc5c9ea 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -923,7 +923,6 @@ void x_handle_property_notify (XPropertyEvent *);
923 923
924/* From xfns.c. */ 924/* From xfns.c. */
925 925
926struct frame *check_x_frame (Lisp_Object);
927extern void x_free_gcs (struct frame *); 926extern void x_free_gcs (struct frame *);
928 927
929/* From xrdb.c. */ 928/* From xrdb.c. */
@@ -1008,7 +1007,6 @@ extern void x_clipboard_manager_save_all (void);
1008 1007
1009extern struct x_display_info * check_x_display_info (Lisp_Object); 1008extern struct x_display_info * check_x_display_info (Lisp_Object);
1010extern Lisp_Object x_get_focus_frame (struct frame *); 1009extern Lisp_Object x_get_focus_frame (struct frame *);
1011extern int x_in_use;
1012 1010
1013#ifdef USE_GTK 1011#ifdef USE_GTK
1014extern int xg_set_icon (struct frame *, Lisp_Object); 1012extern int xg_set_icon (struct frame *, Lisp_Object);