changeset 84621:5d074ea0e4a2

(gdpy_def): New variable. (xg_initialize): Initialize gdpy_def. (xg_display_close): If no other display exists, set gdpy_def to a new connection.
author Jan Djärv <jan.h.d@swipnet.se>
date Mon, 17 Sep 2007 08:07:19 +0000
parents 71ee9cbb96e8
children f967b253f826
files src/gtkutil.c
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkutil.c	Mon Sep 17 07:04:46 2007 +0000
+++ b/src/gtkutil.c	Mon Sep 17 08:07:19 2007 +0000
@@ -51,6 +51,13 @@
 
 #ifdef HAVE_GTK_MULTIDISPLAY
 
+/* Gtk does not work well without any display open.  Emacs may close
+   all its displays.  In that case, keep a display around just for
+   the purpose of having one.  */
+
+static GdkDisplay *gdpy_def;
+
+
 /* Return the GdkDisplay that corresponds to the X display DPY.  */
 
 static GdkDisplay *
@@ -147,9 +154,15 @@
             break;
           }
 
-      if (! new_dpy) return; /* Emacs will exit anyway.  */
-
-      gdpy_new = gdk_x11_lookup_xdisplay (new_dpy);
+      if (new_dpy)
+        gdpy_new = gdk_x11_lookup_xdisplay (new_dpy);
+      else
+        {
+          if (!gdpy_def)
+            gdpy_def = gdk_display_open (gdk_display_get_name (gdpy));
+          gdpy_new = gdpy_def;
+        }
+
       gdk_display_manager_set_default_display (gdk_display_manager_get (),
                                                gdpy_new);
     }
@@ -4091,6 +4104,8 @@
      we keep it permanently linked in.  */
   XftInit (0);
 #endif
+
+  gdpy_def = NULL;
   xg_ignore_gtk_scrollbar = 0;
   xg_detached_menus = 0;
   xg_menu_cb_list.prev = xg_menu_cb_list.next =