diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2013-04-07 08:41:19 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2013-04-07 08:41:19 +0400 |
commit | 7452b7bd70f01fb96f13269250bda32507ce0cf1 (patch) | |
tree | 7751bfa41bc66b5516fb734cb44c98c2b74c5a5b /src/nsfns.m | |
parent | 6096db2e0067715c06573c924214385a2c0a1baf (diff) | |
download | emacs-7452b7bd70f01fb96f13269250bda32507ce0cf1.tar.gz |
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/nsfns.m')
-rw-r--r-- | src/nsfns.m | 142 |
1 files changed, 36 insertions, 106 deletions
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; ========================================================================== */ - -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 |