]> git.eshelyaron.com Git - emacs.git/commitdiff
Create and initialize a client leader window so session management
authorJan Djärv <jan.h.d@swipnet.se>
Thu, 21 Aug 2003 19:54:47 +0000 (19:54 +0000)
committerJan Djärv <jan.h.d@swipnet.se>
Thu, 21 Aug 2003 19:54:47 +0000 (19:54 +0000)
doesn't restart Emacs twice.

src/ChangeLog
src/Makefile.in
src/xfns.c
src/xsmfns.c
src/xterm.c
src/xterm.h

index 597fb252d88eba124e6bcf8ee278b2d8c6aa127f..ee01b86dfd1be6f24a24bfa6a2c23b5bded847f0 100644 (file)
@@ -1,3 +1,19 @@
+2003-08-21  Jan Dj\e,Ad\e(Brv  <jan.h.d@swipnet.se>
+
+       * xterm.h (struct x_display_info): New fields: client_leader_window
+       and Xatom_wm_client_leader.
+
+       * xterm.c (x_initialize): Move call to x_session_initialize to ...
+       (x_term_init): ... here.  Initialize client_leader fields in dpyinfo.
+
+       * xsmfns.c (create_client_leader_window): New function.
+       (x_session_initialize): Call create_client_leader_window, take
+       dpyinfo as argument.
+
+       * xfns.c (Fx_create_frame): Set property WM_CLIENT_LEADER.
+
+       * Makefile.in (xsmfns.o): Add more depenedencies.
+
 2003-08-21  Dave Love  <fx@gnu.org>
 
        * m/iris4d.h: Use _MIPS_SZLONG, not _LP64.
index ec244012b28f46fa9ce4553ef4562de7023ed7c0..90605dd669d514924547be12a2dd370afce0c057 100644 (file)
@@ -1153,7 +1153,8 @@ xterm.o: xterm.c xterm.h termhooks.h termopts.h termchar.h window.h buffer.h \
 xselect.o: xselect.c process.h dispextern.h frame.h xterm.h blockinput.h \
   buffer.h atimer.h systime.h $(config_h)
 xrdb.o: xrdb.c $(config_h) epaths.h
-xsmfns.o: xsmfns.c $(config_h) systime.h sysselect.h termhooks.h
+xsmfns.o: xsmfns.c $(config_h) systime.h sysselect.h termhooks.h xterm.h \
+  lisp.h termopts.h
 gtkutil.o:  gtkutil.c gtkutil.h xterm.h lisp.h frame.h $(config_h) \
   blockinput.h window.h atimer.h termhooks.h
 
index af7ed7473e863d24f694b03fd3b49f55e3920139..439ddbfec2f210fe2bda2a31064bf1d5467c070a 100644 (file)
@@ -3526,6 +3526,19 @@ This function is an internal primitive--use `make-frame' instead.  */)
        ;
     }
 
+  /* Set the WM leader property.  GTK does this itself, so this is not
+     needed when using GTK.  */
+  if (dpyinfo->client_leader_window != 0)
+    {
+      BLOCK_INPUT;
+      XChangeProperty (FRAME_X_DISPLAY (f),
+                       FRAME_OUTER_WINDOW (f),
+                       dpyinfo->Xatom_wm_client_leader,
+                       XA_WINDOW, 32, PropModeReplace,
+                       (char *) &dpyinfo->client_leader_window, 1);
+      UNBLOCK_INPUT;
+    }
+
   UNGCPRO;
 
   /* Make sure windows on this frame appear in calls to next-window
index 5e712fa1b38af89c4991da6eb34bfc8985bf553c..b4a612f1544001a41accaf0687277b228f31c92a 100644 (file)
@@ -24,6 +24,9 @@ Boston, MA 02111-1307, USA.  */
 #ifdef HAVE_X_SM
 
 #include <X11/SM/SMlib.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
 #ifdef HAVE_STRING_H
 #include <string.h>
 #else
@@ -47,6 +50,7 @@ Boston, MA 02111-1307, USA.  */
 #include "lisp.h"
 #include "termhooks.h"
 #include "termopts.h"
+#include "xterm.h"
 
 #ifndef MAXPATHLEN
 #define MAXPATHLEN 1024
@@ -403,9 +407,37 @@ ice_conn_watch_CB (iceConn, clientData, opening, watchData)
 #endif /* ! defined (SIGIO) */
 }
 
+/* Create the client leader window.  */
+static void
+create_client_leader_window (dpyinfo, client_id)
+     struct x_display_info *dpyinfo;
+     char *client_id;
+{
+  Window w;
+  XClassHint class_hints;
+  Atom sm_id;
+
+  w = XCreateSimpleWindow (dpyinfo->display,
+                           dpyinfo->root_window,
+                           -1, -1, 1, 1,
+                           CopyFromParent, CopyFromParent, CopyFromParent);
+
+  class_hints.res_name = (char *) SDATA (Vx_resource_name);
+  class_hints.res_class = (char *) SDATA (Vx_resource_class);
+  XSetClassHint (dpyinfo->display, w, &class_hints);
+  XStoreName (dpyinfo->display, w, class_hints.res_name);
+
+  sm_id = XInternAtom (dpyinfo->display, "SM_CLIENT_ID", False);
+  XChangeProperty (dpyinfo->display, w, sm_id, XA_STRING, 8, PropModeReplace,
+                   client_id, strlen (client_id));
+
+  dpyinfo->client_leader_window = w;
+}
+
 /* Try to open a connection to the session manager. */
 void
-x_session_initialize ()
+x_session_initialize (dpyinfo)
+     struct x_display_info *dpyinfo;
 {
 #define SM_ERRORSTRING_LEN 512
   char errorstring[SM_ERRORSTRING_LEN];
@@ -466,7 +498,17 @@ x_session_initialize ()
                                 errorstring);
 
   if (smc_conn != 0)
-    Vx_session_id = make_string (client_id, strlen (client_id));
+    {
+      Vx_session_id = make_string (client_id, strlen (client_id));
+
+#ifdef USE_GTK
+      /* GTK creats a leader window by itself, but we need to tell
+         it about our client_id.  */
+      gdk_set_sm_client_id (client_id);
+#else
+      create_client_leader_window (dpyinfo, client_id);
+#endif
+    }
 }
 
 
index 18f225182c865b71b5c34cf2a157007602828eaa..60bd3cc375c44bc406e78c4294495732424fd184 100644 (file)
@@ -10136,7 +10136,7 @@ x_term_init (display_name, xrm_option, resource_name)
   if (!x_initialized)
     {
       x_initialize ();
-      x_initialized = 1;
+      ++x_initialized;
     }
 
 #ifdef USE_GTK
@@ -10152,8 +10152,6 @@ x_term_init (display_name, xrm_option, resource_name)
     if (x_initialized > 1)
       return 0;
 
-    x_initialized++;
-
     for (argc = 0; argc < NUM_ARGV; ++argc)
       argv[argc] = 0;
 
@@ -10343,6 +10341,7 @@ x_term_init (display_name, xrm_option, resource_name)
   dpyinfo->height = HeightOfScreen (dpyinfo->screen);
   dpyinfo->width = WidthOfScreen (dpyinfo->screen);
   dpyinfo->root_window = RootWindowOfScreen (dpyinfo->screen);
+  dpyinfo->client_leader_window = 0;
   dpyinfo->grabbed = 0;
   dpyinfo->reference_count = 0;
   dpyinfo->icon_bitmap_id = -1;
@@ -10412,6 +10411,8 @@ x_term_init (display_name, xrm_option, resource_name)
     = XInternAtom (dpyinfo->display, "WM_CONFIGURE_DENIED", False);
   dpyinfo->Xatom_wm_window_moved
     = XInternAtom (dpyinfo->display, "WM_MOVED", False);
+  dpyinfo->Xatom_wm_client_leader
+    = XInternAtom (dpyinfo->display, "WM_CLIENT_LEADER", False);
   dpyinfo->Xatom_editres
     = XInternAtom (dpyinfo->display, "Editres", False);
   dpyinfo->Xatom_CLIPBOARD
@@ -10566,6 +10567,12 @@ x_term_init (display_name, xrm_option, resource_name)
 #endif
   }
 
+#ifdef HAVE_X_SM
+  /* Only do this for the first display.  */
+  if (x_initialized == 1)
+    x_session_initialize (dpyinfo);
+#endif
+
   UNBLOCK_INPUT;
 
   return dpyinfo;
@@ -10779,10 +10786,6 @@ x_initialize ()
 #endif /* SIGWINCH */
 
   signal (SIGPIPE, x_connection_signal);
-
-#ifdef HAVE_X_SM
-  x_session_initialize ();
-#endif
 }
 
 
index fd1e79b9082ba3ca2c24c2e9d45fe775895ffbc3..03c0dc32accf279471a12819ce7a2e4d16f710e8 100644 (file)
@@ -183,6 +183,9 @@ struct x_display_info
   /* The root window of this screen.  */
   Window root_window;
 
+  /* Client leader window.  */
+  Window client_leader_window;
+
   /* The cursor to use for vertical scroll bars.  */
   Cursor vertical_scroll_bar_cursor;
 
@@ -289,6 +292,7 @@ struct x_display_info
   /* Other WM communication */
   Atom Xatom_wm_configure_denied; /* When our config request is denied */
   Atom Xatom_wm_window_moved;     /* When the WM moves us.  */
+  Atom Xatom_wm_client_leader;    /* Id of client leader window.  */
 
   /* EditRes protocol */
   Atom Xatom_editres;
@@ -1029,7 +1033,7 @@ extern void widget_store_internal_border P_ ((Widget));
 
 /* Defined in xsmfns.c */
 #ifdef HAVE_X_SM
-extern void x_session_initialize P_ ((void));
+extern void x_session_initialize P_ ((struct x_display_info *dpyinfo));
 extern int x_session_check_input P_ ((struct input_event *bufp,
                                       int *numchars));
 extern int x_session_have_connection P_ ((void));