]> git.eshelyaron.com Git - emacs.git/commitdiff
(ns_get_screen): Rewrite.
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 6 May 2009 03:09:11 +0000 (03:09 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 6 May 2009 03:09:11 +0000 (03:09 +0000)
Don't presume selected-frame is of type `ns'.

src/ChangeLog
src/nsfns.m

index 5f41bd894f41cfce03e2fbb4df1be88c7647857d..47be6be45f02ce4390648cc6f501070591122314 100644 (file)
@@ -1,5 +1,8 @@
 2009-05-06  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * nsfns.m (ns_get_screen): Rewrite.
+       Don't presume selected-frame is of type `ns'.
+
        * font.c (font_update_drivers): Sanity fallback to avoid disabling
        all drivers.
 
index b6d0d189cc576d6b8371149a889908441da87b4f..13f9953554fb68ddb76a799e3e0db4bc50b93676 100644 (file)
@@ -203,46 +203,32 @@ ns_get_window (Lisp_Object maybeFrame)
 
 
 static NSScreen *
-ns_get_screen (Lisp_Object anythingUnderTheSun)
-{
-  id window =nil;
-  NSScreen *screen = 0;
-
-  struct terminal *terminal;
-  struct ns_display_info *dpyinfo;
-  struct frame *f = NULL;
-  Lisp_Object frame;
-
-  if (INTEGERP (anythingUnderTheSun)) {
-    /* we got a terminal */
-    terminal = get_terminal (anythingUnderTheSun, 1);
-    dpyinfo = terminal->display_info.ns;
-    f = dpyinfo->x_focus_frame;
-    if (!f)
-      f = dpyinfo->x_highlight_frame;
-
-  } else if (FRAMEP (anythingUnderTheSun) &&
-             FRAME_NS_P (XFRAME (anythingUnderTheSun))) {
-    /* we got a frame */
-    f = XFRAME (anythingUnderTheSun);
-
-  } else if (STRINGP (anythingUnderTheSun)) { /* FIXME/cl for multi-display */
-  }
-
-  if (!f)
-    f = SELECTED_FRAME ();
-  if (f)
+ns_get_screen (Lisp_Object screen)
+{
+  struct terminal *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);
+  else
     {
-      XSETFRAME (frame, f);
-      window = ns_get_window (frame);
+      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;
+       }
     }
-
-  if (window)
-    screen = [window screen];
-  if (!screen)
-    screen = [NSScreen mainScreen];
-
-  return screen;
 }