aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2003-08-21 19:54:47 +0000
committerJan Djärv2003-08-21 19:54:47 +0000
commit231d6cfb0c65a7ece2455e7fd0a488851a634778 (patch)
treea96f35f47b7a1457a5a484925abc178e21ce8a0a /src
parentafa88464b1e4728c53d8225257b6dda73d676b17 (diff)
downloademacs-231d6cfb0c65a7ece2455e7fd0a488851a634778.tar.gz
emacs-231d6cfb0c65a7ece2455e7fd0a488851a634778.zip
Create and initialize a client leader window so session management
doesn't restart Emacs twice.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog16
-rw-r--r--src/Makefile.in3
-rw-r--r--src/xfns.c13
-rw-r--r--src/xsmfns.c46
-rw-r--r--src/xterm.c17
-rw-r--r--src/xterm.h6
6 files changed, 90 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 597fb252d88..ee01b86dfd1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,19 @@
12003-08-21 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2
3 * xterm.h (struct x_display_info): New fields: client_leader_window
4 and Xatom_wm_client_leader.
5
6 * xterm.c (x_initialize): Move call to x_session_initialize to ...
7 (x_term_init): ... here. Initialize client_leader fields in dpyinfo.
8
9 * xsmfns.c (create_client_leader_window): New function.
10 (x_session_initialize): Call create_client_leader_window, take
11 dpyinfo as argument.
12
13 * xfns.c (Fx_create_frame): Set property WM_CLIENT_LEADER.
14
15 * Makefile.in (xsmfns.o): Add more depenedencies.
16
12003-08-21 Dave Love <fx@gnu.org> 172003-08-21 Dave Love <fx@gnu.org>
2 18
3 * m/iris4d.h: Use _MIPS_SZLONG, not _LP64. 19 * m/iris4d.h: Use _MIPS_SZLONG, not _LP64.
diff --git a/src/Makefile.in b/src/Makefile.in
index ec244012b28..90605dd669d 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1153,7 +1153,8 @@ xterm.o: xterm.c xterm.h termhooks.h termopts.h termchar.h window.h buffer.h \
1153xselect.o: xselect.c process.h dispextern.h frame.h xterm.h blockinput.h \ 1153xselect.o: xselect.c process.h dispextern.h frame.h xterm.h blockinput.h \
1154 buffer.h atimer.h systime.h $(config_h) 1154 buffer.h atimer.h systime.h $(config_h)
1155xrdb.o: xrdb.c $(config_h) epaths.h 1155xrdb.o: xrdb.c $(config_h) epaths.h
1156xsmfns.o: xsmfns.c $(config_h) systime.h sysselect.h termhooks.h 1156xsmfns.o: xsmfns.c $(config_h) systime.h sysselect.h termhooks.h xterm.h \
1157 lisp.h termopts.h
1157gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h $(config_h) \ 1158gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h $(config_h) \
1158 blockinput.h window.h atimer.h termhooks.h 1159 blockinput.h window.h atimer.h termhooks.h
1159 1160
diff --git a/src/xfns.c b/src/xfns.c
index af7ed7473e8..439ddbfec2f 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -3526,6 +3526,19 @@ This function is an internal primitive--use `make-frame' instead. */)
3526 ; 3526 ;
3527 } 3527 }
3528 3528
3529 /* Set the WM leader property. GTK does this itself, so this is not
3530 needed when using GTK. */
3531 if (dpyinfo->client_leader_window != 0)
3532 {
3533 BLOCK_INPUT;
3534 XChangeProperty (FRAME_X_DISPLAY (f),
3535 FRAME_OUTER_WINDOW (f),
3536 dpyinfo->Xatom_wm_client_leader,
3537 XA_WINDOW, 32, PropModeReplace,
3538 (char *) &dpyinfo->client_leader_window, 1);
3539 UNBLOCK_INPUT;
3540 }
3541
3529 UNGCPRO; 3542 UNGCPRO;
3530 3543
3531 /* Make sure windows on this frame appear in calls to next-window 3544 /* Make sure windows on this frame appear in calls to next-window
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 5e712fa1b38..b4a612f1544 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -24,6 +24,9 @@ Boston, MA 02111-1307, USA. */
24#ifdef HAVE_X_SM 24#ifdef HAVE_X_SM
25 25
26#include <X11/SM/SMlib.h> 26#include <X11/SM/SMlib.h>
27#include <X11/Xlib.h>
28#include <X11/Xutil.h>
29
27#ifdef HAVE_STRING_H 30#ifdef HAVE_STRING_H
28#include <string.h> 31#include <string.h>
29#else 32#else
@@ -47,6 +50,7 @@ Boston, MA 02111-1307, USA. */
47#include "lisp.h" 50#include "lisp.h"
48#include "termhooks.h" 51#include "termhooks.h"
49#include "termopts.h" 52#include "termopts.h"
53#include "xterm.h"
50 54
51#ifndef MAXPATHLEN 55#ifndef MAXPATHLEN
52#define MAXPATHLEN 1024 56#define MAXPATHLEN 1024
@@ -403,9 +407,37 @@ ice_conn_watch_CB (iceConn, clientData, opening, watchData)
403#endif /* ! defined (SIGIO) */ 407#endif /* ! defined (SIGIO) */
404} 408}
405 409
410/* Create the client leader window. */
411static void
412create_client_leader_window (dpyinfo, client_id)
413 struct x_display_info *dpyinfo;
414 char *client_id;
415{
416 Window w;
417 XClassHint class_hints;
418 Atom sm_id;
419
420 w = XCreateSimpleWindow (dpyinfo->display,
421 dpyinfo->root_window,
422 -1, -1, 1, 1,
423 CopyFromParent, CopyFromParent, CopyFromParent);
424
425 class_hints.res_name = (char *) SDATA (Vx_resource_name);
426 class_hints.res_class = (char *) SDATA (Vx_resource_class);
427 XSetClassHint (dpyinfo->display, w, &class_hints);
428 XStoreName (dpyinfo->display, w, class_hints.res_name);
429
430 sm_id = XInternAtom (dpyinfo->display, "SM_CLIENT_ID", False);
431 XChangeProperty (dpyinfo->display, w, sm_id, XA_STRING, 8, PropModeReplace,
432 client_id, strlen (client_id));
433
434 dpyinfo->client_leader_window = w;
435}
436
406/* Try to open a connection to the session manager. */ 437/* Try to open a connection to the session manager. */
407void 438void
408x_session_initialize () 439x_session_initialize (dpyinfo)
440 struct x_display_info *dpyinfo;
409{ 441{
410#define SM_ERRORSTRING_LEN 512 442#define SM_ERRORSTRING_LEN 512
411 char errorstring[SM_ERRORSTRING_LEN]; 443 char errorstring[SM_ERRORSTRING_LEN];
@@ -466,7 +498,17 @@ x_session_initialize ()
466 errorstring); 498 errorstring);
467 499
468 if (smc_conn != 0) 500 if (smc_conn != 0)
469 Vx_session_id = make_string (client_id, strlen (client_id)); 501 {
502 Vx_session_id = make_string (client_id, strlen (client_id));
503
504#ifdef USE_GTK
505 /* GTK creats a leader window by itself, but we need to tell
506 it about our client_id. */
507 gdk_set_sm_client_id (client_id);
508#else
509 create_client_leader_window (dpyinfo, client_id);
510#endif
511 }
470} 512}
471 513
472 514
diff --git a/src/xterm.c b/src/xterm.c
index 18f225182c8..60bd3cc375c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10136,7 +10136,7 @@ x_term_init (display_name, xrm_option, resource_name)
10136 if (!x_initialized) 10136 if (!x_initialized)
10137 { 10137 {
10138 x_initialize (); 10138 x_initialize ();
10139 x_initialized = 1; 10139 ++x_initialized;
10140 } 10140 }
10141 10141
10142#ifdef USE_GTK 10142#ifdef USE_GTK
@@ -10152,8 +10152,6 @@ x_term_init (display_name, xrm_option, resource_name)
10152 if (x_initialized > 1) 10152 if (x_initialized > 1)
10153 return 0; 10153 return 0;
10154 10154
10155 x_initialized++;
10156
10157 for (argc = 0; argc < NUM_ARGV; ++argc) 10155 for (argc = 0; argc < NUM_ARGV; ++argc)
10158 argv[argc] = 0; 10156 argv[argc] = 0;
10159 10157
@@ -10343,6 +10341,7 @@ x_term_init (display_name, xrm_option, resource_name)
10343 dpyinfo->height = HeightOfScreen (dpyinfo->screen); 10341 dpyinfo->height = HeightOfScreen (dpyinfo->screen);
10344 dpyinfo->width = WidthOfScreen (dpyinfo->screen); 10342 dpyinfo->width = WidthOfScreen (dpyinfo->screen);
10345 dpyinfo->root_window = RootWindowOfScreen (dpyinfo->screen); 10343 dpyinfo->root_window = RootWindowOfScreen (dpyinfo->screen);
10344 dpyinfo->client_leader_window = 0;
10346 dpyinfo->grabbed = 0; 10345 dpyinfo->grabbed = 0;
10347 dpyinfo->reference_count = 0; 10346 dpyinfo->reference_count = 0;
10348 dpyinfo->icon_bitmap_id = -1; 10347 dpyinfo->icon_bitmap_id = -1;
@@ -10412,6 +10411,8 @@ x_term_init (display_name, xrm_option, resource_name)
10412 = XInternAtom (dpyinfo->display, "WM_CONFIGURE_DENIED", False); 10411 = XInternAtom (dpyinfo->display, "WM_CONFIGURE_DENIED", False);
10413 dpyinfo->Xatom_wm_window_moved 10412 dpyinfo->Xatom_wm_window_moved
10414 = XInternAtom (dpyinfo->display, "WM_MOVED", False); 10413 = XInternAtom (dpyinfo->display, "WM_MOVED", False);
10414 dpyinfo->Xatom_wm_client_leader
10415 = XInternAtom (dpyinfo->display, "WM_CLIENT_LEADER", False);
10415 dpyinfo->Xatom_editres 10416 dpyinfo->Xatom_editres
10416 = XInternAtom (dpyinfo->display, "Editres", False); 10417 = XInternAtom (dpyinfo->display, "Editres", False);
10417 dpyinfo->Xatom_CLIPBOARD 10418 dpyinfo->Xatom_CLIPBOARD
@@ -10566,6 +10567,12 @@ x_term_init (display_name, xrm_option, resource_name)
10566#endif 10567#endif
10567 } 10568 }
10568 10569
10570#ifdef HAVE_X_SM
10571 /* Only do this for the first display. */
10572 if (x_initialized == 1)
10573 x_session_initialize (dpyinfo);
10574#endif
10575
10569 UNBLOCK_INPUT; 10576 UNBLOCK_INPUT;
10570 10577
10571 return dpyinfo; 10578 return dpyinfo;
@@ -10779,10 +10786,6 @@ x_initialize ()
10779#endif /* SIGWINCH */ 10786#endif /* SIGWINCH */
10780 10787
10781 signal (SIGPIPE, x_connection_signal); 10788 signal (SIGPIPE, x_connection_signal);
10782
10783#ifdef HAVE_X_SM
10784 x_session_initialize ();
10785#endif
10786} 10789}
10787 10790
10788 10791
diff --git a/src/xterm.h b/src/xterm.h
index fd1e79b9082..03c0dc32acc 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -183,6 +183,9 @@ struct x_display_info
183 /* The root window of this screen. */ 183 /* The root window of this screen. */
184 Window root_window; 184 Window root_window;
185 185
186 /* Client leader window. */
187 Window client_leader_window;
188
186 /* The cursor to use for vertical scroll bars. */ 189 /* The cursor to use for vertical scroll bars. */
187 Cursor vertical_scroll_bar_cursor; 190 Cursor vertical_scroll_bar_cursor;
188 191
@@ -289,6 +292,7 @@ struct x_display_info
289 /* Other WM communication */ 292 /* Other WM communication */
290 Atom Xatom_wm_configure_denied; /* When our config request is denied */ 293 Atom Xatom_wm_configure_denied; /* When our config request is denied */
291 Atom Xatom_wm_window_moved; /* When the WM moves us. */ 294 Atom Xatom_wm_window_moved; /* When the WM moves us. */
295 Atom Xatom_wm_client_leader; /* Id of client leader window. */
292 296
293 /* EditRes protocol */ 297 /* EditRes protocol */
294 Atom Xatom_editres; 298 Atom Xatom_editres;
@@ -1029,7 +1033,7 @@ extern void widget_store_internal_border P_ ((Widget));
1029 1033
1030/* Defined in xsmfns.c */ 1034/* Defined in xsmfns.c */
1031#ifdef HAVE_X_SM 1035#ifdef HAVE_X_SM
1032extern void x_session_initialize P_ ((void)); 1036extern void x_session_initialize P_ ((struct x_display_info *dpyinfo));
1033extern int x_session_check_input P_ ((struct input_event *bufp, 1037extern int x_session_check_input P_ ((struct input_event *bufp,
1034 int *numchars)); 1038 int *numchars));
1035extern int x_session_have_connection P_ ((void)); 1039extern int x_session_have_connection P_ ((void));