doesn't restart Emacs twice.
+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.
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
;
}
+ /* 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
#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
#include "lisp.h"
#include "termhooks.h"
#include "termopts.h"
+#include "xterm.h"
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#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];
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
+ }
}
if (!x_initialized)
{
x_initialize ();
- x_initialized = 1;
+ ++x_initialized;
}
#ifdef USE_GTK
if (x_initialized > 1)
return 0;
- x_initialized++;
-
for (argc = 0; argc < NUM_ARGV; ++argc)
argv[argc] = 0;
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;
= 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
#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;
#endif /* SIGWINCH */
signal (SIGPIPE, x_connection_signal);
-
-#ifdef HAVE_X_SM
- x_session_initialize ();
-#endif
}
/* 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;
/* 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;
/* 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));