]> code.delx.au - gnu-emacs/blobdiff - src/nsfns.m
Ensure NS frames remain hidden when invisible
[gnu-emacs] / src / nsfns.m
index 77a222b0c3dd1b091b3971009e41940a4fcff698..5d944593f56065f7dd9e82d0c6d397d6b8506a98 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;
 }
 
 
@@ -1331,13 +1317,20 @@ be shared by the new frame.  */)
 
   if (! f->output_data.ns->explicit_parent)
     {
-        tem = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_BOOLEAN);
-        if (EQ (tem, Qunbound))
-            tem = Qnil;
-
-        x_set_visibility (f, tem, Qnil);
-        if (EQ (tem, Qt))
-            [[FRAME_NS_VIEW (f) window] makeKeyWindow];
+      tem = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
+      if (EQ (tem, Qunbound))
+       tem = Qt;
+      x_set_visibility (f, tem, Qnil);
+      if (EQ (tem, Qicon))
+       x_iconify_frame (f);
+      else if (! NILP (tem))
+       {
+         x_make_frame_visible (f);
+         f->async_visible = 1;
+         [[FRAME_NS_VIEW (f) window] makeKeyWindow];
+       }
+      else
+         f->async_visible = 0;
     }
 
   if (FRAME_HAS_MINIBUF_P (f)
@@ -1379,17 +1372,6 @@ FRAME nil means use the selected frame.  */)
 }
 
 
-DEFUN ("ns-popup-prefs-panel", Fns_popup_prefs_panel, Sns_popup_prefs_panel,
-       0, 0, "",
-       doc: /* Pop up the preferences panel. */)
-     ()
-{
-  check_ns ();
-  [(EmacsApp *)NSApp showPreferencesWindow: NSApp];
-  return Qnil;
-}
-
-
 DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel,
        0, 1, "",
        doc: /* Pop up the font panel. */)
@@ -2408,7 +2390,7 @@ If omitted or nil, that stands for the selected frame's display.  */)
 {
   check_ns ();
   return make_number
-    (NSBitsPerSampleFromDepth ([ns_get_screen (display) depth]));
+    (NSBitsPerPixelFromDepth ([ns_get_screen (display) depth]));
 }
 
 
@@ -2729,7 +2711,6 @@ be used as the image of the icon representing the frame.  */);
   defsubr (&Sns_perform_service);
   defsubr (&Sns_convert_utf8_nfd_to_nfc);
   defsubr (&Sx_focus_frame);
-  defsubr (&Sns_popup_prefs_panel);
   defsubr (&Sns_popup_font_panel);
   defsubr (&Sns_popup_color_panel);