aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorDaniel Colascione2012-09-17 03:55:03 -0800
committerDaniel Colascione2012-09-17 03:55:03 -0800
commit5e0944c6f072cc1b9304b7369bf61091ffd23ea7 (patch)
treedfe2ba7d65ed993c2a8fb2cec03119024aeef839 /lib-src
parent0fda9b750e337d876c9461db7d4426a3f0b81482 (diff)
downloademacs-5e0944c6f072cc1b9304b7369bf61091ffd23ea7.tar.gz
emacs-5e0944c6f072cc1b9304b7369bf61091ffd23ea7.zip
Fix emacsclient to work with cygw32
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/emacsclient.c71
1 files changed, 37 insertions, 34 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 07300dbf249..103473abdb1 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -44,6 +44,10 @@ char *w32_getenv (char *);
44 44
45#else /* !WINDOWSNT */ 45#else /* !WINDOWSNT */
46 46
47# ifdef HAVE_NTGUI
48# include <windows.h>
49# endif /* HAVE_NTGUI */
50
47# include "syswait.h" 51# include "syswait.h"
48 52
49# ifdef HAVE_INET_SOCKETS 53# ifdef HAVE_INET_SOCKETS
@@ -182,9 +186,7 @@ struct option longopts[] =
182 { "socket-name", required_argument, NULL, 's' }, 186 { "socket-name", required_argument, NULL, 's' },
183#endif 187#endif
184 { "server-file", required_argument, NULL, 'f' }, 188 { "server-file", required_argument, NULL, 'f' },
185#ifndef WINDOWSNT
186 { "display", required_argument, NULL, 'd' }, 189 { "display", required_argument, NULL, 'd' },
187#endif
188 { "parent-id", required_argument, NULL, 'p' }, 190 { "parent-id", required_argument, NULL, 'p' },
189 { 0, 0, 0, 0 } 191 { 0, 0, 0, 0 }
190}; 192};
@@ -385,32 +387,6 @@ w32_getenv (char *envvar)
385 return NULL; 387 return NULL;
386} 388}
387 389
388void
389w32_set_user_model_id (void)
390{
391 HMODULE shell;
392 HRESULT (WINAPI * set_user_model) (wchar_t * id);
393
394 /* On Windows 7 and later, we need to set the user model ID
395 to associate emacsclient launched files with Emacs frames
396 in the UI. */
397 shell = LoadLibrary ("shell32.dll");
398 if (shell)
399 {
400 set_user_model
401 = (void *) GetProcAddress (shell,
402 "SetCurrentProcessExplicitAppUserModelID");
403 /* If the function is defined, then we are running on Windows 7
404 or newer, and the UI uses this to group related windows
405 together. Since emacs, runemacs, emacsclient are related, we
406 want them grouped even though the executables are different,
407 so we need to set a consistent ID between them. */
408 if (set_user_model)
409 set_user_model (L"GNU.Emacs");
410
411 FreeLibrary (shell);
412 }
413}
414 390
415int 391int
416w32_window_app (void) 392w32_window_app (void)
@@ -1415,10 +1391,37 @@ set_socket (int no_exit_if_error)
1415 exit (EXIT_FAILURE); 1391 exit (EXIT_FAILURE);
1416} 1392}
1417 1393
1418#ifdef WINDOWSNT 1394#ifdef HAVE_NTGUI
1419FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */ 1395FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */
1420FARPROC get_wc; /* Pointer to RealGetWindowClassA. */ 1396FARPROC get_wc; /* Pointer to RealGetWindowClassA. */
1421 1397
1398void
1399w32_set_user_model_id (void)
1400{
1401 HMODULE shell;
1402 HRESULT (WINAPI * set_user_model) (wchar_t * id);
1403
1404 /* On Windows 7 and later, we need to set the user model ID
1405 to associate emacsclient launched files with Emacs frames
1406 in the UI. */
1407 shell = LoadLibrary ("shell32.dll");
1408 if (shell)
1409 {
1410 set_user_model
1411 = (void *) GetProcAddress (shell,
1412 "SetCurrentProcessExplicitAppUserModelID");
1413 /* If the function is defined, then we are running on Windows 7
1414 or newer, and the UI uses this to group related windows
1415 together. Since emacs, runemacs, emacsclient are related, we
1416 want them grouped even though the executables are different,
1417 so we need to set a consistent ID between them. */
1418 if (set_user_model)
1419 set_user_model (L"GNU.Emacs");
1420
1421 FreeLibrary (shell);
1422 }
1423}
1424
1422BOOL CALLBACK 1425BOOL CALLBACK
1423w32_find_emacs_process (HWND hWnd, LPARAM lParam) 1426w32_find_emacs_process (HWND hWnd, LPARAM lParam)
1424{ 1427{
@@ -1467,7 +1470,7 @@ w32_give_focus (void)
1467 && (get_wc = GetProcAddress (user32, "RealGetWindowClassA"))) 1470 && (get_wc = GetProcAddress (user32, "RealGetWindowClassA")))
1468 EnumWindows (w32_find_emacs_process, (LPARAM) 0); 1471 EnumWindows (w32_find_emacs_process, (LPARAM) 0);
1469} 1472}
1470#endif 1473#endif /* HAVE_NTGUI */
1471 1474
1472/* Start the emacs daemon and try to connect to it. */ 1475/* Start the emacs daemon and try to connect to it. */
1473 1476
@@ -1537,11 +1540,11 @@ main (int argc, char **argv)
1537 main_argv = argv; 1540 main_argv = argv;
1538 progname = argv[0]; 1541 progname = argv[0];
1539 1542
1540#ifdef WINDOWSNT 1543#ifdef HAVE_NTGUI
1541 /* On Windows 7 and later, we need to explicitly associate emacsclient 1544 /* On Windows 7 and later, we need to explicitly associate emacsclient
1542 with emacs so the UI behaves sensibly. */ 1545 with emacs so the UI behaves sensibly. */
1543 w32_set_user_model_id (); 1546 w32_set_user_model_id ();
1544#endif 1547#endif /* HAVE_NTGUI */
1545 1548
1546 /* Process options. */ 1549 /* Process options. */
1547 decode_options (argc, argv); 1550 decode_options (argc, argv);
@@ -1577,9 +1580,9 @@ main (int argc, char **argv)
1577 fail (); 1580 fail ();
1578 } 1581 }
1579 1582
1580#ifdef WINDOWSNT 1583#ifdef HAVE_NTGUI
1581 w32_give_focus (); 1584 w32_give_focus ();
1582#endif 1585#endif /* HAVE_NTGUI */
1583 1586
1584 /* Send over our environment and current directory. */ 1587 /* Send over our environment and current directory. */
1585 if (!current_frame) 1588 if (!current_frame)