Get rid of some platform-specific functions examining window
authorDmitry Antipov <dmantipov@yandex.ru>
Sun, 7 Apr 2013 04:41:19 +0000 (08:41 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Sun, 7 Apr 2013 04:41:19 +0000 (08:41 +0400)
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.

26 files changed:
src/ChangeLog
src/fileio.c
src/fns.c
src/font.c
src/fontset.c
src/frame.c
src/frame.h
src/image.c
src/lisp.h
src/menu.c
src/msdos.c
src/nsfns.m
src/nsmenu.m
src/nsselect.m
src/nsterm.h
src/nsterm.m
src/w32fns.c
src/w32font.c
src/w32menu.c
src/w32term.h
src/xfaces.c
src/xfns.c
src/xgselect.c
src/xmenu.c
src/xselect.c
src/xterm.h

index 70e342d..e39a104 100644 (file)
@@ -1,3 +1,34 @@
+2013-04-07  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       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.
+
 2013-04-03  Kenichi Handa  <handa@gnu.org>
 
        The following changes is to optimize the code for reading UTF-8
index 2047338..bffaff0 100644 (file)
@@ -5816,7 +5816,7 @@ before any other event (mouse or keypress) is handled.  */)
   if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
       && use_dialog_box
       && use_file_dialog
-      && have_menus_p ())
+      && window_system_available (SELECTED_FRAME ()))
     return Qt;
 #endif
   return Qnil;
index b3a1dc2..86bdc02 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -2443,10 +2443,9 @@ is nil, and `use-dialog-box' is non-nil.  */)
   CHECK_STRING (prompt);
 
 #ifdef HAVE_MENUS
-  if (FRAME_WINDOW_P (SELECTED_FRAME ())
-      && (NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
+  if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
       && use_dialog_box
-      && have_menus_p ())
+      && window_system_available (SELECTED_FRAME ()))
     {
       Lisp_Object pane, menu, obj;
       redisplay_preserve_echo_area (4);
index 17573cd..6247eec 100644 (file)
@@ -4844,11 +4844,9 @@ If the named font is not yet loaded, return nil.  */)
   Lisp_Object info;
   Lisp_Object font_object;
 
-  check_window_system ();
-
   if (! FONTP (name))
     CHECK_STRING (name);
-  f = decode_live_frame (frame);
+  f = decode_window_system_frame (frame);
 
   if (STRINGP (name))
     {
index 7aec26b..2f6313c 100644 (file)
@@ -1209,7 +1209,7 @@ If REGEXPP is non-nil, PATTERN is a regular expression.  */)
   Lisp_Object fontset;
   int id;
 
-  check_window_system ();
+  check_window_system (NULL);
 
   CHECK_STRING (pattern);
 
@@ -1915,8 +1915,7 @@ format is the same as above.  */)
   Lisp_Object val, elt;
   int c, i, j, k;
 
-  check_window_system ();
-
+  check_window_system (NULL);
   fontset = check_fontset_name (fontset, &frame);
 
   /* Recode fontsets realized on FRAME from the base fontset FONTSET
index 5d5876e..2fe3982 100644 (file)
@@ -149,6 +149,37 @@ decode_any_frame (register Lisp_Object frame)
   return XFRAME (frame);
 }
 
+bool
+window_system_available (struct frame *f)
+{
+  if (f)
+    return FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f);
+  else
+#ifdef HAVE_WINDOW_SYSTEM
+    return x_display_list != NULL;
+#else
+    return 0;
+#endif
+}
+
+struct frame *
+decode_window_system_frame (Lisp_Object frame)
+{
+  struct frame *f = decode_live_frame (frame);
+  
+  if (!window_system_available (f))
+    error ("Window system frame should be used");
+  return f;
+}
+
+void
+check_window_system (struct frame *f)
+{
+  if (!window_system_available (f))
+    error (f ? "Window system frame should be used"
+          : "Window system is not in use or not initialized");
+}
+
 static void
 set_menu_bar_lines_1 (Lisp_Object window, int n)
 {
@@ -3493,7 +3524,7 @@ and the class is `Emacs.CLASS.SUBCLASS'.  */)
   (Lisp_Object attribute, Lisp_Object class, Lisp_Object component,
    Lisp_Object subclass)
 {
-  check_window_system ();
+  check_window_system (NULL);
 
   return xrdb_get_resource (check_x_display_info (Qnil)->xrdb,
                            attribute, class, component, subclass);
index 46e18dd..b69f19b 100644 (file)
@@ -958,6 +958,7 @@ extern Lisp_Object Qnoelisp;
 extern struct frame *last_nonminibuf_frame;
 
 extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
+extern struct frame *decode_window_system_frame (Lisp_Object);
 extern struct frame *decode_live_frame (Lisp_Object);
 extern struct frame *decode_any_frame (Lisp_Object);
 extern struct frame *make_initial_frame (void);
@@ -968,6 +969,8 @@ extern struct frame *make_frame_without_minibuffer (Lisp_Object,
                                                     struct kboard *,
                                                     Lisp_Object);
 #endif /* HAVE_WINDOW_SYSTEM */
+extern bool window_system_available (struct frame *);
+extern void check_window_system (struct frame *);
 extern void frame_make_pointer_invisible (void);
 extern void frame_make_pointer_visible (void);
 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
index cac23b7..2dae63a 100644 (file)
@@ -889,7 +889,7 @@ or omitted means use the selected frame.  */)
   size = Qnil;
   if (valid_image_p (spec))
     {
-      struct frame *f = check_x_frame (frame);
+      struct frame *f = decode_window_system_frame (frame);
       ptrdiff_t id = lookup_image (f, spec);
       struct image *img = IMAGE_FROM_ID (f, id);
       int width = img->width + 2 * img->hmargin;
@@ -919,7 +919,7 @@ or omitted means use the selected frame.  */)
   mask = Qnil;
   if (valid_image_p (spec))
     {
-      struct frame *f = check_x_frame (frame);
+      struct frame *f = decode_window_system_frame (frame);
       ptrdiff_t id = lookup_image (f, spec);
       struct image *img = IMAGE_FROM_ID (f, id);
       if (img->mask)
@@ -942,7 +942,7 @@ or omitted means use the selected frame.  */)
   ext = Qnil;
   if (valid_image_p (spec))
     {
-      struct frame *f = check_x_frame (frame);
+      struct frame *f = decode_window_system_frame (frame);
       ptrdiff_t id = lookup_image (f, spec);
       struct image *img = IMAGE_FROM_ID (f, id);
       ext = img->lisp_data;
@@ -1550,7 +1550,7 @@ which is then usually a filename.  */)
   if (!(EQ (filter, Qnil) || FRAMEP (filter)))
     clear_image_caches (filter);
   else
-    clear_image_cache (check_x_frame (filter), Qt);
+    clear_image_cache (decode_window_system_frame (filter), Qt);
 
   return Qnil;
 }
@@ -1581,7 +1581,7 @@ FRAME t means refresh the image on all frames.  */)
        }
     }
   else
-    uncache_image (check_x_frame (frame), spec);
+    uncache_image (decode_window_system_frame (frame), spec);
 
   return Qnil;
 }
index 2e1d20a..bcb866b 100644 (file)
@@ -3765,22 +3765,12 @@ extern void syms_of_xterm (void);
 extern char *x_get_keysym_name (int);
 #endif /* HAVE_WINDOW_SYSTEM */
 
-#if defined(HAVE_WINDOW_SYSTEM) || defined (MSDOS)
-/* Defined in (x|w32)fns.c, nsfns.m, msdos.c.  */
-extern void check_window_system (void);
-#endif
-
 #ifdef HAVE_LIBXML2
 /* Defined in xml.c.  */
 extern void syms_of_xml (void);
 extern void xml_cleanup_parser (void);
 #endif
 
-#ifdef HAVE_MENUS
-/* Defined in (x|w32)fns.c, nsfns.m, msdos.c.  */
-extern int have_menus_p (void);
-#endif
-
 #ifdef HAVE_DBUS
 /* Defined in dbusbind.c.  */
 void syms_of_dbusbind (void);
index ec9c681..58558d5 100644 (file)
@@ -1086,7 +1086,7 @@ no quit occurs and `x-popup-menu' returns nil.  */)
   {
     bool get_current_pos_p = 0;
 
-    check_window_system ();
+    check_window_system (SELECTED_FRAME ());
 
     /* Decode the first argument: find the window and the coordinates.  */
     if (EQ (position, Qt)
index dc79b66..a2bcc06 100644 (file)
@@ -2983,11 +2983,6 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
 \f
 /* --------------------------- X Menu emulation ---------------------- */
 
-/* Report availability of menus.  */
-
-int
-have_menus_p (void) {  return 1; }
-
 /* Create a brand new menu structure.  */
 
 XMenu *
index f7cf898..a483f84 100644 (file)
@@ -107,43 +107,6 @@ static ptrdiff_t image_cache_refcount;
 
    ========================================================================== */
 
-
-void
-check_window_system (void)
-{
- if (NSApp == nil)
-   error ("OpenStep is not in use or not initialized");
-}
-
-
-/* Nonzero if we can use mouse menus. */
-int
-have_menus_p (void)
-{
-  return NSApp != nil;
-}
-
-
-/* Extract a frame as a FRAME_PTR, defaulting to the selected frame
-   and checking validity for NS.  */
-static FRAME_PTR
-check_ns_frame (Lisp_Object frame)
-{
-  FRAME_PTR f;
-
-  if (NILP (frame))
-      f = SELECTED_FRAME ();
-  else
-    {
-      CHECK_LIVE_FRAME (frame);
-      f = XFRAME (frame);
-    }
-  if (! FRAME_NS_P (f))
-    error ("non-Nextstep frame used");
-  return f;
-}
-
-
 /* Let the user specify an Nextstep display with a frame.
    nil stands for the selected frame--or, if that is not an Nextstep frame,
    the first Nextstep display on the list.  */
@@ -1145,8 +1108,6 @@ This function is an internal primitive--use `make-frame' instead.  */)
   Lisp_Object tfont, tfontsize;
   static int desc_ctr = 1;
 
-  check_window_system ();
-
   /* x_get_arg modifies parms.  */
   parms = Fcopy_alist (parms);
 
@@ -1418,7 +1379,7 @@ DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
 FRAME nil means use the selected frame.  */)
      (Lisp_Object frame)
 {
-  struct frame *f = check_ns_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
   struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
 
   if (dpyinfo->x_focus_frame != f)
@@ -1439,18 +1400,8 @@ DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel,
        doc: /* Pop up the font panel. */)
      (Lisp_Object frame)
 {
-  id fm;
-  struct frame *f;
-
-  check_window_system ();
-  fm = [NSFontManager sharedFontManager];
-  if (NILP (frame))
-    f = SELECTED_FRAME ();
-  else
-    {
-      CHECK_FRAME (frame);
-      f = XFRAME (frame);
-    }
+  struct frame *f = decode_window_system_frame (frame);
+  id fm = [NSFontManager sharedFontManager];
 
   [fm setSelectedFont: ((struct nsfont_info *)f->output_data.ns->font)->nsfont
            isMultiple: NO];
@@ -1464,17 +1415,7 @@ DEFUN ("ns-popup-color-panel", Fns_popup_color_panel, Sns_popup_color_panel,
        doc: /* Pop up the color panel.  */)
      (Lisp_Object frame)
 {
-  struct frame *f;
-
-  check_window_system ();
-  if (NILP (frame))
-    f = SELECTED_FRAME ();
-  else
-    {
-      CHECK_FRAME (frame);
-      f = XFRAME (frame);
-    }
-
+  check_window_system (NULL);
   [NSApp orderFrontColorPanel: NSApp];
   return Qnil;
 }
@@ -1503,7 +1444,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories.  */)
   NSString *initS = NILP (init) || !STRINGP (init) ? nil :
     [NSString stringWithUTF8String: SSDATA (init)];
 
-  check_window_system ();
+  check_window_system (NULL);
 
   if (fileDelegate == nil)
     fileDelegate = [EmacsFileDelegate new];
@@ -1594,11 +1535,10 @@ If OWNER is nil, Emacs is assumed.  */)
 {
   const char *value;
 
-  check_window_system ();
+  check_window_system (NULL);
   if (NILP (owner))
     owner = build_string([ns_app_name UTF8String]);
   CHECK_STRING (name);
-/*fprintf (stderr, "ns-get-resource checking resource '%s'\n", SSDATA (name)); */
 
   value = ns_get_defaults_value (SSDATA (name));
 
@@ -1614,7 +1554,7 @@ If OWNER is nil, Emacs is assumed.
 If VALUE is nil, the default is removed.  */)
      (Lisp_Object owner, Lisp_Object name, Lisp_Object value)
 {
-  check_window_system ();
+  check_window_system (NULL);
   if (NILP (owner))
     owner = build_string ([ns_app_name UTF8String]);
   CHECK_STRING (name);
@@ -1642,7 +1582,7 @@ DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
        doc: /* This function is a no-op.  It is only present for completeness.  */)
      (Lisp_Object display)
 {
-  check_window_system ();
+  check_ns_display_info (display);
   /* This function has no real equivalent under NeXTstep.  Return nil to
      indicate this. */
   return Qnil;
@@ -1692,7 +1632,7 @@ If omitted or nil, the selected frame's display is used.  */)
 {
   int num;
 
-  check_window_system ();
+  check_ns_display_info (display);
   num = [[NSScreen screens] count];
 
   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.
 If omitted or nil, the selected frame's display is used.  */)
      (Lisp_Object display)
 {
-  check_window_system ();
+  check_ns_display_info (display);
   return make_number ((int)
                      ([ns_get_screen (display) frame].size.height/(92.0/25.4)));
 }
@@ -1719,7 +1659,7 @@ DISPLAY should be a frame, the display name as a string, or a terminal ID.
 If omitted or nil, the selected frame's display is used.  */)
      (Lisp_Object display)
 {
-  check_window_system ();
+  check_ns_display_info (display);
   return make_number ((int)
                      ([ns_get_screen (display) frame].size.width/(92.0/25.4)));
 }
@@ -1733,7 +1673,7 @@ DISPLAY should be a frame, the display name as a string, or a terminal ID.
 If omitted or nil, the selected frame's display is used.  */)
      (Lisp_Object display)
 {
-  check_window_system ();
+  check_ns_display_info (display);
   switch ([ns_get_window (display) backingType])
     {
     case NSBackingStoreBuffered:
@@ -1759,7 +1699,8 @@ If omitted or nil, the selected frame's display is used.  */)
      (Lisp_Object display)
 {
   NSWindowDepth depth;
-  check_window_system ();
+  
+  check_ns_display_info (display);
   depth = [ns_get_screen (display) depth];
 
   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.
 If omitted or nil, the selected frame's display is used.  */)
      (Lisp_Object display)
 {
-  check_window_system ();
+  check_ns_display_info (display);
   switch ([ns_get_window (display) backingType])
     {
     case NSBackingStoreBuffered:
@@ -1836,11 +1777,10 @@ terminate Emacs if we can't open the connection.
 DEFUN ("x-close-connection", Fx_close_connection, Sx_close_connection,
        1, 1, 0,
        doc: /* Close the connection to the current Nextstep display server.
-The argument DISPLAY is currently ignored.  */)
+DISPLAY should be a frame, the display name as a string, or a terminal ID.  */)
      (Lisp_Object display)
 {
-  check_window_system ();
-  /*ns_delete_terminal (dpyinfo->terminal); */
+  check_ns_display_info (display);
   [NSApp terminate: NSApp];
   return Qnil;
 }
@@ -1865,7 +1805,7 @@ DEFUN ("ns-hide-others", Fns_hide_others, Sns_hide_others,
        doc: /* Hides all applications other than Emacs.  */)
      (void)
 {
-  check_window_system ();
+  check_window_system (NULL);
   [NSApp hideOtherApplications: NSApp];
   return Qnil;
 }
@@ -1878,7 +1818,7 @@ If ON is equal to `activate', Emacs is unhidden and becomes
 the active application.  */)
      (Lisp_Object on)
 {
-  check_window_system ();
+  check_window_system (NULL);
   if (EQ (on, intern ("activate")))
     {
       [NSApp unhide: NSApp];
@@ -1897,7 +1837,7 @@ DEFUN ("ns-emacs-info-panel", Fns_emacs_info_panel, Sns_emacs_info_panel,
        doc: /* Shows the 'Info' or 'About' panel for Emacs.  */)
      (void)
 {
-  check_window_system ();
+  check_window_system (NULL);
   [NSApp orderFrontStandardAboutPanel: nil];
   return Qnil;
 }
@@ -1975,7 +1915,7 @@ DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0,
   NSMenu *svcs;
   id delegate;
 
-  check_window_system ();
+  check_window_system (NULL);
   svcs = [[NSMenu alloc] initWithTitle: @"Services"];
   [NSApp setServicesMenu: svcs];
   [NSApp registerServicesMenuSendTypes: ns_send_types
@@ -2028,7 +1968,7 @@ there was no result.  */)
   char *utfStr;
 
   CHECK_STRING (service);
-  check_window_system ();
+  check_window_system (NULL);
 
   utfStr = SSDATA (service);
   svcName = [NSString stringWithUTF8String: utfStr];
@@ -2152,7 +2092,7 @@ In case the execution fails, an error is signaled. */)
   NSEvent *nxev;
 
   CHECK_STRING (script);
-  check_window_system ();
+  check_window_system (NULL);
 
   block_input ();
 
@@ -2201,15 +2141,6 @@ In case the execution fails, an error is signaled. */)
 
    ========================================================================== */
 
-
-/* called from image.c */
-FRAME_PTR
-check_x_frame (Lisp_Object frame)
-{
-  return check_ns_frame (frame);
-}
-
-
 /* called from frame.c */
 struct ns_display_info *
 check_x_display_info (Lisp_Object frame)
@@ -2235,7 +2166,7 @@ x_get_string_resource (XrmDatabase rdb, char *name, char *class)
   /* remove appname prefix; TODO: allow for !="Emacs" */
   char *toCheck = class + (!strncmp (class, "Emacs.", 6) ? 6 : 0);
   const char *res;
-  check_window_system ();
+  check_window_system (NULL);
 
   if (inhibit_x_resources)
     /* --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,
      (Lisp_Object color, Lisp_Object frame)
 {
   NSColor * col;
-  check_window_system ();
+  check_window_system (NULL);
   return ns_lisp_to_color (color, &col) ? Qnil : Qt;
 }
 
@@ -2317,7 +2248,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
   NSColor * col;
   CGFloat red, green, blue, alpha;
 
-  check_window_system ();
+  check_window_system (NULL);
   CHECK_STRING (color);
 
   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,
 {
   NSWindowDepth depth;
   NSString *colorSpace;
-  check_window_system ();
+  
+  check_ns_display_info (display);
   depth = [ns_get_screen (display) depth];
   colorSpace = NSColorSpaceFromDepth (depth);
 
@@ -2356,7 +2288,8 @@ If omitted or nil, that stands for the selected frame's display. */)
      (Lisp_Object display)
 {
   NSWindowDepth depth;
-  check_window_system ();
+
+  check_ns_display_info (display);
   depth = [ns_get_screen (display) depth];
 
   return NSBitsPerPixelFromDepth (depth) > 1 ? Qt : Qnil;
@@ -2371,7 +2304,7 @@ DISPLAY should be either a frame, a display name (a string), or terminal ID.
 If omitted or nil, that stands for the selected frame's display.  */)
      (Lisp_Object display)
 {
-  check_window_system ();
+  check_ns_display_info (display);
   return make_number ((int) [ns_get_screen (display) frame].size.width);
 }
 
@@ -2384,7 +2317,7 @@ DISPLAY should be either a frame, a display name (a string), or terminal ID.
 If omitted or nil, that stands for the selected frame's display.  */)
      (Lisp_Object display)
 {
-  check_window_system ();
+  check_ns_display_info (display);
   return make_number ((int) [ns_get_screen (display) frame].size.height);
 }
 
@@ -2404,7 +2337,7 @@ that stands for the selected frame's display. */)
   NSScreen *screen;
   NSRect vScreen;
 
-  check_window_system ();
+  check_ns_display_info (display);
   screen = ns_get_screen (display);
   if (!screen)
     return Qnil;
@@ -2428,7 +2361,7 @@ DISPLAY should be either a frame, a display name (a string), or terminal ID.
 If omitted or nil, that stands for the selected frame's display.  */)
      (Lisp_Object display)
 {
-  check_window_system ();
+  check_ns_display_info (display);
   return make_number
     (NSBitsPerPixelFromDepth ([ns_get_screen (display) depth]));
 }
@@ -2442,10 +2375,7 @@ DISPLAY should be either a frame, a display name (a string), or terminal ID.
 If omitted or nil, that stands for the selected frame's display.  */)
      (Lisp_Object display)
 {
-  struct ns_display_info *dpyinfo;
-  check_window_system ();
-
-  dpyinfo = check_ns_display_info (display);
+  struct ns_display_info *dpyinfo = check_ns_display_info (display);
   /* We force 24+ bit depths to 24-bit to prevent an overflow.  */
   return make_number (1 << min (dpyinfo->n_planes, 24));
 }
@@ -2558,7 +2488,7 @@ Text larger than the specified size is clipped.  */)
 
   CHECK_STRING (string);
   str = SSDATA (string);
-  f = check_x_frame (frame);
+  f = decode_window_system_frame (frame);
   if (NILP (timeout))
     timeout = make_number (5);
   else
index d364639..648b568 100644 (file)
@@ -1409,8 +1409,6 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
 
   NSTRACE (x-popup-dialog);
 
-  check_window_system ();
-
   isQ = NILP (header);
 
   if (EQ (position, Qt)
@@ -1448,6 +1446,8 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
   else
     CHECK_WINDOW (window);
 
+  check_window_system (f);
+
   p.x = (int)f->left_pos + ((int)FRAME_COLUMN_WIDTH (f) * f->text_cols)/2;
   p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2;
 
index 2f539a1..bb9eacd 100644 (file)
@@ -354,8 +354,7 @@ On Nextstep, FRAME is unused.  */)
   Lisp_Object successful_p = Qnil, rest;
   Lisp_Object target_symbol, data;
 
-
-  check_window_system ();
+  check_window_system (NULL);
   CHECK_SYMBOL (selection);
   if (NILP (value))
       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.  */)
   (Lisp_Object selection, Lisp_Object time_object, Lisp_Object terminal)
 {
   id pb;
-  check_window_system ();
+  check_window_system (NULL);
   CHECK_SYMBOL (selection);
   if (NILP (assq_no_quit (selection, Vselection_alist))) return Qnil;
 
@@ -436,7 +435,7 @@ On Nextstep, TERMINAL is unused.  */)
   id pb;
   NSArray *types;
 
-  check_window_system ();
+  check_window_system (NULL);
   CHECK_SYMBOL (selection);
   if (EQ (selection, Qnil)) selection = QPRIMARY;
   if (EQ (selection, Qt)) selection = QSECONDARY;
@@ -464,7 +463,7 @@ frame's display, or the first available X display.
 On Nextstep, TERMINAL is unused.  */)
      (Lisp_Object selection, Lisp_Object terminal)
 {
-  check_window_system ();
+  check_window_system (NULL);
   CHECK_SYMBOL (selection);
   if (EQ (selection, Qnil)) selection = QPRIMARY;
   if (EQ (selection, Qt)) selection = QSECONDARY;
@@ -492,7 +491,7 @@ On Nextstep, TIME-STAMP and TERMINAL are unused.  */)
 {
   Lisp_Object val;
 
-  check_window_system ();
+  check_window_system (NULL);
   CHECK_SYMBOL (selection_name);
   CHECK_SYMBOL (target_type);
   val = ns_get_local_selection (selection_name, target_type);
@@ -516,7 +515,7 @@ SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */)
      (Lisp_Object selection)
 {
   id pb;
-  check_window_system ();
+  check_window_system (NULL);
   pb = ns_symbol_to_pb (selection);
   return pb != nil ? ns_string_from_pasteboard (pb) : Qnil;
 }
@@ -529,7 +528,7 @@ SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. */)
      (Lisp_Object selection, Lisp_Object string)
 {
   id pb;
-  check_window_system ();
+  check_window_system (NULL);
   pb = ns_symbol_to_pb (selection);
   if (pb != nil) ns_string_to_pasteboard (pb, string);
   return Qnil;
index 59cac34..07cfc2e 100644 (file)
@@ -577,8 +577,6 @@ extern Lisp_Object ns_display_name_list;
 extern struct ns_display_info *ns_display_info_for_name (Lisp_Object name);
 
 struct ns_display_info *check_x_display_info (Lisp_Object frame);
-FRAME_PTR check_x_frame (Lisp_Object frame);
-
 
 struct ns_output
 {
index fb1b0aa..bc3150c 100644 (file)
@@ -1012,8 +1012,9 @@ ns_raise_frame (struct frame *f)
      Bring window to foreground and make it active
    -------------------------------------------------------------------------- */
 {
-  NSView *view = FRAME_NS_VIEW (f);
-  check_window_system ();
+  NSView *view;
+  check_window_system (f);
+  view = FRAME_NS_VIEW (f);
   block_input ();
   if (FRAME_VISIBLE_P (f))
     [[view window] makeKeyAndOrderFront: NSApp];
@@ -1027,8 +1028,9 @@ ns_lower_frame (struct frame *f)
      Send window to back
    -------------------------------------------------------------------------- */
 {
-  NSView *view = FRAME_NS_VIEW (f);
-  check_window_system ();
+  NSView *view;
+  check_window_system (f);
+  view = FRAME_NS_VIEW (f);
   block_input ();
   [[view window] orderBack: NSApp];
   unblock_input ();
@@ -1131,9 +1133,10 @@ x_make_frame_invisible (struct frame *f)
      External: Hide the window (X11 semantics)
    -------------------------------------------------------------------------- */
 {
-  NSView * view = FRAME_NS_VIEW (f);
+  NSView *view;
   NSTRACE (x_make_frame_invisible);
-  check_window_system ();
+  check_window_system (f);
+  view = FRAME_NS_VIEW (f);
   [[view window] orderOut: NSApp];
   SET_FRAME_VISIBLE (f, 0);
   SET_FRAME_ICONIFIED (f, 0);
@@ -1146,10 +1149,13 @@ x_iconify_frame (struct frame *f)
      External: Iconify window
    -------------------------------------------------------------------------- */
 {
-  NSView * view = FRAME_NS_VIEW (f);
-  struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
+  NSView *view;
+  struct ns_display_info *dpyinfo;
+
   NSTRACE (x_iconify_frame);
-  check_window_system ();
+  check_window_system (f);
+  view = FRAME_NS_VIEW (f);
+  dpyinfo = FRAME_NS_DISPLAY_INFO (f);
 
   if (dpyinfo->x_highlight_frame == f)
     dpyinfo->x_highlight_frame = 0;
@@ -1174,11 +1180,15 @@ x_iconify_frame (struct frame *f)
 void
 x_free_frame_resources (struct frame *f)
 {
-  NSView *view = FRAME_NS_VIEW (f);
-  struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
-  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+  NSView *view;
+  struct ns_display_info *dpyinfo;
+  Mouse_HLInfo *hlinfo;
+
   NSTRACE (x_free_frame_resources);
-  check_window_system ();
+  check_window_system (f);
+  view = FRAME_NS_VIEW (f);
+  dpyinfo = FRAME_NS_DISPLAY_INFO (f);
+  hlinfo = MOUSE_HL_INFO (f);
 
   [(EmacsView *)view setWindowClosing: YES]; /* may not have been informed */
 
@@ -1219,7 +1229,7 @@ x_destroy_window (struct frame *f)
    -------------------------------------------------------------------------- */
 {
   NSTRACE (x_destroy_window);
-  check_window_system ();
+  check_window_system (f);
   x_free_frame_resources (f);
   ns_window_num--;
 }
index 2bc1042..5d3a78f 100644 (file)
@@ -95,10 +95,6 @@ static HWND hourglass_hwnd = NULL;
 #define IDC_HAND MAKEINTRESOURCE(32649)
 #endif
 
-/* Nonzero if using Windows.  */
-
-static int w32_in_use;
-
 Lisp_Object Qsuppress_icon;
 Lisp_Object Qundefined_color;
 Lisp_Object Qcancel_timer;
@@ -239,37 +235,6 @@ HINSTANCE hinst = NULL;
 static unsigned int sound_type = 0xFFFFFFFF;
 #define MB_EMACS_SILENT (0xFFFFFFFF - 1)
 
-\f
-/* Error if we are not connected to MS-Windows.  */
-void
-check_window_system (void)
-{
-  if (! w32_in_use)
-    error ("MS-Windows not in use or not initialized");
-}
-
-/* Nonzero if we can use mouse menus.
-   You should not call this unless HAVE_MENUS is defined.  */
-
-int
-have_menus_p (void)
-{
-  return w32_in_use;
-}
-
-/* Extract a frame as a FRAME_PTR, defaulting to the selected frame
-   and checking validity for W32.  */
-
-FRAME_PTR
-check_x_frame (Lisp_Object frame)
-{
-  struct frame *f = decode_live_frame (frame);
-
-  if (! FRAME_W32_P (f))
-    error ("Non-W32 frame used");
-  return f;
-}
-
 /* Let the user specify a display with a frame.
    nil stands for the selected frame--or, if that is not a w32 frame,
    the first display on the list.  */
@@ -4567,7 +4532,7 @@ DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
        doc: /* Give FRAME input focus, raising to foreground if necessary.  */)
   (Lisp_Object frame)
 {
-  x_focus_on_frame (check_x_frame (frame));
+  x_focus_on_frame (decode_window_system_frame (frame));
   return Qnil;
 }
 
@@ -4578,7 +4543,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
   (Lisp_Object color, Lisp_Object frame)
 {
   XColor foo;
-  FRAME_PTR f = check_x_frame (frame);
+  FRAME_PTR f = decode_window_system_frame (frame);
 
   CHECK_STRING (color);
 
@@ -4593,7 +4558,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
   (Lisp_Object color, Lisp_Object frame)
 {
   XColor foo;
-  FRAME_PTR f = check_x_frame (frame);
+  FRAME_PTR f = decode_window_system_frame (frame);
 
   CHECK_STRING (color);
 
@@ -4911,7 +4876,6 @@ x_display_info_for_name (Lisp_Object name)
   if (dpyinfo == 0)
     error ("Cannot connect to server %s", SDATA (name));
 
-  w32_in_use = 1;
   XSETFASTINT (Vwindow_system_version, w32_major_version);
 
   return dpyinfo;
@@ -4941,7 +4905,7 @@ terminate Emacs if we can't open the connection.
 
   /* If initialization has already been done, return now to avoid
      overwriting critical parts of one_w32_display_info.  */
-  if (w32_in_use)
+  if (window_system_available (NULL))
     return Qnil;
 
   if (! NILP (xrm_string))
@@ -5010,8 +4974,6 @@ terminate Emacs if we can't open the connection.
        error ("Cannot connect to server %s", SDATA (display));
     }
 
-  w32_in_use = 1;
-
   XSETFASTINT (Vwindow_system_version, w32_major_version);
   return Qnil;
 }
@@ -5095,7 +5057,7 @@ FRAME.  Default is to change on the edit X window.  */)
   (Lisp_Object prop, Lisp_Object value, Lisp_Object frame,
    Lisp_Object type, Lisp_Object format, Lisp_Object outer_p)
 {
-  struct frame *f = check_x_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
   Atom prop_atom;
 
   CHECK_STRING (prop);
@@ -5121,7 +5083,7 @@ DEFUN ("x-delete-window-property", Fx_delete_window_property,
 FRAME nil or omitted means use the selected frame.  Value is PROP.  */)
   (Lisp_Object prop, Lisp_Object frame)
 {
-  struct frame *f = check_x_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
   Atom prop_atom;
 
   CHECK_STRING (prop);
@@ -5157,7 +5119,7 @@ no value of TYPE (always string in the MS Windows case).  */)
   (Lisp_Object prop, Lisp_Object frame, Lisp_Object type,
    Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p)
 {
-  struct frame *f = check_x_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
   Atom prop_atom;
   int rc;
   Lisp_Object prop_value = Qnil;
@@ -5358,8 +5320,6 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
   Lisp_Object buffer;
   struct buffer *old_buffer;
 
-  check_window_system ();
-
   /* Use this general default value to start with until we know if
      this frame has a specified name.  */
   Vx_resource_name = Vinvocation_name;
@@ -5703,7 +5663,7 @@ Text larger than the specified size is clipped.  */)
   GCPRO4 (string, parms, frame, timeout);
 
   CHECK_STRING (string);
-  f = check_x_frame (frame);
+  f = decode_window_system_frame (frame);
   if (NILP (timeout))
     timeout = make_number (5);
   else
@@ -6354,7 +6314,7 @@ screen saver if defined.
 If optional parameter FRAME is not specified, use selected frame.  */)
   (Lisp_Object command, Lisp_Object frame)
 {
-  FRAME_PTR f = check_x_frame (frame);
+  FRAME_PTR f = decode_window_system_frame (frame);
 
   CHECK_NUMBER (command);
 
@@ -7312,8 +7272,6 @@ void
 syms_of_w32fns (void)
 {
   globals_of_w32fns ();
-  /* This is zero if not using MS-Windows.  */
-  w32_in_use = 0;
   track_mouse_window = NULL;
 
   w32_visible_system_caret_hwnd = NULL;
index fb52376..105daa0 100644 (file)
@@ -2467,7 +2467,7 @@ If EXCLUDE-PROPORTIONAL is non-nil, exclude proportional fonts
 in the font selection dialog. */)
   (Lisp_Object frame, Lisp_Object exclude_proportional)
 {
-  FRAME_PTR f = check_x_frame (frame);
+  FRAME_PTR f = decode_window_system_frame (frame);
   CHOOSEFONT cf;
   LOGFONT lf;
   TEXTMETRIC tm;
index 0c8d5ca..346402b 100644 (file)
@@ -140,8 +140,6 @@ otherwise it is "Question". */)
   FRAME_PTR f = NULL;
   Lisp_Object window;
 
-  check_window_system ();
-
   /* Decode the first argument: find the window or frame to use.  */
   if (EQ (position, Qt)
       || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
@@ -194,6 +192,8 @@ otherwise it is "Question". */)
        but I don't want to make one now.  */
     CHECK_WINDOW (window);
 
+  check_window_system (f);
+
 #ifndef HAVE_DIALOGS
 
   {
index e85ee77..9bb37b3 100644 (file)
@@ -739,7 +739,6 @@ struct image;
 struct face;
 
 XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *);
-struct frame * check_x_frame (Lisp_Object);
 
 typedef DWORD (WINAPI * ClipboardSequence_Proc) (void);
 typedef BOOL (WINAPI * AppendMenuW_Proc) (
index 9acaf6d..b2ace1b 100644 (file)
@@ -1634,7 +1634,7 @@ the WIDTH times as wide as FACE on FRAME.  */)
   struct frame *f;
   int size, avgwidth IF_LINT (= 0);
 
-  check_window_system ();
+  check_window_system (NULL);
   CHECK_STRING (pattern);
 
   if (! NILP (maximum))
@@ -1643,8 +1643,8 @@ the WIDTH times as wide as FACE on FRAME.  */)
   if (!NILP (width))
     CHECK_NUMBER (width);
 
-  /* We can't simply call check_x_frame because this function may be
-     called before any frame is created.  */
+  /* We can't simply call decode_window_system_frame because
+     this function may be called before any frame is created.  */
   f = decode_live_frame (frame);
   if (! FRAME_WINDOW_P (f))
     {
@@ -3923,8 +3923,8 @@ If FRAME is omitted or nil, use the selected frame.  */)
   struct frame *f;
   Lisp_Object lface1, lface2;
 
-  /* Don't use check_x_frame here because this function is called
-     before X frames exist.  At that time, if FRAME is nil,
+  /* Don't use decode_window_system_frame here because this function
+     is called before X frames exist.  At that time, if FRAME is nil,
      selected_frame will be used which is the frame dumped with
      Emacs.  That frame is not an X frame.  */
   f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
index 8b8d94d..f4c24cb 100644 (file)
@@ -123,10 +123,6 @@ extern LWLIB_ID widget_id_tick;
 
 #define MAXREQUEST(dpy) (XMaxRequestSize (dpy))
 
-/* Nonzero if using X.  */
-
-int x_in_use;
-
 static Lisp_Object Qsuppress_icon;
 static Lisp_Object Qundefined_color;
 static Lisp_Object Qcompound_text, Qcancel_timer;
@@ -139,38 +135,6 @@ static int dpyinfo_refcount;
 
 static struct x_display_info *x_display_info_for_name (Lisp_Object);
 
-\f
-/* Error if we are not connected to X.  */
-
-void
-check_window_system (void)
-{
-  if (! x_in_use)
-    error ("X windows are not in use or not initialized");
-}
-
-/* Nonzero if we can use mouse menus.
-   You should not call this unless HAVE_MENUS is defined.  */
-
-int
-have_menus_p (void)
-{
-  return x_in_use;
-}
-
-/* Extract a frame as a FRAME_PTR, defaulting to the selected frame
-   and checking validity for X.  */
-
-FRAME_PTR
-check_x_frame (Lisp_Object frame)
-{
-  struct frame *f = decode_live_frame (frame);
-
-  if (! FRAME_X_P (f))
-    error ("Non-X frame used");
-  return f;
-}
-
 /* Let the user specify an X display with a Lisp object.
    OBJECT may be nil, a frame or a terminal object.
    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)
     dpyinfo = x_display_info_for_name (object);
   else
     {
-      FRAME_PTR f = check_x_frame (object);
+      FRAME_PTR f = decode_window_system_frame (object);
       dpyinfo = FRAME_X_DISPLAY_INFO (f);
     }
 
@@ -2992,7 +2956,7 @@ If FRAME is omitted or nil, use the selected frame.
 Signal error if FRAME is not an X frame.  */)
   (Lisp_Object frame)
 {
-  struct frame *f = check_x_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
 
   block_input ();
   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,
 FRAME nil means use the selected frame.  */)
   (Lisp_Object frame)
 {
-  struct frame *f = check_x_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
   Display *dpy = FRAME_X_DISPLAY (f);
 
   block_input ();
@@ -3516,7 +3480,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
   (Lisp_Object color, Lisp_Object frame)
 {
   XColor foo;
-  FRAME_PTR f = check_x_frame (frame);
+  FRAME_PTR f = decode_window_system_frame (frame);
 
   CHECK_STRING (color);
 
@@ -3531,7 +3495,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
   (Lisp_Object color, Lisp_Object frame)
 {
   XColor foo;
-  FRAME_PTR f = check_x_frame (frame);
+  FRAME_PTR f = decode_window_system_frame (frame);
 
   CHECK_STRING (color);
 
@@ -3996,7 +3960,6 @@ x_display_info_for_name (Lisp_Object name)
   if (dpyinfo == 0)
     error ("Cannot connect to X server %s", SDATA (name));
 
-  x_in_use = 1;
   XSETFASTINT (Vwindow_system_version, 11);
 
   return dpyinfo;
@@ -4050,8 +4013,6 @@ An insecure way to solve the problem may be to use `xhost'.\n",
        error ("Cannot connect to X server %s", SDATA (display));
     }
 
-  x_in_use = 1;
-
   XSETFASTINT (Vwindow_system_version, 11);
   return Qnil;
 }
@@ -4143,7 +4104,7 @@ FRAME.  Default is to change on the edit X window.  */)
   (Lisp_Object prop, Lisp_Object value, Lisp_Object frame,
    Lisp_Object type, Lisp_Object format, Lisp_Object outer_p)
 {
-  struct frame *f = check_x_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
   Atom prop_atom;
   Atom target_type = XA_STRING;
   int element_format = 8;
@@ -4221,7 +4182,7 @@ DEFUN ("x-delete-window-property", Fx_delete_window_property,
 FRAME nil or omitted means use the selected frame.  Value is PROP.  */)
   (Lisp_Object prop, Lisp_Object frame)
 {
-  struct frame *f = check_x_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
   Atom prop_atom;
 
   CHECK_STRING (prop);
@@ -4257,7 +4218,7 @@ no value of TYPE (always string in the MS Windows case).  */)
   (Lisp_Object prop, Lisp_Object frame, Lisp_Object type,
    Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p)
 {
-  struct frame *f = check_x_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
   Atom prop_atom;
   int rc;
   Lisp_Object prop_value = Qnil;
@@ -4525,8 +4486,6 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
   Lisp_Object buffer;
   struct buffer *old_buffer;
 
-  check_window_system ();
-
   if (!dpyinfo->terminal->name)
     error ("Terminal is not live, can't create new frames on it");
 
@@ -4923,7 +4882,7 @@ Text larger than the specified size is clipped.  */)
   if (SCHARS (string) == 0)
     string = make_unibyte_string (" ", 1);
 
-  f = check_x_frame (frame);
+  f = decode_window_system_frame (frame);
   if (NILP (timeout))
     timeout = make_number (5);
   else
@@ -5246,7 +5205,7 @@ DEFUN ("x-uses-old-gtk-dialog", Fx_uses_old_gtk_dialog,
 #ifdef USE_GTK
   if (use_dialog_box
       && use_file_dialog
-      && have_menus_p ()
+      && window_system_available (SELECTED_FRAME ())
       && xg_uses_old_file_dialog ())
     return Qt;
 #endif
@@ -5316,7 +5275,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
   ptrdiff_t count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
 
-  check_window_system ();
+  check_window_system (f);
 
   GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
 
@@ -5486,7 +5445,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
   char *cdef_file;
 
-  check_window_system ();
+  check_window_system (f);
 
   GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
 
@@ -5541,15 +5500,13 @@ FRAME is the frame on which to pop up the font chooser.  If omitted or
 nil, it defaults to the selected frame. */)
   (Lisp_Object frame, Lisp_Object ignored)
 {
-  FRAME_PTR f = check_x_frame (frame);
+  FRAME_PTR f = decode_window_system_frame (frame);
   Lisp_Object font;
   Lisp_Object font_param;
   char *default_name = NULL;
   struct gcpro gcpro1, gcpro2;
   ptrdiff_t count = SPECPDL_INDEX ();
 
-  check_window_system ();
-
   if (popup_activated ())
     error ("Trying to use a menu from within a menu-entry");
 
@@ -5609,7 +5566,7 @@ present and mapped to the usual X keysyms.  */)
   return Qlambda;
 #else
   XkbDescPtr kb;
-  struct frame *f = check_x_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
   Display *dpy = FRAME_X_DISPLAY (f);
   Lisp_Object have_keys;
   int major, minor, op, event, error_code;
@@ -5737,9 +5694,6 @@ frame_parm_handler x_frame_parm_handlers[] =
 void
 syms_of_xfns (void)
 {
-  /* This is zero if not using X windows.  */
-  x_in_use = 0;
-
   /* The section below is built by the lisp expression at the top of the file,
      just above where these variables are declared.  */
   /*&&& init symbols here &&&*/
index 2c8e967..0b5ad6a 100644 (file)
@@ -26,6 +26,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <glib.h>
 #include <errno.h>
 #include "xterm.h"
+#include "frame.h"
 
 int
 xg_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,
   int i, nfds, tmo_in_millisec;
   USE_SAFE_ALLOCA;
 
-  if (! (x_in_use
+  if (! (window_system_available (NULL)
         && g_main_context_pending (context = g_main_context_default ())))
     return pselect (fds_lim, rfds, wfds, efds, timeout, sigmask);
 
index e6291ed..9993bd8 100644 (file)
@@ -223,8 +223,6 @@ for instance using the window manager, then this produces a quit and
   FRAME_PTR f = NULL;
   Lisp_Object window;
 
-  check_window_system ();
-
   /* Decode the first argument: find the window or frame to use.  */
   if (EQ (position, Qt)
       || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
@@ -277,8 +275,7 @@ for instance using the window manager, then this produces a quit and
        but I don't want to make one now.  */
     CHECK_WINDOW (window);
 
-  if (! FRAME_X_P (f) && ! FRAME_MSDOS_P (f))
-    error ("Can not put X dialog on this terminal");
+  check_window_system (f);
 
   /* Force a redisplay before showing the dialog.  If a frame is created
      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.  */)
   (Lisp_Object frame)
 {
   XEvent ev;
-  FRAME_PTR f = check_x_frame (frame);
+  FRAME_PTR f = decode_window_system_frame (frame);
   Widget menubar;
   block_input ();
 
@@ -569,7 +566,7 @@ If FRAME is nil or not given, use the selected frame.  */)
      block_input ().  */
 
   block_input ();
-  f = check_x_frame (frame);
+  f = decode_window_system_frame (frame);
 
   if (FRAME_EXTERNAL_MENU_BAR (f))
     set_frame_menubar (f, 0, 1);
index cca1a47..b422a22 100644 (file)
@@ -2450,7 +2450,7 @@ Use the display for FRAME or the current frame if FRAME is not given or nil.
 If the value is 0 or the atom is not known, return the empty string.  */)
   (Lisp_Object value, Lisp_Object frame)
 {
-  struct frame *f = check_x_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
   char *name = 0;
   char empty[] = "";
   Lisp_Object ret = Qnil;
@@ -2485,7 +2485,7 @@ FRAME is on.  If FRAME is nil, the selected frame is used.  */)
   (Lisp_Object atom, Lisp_Object frame)
 {
   Atom x_atom;
-  struct frame *f = check_x_frame (frame);
+  struct frame *f = decode_window_system_frame (frame);
   ptrdiff_t i;
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
 
@@ -2618,7 +2618,7 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from,
   struct x_display_info *dpyinfo = check_x_display_info (display);
   Window wdest;
   XEvent event;
-  struct frame *f = check_x_frame (from);
+  struct frame *f = decode_window_system_frame (from);
   int to_root;
 
   CHECK_NUMBER (format);
@@ -2635,7 +2635,7 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from,
 
   if (FRAMEP (dest) || NILP (dest))
     {
-      struct frame *fdest = check_x_frame (dest);
+      struct frame *fdest = decode_window_system_frame (dest);
       wdest = FRAME_OUTER_WINDOW (fdest);
     }
   else if (STRINGP (dest))
index 6b64135..16effc5 100644 (file)
@@ -923,7 +923,6 @@ void x_handle_property_notify (XPropertyEvent *);
 
 /* From xfns.c.  */
 
-struct frame *check_x_frame (Lisp_Object);
 extern void x_free_gcs (struct frame *);
 
 /* From xrdb.c.  */
@@ -1008,7 +1007,6 @@ extern void x_clipboard_manager_save_all (void);
 
 extern struct x_display_info * check_x_display_info (Lisp_Object);
 extern Lisp_Object x_get_focus_frame (struct frame *);
-extern int x_in_use;
 
 #ifdef USE_GTK
 extern int xg_set_icon (struct frame *, Lisp_Object);