* xterm.h (struct x_display_info): Do not track X connection
authorDmitry Antipov <dmantipov@yandex.ru>
Wed, 4 Sep 2013 04:02:56 +0000 (08:02 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Wed, 4 Sep 2013 04:02:56 +0000 (08:02 +0400)
fd separately because it is always available from Display.
* xterm.c (x_term_init, x_delete_terminal, x_delete_display):
Adjust users.

src/ChangeLog
src/xterm.c
src/xterm.h

index e0aa1ed..c355232 100644 (file)
@@ -1,3 +1,10 @@
+2013-09-04  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * xterm.h (struct x_display_info): Do not track X connection
+       fd separately because it is always available from Display.
+       * xterm.c (x_term_init, x_delete_terminal, x_delete_display):
+       Adjust users.
+
 2013-09-03  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * buffer.c (drop_overlay):
index bd99001..c7bfbae 100644 (file)
@@ -10170,9 +10170,6 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
   dpyinfo->x_dnd_atoms_size = 8;
   dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms
                                   * dpyinfo->x_dnd_atoms_size);
-
-  connection = ConnectionNumber (dpyinfo->display);
-  dpyinfo->connection = connection;
   dpyinfo->gray
     = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window,
                                   gray_bits, gray_width, gray_height,
@@ -10184,6 +10181,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
 
   xsettings_initialize (dpyinfo);
 
+  connection = ConnectionNumber (dpyinfo->display);
+
   /* This is only needed for distinguishing keyboard and process input.  */
   if (connection != 0)
     add_keyboard_wait_descriptor (connection);
@@ -10284,8 +10283,6 @@ x_delete_display (struct x_display_info *dpyinfo)
         break;
       }
 
-  delete_keyboard_wait_descriptor (dpyinfo->connection);
-
   /* Discard this display from x_display_name_list and x_display_list.
      We can't use Fdelq because that can quit.  */
   if (! NILP (x_display_name_list)
@@ -10413,6 +10410,7 @@ void
 x_delete_terminal (struct terminal *terminal)
 {
   struct x_display_info *dpyinfo = terminal->display_info.x;
+  int connection = -1;
 
   /* Protect against recursive calls.  delete_frame in
      delete_terminal calls us back when it deletes our last frame.  */
@@ -10431,6 +10429,8 @@ x_delete_terminal (struct terminal *terminal)
      and dpyinfo->display was set to 0 to indicate that.  */
   if (dpyinfo->display)
     {
+      connection = ConnectionNumber (dpyinfo->display);
+
       x_destroy_all_bitmaps (dpyinfo);
       XSetCloseDownMode (dpyinfo->display, DestroyAll);
 
@@ -10471,6 +10471,10 @@ x_delete_terminal (struct terminal *terminal)
 #endif /* ! USE_GTK */
     }
 
+  /* No more input on this descriptor.  */
+  if (connection != -1)
+    delete_keyboard_wait_descriptor (connection);
+
   /* Mark as dead. */
   dpyinfo->display = NULL;
   x_delete_display (dpyinfo);
index c579d34..883a249 100644 (file)
@@ -138,9 +138,6 @@ struct x_display_info
   /* The generic display parameters corresponding to this X display. */
   struct terminal *terminal;
 
-  /* Connection number (normally a file descriptor number).  */
-  int connection;
-
   /* This says how to access this display in Xlib.  */
   Display *display;