comparison src/xfns.c @ 107779:41e0da544208

Set WM_CLIENT_MACHINE and _NET_WM_PID properties (Bug#5828). * xfns.c (set_machine_and_pid_properties): New function. (Fx_create_frame): Call set_machine_and_pid_properties.
author jhd <jhd@f12.localdomain>
date Sun, 04 Apr 2010 12:47:12 +0200
parents 75e87467a0db
children c34901ea512b
comparison
equal deleted inserted replaced
107778:a91f626531f7 107779:41e0da544208
200 Lisp_Object Qfont_param; 200 Lisp_Object Qfont_param;
201 201
202 /* In dispnew.c */ 202 /* In dispnew.c */
203 203
204 extern Lisp_Object Vwindow_system_version; 204 extern Lisp_Object Vwindow_system_version;
205
206 /* In editfns.c */
207
208 extern Lisp_Object Vsystem_name;
205 209
206 /* The below are defined in frame.c. */ 210 /* The below are defined in frame.c. */
207 211
208 #if GLYPH_DEBUG 212 #if GLYPH_DEBUG
209 int image_cache_refcount, dpyinfo_refcount; 213 int image_cache_refcount, dpyinfo_refcount;
3143 x_wm_set_size_hint (f, 0, 0); 3147 x_wm_set_size_hint (f, 0, 0);
3144 UNBLOCK_INPUT; 3148 UNBLOCK_INPUT;
3145 return Qnil; 3149 return Qnil;
3146 } 3150 }
3147 3151
3152 static void
3153 set_machine_and_pid_properties (struct frame *f)
3154 {
3155 /* See the above comment "Note: Encoding strategy". */
3156 XTextProperty text;
3157 int bytes, stringp;
3158 int do_free_text_value = 0;
3159
3160 text.value = x_encode_text (Vsystem_name,
3161 Qcompound_text, 0, &bytes, &stringp,
3162 &do_free_text_value);
3163 text.encoding = (stringp ? XA_STRING
3164 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
3165 text.format = 8;
3166 text.nitems = bytes;
3167 XSetWMClientMachine (FRAME_X_DISPLAY (f),
3168 FRAME_OUTER_WINDOW (f),
3169 &text);
3170 if (do_free_text_value)
3171 xfree (text.value);
3172
3173 long pid = (long)getpid();
3174 XChangeProperty (FRAME_X_DISPLAY (f),
3175 FRAME_OUTER_WINDOW (f),
3176 XInternAtom (FRAME_X_DISPLAY (f),
3177 "_NET_WM_PID",
3178 False),
3179 XA_CARDINAL, 32, PropModeReplace,
3180 (unsigned char *) &pid, 1);
3181 }
3182
3148 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 3183 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
3149 1, 1, 0, 3184 1, 1, 0,
3150 doc: /* Make a new X window, which is called a "frame" in Emacs terms. 3185 doc: /* Make a new X window, which is called a "frame" in Emacs terms.
3151 Return an Emacs frame object. 3186 Return an Emacs frame object.
3152 PARMS is an alist of frame parameters. 3187 PARMS is an alist of frame parameters.
3529 else 3564 else
3530 /* Must have been Qnil. */ 3565 /* Must have been Qnil. */
3531 ; 3566 ;
3532 } 3567 }
3533 3568
3569 BLOCK_INPUT;
3570
3571 /* Set machine name and pid for the purpose of window managers. */
3572 set_machine_and_pid_properties(f);
3573
3534 /* Set the WM leader property. GTK does this itself, so this is not 3574 /* Set the WM leader property. GTK does this itself, so this is not
3535 needed when using GTK. */ 3575 needed when using GTK. */
3536 if (dpyinfo->client_leader_window != 0) 3576 if (dpyinfo->client_leader_window != 0)
3537 { 3577 {
3538 BLOCK_INPUT;
3539 XChangeProperty (FRAME_X_DISPLAY (f), 3578 XChangeProperty (FRAME_X_DISPLAY (f),
3540 FRAME_OUTER_WINDOW (f), 3579 FRAME_OUTER_WINDOW (f),
3541 dpyinfo->Xatom_wm_client_leader, 3580 dpyinfo->Xatom_wm_client_leader,
3542 XA_WINDOW, 32, PropModeReplace, 3581 XA_WINDOW, 32, PropModeReplace,
3543 (unsigned char *) &dpyinfo->client_leader_window, 1); 3582 (unsigned char *) &dpyinfo->client_leader_window, 1);
3544 UNBLOCK_INPUT; 3583 }
3545 } 3584
3585 UNBLOCK_INPUT;
3546 3586
3547 /* Initialize `default-minibuffer-frame' in case this is the first 3587 /* Initialize `default-minibuffer-frame' in case this is the first
3548 frame on this terminal. */ 3588 frame on this terminal. */
3549 if (FRAME_HAS_MINIBUF_P (f) 3589 if (FRAME_HAS_MINIBUF_P (f)
3550 && (!FRAMEP (kb->Vdefault_minibuffer_frame) 3590 && (!FRAMEP (kb->Vdefault_minibuffer_frame)