+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
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;
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);
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))
{
Lisp_Object fontset;
int id;
- check_window_system ();
+ check_window_system (NULL);
CHECK_STRING (pattern);
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
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)
{
(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);
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);
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);
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;
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)
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;
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;
}
}
}
else
- uncache_image (check_x_frame (frame), spec);
+ uncache_image (decode_window_system_frame (frame), spec);
return Qnil;
}
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);
{
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)
\f
/* --------------------------- X Menu emulation ---------------------- */
-/* Report availability of menus. */
-
-int
-have_menus_p (void) { return 1; }
-
/* Create a brand new menu structure. */
XMenu *
========================================================================== */
-
-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. */
Lisp_Object tfont, tfontsize;
static int desc_ctr = 1;
- check_window_system ();
-
/* x_get_arg modifies parms. */
parms = Fcopy_alist (parms);
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)
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];
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;
}
NSString *initS = NILP (init) || !STRINGP (init) ? nil :
[NSString stringWithUTF8String: SSDATA (init)];
- check_window_system ();
+ check_window_system (NULL);
if (fileDelegate == nil)
fileDelegate = [EmacsFileDelegate new];
{
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));
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);
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;
{
int num;
- check_window_system ();
+ check_ns_display_info (display);
num = [[NSScreen screens] count];
return (num != 0) ? make_number (num) : Qnil;
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)));
}
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)));
}
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:
(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))
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:
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;
}
doc: /* Hides all applications other than Emacs. */)
(void)
{
- check_window_system ();
+ check_window_system (NULL);
[NSApp hideOtherApplications: NSApp];
return Qnil;
}
the active application. */)
(Lisp_Object on)
{
- check_window_system ();
+ check_window_system (NULL);
if (EQ (on, intern ("activate")))
{
[NSApp unhide: NSApp];
doc: /* Shows the 'Info' or 'About' panel for Emacs. */)
(void)
{
- check_window_system ();
+ check_window_system (NULL);
[NSApp orderFrontStandardAboutPanel: nil];
return Qnil;
}
NSMenu *svcs;
id delegate;
- check_window_system ();
+ check_window_system (NULL);
svcs = [[NSMenu alloc] initWithTitle: @"Services"];
[NSApp setServicesMenu: svcs];
[NSApp registerServicesMenuSendTypes: ns_send_types
char *utfStr;
CHECK_STRING (service);
- check_window_system ();
+ check_window_system (NULL);
utfStr = SSDATA (service);
svcName = [NSString stringWithUTF8String: utfStr];
NSEvent *nxev;
CHECK_STRING (script);
- check_window_system ();
+ check_window_system (NULL);
block_input ();
========================================================================== */
-
-/* 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)
/* 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. */
(Lisp_Object color, Lisp_Object frame)
{
NSColor * col;
- check_window_system ();
+ check_window_system (NULL);
return ns_lisp_to_color (color, &col) ? Qnil : Qt;
}
NSColor * col;
CGFloat red, green, blue, alpha;
- check_window_system ();
+ check_window_system (NULL);
CHECK_STRING (color);
if (ns_lisp_to_color (color, &col))
{
NSWindowDepth depth;
NSString *colorSpace;
- check_window_system ();
+
+ check_ns_display_info (display);
depth = [ns_get_screen (display) depth];
colorSpace = NSColorSpaceFromDepth (depth);
(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;
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);
}
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);
}
NSScreen *screen;
NSRect vScreen;
- check_window_system ();
+ check_ns_display_info (display);
screen = ns_get_screen (display);
if (!screen)
return Qnil;
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]));
}
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));
}
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
NSTRACE (x-popup-dialog);
- check_window_system ();
-
isQ = NILP (header);
if (EQ (position, Qt)
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;
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.");
(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;
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;
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;
{
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);
(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;
}
(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;
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
{
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];
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 ();
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);
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;
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 */
-------------------------------------------------------------------------- */
{
NSTRACE (x_destroy_window);
- check_window_system ();
+ check_window_system (f);
x_free_frame_resources (f);
ns_window_num--;
}
#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;
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. */
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;
}
(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);
(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);
if (dpyinfo == 0)
error ("Cannot connect to server %s", SDATA (name));
- w32_in_use = 1;
XSETFASTINT (Vwindow_system_version, w32_major_version);
return dpyinfo;
/* 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))
error ("Cannot connect to server %s", SDATA (display));
}
- w32_in_use = 1;
-
XSETFASTINT (Vwindow_system_version, w32_major_version);
return Qnil;
}
(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);
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);
(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;
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;
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
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);
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;
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;
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)
but I don't want to make one now. */
CHECK_WINDOW (window);
+ check_window_system (f);
+
#ifndef HAVE_DIALOGS
{
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) (
struct frame *f;
int size, avgwidth IF_LINT (= 0);
- check_window_system ();
+ check_window_system (NULL);
CHECK_STRING (pattern);
if (! NILP (maximum))
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))
{
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);
#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;
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,
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);
}
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);
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 ();
(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);
(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);
if (dpyinfo == 0)
error ("Cannot connect to X server %s", SDATA (name));
- x_in_use = 1;
XSETFASTINT (Vwindow_system_version, 11);
return dpyinfo;
error ("Cannot connect to X server %s", SDATA (display));
}
- x_in_use = 1;
-
XSETFASTINT (Vwindow_system_version, 11);
return Qnil;
}
(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;
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);
(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;
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");
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
#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
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);
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);
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");
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;
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 &&&*/
#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,
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);
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)
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
(Lisp_Object frame)
{
XEvent ev;
- FRAME_PTR f = check_x_frame (frame);
+ FRAME_PTR f = decode_window_system_frame (frame);
Widget menubar;
block_input ();
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);
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;
(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);
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);
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))
/* From xfns.c. */
-struct frame *check_x_frame (Lisp_Object);
extern void x_free_gcs (struct frame *);
/* From xrdb.c. */
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);