changeset 83619:5da6a46ddbd6

* s/darwin.h (SYSTEM_PURESIZE_EXTRA): Define here. * termhooks.h (union display_info): Add mac_display_info. * term.c (init_tty): Only use terminal->kboard when MULTI_KBOARD is defined. * macterm.h (struct mac_display_info): Add terminal. * w32term.c (w32_initialize): Make static. * macterm.c (XTset_terminal_modes): Add a terminal parameter. (XTreset_terminal_modes): Likewise. (x_clear_frame): Add a frame parameter. (note_mouse_movement): Get rif from the frame. (mac_term_init): Initialize the terminal. (mac_initialize): Make static and move terminal initialization ... (mac_create_terminal): ... in this new function. * macmenu.c: Reorder includes. (Fx_popup_menu): Use terminal specific mouse_position_hook. * macfns.c (x_set_mouse_color): Get rif from the frame. (x_set_tool_bar_lines): Don't use updating_frame. (mac_window): Add 2 new parameters for consistency with other systems. (Fx_create_frame): Fix doc string. Rename the parameter. (Fx_create_frame): Set the frame parameters following what is done in X11 and w32. (Fx_open_connection): Remove window-system check. (start_hourglass): Likewise. (x_create_tip_frame): Get the keyboard from the terminal. * w32fns.c (Fx_create_frame): Use kboard from the terminal. * term/mac-win.el: Provide mac-win. (mac-initialized): New variable. (mac-initialize-window-system): New function. Move global setup here. (handle-args-function-alist, frame-creation-function-alist): (window-system-initialization-alist): Add mac entries. * loadup.el: Load mac-win on a Mac.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sat, 19 May 2007 19:08:02 +0000
parents fe83377d2247
children ce4352d8bee9
files lisp/ChangeLog.multi-tty lisp/loadup.el lisp/term/mac-win.el src/ChangeLog.multi-tty src/macfns.c src/macmenu.c src/macterm.c src/macterm.h src/s/darwin.h src/term.c src/termhooks.h src/w32fns.c src/w32term.c
diffstat 13 files changed, 227 insertions(+), 130 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog.multi-tty	Thu May 17 14:19:43 2007 +0000
+++ b/lisp/ChangeLog.multi-tty	Sat May 19 19:08:02 2007 +0000
@@ -1,3 +1,14 @@
+2007-05-19  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* term/mac-win.el: Provide mac-win.
+	(mac-initialized): New variable.
+	(mac-initialize-window-system): New function. Move global setup
+	here.
+	(handle-args-function-alist, frame-creation-function-alist):
+	(window-system-initialization-alist): Add mac entries.
+
+	* loadup.el: Load mac-win on a Mac.
+
 2007-05-17  Jason Rumney  <jasonr@gnu.org>
 
 	* term/w32-win.el (internal-face-interactive): Remove obsolete function.
--- a/lisp/loadup.el	Thu May 17 14:19:43 2007 +0000
+++ b/lisp/loadup.el	Sat May 19 19:08:02 2007 +0000
@@ -212,6 +212,9 @@
 (if (eq system-type 'macos)
     (progn
       (load "ls-lisp")))
+(if (eq system-type 'darwin)
+    (progn
+      (load "term/mac-win")))
 (if (fboundp 'atan)	; preload some constants and
     (progn		; floating pt. functions if we have float support.
       (load "emacs-lisp/float-sup")))
--- a/lisp/term/mac-win.el	Thu May 17 14:19:43 2007 +0000
+++ b/lisp/term/mac-win.el	Sat May 19 19:08:02 2007 +0000
@@ -65,8 +65,8 @@
 ;; An alist of X options and the function which handles them.  See
 ;; ../startup.el.
 
-(if (not (eq window-system 'mac))
-    (error "%s: Loading mac-win.el but not compiled for Mac" (invocation-name)))
+;; (if (not (eq window-system 'mac))
+;;     (error "%s: Loading mac-win.el but not compiled for Mac" (invocation-name)))
 
 (require 'frame)
 (require 'mouse)
@@ -2594,13 +2594,23 @@
 
 (defun x-win-suspend-error ()
   (error "Suspending an Emacs running under Mac makes no sense"))
+
+(defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value)
+
+(defvar mac-initialized nil
+  "Non-nil if the w32 window system has been initialized.")
+
+(defun mac-initialize-window-system ()
+  "Initialize Emacs for Mac GUI frames."
+
 (add-hook 'suspend-hook 'x-win-suspend-error)
 
 ;;; Arrange for the kill and yank functions to set and check the clipboard.
 (setq interprogram-cut-function 'x-select-text)
 (setq interprogram-paste-function 'x-get-selection-value)
 
-(defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value)
+
+
 
 ;;; Turn off window-splitting optimization; Mac is usually fast enough
 ;;; that this is only annoying.
@@ -2616,6 +2626,7 @@
 ;; Enable CLIPBOARD copy/paste through menu bar commands.
 (menu-bar-enable-clipboard)
 
+
 ;; Initiate drag and drop
 
 (define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event)
@@ -2637,6 +2648,8 @@
 (global-unset-key [vertical-scroll-bar drag-mouse-1])
 (global-unset-key [vertical-scroll-bar mouse-1])
 
+(setq mac-initialized t)))
+
 (defun mac-handle-scroll-bar-event (event)
   "Handle scroll bar EVENT to emulate Mac Toolbox style scrolling."
   (interactive "e")
@@ -2683,7 +2696,6 @@
     (mac-scroll-ignore-events)
     (scroll-up 1)))
 
-)
 
 
 ;;;; Others
@@ -2721,5 +2733,11 @@
 ;; or bold bitmap versions will not display these variants correctly.
 (setq scalable-fonts-allowed t)
 
+(add-to-list 'handle-args-function-alist '(mac . x-handle-args))
+(add-to-list 'frame-creation-function-alist '(mac . x-create-frame-with-faces))
+(add-to-list 'window-system-initialization-alist '(mac . mac-initialize-window-system))
+
+(provide 'mac-win)
+
 ;; arch-tag: 71dfcd14-cde8-4d66-b05c-85ec94fb23a6
 ;;; mac-win.el ends here
--- a/src/ChangeLog.multi-tty	Thu May 17 14:19:43 2007 +0000
+++ b/src/ChangeLog.multi-tty	Sat May 19 19:08:02 2007 +0000
@@ -1,3 +1,40 @@
+2007-05-19  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* s/darwin.h (SYSTEM_PURESIZE_EXTRA): Define here.
+
+	* termhooks.h (union display_info): Add mac_display_info.
+
+	* term.c (init_tty): Only use terminal->kboard when MULTI_KBOARD
+	is defined.
+
+	* macterm.h (struct mac_display_info): Add terminal.
+
+	* w32term.c (w32_initialize): Make static.
+
+	* macterm.c (XTset_terminal_modes): Add a terminal parameter.
+	(XTreset_terminal_modes): Likewise.
+	(x_clear_frame): Add a frame parameter.
+	(note_mouse_movement): Get rif from the frame.
+	(mac_term_init): Initialize the terminal.
+	(mac_initialize): Make static and move terminal initialization ...
+	(mac_create_terminal): ... in this new function.
+
+	* macmenu.c: Reorder includes.
+	(Fx_popup_menu): Use terminal specific mouse_position_hook.
+
+	* macfns.c (x_set_mouse_color): Get rif from the frame.
+	(x_set_tool_bar_lines): Don't use updating_frame.
+	(mac_window): Add 2 new parameters for consistency with other
+	systems.  
+	(Fx_create_frame): Fix doc string. Rename the parameter.
+	(Fx_create_frame): Set the frame parameters following what is done
+	in X11 and w32.
+	(Fx_open_connection): Remove window-system check.
+	(start_hourglass): Likewise.
+	(x_create_tip_frame): Get the keyboard from the terminal.
+
+	* w32fns.c (Fx_create_frame): Use kboard from the terminal.
+
 2007-05-17  Jason Rumney  <jasonr@gnu.org>
 
 	* w32fns.c (x_create_tip_frame): Set window_system.
--- a/src/macfns.c	Thu May 17 14:19:43 2007 +0000
+++ b/src/macfns.c	Sat May 19 19:08:02 2007 +0000
@@ -107,7 +107,6 @@
 int image_cache_refcount, dpyinfo_refcount;
 #endif
 
-
 #if 0 /* Use xstricmp instead.  */
 /* compare two strings ignoring case */
 
@@ -1447,7 +1446,7 @@
   BLOCK_INPUT;
 
   if (FRAME_MAC_WINDOW (f) != 0)
-    rif->define_frame_cursor (f, cursor);
+    FRAME_TERMINAL (f)->rif->define_frame_cursor (f, cursor);
 
   f->output_data.mac->text_cursor = cursor;
   f->output_data.mac->nontext_cursor = nontext_cursor;
@@ -1708,10 +1707,8 @@
      below the menu bar.  */
   if (FRAME_MAC_WINDOW (f) && FRAME_TOOL_BAR_LINES (f) == 0)
     {
-      updating_frame = f;
-      clear_frame ();
+      clear_frame (f);
       clear_current_matrices (f);
-      updating_frame = NULL;
     }
 
   /* If the tool bar gets smaller, the internal border below it
@@ -2237,8 +2234,10 @@
 /* Create and set up the Mac window for frame F.  */
 
 static void
-mac_window (f)
+mac_window (f, window_prompting, minibuffer_only)
      struct frame *f;
+     long window_prompting;
+     int minibuffer_only;
 {
   Rect r;
 
@@ -2497,15 +2496,15 @@
        1, 1, 0,
        doc: /* Make a new window, which is called a "frame" in Emacs terms.
 Returns an Emacs frame object.
-ALIST is an alist of frame parameters.
+PARAMETERS is an alist of frame parameters.
 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.
 
 This function is an internal primitive--use `make-frame' instead.  */)
-     (parms)
-     Lisp_Object parms;
+     (parameters)
+     Lisp_Object parameters;
 {
   struct frame *f;
   Lisp_Object frame, tem;
@@ -2522,23 +2521,21 @@
 
   check_mac ();
 
-  parms = Fcopy_alist (parms);
-
   /* Use this general default value to start with
      until we know if this frame has a specified name.  */
   Vx_resource_name = Vinvocation_name;
 
-  display = mac_get_arg (parms, Qdisplay, 0, 0, RES_TYPE_STRING);
+  display = mac_get_arg (parameters, Qdisplay, 0, 0, RES_TYPE_STRING);
   if (EQ (display, Qunbound))
     display = Qnil;
   dpyinfo = check_x_display_info (display);
 #ifdef MULTI_KBOARD
-  kb = dpyinfo->kboard;
+  kb = dpyinfo->terminal->kboard;
 #else
   kb = &the_only_kboard;
 #endif
 
-  name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING);
+  name = mac_get_arg (parameters, Qname, "name", "Name", RES_TYPE_STRING);
   if (!STRINGP (name)
       && ! EQ (name, Qunbound)
       && ! NILP (name))
@@ -2548,7 +2545,7 @@
     Vx_resource_name = name;
 
   /* See if parent window is specified.  */
-  parent = mac_get_arg (parms, Qparent_id, NULL, NULL, RES_TYPE_NUMBER);
+  parent = mac_get_arg (parameters, Qparent_id, NULL, NULL, RES_TYPE_NUMBER);
   if (EQ (parent, Qunbound))
     parent = Qnil;
   if (! NILP (parent))
@@ -2558,8 +2555,8 @@
   /* No need to protect DISPLAY because that's not used after passing
      it to make_frame_without_minibuffer.  */
   frame = Qnil;
-  GCPRO4 (parms, parent, name, frame);
-  tem = mac_get_arg (parms, Qminibuffer, "minibuffer", "Minibuffer",
+  GCPRO4 (parameters, parent, name, frame);
+  tem = mac_get_arg (parameters, Qminibuffer, "minibuffer", "Minibuffer",
 		     RES_TYPE_SYMBOL);
   if (EQ (tem, Qnone) || NILP (tem))
     f = make_frame_without_minibuffer (Qnil, kb, display);
@@ -2578,20 +2575,24 @@
   /* Note that X Windows does support scroll bars.  */
   FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
 
+  f->terminal = dpyinfo->terminal;
+  f->terminal->reference_count++;
+
   f->output_method = output_mac;
   f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output));
   bzero (f->output_data.mac, sizeof (struct mac_output));
   FRAME_FONTSET (f) = -1;
+  record_unwind_protect (unwind_create_frame, frame);
 
   f->icon_name
-    = mac_get_arg (parms, Qicon_name, "iconName", "Title", RES_TYPE_STRING);
+    = mac_get_arg (parameters, Qicon_name, "iconName", "Title", RES_TYPE_STRING);
   if (! STRINGP (f->icon_name))
     f->icon_name = Qnil;
 
-/*   FRAME_MAC_DISPLAY_INFO (f) = dpyinfo; */
+  /* XXX Is this needed? */
+  FRAME_MAC_DISPLAY_INFO (f) = dpyinfo;
 
   /* With FRAME_MAC_DISPLAY_INFO set up, this unwind-protect is safe.  */
-  record_unwind_protect (unwind_create_frame, frame);
 #if GLYPH_DEBUG
   image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
   dpyinfo_refcount = dpyinfo->reference_count;
@@ -2633,7 +2634,7 @@
   {
     Lisp_Object font;
 
-    font = mac_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING);
+    font = mac_get_arg (parameters, Qfont, "font", "Font", RES_TYPE_STRING);
 
     BLOCK_INPUT;
     /* First, try whatever font the caller has specified.  */
@@ -2645,7 +2646,6 @@
 	else
 	  font = x_new_font (f, SDATA (font));
       }
-
     /* Try out a font which we hope has bold and italic variations.  */
 #if USE_ATSUI
     if (! STRINGP (font))
@@ -2664,48 +2664,50 @@
       error ("Cannot find any usable font");
     UNBLOCK_INPUT;
 
-    x_set_frame_parameters (f, Fcons (Fcons (Qfont, font), Qnil));
+    x_default_parameter (f, parameters, Qfont, font,
+			 "font", "Font", RES_TYPE_STRING);
   }
 
-  x_default_parameter (f, parms, Qborder_width, make_number (0),
+  /* XXX Shouldn't this be borderWidth,  not borderwidth ?*/
+  x_default_parameter (f, parameters, Qborder_width, make_number (0),
 		       "borderwidth", "BorderWidth", RES_TYPE_NUMBER);
   /* This defaults to 2 in order to match xterm.  We recognize either
      internalBorderWidth or internalBorder (which is what xterm calls
      it).  */
-  if (NILP (Fassq (Qinternal_border_width, parms)))
+  if (NILP (Fassq (Qinternal_border_width, parameters)))
     {
       Lisp_Object value;
 
-      value = mac_get_arg (parms, Qinternal_border_width,
+      value = mac_get_arg (parameters, Qinternal_border_width,
 			 "internalBorder", "InternalBorder", RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
-	parms = Fcons (Fcons (Qinternal_border_width, value),
-		       parms);
+	parameters = Fcons (Fcons (Qinternal_border_width, value),
+                            parameters);
     }
   /* Default internalBorderWidth to 0 on Windows to match other programs.  */
-  x_default_parameter (f, parms, Qinternal_border_width, make_number (0),
+  x_default_parameter (f, parameters, Qinternal_border_width, make_number (0),
 		       "internalBorderWidth", "InternalBorder", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qvertical_scroll_bars, Qright,
+  x_default_parameter (f, parameters, Qvertical_scroll_bars, Qright,
 		       "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL);
 
   /* Also do the stuff which must be set before the window exists.  */
-  x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
+  x_default_parameter (f, parameters, Qforeground_color, build_string ("black"),
 		       "foreground", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qbackground_color, build_string ("white"),
+  x_default_parameter (f, parameters, Qbackground_color, build_string ("white"),
 		       "background", "Background", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qmouse_color, build_string ("black"),
+  x_default_parameter (f, parameters, Qmouse_color, build_string ("black"),
 		       "pointerColor", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qcursor_color, build_string ("black"),
+  x_default_parameter (f, parameters, Qcursor_color, build_string ("black"),
 		       "cursorColor", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qborder_color, build_string ("black"),
+  x_default_parameter (f, parameters, Qborder_color, build_string ("black"),
 		       "borderColor", "BorderColor", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qscreen_gamma, Qnil,
+  x_default_parameter (f, parameters, Qscreen_gamma, Qnil,
 		       "screenGamma", "ScreenGamma", RES_TYPE_FLOAT);
-  x_default_parameter (f, parms, Qline_spacing, Qnil,
+  x_default_parameter (f, parameters, Qline_spacing, Qnil,
 		       "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qleft_fringe, Qnil,
+  x_default_parameter (f, parameters, Qleft_fringe, Qnil,
 		       "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qright_fringe, Qnil,
+  x_default_parameter (f, parameters, Qright_fringe, Qnil,
 		       "rightFringe", "RightFringe", RES_TYPE_NUMBER);
 
 
@@ -2717,29 +2719,29 @@
      happen.  */
   init_frame_faces (f);
 
-  x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
+  x_default_parameter (f, parameters, Qmenu_bar_lines, make_number (1),
 		       "menuBar", "MenuBar", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),
-		       "toolBar", "ToolBar", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
-		       "bufferPredicate", "BufferPredicate",
-		       RES_TYPE_SYMBOL);
-  x_default_parameter (f, parms, Qtitle, Qnil,
+  x_default_parameter (f, parameters, Qtool_bar_lines, make_number (1),
+                       "toolBar", "ToolBar", RES_TYPE_NUMBER);
+
+  x_default_parameter (f, parameters, Qbuffer_predicate, Qnil,
+		       "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
+  x_default_parameter (f, parameters, Qtitle, Qnil,
 		       "title", "Title", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qfullscreen, Qnil,
+  x_default_parameter (f, parameters, Qfullscreen, Qnil,
                        "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
 
   f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
 
   /* Compute the size of the window.  */
-  window_prompting = x_figure_window_size (f, parms, 1);
-
-  tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
+  window_prompting = x_figure_window_size (f, parameters, 1);
+
+  tem = mac_get_arg (parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || EQ (tem, Qt);
 
-  mac_window (f);
-
-  x_icon (f, parms);
+  mac_window (f, window_prompting, minibuffer_only);
+  x_icon (f, parameters);
+
   x_make_gc (f);
 
   /* Now consider the frame official.  */
@@ -2748,18 +2750,17 @@
 
   /* We need to do this after creating the window, so that the
      icon-creation functions can say whose icon they're describing.  */
-  x_default_parameter (f, parms, Qicon_type, Qnil,
+  x_default_parameter (f, parameters, Qicon_type, Qnil,
 		       "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
 
-  x_default_parameter (f, parms, Qauto_raise, Qnil,
+  x_default_parameter (f, parameters, Qauto_raise, Qnil,
 		       "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qauto_lower, Qnil,
+  x_default_parameter (f, parameters, Qauto_lower, Qnil,
 		       "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qcursor_type, Qbox,
+  x_default_parameter (f, parameters, Qcursor_type, Qbox,
 		       "cursorType", "CursorType", RES_TYPE_SYMBOL);
-  x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
-		       "scrollBarWidth", "ScrollBarWidth",
-		       RES_TYPE_NUMBER);
+  x_default_parameter (f, parameters, Qscroll_bar_width, Qnil,
+		       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -2767,8 +2768,8 @@
   width = FRAME_COLS (f);
   height = FRAME_LINES (f);
 
+  FRAME_LINES (f) = 0;
   SET_FRAME_COLS (f, 0);
-  FRAME_LINES (f) = 0;
   change_frame_size (f, height, width, 1, 0, 0);
 
   /* Tell the server what size and position, etc, we want, and how
@@ -2785,7 +2786,7 @@
     {
       Lisp_Object visibility;
 
-      visibility = mac_get_arg (parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
+      visibility = mac_get_arg (parameters, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
       if (EQ (visibility, Qunbound))
 	visibility = Qt;
 
@@ -2807,10 +2808,12 @@
 
   /* All remaining specified parameters, which have not been "used"
      by x_get_arg and friends, now go in the misc. alist of the frame.  */
-  for (tem = parms; !NILP (tem); tem = XCDR (tem))
+  for (tem = parameters; !NILP (tem); tem = XCDR (tem))
     if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
       f->param_alist = Fcons (XCAR (tem), f->param_alist);
 
+  store_frame_param (f, Qwindow_system, Qmac);
+  
   UNGCPRO;
 
   /* Make sure windows on this frame appear in calls to next-window
@@ -3273,9 +3276,6 @@
 
   CHECK_STRING (name);
 
-  if (! EQ (Vwindow_system, intern ("mac")))
-    error ("Not using Mac native windows");
-
   for (dpyinfo = &one_mac_display_info, names = x_display_name_list;
        dpyinfo;
        dpyinfo = dpyinfo->next, names = XCDR (names))
@@ -3320,9 +3320,6 @@
   if (! NILP (xrm_string))
     CHECK_STRING (xrm_string);
 
-  if (! EQ (Vwindow_system, intern ("mac")))
-    error ("Not using Mac native windows");
-
   if (! NILP (xrm_string))
     xrm_option = (unsigned char *) SDATA (xrm_string);
   else
@@ -3585,10 +3582,6 @@
   EMACS_TIME delay;
   int secs, usecs = 0;
 
-  /* Don't bother for ttys.  */
-  if (NILP (Vwindow_system))
-    return;
-
   cancel_hourglass ();
 
   if (INTEGERP (Vhourglass_delay)
@@ -3801,7 +3794,7 @@
   parms = Fcopy_alist (parms);
 
 #ifdef MULTI_KBOARD
-  kb = dpyinfo->kboard;
+  kb = dpyinfo->terminal->kboard;
 #else
   kb = &the_only_kboard;
 #endif
--- a/src/macmenu.c	Thu May 17 14:19:43 2007 +0000
+++ b/src/macmenu.c	Sat May 19 19:08:02 2007 +0000
@@ -26,10 +26,10 @@
 #include <stdio.h>
 
 #include "lisp.h"
+#include "frame.h"
 #include "termhooks.h"
 #include "keyboard.h"
 #include "keymap.h"
-#include "frame.h"
 #include "window.h"
 #include "blockinput.h"
 #include "buffer.h"
@@ -720,8 +720,8 @@
 	  enum scroll_bar_part part;
 	  unsigned long time;
 
-	  if (mouse_position_hook)
-	    (*mouse_position_hook) (&new_f, 1, &bar_window,
+	  if (FRAME_TERMINAL (new_f)->mouse_position_hook)
+	    (*FRAME_TERMINAL (new_f)->mouse_position_hook) (&new_f, 1, &bar_window,
 				    &part, &x, &y, &time);
 	  if (new_f != 0)
 	    XSETFRAME (window, new_f);
--- a/src/macterm.c	Thu May 17 14:19:43 2007 +0000
+++ b/src/macterm.c	Sat May 19 19:08:02 2007 +0000
@@ -231,14 +231,14 @@
 void x_set_window_size P_ ((struct frame *, int, int, int));
 void x_wm_set_window_state P_ ((struct frame *, int));
 void x_wm_set_icon_pixmap P_ ((struct frame *, int));
-void mac_initialize P_ ((void));
+static void mac_initialize P_ ((void));
 static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
 static int x_compute_min_glyph_bounds P_ ((struct frame *));
 static void x_update_end P_ ((struct frame *));
 static void XTframe_up_to_date P_ ((struct frame *));
-static void XTset_terminal_modes P_ ((void));
-static void XTreset_terminal_modes P_ ((void));
-static void x_clear_frame P_ ((void));
+static void XTset_terminal_modes P_ ((struct terminal *));
+static void XTreset_terminal_modes P_ ((struct terminal *));
+static void x_clear_frame P_ ((struct frame *));
 static void frame_highlight P_ ((struct frame *));
 static void frame_unhighlight P_ ((struct frame *));
 static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *));
@@ -266,6 +266,8 @@
 static int is_emacs_window P_ ((WindowPtr));
 static XCharStruct *mac_per_char_metric P_ ((XFontStruct *, XChar2b *, int));
 static void XSetFont P_ ((Display *, GC, XFontStruct *));
+static struct terminal *mac_create_terminal P_ ((struct mac_display_info *dpyinfo));
+
 
 #define GC_FORE_COLOR(gc)	(&(gc)->fore_color)
 #define GC_BACK_COLOR(gc)	(&(gc)->back_color)
@@ -2306,7 +2308,7 @@
    rarely happens).  */
 
 static void
-XTset_terminal_modes ()
+XTset_terminal_modes (struct terminal *t)
 {
 }
 
@@ -2314,7 +2316,7 @@
    the windows go away, and suspending requires no action.  */
 
 static void
-XTreset_terminal_modes ()
+XTreset_terminal_modes (struct terminal *t)
 {
 }
 
@@ -3957,15 +3959,8 @@
    frame.  Otherwise clear the selected frame.  */
 
 static void
-x_clear_frame ()
-{
-  struct frame *f;
-
-  if (updating_frame)
-    f = updating_frame;
-  else
-    f = SELECTED_FRAME ();
-
+x_clear_frame (struct frame *f)
+{
   /* Clearing the frame will erase any cursor, so mark them all as no
      longer visible.  */
   mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f)));
@@ -4499,7 +4494,7 @@
       clear_mouse_face (dpyinfo);
       dpyinfo->mouse_face_mouse_frame = 0;
       if (!dpyinfo->grabbed)
-	rif->define_frame_cursor (frame,
+	FRAME_RIF (frame)->define_frame_cursor (frame,
 				  frame->output_data.mac->nontext_cursor);
     }
 
@@ -11626,6 +11621,7 @@
      char *resource_name;
 {
   struct mac_display_info *dpyinfo;
+  struct terminal *terminal;
 
   BLOCK_INPUT;
 
@@ -11641,6 +11637,13 @@
   dpyinfo = &one_mac_display_info;
   bzero (dpyinfo, sizeof (*dpyinfo));
 
+  terminal = mac_create_terminal (dpyinfo);
+
+  /* Set the name of the terminal. */
+  terminal->name = (char *) xmalloc (SBYTES (display_name) + 1);
+  strncpy (terminal->name, SDATA (display_name), SBYTES (display_name));
+  terminal->name[SBYTES (display_name)] = 0;
+
 #ifdef MAC_OSX
   dpyinfo->mac_id_name
     = (char *) xmalloc (SCHARS (Vinvocation_name)
@@ -11844,31 +11847,39 @@
   mac_shift_glyphs_for_insert
 };
 
-void
-mac_initialize ()
-{
-  rif = &x_redisplay_interface;
-
-  clear_frame_hook = x_clear_frame;
-  ins_del_lines_hook = x_ins_del_lines;
-  delete_glyphs_hook = x_delete_glyphs;
-  ring_bell_hook = XTring_bell;
-  reset_terminal_modes_hook = XTreset_terminal_modes;
-  set_terminal_modes_hook = XTset_terminal_modes;
-  update_begin_hook = x_update_begin;
-  update_end_hook = x_update_end;
-  set_terminal_window_hook = XTset_terminal_window;
-  read_socket_hook = XTread_socket;
-  frame_up_to_date_hook = XTframe_up_to_date;
-  mouse_position_hook = XTmouse_position;
-  frame_rehighlight_hook = XTframe_rehighlight;
-  frame_raise_lower_hook = XTframe_raise_lower;
-
-  set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar;
-  condemn_scroll_bars_hook = XTcondemn_scroll_bars;
-  redeem_scroll_bar_hook = XTredeem_scroll_bar;
-  judge_scroll_bars_hook = XTjudge_scroll_bars;
-
+static struct terminal *
+mac_create_terminal (struct mac_display_info *dpyinfo)
+{
+  struct terminal *terminal;
+  
+  terminal = create_terminal ();
+
+  terminal->type = output_mac;
+  terminal->display_info.mac = dpyinfo;
+  dpyinfo->terminal = terminal;
+
+  terminal->rif = &x_redisplay_interface;
+  terminal->clear_frame_hook = x_clear_frame;
+  terminal->ins_del_lines_hook = x_ins_del_lines;
+  terminal->delete_glyphs_hook = x_delete_glyphs;
+  terminal->ring_bell_hook = XTring_bell;
+  terminal->reset_terminal_modes_hook = XTreset_terminal_modes;
+  terminal->set_terminal_modes_hook = XTset_terminal_modes;
+  terminal->update_begin_hook = x_update_begin;
+  terminal->update_end_hook = x_update_end;
+  terminal->set_terminal_window_hook = XTset_terminal_window;
+  terminal->read_socket_hook = XTread_socket;
+  terminal->frame_up_to_date_hook = XTframe_up_to_date;
+  terminal->mouse_position_hook = XTmouse_position;
+  terminal->frame_rehighlight_hook = XTframe_rehighlight;
+  terminal->frame_raise_lower_hook = XTframe_raise_lower;
+
+ terminal->set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar;
+ terminal->condemn_scroll_bars_hook = XTcondemn_scroll_bars;
+ terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar;
+ terminal->judge_scroll_bars_hook = XTjudge_scroll_bars;
+
+#if 0
   TTY_SCROLL_REGION_OK (CURTTY ()) = 1; /* we'll scroll partial frames */
   TTY_CHAR_INS_DEL_OK (CURTTY ()) = 1;
   TTY_LINE_INS_DEL_OK (CURTTY ()) = 1; /* we'll just blt 'em */
@@ -11876,6 +11887,22 @@
   TTY_MEMORY_BELOW_FRAME (CURTTY ()) = 0; /* we don't remember what
                                                          scrolls off the
                                                          bottom */
+#else
+  terminal->scroll_region_ok = 1;    /* We'll scroll partial frames. */
+  terminal->char_ins_del_ok = 1;
+  terminal->line_ins_del_ok = 1;         /* We'll just blt 'em. */
+  terminal->fast_clear_end_of_line = 1;  /* X does this well. */
+  terminal->memory_below_frame = 0;   /* We don't remember what scrolls
+                                        off the bottom. */
+
+#endif
+  return terminal;
+}
+
+static void
+mac_initialize ()
+{
+
   baud_rate = 19200;
 
   last_tool_bar_item = -1;
@@ -11925,6 +11952,7 @@
 #endif
 
   UNBLOCK_INPUT;
+
 }
 
 
--- a/src/macterm.h	Thu May 17 14:19:43 2007 +0000
+++ b/src/macterm.h	Sat May 19 19:08:02 2007 +0000
@@ -64,6 +64,9 @@
   /* Chain of all mac_display_info structures.  */
   struct mac_display_info *next;
 
+  /* The generic display parameters corresponding to this X display. */
+  struct terminal *terminal;
+
   /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
      The same cons cell also appears in x_display_name_list.  */
   Lisp_Object name_list_element;
@@ -611,7 +614,6 @@
 extern void x_destroy_window P_ ((struct frame *));
 extern void x_wm_set_size_hint P_ ((struct frame *, long, int));
 extern void x_delete_display P_ ((struct x_display_info *));
-extern void mac_initialize P_ ((void));
 extern Pixmap XCreatePixmap P_ ((Display *, WindowPtr, unsigned int,
 				 unsigned int, unsigned int));
 extern Pixmap XCreatePixmapFromBitmapData P_ ((Display *, WindowPtr, char *,
--- a/src/s/darwin.h	Thu May 17 14:19:43 2007 +0000
+++ b/src/s/darwin.h	Sat May 19 19:08:02 2007 +0000
@@ -53,6 +53,10 @@
 #endif
 #endif
 
+/* We need a little extra space, see ../../lisp/loadup.el. */
+#define SYSTEM_PURESIZE_EXTRA 30000
+
+
 /* SYSTEM_TYPE should indicate the kind of system you are using.
  It sets the Lisp variable system-type.  */
 
--- a/src/term.c	Thu May 17 14:19:43 2007 +0000
+++ b/src/term.c	Sat May 19 19:08:02 2007 +0000
@@ -2732,10 +2732,9 @@
      prompt in the mini-buffer.  */
   if (current_kboard == initial_kboard)
     current_kboard = terminal->kboard;
+  term_get_fkeys (address, terminal->kboard);
 #endif
 
-  term_get_fkeys (address, terminal->kboard);
-
   /* Get frame size from system, or else from termcap.  */
   {
     int height, width;
--- a/src/termhooks.h	Thu May 17 14:19:43 2007 +0000
+++ b/src/termhooks.h	Sat May 19 19:08:02 2007 +0000
@@ -293,6 +293,9 @@
 #endif /* CONSP */
 
 
+struct mac_display_info;
+struct w32_display_info;
+
 /* Terminal-local parameters. */
 struct terminal
 {
@@ -327,9 +330,8 @@
   {
     struct tty_display_info *tty;     /* termchar.h */
     struct x_display_info *x;         /* xterm.h */
-#ifdef WINDOWSNT
     struct w32_display_info *w32;     /* w32term.h */
-#endif
+    struct mac_display_info *mac;     /* macterm.h */
   } display_info;
 
 
--- a/src/w32fns.c	Thu May 17 14:19:43 2007 +0000
+++ b/src/w32fns.c	Sat May 19 19:08:02 2007 +0000
@@ -4165,7 +4165,7 @@
     display = Qnil;
   dpyinfo = check_x_display_info (display);
 #ifdef MULTI_KBOARD
-  kb = dpyinfo->kboard;
+  kb = dpyinfo->terminal->kboard;
 #else
   kb = &the_only_kboard;
 #endif
--- a/src/w32term.c	Thu May 17 14:19:43 2007 +0000
+++ b/src/w32term.c	Sat May 19 19:08:02 2007 +0000
@@ -230,7 +230,7 @@
 void x_set_window_size P_ ((struct frame *, int, int, int));
 void x_wm_set_window_state P_ ((struct frame *, int));
 void x_wm_set_icon_pixmap P_ ((struct frame *, int));
-void w32_initialize P_ ((void));
+static void w32_initialize P_ ((void));
 static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
 int x_compute_min_glyph_bounds P_ ((struct frame *));
 static void x_update_end P_ ((struct frame *));
@@ -6403,7 +6403,7 @@
 
 DWORD WINAPI w32_msg_worker (void * arg);
 
-void
+static void
 w32_initialize ()
 {
   baud_rate = 19200;