]> code.delx.au - gnu-emacs/blobdiff - src/macfns.c
(GDB Graphical Interface): Shorten node names.
[gnu-emacs] / src / macfns.c
index b9a71ca6840e7dc48dfb54bc2a6052dea45931c7..494d6ec1da377999f2fb828b81332919d9a985dc 100644 (file)
@@ -1091,7 +1091,7 @@ x_to_mac_color (colorname)
       char *color;
       unsigned long colorval;
       int i, pos;
-      pos = 0;
+      pos = 16;
 
       colorval = 0;
       color = colorname + 4;
@@ -1127,7 +1127,7 @@ x_to_mac_color (colorname)
          if (value == ULONG_MAX)
            break;
          colorval |= (value << pos);
-         pos += 0x8;
+         pos -= 0x8;
          if (i == 2)
            {
              if (*end != '\0')
@@ -1146,7 +1146,7 @@ x_to_mac_color (colorname)
       char *color;
       unsigned long colorval;
       int i, pos;
-      pos = 0;
+      pos = 16;
 
       colorval = 0;
       color = colorname + 5;
@@ -1168,7 +1168,7 @@ x_to_mac_color (colorname)
          if (val == 0x100)
            val = 0xFF;
          colorval |= (val << pos);
-         pos += 0x8;
+         pos -= 0x8;
          if (i == 2)
            {
              if (*end != '\0')
@@ -1592,7 +1592,7 @@ x_set_icon_name (f, arg, oldval)
       if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
        return;
     }
-  else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil))
+  else if (!NILP (arg) || NILP (oldval))
     return;
 
   f->icon_name = arg;
@@ -1919,6 +1919,27 @@ mac_set_scroll_bar_width (f, arg, oldval)
   x_set_scroll_bar_width (f, arg, oldval);
 }
 
+static void
+mac_set_font (f, arg, oldval)
+     struct frame *f;
+     Lisp_Object arg, oldval;
+{
+  x_set_font (f, arg, oldval);
+#if USE_MAC_FONT_PANEL
+  {
+    Lisp_Object focus_frame = x_get_focus_frame (f);
+
+    if ((NILP (focus_frame) && f == SELECTED_FRAME ())
+       || XFRAME (focus_frame) == f)
+      {
+       BLOCK_INPUT;
+       mac_set_font_info_for_selection (f, DEFAULT_FACE_ID, 0);
+       UNBLOCK_INPUT;
+      }
+  }
+#endif
+}
+
 #if TARGET_API_MAC_CARBON
 static void
 mac_update_proxy_icon (f)
@@ -2013,22 +2034,6 @@ mac_update_title_bar (f, save_match_data)
 #endif
 }
 
-static void
-mac_set_font (f, arg, oldval)
-     struct frame *f;
-     Lisp_Object arg, oldval;
-{
-  x_set_font (f, arg, oldval);
-#if USE_MAC_FONT_PANEL
-  if (FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame == f)
-    {
-      BLOCK_INPUT;
-      mac_set_font_info_for_selection (f);
-      UNBLOCK_INPUT;
-    }
-#endif
-}
-
 \f
 /* Subroutines of creating a frame.  */
 
@@ -2641,8 +2646,7 @@ This function is an internal primitive--use `make-frame' instead.  */)
       error ("Cannot find any usable font");
     UNBLOCK_INPUT;
 
-    x_default_parameter (f, parms, Qfont, font,
-                        "font", "Font", RES_TYPE_STRING);
+    x_set_frame_parameters (f, Fcons (Fcons (Qfont, font), Qnil));
   }
 
   x_default_parameter (f, parms, Qborder_width, make_number (0),
@@ -2824,26 +2828,22 @@ FRAME nil means use the selected frame.  */)
      Lisp_Object frame;
 {
   struct frame *f = check_x_frame (frame);
-  struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
 
-  if (dpyinfo->x_focus_frame != f)
-    {
-      BLOCK_INPUT;
+  BLOCK_INPUT;
 #ifdef MAC_OSX
-      ActivateWindow (ActiveNonFloatingWindow (), false);
-      ActivateWindow (FRAME_MAC_WINDOW (f), true);
+  ActivateWindow (ActiveNonFloatingWindow (), false);
+  ActivateWindow (FRAME_MAC_WINDOW (f), true);
 #else
 #if !TARGET_API_MAC_CARBON
-      /* SelectWindow (Non-Carbon) does not issue deactivate events if
-        the possibly inactive window that is to be selected is
-        already the frontmost one.  */
-      SendBehind (FRAME_MAC_WINDOW (f), NULL);
+  /* SelectWindow (Non-Carbon) does not issue deactivate events if the
+     possibly inactive window that is to be selected is already the
+     frontmost one.  */
+  SendBehind (FRAME_MAC_WINDOW (f), NULL);
 #endif
-      /* This brings the window to the front.  */
-      SelectWindow (FRAME_MAC_WINDOW (f));
+  /* This brings the window to the front.  */
+  SelectWindow (FRAME_MAC_WINDOW (f));
 #endif
-      UNBLOCK_INPUT;
-    }
+  UNBLOCK_INPUT;
 
   return Qnil;
 }
@@ -3023,11 +3023,11 @@ If omitted or nil, that stands for the selected frame's display.  */)
     {
       if (response >= 0x00001040)
        {
-         err = Gestalt ('sys1', &major); /* gestaltSystemVersionMajor */
+         err = Gestalt (gestaltSystemVersionMajor, &major);
          if (err == noErr)
-           err = Gestalt ('sys2', &minor); /* gestaltSystemVersionMinor */
+           err = Gestalt (gestaltSystemVersionMinor, &minor);
          if (err == noErr)
-           err = Gestalt ('sys3', &bugfix); /* gestaltSystemVersionBugFix */
+           err = Gestalt (gestaltSystemVersionBugFix, &bugfix);
        }
       else
        {
@@ -3069,11 +3069,20 @@ If omitted or nil, that stands for the selected frame's display.  */)
      (display)
      Lisp_Object display;
 {
-  /* MAC_TODO: this is an approximation, and only of the main display */
-
   struct mac_display_info *dpyinfo = check_x_display_info (display);
+  /* Only of the main display.  */
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+  CGSize size;
+
+  BLOCK_INPUT;
+  size = CGDisplayScreenSize (kCGDirectMainDisplay);
+  UNBLOCK_INPUT;
 
+  return make_number ((int) (size.height + .5f));
+#else
+  /* This is an approximation.  */
   return make_number ((int) (dpyinfo->height * 25.4 / dpyinfo->resy));
+#endif
 }
 
 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
@@ -3084,11 +3093,20 @@ If omitted or nil, that stands for the selected frame's display.  */)
      (display)
      Lisp_Object display;
 {
-  /* MAC_TODO: this is an approximation, and only of the main display */
-
   struct mac_display_info *dpyinfo = check_x_display_info (display);
+  /* Only of the main display.  */
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+  CGSize size;
 
+  BLOCK_INPUT;
+  size = CGDisplayScreenSize (kCGDirectMainDisplay);
+  UNBLOCK_INPUT;
+
+  return make_number ((int) (size.width + .5f));
+#else
+  /* This is an approximation.  */
   return make_number ((int) (dpyinfo->width * 25.4 / dpyinfo->resx));
+#endif
 }
 
 DEFUN ("x-display-backing-store", Fx_display_backing_store,
@@ -4503,7 +4521,7 @@ DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table,
 #if USE_MAC_FONT_PANEL
 DEFUN ("mac-set-font-panel-visibility", Fmac_set_font_panel_visibility,
        Smac_set_font_panel_visibility, 1, 1, 0,
-  doc: /* Set the font panel visibile if and only if VISIBLE is non-nil.
+  doc: /* Make the font panel visible if and only if VISIBLE is non-nil.
 This is for internal use only.  Use `mac-font-panel-mode' instead.  */)
      (visible)
      Lisp_Object visible;
@@ -4513,8 +4531,18 @@ This is for internal use only.  Use `mac-font-panel-mode' instead.  */)
   check_mac ();
 
   BLOCK_INPUT;
-  if (NILP (visible) == (FPIsFontPanelVisible () == true))
-    err = FPShowHideFontPanel ();
+  if (NILP (visible) != !mac_font_panel_visible_p ())
+    {
+      err = mac_show_hide_font_panel ();
+      if (err == noErr && !NILP (visible))
+       {
+         Lisp_Object focus_frame = x_get_focus_frame (SELECTED_FRAME ());
+         struct frame *f = (NILP (focus_frame) ? SELECTED_FRAME ()
+                            : XFRAME (focus_frame));
+
+         mac_set_font_info_for_selection (f, DEFAULT_FACE_ID, 0);
+       }
+    }
   UNBLOCK_INPUT;
 
   if (err != noErr)