diff src/frame.c @ 83167:69ebc75cb461

Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes. * lisp/frame.el (make-frame-on-display): Update doc. (make-frame): Handle display-id parameter. Update doc. (frames-on-display-list): Update for display ids. (framep-on-display): Ditto. (suspend-frame): Use display-name, not frame-tty-name. (selected-display): New function. * lisp/server.el (server-delete-client): Use delete-display, not delete-tty. (server-tty-live-p, server-handle-delete-tty): Removed. (server-handle-delete-frame): Delete tty clients, if needed. (server-process-filter): Set the display parameter, and use it when appropriate. (server-handle-suspend-tty): Use the display parameter. (server-start, server-unload-hook): Removed obsolete delete-tty hook. * lisp/talk.el (talk): Always use talk-add-display. (talk-add-tty-frame, talk-handle-delete-tty): Removed. (talk-handle-delete-frame): New function. (talk-add-display): Open a new frame only if parameter was not a frame. * src/dispextern.h (get_display, Fdisplay_tty_type): New prototypes. (Fframe_tty_type): Removed. * src/dispnew.c (init_display): Use Fdisplay_tty_type, not Fframe_tty_type. * src/frame.c (Qdisplay_id, Qdisplay_live_p): New symbols. (make_terminal_frame): Get display as a parameter. (Fmake_terminal_frame): Get/create display here; pass it to make_terminal_frame. (Fframe_display): New function. (Fdelete_frame): Stop if the hook deleted the frame. (syms_of_frame): Register new stuff. * src/frame.h (Qdisplay_id, Qdisplay_live_p, make_terminal_frame): Updated prototypes. * src/keyboard.c (interrupt_signal): Updated comment. * src/term.c (Vdelete_tty_after_functions): Removed variable. (Qframe_tty_name, Qframe_tty_type): Removed. (next_display_id): New var. (tty_ring_bell): Don't do anything on suspended frames. (Ftty_display_color_p, Ftty_display_color_cells): Doc update. (get_display): New function. (get_tty_display): Use it. (get_named_tty_display): Ignore suspended displays. (Fframe_tty_name): Renamed to Fdisplay_name. Handle all kinds of displays. (Fframe_tty_type): Renamed to Fdisplay_tty_type. (init_initial_display): Set display name. (term_init): Allow more displays on the same device. Set display name. (Fdelete_tty): Removed. (delete_tty): Don't run hooks. (create_display): Set display id. (delete_display): Free display name. (Fdelete_display, Fdisplay_live_p, Fdisplay_list): New functions. (Fsuspend_tty): Call hook with display id. Doc update. (Fresume_tty): Refuse to resume when there is already an active display on the same device. Call hook with display id. Doc update. (syms_of_term): Reflect above changes. * src/termhooks.h (struct display): Added `id' and `name' members. (DISPLAY_ACTIVE_P): New macro. * src/xfns.c (check_x_display_info): Handle display ids. (Fx_create_frame): Try to get display from `display-id' parameter. * src/xterm.c (x_term_init): Set display name. (x_delete_display): Handle the case when `font_table' is NULL. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-207
author Karoly Lorentey <lorentey@elte.hu>
date Sun, 04 Jul 2004 04:48:55 +0000
parents 34a7a8f40548
children 3864ee1088e9
line wrap: on
line diff
--- a/src/frame.c	Sat Jul 03 18:40:41 2004 +0000
+++ b/src/frame.c	Sun Jul 04 04:48:55 2004 +0000
@@ -76,6 +76,8 @@
 
 Lisp_Object Qx_frame_parameter;
 Lisp_Object Qx_resource_name;
+Lisp_Object Qdisplay_id;
+Lisp_Object Qdisplay_live_p;
 
 /* Frame parameters (set or reported).  */
 
@@ -558,19 +560,12 @@
 
 
 struct frame *
-make_terminal_frame (tty_name, tty_type)
-     char *tty_name;
-     char *tty_type;
+make_terminal_frame (struct display *display)
 {
   register struct frame *f;
-  struct display *display;
   Lisp_Object frame;
   char name[20];
   
-  /* Open the display before creating the new frame, because
-     create_tty_display might throw an error. */
-  display = term_init (tty_name, tty_type, 0); /* Errors are not fatal. */
-  
   f = make_frame (1);
 
   XSETFRAME (frame, f);
@@ -673,6 +668,7 @@
      Lisp_Object parms;
 {
   struct frame *f;
+  struct display *d = NULL;
   Lisp_Object frame, tem;
   struct frame *sf = SELECTED_FRAME ();
 
@@ -692,53 +688,70 @@
 #endif
 #endif
 #endif /* not MSDOS */
-
-  { 
-    Lisp_Object tty, tty_type;
-    char *name = 0, *type = 0;
-
-    tty = Fassq (Qtty, parms);
-    if (EQ (tty, Qnil))
-      tty = Fassq (Qtty, XFRAME (selected_frame)->param_alist);
-    if (EQ (tty, Qnil) && FRAME_TERMCAP_P (XFRAME (selected_frame))
-        && FRAME_TTY (XFRAME (selected_frame))->name)
-      tty = build_string (FRAME_TTY (XFRAME (selected_frame))->name);
-    if (EQ (tty, Qnil))
-      tty = Fassq (Qtty, Vdefault_frame_alist);
-    if (! EQ (tty, Qnil) && ! STRINGP (tty))
-      tty = XCDR (tty);
-    if (EQ (tty, Qnil) || !STRINGP (tty))
-      tty = Qnil;
-
-    tty_type = Fassq (Qtty_type, parms);
-    if (EQ (tty_type, Qnil))
-      tty_type = Fassq (Qtty, XFRAME (selected_frame)->param_alist);
-    if (EQ (tty_type, Qnil) && FRAME_TERMCAP_P (XFRAME (selected_frame))
-        && FRAME_TTY (XFRAME (selected_frame))->type)
-      tty_type = build_string (FRAME_TTY (XFRAME (selected_frame))->type);
-    if (EQ (tty_type, Qnil))
-      tty_type = Fassq (Qtty_type, Vdefault_frame_alist);
-    if (! EQ (tty_type, Qnil) && ! STRINGP (tty_type))
-      tty_type = XCDR (tty_type);
-    if (EQ (tty_type, Qnil) || !STRINGP (tty_type))
-      tty_type = Qnil;
-
-    if (! EQ (tty, Qnil))
+  
+  {
+    Lisp_Object display_device;
+
+    display_device = Fassq (Qdisplay_id, parms);
+    if (!NILP (display_device))
       {
-        name = (char *) alloca (SBYTES (tty) + 1);
-        strncpy (name, SDATA (tty), SBYTES (tty));
-        name[SBYTES (tty)] = 0;
+        display_device = XCDR (display_device);
+        CHECK_NUMBER (display_device);
+        d = get_display (XINT (display_device));
+        if (!d)
+          wrong_type_argument (Qdisplay_live_p, display_device);
       }
-
-    if (! EQ (tty_type, Qnil))
-      {
-        type = (char *) alloca (SBYTES (tty_type) + 1);
-        strncpy (type, SDATA (tty_type), SBYTES (tty_type));
-        type[SBYTES (tty_type)] = 0;
-      }
-
-    f = make_terminal_frame (name, type);
   }
+  
+  if (!d)
+    { 
+      Lisp_Object tty, tty_type;
+      char *name = 0, *type = 0;
+
+      tty = Fassq (Qtty, parms);
+      if (EQ (tty, Qnil))
+        tty = Fassq (Qtty, XFRAME (selected_frame)->param_alist);
+      if (EQ (tty, Qnil) && FRAME_TERMCAP_P (XFRAME (selected_frame))
+          && FRAME_TTY (XFRAME (selected_frame))->name)
+        tty = build_string (FRAME_TTY (XFRAME (selected_frame))->name);
+      if (EQ (tty, Qnil))
+        tty = Fassq (Qtty, Vdefault_frame_alist);
+      if (! EQ (tty, Qnil) && ! STRINGP (tty))
+        tty = XCDR (tty);
+      if (EQ (tty, Qnil) || !STRINGP (tty))
+        tty = Qnil;
+
+      tty_type = Fassq (Qtty_type, parms);
+      if (EQ (tty_type, Qnil))
+        tty_type = Fassq (Qtty, XFRAME (selected_frame)->param_alist);
+      if (EQ (tty_type, Qnil) && FRAME_TERMCAP_P (XFRAME (selected_frame))
+          && FRAME_TTY (XFRAME (selected_frame))->type)
+        tty_type = build_string (FRAME_TTY (XFRAME (selected_frame))->type);
+      if (EQ (tty_type, Qnil))
+        tty_type = Fassq (Qtty_type, Vdefault_frame_alist);
+      if (! EQ (tty_type, Qnil) && ! STRINGP (tty_type))
+        tty_type = XCDR (tty_type);
+      if (EQ (tty_type, Qnil) || !STRINGP (tty_type))
+        tty_type = Qnil;
+
+      if (! EQ (tty, Qnil))
+        {
+          name = (char *) alloca (SBYTES (tty) + 1);
+          strncpy (name, SDATA (tty), SBYTES (tty));
+          name[SBYTES (tty)] = 0;
+        }
+      
+      if (! EQ (tty_type, Qnil))
+        {
+          type = (char *) alloca (SBYTES (tty_type) + 1);
+          strncpy (type, SDATA (tty_type), SBYTES (tty_type));
+          type[SBYTES (tty_type)] = 0;
+        }
+
+      d = term_init (name, type, 0); /* Errors are not fatal. */
+    }
+
+  f = make_terminal_frame (d);
 
   {
     int width, height;
@@ -1046,6 +1059,31 @@
   return XFRAME (frame)->selected_window = window;
 }
 
+
+DEFUN ("frame-display", Fframe_display, Sframe_display, 0, 1, 0,
+       doc: /* Return the display device that FRAME is displayed on.
+If FRAME is nil, the selected frame is used.
+
+The display device is represented by its integer identifier.  */)
+  (frame)
+     Lisp_Object frame;
+{
+  struct display *d;
+
+  if (NILP (frame))
+    frame = selected_frame;
+
+  CHECK_LIVE_FRAME (frame);
+
+  d = get_display (frame);
+
+  if (!d)
+    return Qnil;
+  else
+    return make_number (d->id);
+}
+
+
 DEFUN ("frame-list", Fframe_list, Sframe_list,
        0, 0, 0,
        doc: /* Return a list of all frames.  */)
@@ -1387,6 +1425,10 @@
       Frun_hook_with_args (2, args);
     }
 
+  /* The hook may sometimes (indirectly) cause the frame to be deleted.  */
+  if (! FRAME_LIVE_P (f))
+    return Qnil;
+
   minibuffer_selected = EQ (minibuf_window, selected_window);
 
   /* Don't let the frame remain selected.  */
@@ -4154,6 +4196,11 @@
   Qx_frame_parameter = intern ("x-frame-parameter");
   staticpro (&Qx_frame_parameter);
 
+  Qdisplay_id = intern ("display-id");
+  staticpro (&Qdisplay_id);
+  Qdisplay_live_p = intern ("display-live-p");
+  staticpro (&Qdisplay_live_p);
+  
   {
     int i;
 
@@ -4286,6 +4333,7 @@
   defsubr (&Sframe_first_window);
   defsubr (&Sframe_selected_window);
   defsubr (&Sset_frame_selected_window);
+  defsubr (&Sframe_display);
   defsubr (&Sframe_list);
   defsubr (&Snext_frame);
   defsubr (&Sprevious_frame);