struct ns_display_info *
ns_display_info_for_name (Lisp_Object name)
{
- Lisp_Object names;
struct ns_display_info *dpyinfo;
CHECK_STRING (name);
- for (dpyinfo = x_display_list, names = ns_display_name_list;
- dpyinfo;
- dpyinfo = dpyinfo->next, names = XCDR (names))
- {
- Lisp_Object tem;
- tem = Fstring_equal (XCAR (XCAR (names)), name);
- if (!NILP (tem))
- return dpyinfo;
- }
+ for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
+ if (!NILP (Fstring_equal (XCAR (dpyinfo->name_list_element), name)))
+ return dpyinfo;
error ("Emacs for OpenStep does not yet support multi-display.");
if (!NILP (f->title))
arg = f->title;
else
- /* explicit name and no icon-name -> explicit_name */
+ /* Explicit name and no icon-name -> explicit_name. */
if (f->explicit_name)
arg = f->name;
else
{
- /* no explicit name and no icon-name ->
- name has to be rebuild from icon_title_format */
- windows_or_buffers_changed++;
+ /* No explicit name and no icon-name ->
+ name has to be rebuild from icon_title_format. */
+ windows_or_buffers_changed = 62;
return;
}
}
/* Don't change the name if it's already NAME. */
- if ([[view window] miniwindowTitle] &&
- ([[[view window] miniwindowTitle]
+ if ([[view window] miniwindowTitle]
+ && ([[[view window] miniwindowTitle]
isEqualToString: [NSString stringWithUTF8String:
- SSDATA (arg)]]))
+ SSDATA (arg)]]))
return;
[[view window] setMiniwindowTitle:
str = [NSString stringWithUTF8String: SSDATA (encoded_icon_name)];
- if ([[view window] miniwindowTitle] &&
- ! [[[view window] miniwindowTitle] isEqualToString: str])
+ if ([[view window] miniwindowTitle]
+ && ! [[[view window] miniwindowTitle] isEqualToString: str])
[[view window] setMiniwindowTitle: str];
}
/* If we're switching from explicit to implicit, we had better
update the mode lines and thereby update the title. */
if (f->explicit_name && NILP (name))
- update_mode_lines = 1;
+ update_mode_lines = 21;
f->explicit_name = ! NILP (name);
}
return;
if (NILP (name))
- name = build_string([ns_app_name UTF8String]);
+ name = build_string ([ns_app_name UTF8String]);
else
CHECK_STRING (name);
fset_name (f, name);
- /* title overrides explicit name */
+ /* Title overrides explicit name. */
if (! NILP (f->title))
name = f->title;
if (EQ (name, f->title))
return;
- update_mode_lines = 1;
+ update_mode_lines = 22;
fset_title (f, name);
}
}
- x_set_window_size (f, 0, f->text_cols, f->text_lines);
+ x_set_window_size (f, 0, f->text_cols, f->text_lines, 0);
}
x_default_parameter (f, parms, Qfont,
build_string (fontname),
"font", "Font", RES_TYPE_STRING);
+ xfree (fontname);
}
unblock_input ();
f->output_data.ns->hand_cursor = [NSCursor pointingHandCursor];
f->output_data.ns->hourglass_cursor = [NSCursor disappearingItemCursor];
f->output_data.ns->horizontal_drag_cursor = [NSCursor resizeLeftRightCursor];
+ f->output_data.ns->vertical_drag_cursor = [NSCursor resizeUpDownCursor];
FRAME_DISPLAY_INFO (f)->vertical_scroll_bar_cursor
= [NSCursor arrowCursor];
f->output_data.ns->current_pointer = f->output_data.ns->text_cursor;
SET_FRAME_COLS (f, 0);
FRAME_LINES (f) = 0;
- change_frame_size (f, height, width, 1, 0, 0);
+ change_frame_size (f, width, height, 1, 0, 0, 0);
if (! f->output_data.ns->explicit_parent)
{
doc: /* Return the list of display names that Emacs has connections to. */)
(void)
{
- Lisp_Object tail, result;
+ Lisp_Object result = Qnil;
+ struct ns_display_info *ndi;
- result = Qnil;
- for (tail = ns_display_name_list; CONSP (tail); tail = XCDR (tail))
- result = Fcons (XCAR (XCAR (tail)), result);
+ for (ndi = x_display_list; ndi; ndi = ndi->next)
+ result = Fcons (XCAR (ndi->name_list_element), result);
return result;
}
/* TODO: If GNUstep ever implements precomposedStringWithCanonicalMapping,
remove this. */
NSString *utfStr;
- Lisp_Object ret;
+ Lisp_Object ret = Qnil;
+ NSAutoreleasePool *pool;
CHECK_STRING (str);
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- utfStr = [NSString stringWithUTF8String: SSDATA (str)];
+ pool = [[NSAutoreleasePool alloc] init];
+ utfStr = [NSString stringWithUTF8String: SSDATA (str)];
#ifdef NS_IMPL_COCOA
- utfStr = [utfStr precomposedStringWithCanonicalMapping];
+ if (utfStr)
+ utfStr = [utfStr precomposedStringWithCanonicalMapping];
#endif
- ret = build_string ([utfStr UTF8String]);
+ if (utfStr)
+ {
+ const char *cstr = [utfStr UTF8String];
+ if (cstr)
+ ret = build_string (cstr);
+ }
+
[pool release];
+ if (NILP (ret))
+ error ("Invalid UTF-8");
+
return ret;
}
}
#ifdef NS_IMPL_COCOA
-/* Returns the name for the screen that DICT came from, or NULL.
+
+/* Returns the name for the screen that OBJ represents, or NULL.
Caller must free return value.
*/
static char *
-ns_screen_name (CGDirectDisplayID did)
+ns_get_name_from_ioreg (io_object_t obj)
{
char *name = NULL;
+
NSDictionary *info = (NSDictionary *)
- IODisplayCreateInfoDictionary (CGDisplayIOServicePort (did),
- kIODisplayOnlyPreferredName);
- NSDictionary *names
- = [info objectForKey:
- [NSString stringWithUTF8String:kDisplayProductName]];
-
- if ([names count] > 0) {
- NSString *n = [names objectForKey: [[names allKeys] objectAtIndex:0]];
- if (n != nil)
- name = xstrdup ([n UTF8String]);
- }
+ IODisplayCreateInfoDictionary (obj, kIODisplayOnlyPreferredName);
+ NSDictionary *names = [info objectForKey:
+ [NSString stringWithUTF8String:
+ kDisplayProductName]];
+
+ if ([names count] > 0)
+ {
+ NSString *n = [names objectForKey: [[names allKeys]
+ objectAtIndex:0]];
+ if (n != nil) name = xstrdup ([n UTF8String]);
+ }
[info release];
+
+ return name;
+}
+
+/* Returns the name for the screen that DID came from, or NULL.
+ Caller must free return value.
+*/
+
+static char *
+ns_screen_name (CGDirectDisplayID did)
+{
+ char *name = NULL;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
+ mach_port_t masterPort;
+ io_iterator_t it;
+ io_object_t obj;
+
+ // CGDisplayIOServicePort is deprecated. Do it another (harder) way.
+
+ if (IOMasterPort (MACH_PORT_NULL, &masterPort) != kIOReturnSuccess
+ || IOServiceGetMatchingServices (masterPort,
+ IOServiceMatching ("IONDRVDevice"),
+ &it) != kIOReturnSuccess)
+ return name;
+
+ /* Must loop until we find a name. Many devices can have the same unit
+ number (represents different GPU parts), but only one has a name. */
+ while (! name && (obj = IOIteratorNext (it)))
+ {
+ CFMutableDictionaryRef props;
+ const void *val;
+
+ if (IORegistryEntryCreateCFProperties (obj,
+ &props,
+ kCFAllocatorDefault,
+ kNilOptions) == kIOReturnSuccess
+ && props != nil
+ && (val = CFDictionaryGetValue(props, @"IOFBDependentIndex")))
+ {
+ unsigned nr = [(NSNumber *)val unsignedIntegerValue];
+ if (nr == CGDisplayUnitNumber (did))
+ name = ns_get_name_from_ioreg (obj);
+ }
+
+ CFRelease (props);
+ IOObjectRelease (obj);
+ }
+
+ IOObjectRelease (it);
+
+#else
+
+ name = ns_get_name_from_ioreg (CGDisplayIOServicePort (did));
+
+#endif
return name;
}
#endif
{
Lisp_Object left, top;
EmacsView *view = FRAME_NS_VIEW (f);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
NSPoint pt;
/* Start with user-specified or mouse position. */
if (!INTEGERP (left) || !INTEGERP (top))
{
- pt = last_mouse_motion_position;
+ pt.x = dpyinfo->last_mouse_motion_x;
+ pt.y = dpyinfo->last_mouse_motion_y;
/* Convert to screen coordinates */
pt = [view convertPoint: pt toView: nil];
pt = [[view window] convertBaseToScreen: pt];