aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorJuanma Barranquero2006-11-07 10:43:45 +0000
committerJuanma Barranquero2006-11-07 10:43:45 +0000
commit434a6c5d78587690f7b052fa1af83a9c800a1e8f (patch)
tree63ccdf0ac779276a7ebc3916d405f8f0a0fc3cbf /lib-src
parentc42690a67674a93873fd2a4d7c0374bf83f70810 (diff)
downloademacs-434a6c5d78587690f7b052fa1af83a9c800a1e8f.tar.gz
emacs-434a6c5d78587690f7b052fa1af83a9c800a1e8f.zip
(get_server_config): Extract also the Emacs pid from the server file.
On Windows, try to force the Emacs frame to the foreground.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/emacsclient.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index aeb221dfed1..76ed21b29f8 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -432,7 +432,7 @@ initialize_sockets ()
432 432
433/* 433/*
434 * Read the information needed to set up a TCP comm channel with 434 * Read the information needed to set up a TCP comm channel with
435 * the Emacs server: host, port and authentication string. 435 * the Emacs server: host, port, pid and authentication string.
436*/ 436*/
437int 437int
438get_server_config (server, authentication) 438get_server_config (server, authentication)
@@ -441,6 +441,7 @@ get_server_config (server, authentication)
441{ 441{
442 char dotted[32]; 442 char dotted[32];
443 char *port; 443 char *port;
444 char *pid;
444 FILE *config = NULL; 445 FILE *config = NULL;
445 446
446 if (file_name_absolute_p (server_file)) 447 if (file_name_absolute_p (server_file))
@@ -464,9 +465,11 @@ get_server_config (server, authentication)
464 return FALSE; 465 return FALSE;
465 466
466 if (fgets (dotted, sizeof dotted, config) 467 if (fgets (dotted, sizeof dotted, config)
467 && (port = strchr (dotted, ':'))) 468 && (port = strchr (dotted, ':'))
469 && (pid = strchr (port, ' ')))
468 { 470 {
469 *port++ = '\0'; 471 *port++ = '\0';
472 *pid++ = '\0';
470 } 473 }
471 else 474 else
472 { 475 {
@@ -486,6 +489,30 @@ get_server_config (server, authentication)
486 489
487 fclose (config); 490 fclose (config);
488 491
492#ifdef WINDOWSNT
493 /*
494 Modern Windows restrict which processes can set the foreground window.
495 So, for emacsclient to be able to force Emacs into the foreground, we
496 have to call AllowSetForegroundWindow(). Unfortunately, older Windows
497 (W95, W98 and NT) don't have this function, so we have to check first.
498
499 We're doing this here because it has to be done before sending info
500 to Emacs, and otherwise we'll need a global variable just to pass around
501 the pid, which is also inelegant.
502 */
503 {
504 HMODULE hUser32;
505
506 if (hUser32 = LoadLibrary ("user32.dll"))
507 {
508 void (*set_fg)(DWORD);
509 if (set_fg = GetProcAddress (hUser32, "AllowSetForegroundWindow"))
510 set_fg (atoi (pid));
511 FreeLibrary (hUser32);
512 }
513 }
514#endif
515
489 return TRUE; 516 return TRUE;
490} 517}
491 518