1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-21 10:24:55 +00:00

Create and initialize a client leader window so session management

doesn't restart Emacs twice.
This commit is contained in:
Jan Djärv 2003-08-21 19:54:47 +00:00
parent afa88464b1
commit 231d6cfb0c
6 changed files with 90 additions and 11 deletions

View File

@ -1,3 +1,19 @@
2003-08-21 Jan Dj,Ad(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.

View 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

View 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

View 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
}
}

View 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
}

View 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));