X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/56d513e611d280845c311292ea9b2ca3c239aa0c..a8101f663e6cbff953b67b8bef33bc0171818477:/src/nsfns.m diff --git a/src/nsfns.m b/src/nsfns.m index 4df3f9c968..aac2ef0ed3 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1,5 +1,5 @@ /* Functions for the NeXT/Open/GNUstep and MacOSX window system. - Copyright (C) 1989, 1992, 1993, 1994, 2005, 2006, 2008, 2009 + Copyright (C) 1989, 1992, 1993, 1994, 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -27,10 +27,11 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) /* This should be the first include, as it may set up #defines affecting interpretation of even the system includes. */ -#include "config.h" +#include #include #include +#include #include "lisp.h" #include "blockinput.h" @@ -79,8 +80,13 @@ extern Lisp_Object Qface_set_after_frame_default; extern Lisp_Object Qunderline, Qundefined; extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth; extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle; +extern Lisp_Object Qnone; +extern Lisp_Object Vframe_title_format; + +/* The below are defined in frame.c. */ + +extern Lisp_Object Vmenu_bar_mode, Vtool_bar_mode; -Lisp_Object Qnone; Lisp_Object Qbuffered; Lisp_Object Qfontsize; @@ -119,7 +125,7 @@ check_ns (void) /* Nonzero if we can use mouse menus. */ int -have_menus_p () +have_menus_p (void) { return NSApp != nil; } @@ -205,38 +211,36 @@ ns_get_window (Lisp_Object maybeFrame) static NSScreen * ns_get_screen (Lisp_Object screen) { - struct terminal *terminal = get_terminal (screen, 1); + struct frame *f; + struct terminal *terminal; + + if (EQ (Qt, screen)) /* not documented */ + return [NSScreen mainScreen]; + + terminal = get_terminal (screen, 1); if (terminal->type != output_ns) - // Not sure if this special case for nil is needed. It does seem to be - // important in xfns.c for the make-frame call in frame-initialize, - // so let's keep it here for now. - return (NILP (screen) ? [NSScreen mainScreen] : NULL); + return NULL; + + if (NILP (screen)) + f = SELECTED_FRAME (); + else if (FRAMEP (screen)) + f = XFRAME (screen); else { struct ns_display_info *dpyinfo = terminal->display_info.ns; - struct frame *f = dpyinfo->x_focus_frame; - if (!f) - f = dpyinfo->x_highlight_frame; - if (!f) - return NULL; - else - { - id window = nil; - Lisp_Object frame; - eassert (FRAME_NS_P (f)); - XSETFRAME (frame, f); - window = ns_get_window (frame); - return window ? [window screen] : NULL; - } + f = dpyinfo->x_focus_frame + ? dpyinfo->x_focus_frame : dpyinfo->x_highlight_frame; } + + return ((f && FRAME_NS_P (f)) ? [[FRAME_NS_VIEW (f) window] screen] + : NULL); } /* Return the X display structure for the display named NAME. Open a new connection if necessary. */ struct ns_display_info * -ns_display_info_for_name (name) - Lisp_Object name; +ns_display_info_for_name (Lisp_Object name) { Lisp_Object names; struct ns_display_info *dpyinfo; @@ -520,7 +524,7 @@ ns_set_name_iconic (struct frame *f, Lisp_Object name, int explicit) static void ns_set_name (struct frame *f, Lisp_Object name, int explicit) { - NSView *view = FRAME_NS_VIEW (f); + NSView *view; NSTRACE (ns_set_name); if (ns_in_resize) @@ -551,6 +555,8 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit) CHECK_STRING (name); + view = FRAME_NS_VIEW (f); + /* Don't change the name if it's already NAME. */ if ([[[view window] title] isEqualToString: [NSString stringWithUTF8String: @@ -582,6 +588,8 @@ x_implicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) NSTRACE (x_implicitly_set_name); if (FRAME_ICONIFIED_P (f)) ns_set_name_iconic (f, arg, 0); + else if (FRAME_NS_P (f) && EQ (Vframe_title_format, Qt)) + ns_set_name_as_filename (f); else ns_set_name (f, arg, 0); } @@ -614,7 +622,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) void ns_set_name_as_filename (struct frame *f) { - NSView *view = FRAME_NS_VIEW (f); + NSView *view; Lisp_Object name; Lisp_Object buf = XWINDOW (f->selected_window)->buffer; const char *title; @@ -626,17 +634,19 @@ ns_set_name_as_filename (struct frame *f) BLOCK_INPUT; pool = [[NSAutoreleasePool alloc] init]; - name =XBUFFER (buf)->filename; + name = XBUFFER (buf)->filename; if (NILP (name) || FRAME_ICONIFIED_P (f)) name =XBUFFER (buf)->name; if (FRAME_ICONIFIED_P (f) && !NILP (f->icon_name)) name = f->icon_name; if (NILP (name)) - name = build_string([ns_app_name UTF8String]); + name = build_string ([ns_app_name UTF8String]); else CHECK_STRING (name); + view = FRAME_NS_VIEW (f); + title = FRAME_ICONIFIED_P (f) ? [[[view window] miniwindowTitle] UTF8String] : [[[view window] title] UTF8String]; @@ -680,15 +690,18 @@ ns_set_name_as_filename (struct frame *f) void -ns_set_doc_edited (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +ns_set_doc_edited (struct frame *f, Lisp_Object arg) { NSView *view = FRAME_NS_VIEW (f); NSAutoreleasePool *pool; - BLOCK_INPUT; - pool = [[NSAutoreleasePool alloc] init]; - [[view window] setDocumentEdited: !NILP (arg)]; - [pool release]; - UNBLOCK_INPUT; + if (!MINI_WINDOW_P (XWINDOW (f->selected_window))) + { + BLOCK_INPUT; + pool = [[NSAutoreleasePool alloc] init]; + [[view window] setDocumentEdited: !NILP (arg)]; + [pool release]; + UNBLOCK_INPUT; + } } @@ -911,9 +924,7 @@ ns_cursor_type_to_lisp (int arg) /* This is the same as the xfns.c definition. */ void -x_set_cursor_type (f, arg, oldval) - FRAME_PTR f; - Lisp_Object arg, oldval; +x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) { set_frame_cursor_types (f, arg); @@ -935,7 +946,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) #define Xstr(x) Str(x) static Lisp_Object -ns_appkit_version_str () +ns_appkit_version_str (void) { char tmp[80]; @@ -954,7 +965,7 @@ ns_appkit_version_str () have into a single int. For a better picture of the implementation running, use ns_appkit_version_str.*/ static int -ns_appkit_version_int () +ns_appkit_version_int (void) { #ifdef NS_IMPL_GNUSTEP return GNUSTEP_GUI_MAJOR_VERSION * 100 + GNUSTEP_GUI_MINOR_VERSION; @@ -1049,8 +1060,7 @@ If the parameters specify that the frame should not have a minibuffer, and do not specify a specific minibuffer window to use, then `default-minibuffer-frame' must be a frame whose minibuffer can be shared by the new frame. */) - (parms) - Lisp_Object parms; + (Lisp_Object parms) { static int desc_ctr = 1; struct frame *f; @@ -1145,7 +1155,7 @@ be shared by the new frame. */) f->output_method = output_ns; f->output_data.ns = (struct ns_output *)xmalloc (sizeof *(f->output_data.ns)); - bzero (f->output_data.ns, sizeof (*(f->output_data.ns))); + memset (f->output_data.ns, 0, sizeof (*(f->output_data.ns))); FRAME_FONTSET (f) = -1; @@ -1225,10 +1235,18 @@ be shared by the new frame. */) init_frame_faces (f); - x_default_parameter (f, parms, Qmenu_bar_lines, make_number (0), "menuBar", - "menuBar", RES_TYPE_NUMBER); - x_default_parameter (f, parms, Qtool_bar_lines, make_number (0), "toolBar", - "toolBar", RES_TYPE_NUMBER); + /* The X resources controlling the menu-bar and tool-bar are + processed specially at startup, and reflected in the mode + variables; ignore them here. */ + x_default_parameter (f, parms, Qmenu_bar_lines, + NILP (Vmenu_bar_mode) + ? make_number (0) : make_number (1), + NULL, NULL, RES_TYPE_NUMBER); + x_default_parameter (f, parms, Qtool_bar_lines, + NILP (Vtool_bar_mode) + ? make_number (0) : make_number (1), + NULL, NULL, RES_TYPE_NUMBER); + x_default_parameter (f, parms, Qbuffer_predicate, Qnil, "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL); x_default_parameter (f, parms, Qtitle, Qnil, "title", "Title", @@ -1351,8 +1369,7 @@ be shared by the new frame. */) DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, doc: /* Set the input focus to FRAME. FRAME nil means use the selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f = check_ns_frame (frame); struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); @@ -1373,8 +1390,7 @@ FRAME nil means use the selected frame. */) DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel, 0, 1, "", doc: /* Pop up the font panel. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { id fm; struct frame *f; @@ -1399,8 +1415,7 @@ DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel, DEFUN ("ns-popup-color-panel", Fns_popup_color_panel, Sns_popup_color_panel, 0, 1, "", doc: /* Pop up the color panel. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; @@ -1423,8 +1438,7 @@ DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 4, 0, Optional arg DIR, if non-nil, supplies a default directory. Optional arg ISLOAD, if non-nil, means read a file name for saving. Optional arg INIT, if non-nil, provides a default file name to use. */) - (prompt, dir, isLoad, init) - Lisp_Object prompt, dir, isLoad, init; + (Lisp_Object prompt, Lisp_Object dir, Lisp_Object isLoad, Lisp_Object init) { static id fileDelegate = nil; int ret; @@ -1488,8 +1502,7 @@ Optional arg INIT, if non-nil, provides a default file name to use. */) DEFUN ("ns-get-resource", Fns_get_resource, Sns_get_resource, 2, 2, 0, doc: /* Return the value of the property NAME of OWNER from the defaults database. If OWNER is nil, Emacs is assumed. */) - (owner, name) - Lisp_Object owner, name; + (Lisp_Object owner, Lisp_Object name) { const char *value; @@ -1513,8 +1526,7 @@ DEFUN ("ns-set-resource", Fns_set_resource, Sns_set_resource, 3, 3, 0, doc: /* Set property NAME of OWNER to VALUE, from the defaults database. If OWNER is nil, Emacs is assumed. If VALUE is nil, the default is removed. */) - (owner, name, value) - Lisp_Object owner, name, value; + (Lisp_Object owner, Lisp_Object name, Lisp_Object value) { check_ns (); if (NILP (owner)) @@ -1542,8 +1554,7 @@ DEFUN ("x-server-max-request-size", Fx_server_max_request_size, Sx_server_max_request_size, 0, 1, 0, doc: /* This function is a no-op. It is only present for completeness. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); /* This function has no real equivalent under NeXTstep. Return nil to @@ -1556,8 +1567,7 @@ DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, doc: /* Return the vendor ID string of Nextstep display server DISPLAY. DISPLAY should be either a frame or a display name (a string). If omitted or nil, the selected frame's display is used. */) - (display) - Lisp_Object display; + (Lisp_Object display) { #ifdef NS_IMPL_GNUSTEP return build_string ("GNU"); @@ -1576,8 +1586,7 @@ release number. See also the function `x-server-vendor'. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { /*NOTE: it is unclear what would best correspond with "protocol"; we return 10.3, meaning Panther, since this is roughly the @@ -1595,8 +1604,7 @@ DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, doc: /* Return the number of screens on Nextstep display server DISPLAY. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { int num; @@ -1612,8 +1620,7 @@ DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, doc: /* Return the height of Nextstep display server DISPLAY, in millimeters. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); return make_number ((int) @@ -1626,8 +1633,7 @@ DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, doc: /* Return the width of Nextstep display server DISPLAY, in millimeters. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); return make_number ((int) @@ -1641,8 +1647,7 @@ DEFUN ("x-display-backing-store", Fx_display_backing_store, The value may be `buffered', `retained', or `non-retained'. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); switch ([ns_get_window (display) backingType]) @@ -1667,8 +1672,7 @@ The value is one of the symbols `static-gray', `gray-scale', `static-color', `pseudo-color', `true-color', or `direct-color'. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { NSWindowDepth depth; check_ns (); @@ -1696,8 +1700,7 @@ DEFUN ("x-display-save-under", Fx_display_save_under, The optional argument DISPLAY specifies which display to ask about. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); switch ([ns_get_window (display) backingType]) @@ -1721,8 +1724,7 @@ DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection, doc: /* Open a connection to a Nextstep display server. DISPLAY is the name of the display to connect to. Optional arguments XRM-STRING and MUST-SUCCEED are currently ignored. */) - (display, resource_string, must_succeed) - Lisp_Object display, resource_string, must_succeed; + (Lisp_Object display, Lisp_Object resource_string, Lisp_Object must_succeed) { struct ns_display_info *dpyinfo; @@ -1760,8 +1762,7 @@ 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) - Lisp_Object display; + (Lisp_Object display) { check_ns (); /*ns_delete_terminal (dpyinfo->terminal); */ @@ -1772,7 +1773,7 @@ The argument DISPLAY is currently ignored. */) DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, doc: /* Return the list of display names that Emacs has connections to. */) - () + (void) { Lisp_Object tail, result; @@ -1787,7 +1788,7 @@ DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, DEFUN ("ns-hide-others", Fns_hide_others, Sns_hide_others, 0, 0, 0, doc: /* Hides all applications other than Emacs. */) - () + (void) { check_ns (); [NSApp hideOtherApplications: NSApp]; @@ -1800,8 +1801,7 @@ DEFUN ("ns-hide-emacs", Fns_hide_emacs, Sns_hide_emacs, Otherwise if Emacs is hidden, it is unhidden. If ON is equal to `activate', Emacs is unhidden and becomes the active application. */) - (on) - Lisp_Object on; + (Lisp_Object on) { check_ns (); if (EQ (on, intern ("activate"))) @@ -1820,7 +1820,7 @@ the active application. */) DEFUN ("ns-emacs-info-panel", Fns_emacs_info_panel, Sns_emacs_info_panel, 0, 0, 0, doc: /* Shows the 'Info' or 'About' panel for Emacs. */) - () + (void) { check_ns (); [NSApp orderFrontStandardAboutPanel: nil]; @@ -1833,8 +1833,7 @@ DEFUN ("ns-font-name", Fns_font_name, Sns_font_name, 1, 1, 0, NAME should be a string containing either the font name or an XLFD font descriptor. If string contains `fontset' and not `fontset-startup', it is left alone. */) - (name) - Lisp_Object name; + (Lisp_Object name) { char *nm; CHECK_STRING (name); @@ -1852,8 +1851,7 @@ font descriptor. If string contains `fontset' and not DEFUN ("ns-list-colors", Fns_list_colors, Sns_list_colors, 0, 1, 0, doc: /* Return a list of all available colors. The optional argument FRAME is currently ignored. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { Lisp_Object list = Qnil; NSEnumerator *colorlists; @@ -1892,7 +1890,7 @@ The optional argument FRAME is currently ignored. */) DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0, doc: /* List available Nextstep services by querying NSApp. */) - () + (void) { Lisp_Object ret = Qnil; NSMenu *svcs; @@ -1946,8 +1944,7 @@ DEFUN ("ns-perform-service", Fns_perform_service, Sns_perform_service, SEND should be either a string or nil. The return value is the result of the service, as string, or nil if there was no result. */) - (service, send) - Lisp_Object service, send; + (Lisp_Object service, Lisp_Object send) { id pb; NSString *svcName; @@ -1975,8 +1972,7 @@ there was no result. */) DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc, Sns_convert_utf8_nfd_to_nfc, 1, 1, 0, doc: /* Return an NFC string that matches the UTF-8 NFD string STR. */) - (str) - Lisp_Object str; + (Lisp_Object str) { /* TODO: If GNUstep ever implements precomposedStringWithCanonicalMapping, remove this. */ @@ -2005,8 +2001,7 @@ DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc, string or a number containing the resulting script value. Otherwise, 1 is returned. */ static int -ns_do_applescript (script, result) - Lisp_Object script, *result; +ns_do_applescript (Lisp_Object script, Lisp_Object *result) { NSAppleEventDescriptor *desc; NSDictionary* errorDict; @@ -2063,8 +2058,7 @@ DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0, If compilation and execution are successful, the resulting script value is returned as a string, a number or, in the case of other constructs, t. In case the execution fails, an error is signaled. */) - (script) - Lisp_Object script; + (Lisp_Object script) { Lisp_Object result; long status; @@ -2110,8 +2104,7 @@ check_x_display_info (Lisp_Object frame) void -x_set_scroll_bar_default_width (f) - struct frame *f; +x_set_scroll_bar_default_width (struct frame *f) { int wid = FRAME_COLUMN_WIDTH (f); FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = NS_SCROLL_BAR_WIDTH_DEFAULT; @@ -2191,7 +2184,7 @@ x_screen_planes (struct frame *f) void -x_sync (Lisp_Object frame) +x_sync (struct frame *f) { /* XXX Not implemented XXX */ return; @@ -2209,8 +2202,7 @@ x_sync (Lisp_Object frame) DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, doc: /* Return t if the current Nextstep display supports the color COLOR. The optional argument FRAME is currently ignored. */) - (color, frame) - Lisp_Object color, frame; + (Lisp_Object color, Lisp_Object frame) { NSColor * col; check_ns (); @@ -2220,11 +2212,10 @@ The optional argument FRAME is currently ignored. */) DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, doc: /* Internal function called by `color-values', which see. */) - (color, frame) - Lisp_Object color, frame; + (Lisp_Object color, Lisp_Object frame) { NSColor * col; - float red, green, blue, alpha; + CGFloat red, green, blue, alpha; check_ns (); CHECK_STRING (color); @@ -2245,8 +2236,7 @@ DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0, The optional argument DISPLAY specifies which display to ask about. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { NSWindowDepth depth; NSString *colorSpace; @@ -2267,8 +2257,7 @@ Note that color displays do support shades of gray. The optional argument DISPLAY specifies which display to ask about. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { NSWindowDepth depth; check_ns (); @@ -2284,8 +2273,7 @@ DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, The optional argument DISPLAY specifies which display to ask about. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); return make_number ((int) [ns_get_screen (display) frame].size.width); @@ -2298,8 +2286,7 @@ DEFUN ("x-display-pixel-height", Fx_display_pixel_height, The optional argument DISPLAY specifies which display to ask about. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); return make_number ((int) [ns_get_screen (display) frame].size.height); @@ -2316,19 +2303,24 @@ reserved for the Mac menu, dock, and so forth. The screen queried corresponds to DISPLAY, which 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { int top; + NSScreen *screen; NSRect vScreen; check_ns (); - vScreen = [ns_get_screen (display) visibleFrame]; - top = vScreen.origin.y == 0.0 ? - (int) [ns_get_screen (display) frame].size.height - vScreen.size.height : 0; + screen = ns_get_screen (display); + if (!screen) + return Qnil; + vScreen = [screen visibleFrame]; + + /* NS coordinate system is upside-down. + Transform to screen-specific coordinates. */ return list4 (make_number ((int) vScreen.origin.x), - make_number (top), + make_number ((int) [screen frame].size.height + - vScreen.size.height - vScreen.origin.y), make_number ((int) vScreen.size.width), make_number ((int) vScreen.size.height)); } @@ -2340,8 +2332,7 @@ DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, The optional argument DISPLAY specifies which display to ask about. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); return make_number @@ -2355,12 +2346,12 @@ DEFUN ("x-display-color-cells", Fx_display_color_cells, The optional argument DISPLAY specifies which display to ask about. 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. */) - (display) - Lisp_Object display; + (Lisp_Object display) { + struct ns_display_info *dpyinfo; check_ns (); - struct ns_display_info *dpyinfo = check_ns_display_info (display); - + + 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)); } @@ -2371,11 +2362,14 @@ Lisp_Object tip_frame; /* TODO: move to xdisp or similar */ static void -compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) - struct frame *f; - Lisp_Object parms, dx, dy; - int width, height; - int *root_x, *root_y; +compute_tip_xy (struct frame *f, + Lisp_Object parms, + Lisp_Object dx, + Lisp_Object dy, + int width, + int height, + int *root_x, + int *root_y) { Lisp_Object left, top; EmacsView *view = FRAME_NS_VIEW (f); @@ -2383,22 +2377,27 @@ compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) /* Start with user-specified or mouse position. */ left = Fcdr (Fassq (Qleft, parms)); - if (INTEGERP (left)) - pt.x = XINT (left); - else - pt.x = last_mouse_motion_position.x; top = Fcdr (Fassq (Qtop, parms)); - if (INTEGERP (top)) - pt.y = XINT (top); - else - pt.y = last_mouse_motion_position.y; - - /* Convert to screen coordinates */ - pt = [view convertPoint: pt toView: nil]; - pt = [[view window] convertBaseToScreen: pt]; + if (!INTEGERP (left) || !INTEGERP (top)) + { + pt = last_mouse_motion_position; + /* Convert to screen coordinates */ + pt = [view convertPoint: pt toView: nil]; + pt = [[view window] convertBaseToScreen: pt]; + } + else + { + /* Absolute coordinates. */ + pt.x = XINT (left); + pt.y = x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)) - XINT (top) + - height; + } + /* Ensure in bounds. (Note, screen origin = lower left.) */ - if (pt.x + XINT (dx) <= 0) + if (INTEGERP (left)) + *root_x = pt.x; + else if (pt.x + XINT (dx) <= 0) *root_x = 0; /* Can happen for negative dx */ else if (pt.x + XINT (dx) + width <= x_display_pixel_width (FRAME_NS_DISPLAY_INFO (f))) @@ -2411,7 +2410,9 @@ compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) /* Put it left justified on the screen -- it ought to fit that way. */ *root_x = 0; - if (pt.y - XINT (dy) - height >= 0) + if (INTEGERP (top)) + *root_y = pt.y; + else if (pt.y - XINT (dy) - height >= 0) /* It fits below the pointer. */ *root_y = pt.y - height - XINT (dy); else if (pt.y + XINT (dy) + height @@ -2446,8 +2447,7 @@ DY added (default is -10). A tooltip's maximum size is specified by `x-max-tooltip-size'. Text larger than the specified size is clipped. */) - (string, frame, parms, timeout, dx, dy) - Lisp_Object string, frame, parms, timeout, dx, dy; + (Lisp_Object string, Lisp_Object frame, Lisp_Object parms, Lisp_Object timeout, Lisp_Object dx, Lisp_Object dy) { int root_x, root_y; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; @@ -2503,7 +2503,7 @@ Text larger than the specified size is clipped. */) DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0, doc: /* Hide the current tooltip window, if there is any. Value is t if tooltip was open, nil otherwise. */) - () + (void) { if (ns_tooltip == nil || ![ns_tooltip isActive]) return Qnil; @@ -2593,12 +2593,10 @@ Value is t if tooltip was open, nil otherwise. */) void -syms_of_nsfns () +syms_of_nsfns (void) { int i; - Qnone = intern ("none"); - staticpro (&Qnone); Qfontsize = intern ("fontsize"); staticpro (&Qfontsize);