diff options
| author | Kenichi Handa | 2012-10-11 20:29:47 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2012-10-11 20:29:47 +0900 |
| commit | d3e4228575e9ba9e99dc4a7dae788280ffcc4566 (patch) | |
| tree | 97d35f3c0766372c166a31f3c0f7aba791a38dde /lib-src | |
| parent | cde44a7728488ca6bc6a46c18d9c5e647b160547 (diff) | |
| parent | fd2f90cf5c6a15610aa1e17e73d6d8a5f8cb1999 (diff) | |
| download | emacs-d3e4228575e9ba9e99dc4a7dae788280ffcc4566.tar.gz emacs-d3e4228575e9ba9e99dc4a7dae788280ffcc4566.zip | |
merge trunk
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 17 | ||||
| -rw-r--r-- | lib-src/emacsclient.c | 198 | ||||
| -rw-r--r-- | lib-src/makefile.w32-in | 2 |
3 files changed, 133 insertions, 84 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 2a8ac9b8131..85351d7f08d 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,20 @@ | |||
| 1 | 2012-10-08 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * makefile.w32-in (obj): Add cygw32.o. | ||
| 4 | |||
| 5 | 2012-10-08 Daniel Colascione <dancol@dancol.org> | ||
| 6 | |||
| 7 | * emacsclient.c: Include windows.h when HAVE_NTGUI. | ||
| 8 | (alt_display): New variable. We send the display held by this | ||
| 9 | variable when the primary display is either unsupported or not | ||
| 10 | present. | ||
| 11 | (longopts): Allow display everywhere. | ||
| 12 | (w32_set_user_model_id): Move lower in file, inside HAVE_NTGUI | ||
| 13 | section. | ||
| 14 | (decode_options): Use alt_display. Explain why. | ||
| 15 | (main): Retry connection with alt_display if connection with main | ||
| 16 | display fails. | ||
| 17 | |||
| 1 | 2012-10-01 Fabrice Popineau <fabrice.popineau@gmail.com> | 18 | 2012-10-01 Fabrice Popineau <fabrice.popineau@gmail.com> |
| 2 | 19 | ||
| 3 | * make-docfile.c (write_globals): Special-case | 20 | * make-docfile.c (write_globals): Special-case |
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 07300dbf249..8d60d7961da 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 |
| @@ -140,6 +144,9 @@ int current_frame = 1; | |||
| 140 | /* The display on which Emacs should work. --display. */ | 144 | /* The display on which Emacs should work. --display. */ |
| 141 | const char *display = NULL; | 145 | const char *display = NULL; |
| 142 | 146 | ||
| 147 | /* The alternate display we should try if Emacs does not support display. */ | ||
| 148 | const char *alt_display = NULL; | ||
| 149 | |||
| 143 | /* The parent window ID, if we are opening a frame via XEmbed. */ | 150 | /* The parent window ID, if we are opening a frame via XEmbed. */ |
| 144 | char *parent_id = NULL; | 151 | char *parent_id = NULL; |
| 145 | 152 | ||
| @@ -182,9 +189,7 @@ struct option longopts[] = | |||
| 182 | { "socket-name", required_argument, NULL, 's' }, | 189 | { "socket-name", required_argument, NULL, 's' }, |
| 183 | #endif | 190 | #endif |
| 184 | { "server-file", required_argument, NULL, 'f' }, | 191 | { "server-file", required_argument, NULL, 'f' }, |
| 185 | #ifndef WINDOWSNT | ||
| 186 | { "display", required_argument, NULL, 'd' }, | 192 | { "display", required_argument, NULL, 'd' }, |
| 187 | #endif | ||
| 188 | { "parent-id", required_argument, NULL, 'p' }, | 193 | { "parent-id", required_argument, NULL, 'p' }, |
| 189 | { 0, 0, 0, 0 } | 194 | { 0, 0, 0, 0 } |
| 190 | }; | 195 | }; |
| @@ -385,32 +390,6 @@ w32_getenv (char *envvar) | |||
| 385 | return NULL; | 390 | return NULL; |
| 386 | } | 391 | } |
| 387 | 392 | ||
| 388 | void | ||
| 389 | w32_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 | 393 | ||
| 415 | int | 394 | int |
| 416 | w32_window_app (void) | 395 | w32_window_app (void) |
| @@ -605,16 +584,29 @@ decode_options (int argc, char **argv) | |||
| 605 | Without the -c option, we used to set `display' to $DISPLAY by | 584 | Without the -c option, we used to set `display' to $DISPLAY by |
| 606 | default, but this changed the default behavior and is sometimes | 585 | default, but this changed the default behavior and is sometimes |
| 607 | inconvenient. So we force users to use "--display $DISPLAY" if | 586 | inconvenient. So we force users to use "--display $DISPLAY" if |
| 608 | they want Emacs to connect to their current display. */ | 587 | they want Emacs to connect to their current display. |
| 588 | |||
| 589 | Some window systems have a notion of default display not | ||
| 590 | reflected in the DISPLAY variable. If the user didn't give us an | ||
| 591 | explicit display, try this platform-specific after trying the | ||
| 592 | display in DISPLAY (if any). */ | ||
| 609 | if (!current_frame && !tty && !display) | 593 | if (!current_frame && !tty && !display) |
| 610 | { | 594 | { |
| 611 | display = egetenv ("DISPLAY"); | 595 | /* Set these here so we use a default_display only when the user |
| 612 | #ifdef NS_IMPL_COCOA | 596 | didn't give us an explicit display. */ |
| 613 | /* Under Cocoa, we don't really use displays the same way as in X, | 597 | #if defined (NS_IMPL_COCOA) |
| 614 | so provide a dummy. */ | 598 | alt_display = "ns"; |
| 615 | if (!display || strlen (display) == 0) | 599 | #elif defined (HAVE_NTGUI) |
| 616 | display = "ns"; | 600 | alt_display = "w32"; |
| 617 | #endif | 601 | #endif |
| 602 | |||
| 603 | display = egetenv ("DISPLAY"); | ||
| 604 | } | ||
| 605 | |||
| 606 | if (!display) | ||
| 607 | { | ||
| 608 | display = alt_display; | ||
| 609 | alt_display = NULL; | ||
| 618 | } | 610 | } |
| 619 | 611 | ||
| 620 | /* A null-string display is invalid. */ | 612 | /* A null-string display is invalid. */ |
| @@ -1415,10 +1407,37 @@ set_socket (int no_exit_if_error) | |||
| 1415 | exit (EXIT_FAILURE); | 1407 | exit (EXIT_FAILURE); |
| 1416 | } | 1408 | } |
| 1417 | 1409 | ||
| 1418 | #ifdef WINDOWSNT | 1410 | #ifdef HAVE_NTGUI |
| 1419 | FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */ | 1411 | FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */ |
| 1420 | FARPROC get_wc; /* Pointer to RealGetWindowClassA. */ | 1412 | FARPROC get_wc; /* Pointer to RealGetWindowClassA. */ |
| 1421 | 1413 | ||
| 1414 | void | ||
| 1415 | w32_set_user_model_id (void) | ||
| 1416 | { | ||
| 1417 | HMODULE shell; | ||
| 1418 | HRESULT (WINAPI * set_user_model) (wchar_t * id); | ||
| 1419 | |||
| 1420 | /* On Windows 7 and later, we need to set the user model ID | ||
| 1421 | to associate emacsclient launched files with Emacs frames | ||
| 1422 | in the UI. */ | ||
| 1423 | shell = LoadLibrary ("shell32.dll"); | ||
| 1424 | if (shell) | ||
| 1425 | { | ||
| 1426 | set_user_model | ||
| 1427 | = (void *) GetProcAddress (shell, | ||
| 1428 | "SetCurrentProcessExplicitAppUserModelID"); | ||
| 1429 | /* If the function is defined, then we are running on Windows 7 | ||
| 1430 | or newer, and the UI uses this to group related windows | ||
| 1431 | together. Since emacs, runemacs, emacsclient are related, we | ||
| 1432 | want them grouped even though the executables are different, | ||
| 1433 | so we need to set a consistent ID between them. */ | ||
| 1434 | if (set_user_model) | ||
| 1435 | set_user_model (L"GNU.Emacs"); | ||
| 1436 | |||
| 1437 | FreeLibrary (shell); | ||
| 1438 | } | ||
| 1439 | } | ||
| 1440 | |||
| 1422 | BOOL CALLBACK | 1441 | BOOL CALLBACK |
| 1423 | w32_find_emacs_process (HWND hWnd, LPARAM lParam) | 1442 | w32_find_emacs_process (HWND hWnd, LPARAM lParam) |
| 1424 | { | 1443 | { |
| @@ -1467,7 +1486,7 @@ w32_give_focus (void) | |||
| 1467 | && (get_wc = GetProcAddress (user32, "RealGetWindowClassA"))) | 1486 | && (get_wc = GetProcAddress (user32, "RealGetWindowClassA"))) |
| 1468 | EnumWindows (w32_find_emacs_process, (LPARAM) 0); | 1487 | EnumWindows (w32_find_emacs_process, (LPARAM) 0); |
| 1469 | } | 1488 | } |
| 1470 | #endif | 1489 | #endif /* HAVE_NTGUI */ |
| 1471 | 1490 | ||
| 1472 | /* Start the emacs daemon and try to connect to it. */ | 1491 | /* Start the emacs daemon and try to connect to it. */ |
| 1473 | 1492 | ||
| @@ -1537,11 +1556,13 @@ main (int argc, char **argv) | |||
| 1537 | main_argv = argv; | 1556 | main_argv = argv; |
| 1538 | progname = argv[0]; | 1557 | progname = argv[0]; |
| 1539 | 1558 | ||
| 1540 | #ifdef WINDOWSNT | 1559 | #ifdef HAVE_NTGUI |
| 1541 | /* On Windows 7 and later, we need to explicitly associate emacsclient | 1560 | /* On Windows 7 and later, we need to explicitly associate |
| 1542 | with emacs so the UI behaves sensibly. */ | 1561 | emacsclient with emacs so the UI behaves sensibly. This |
| 1562 | association does no harm if we're not actually connecting to an | ||
| 1563 | Emacs using a window display. */ | ||
| 1543 | w32_set_user_model_id (); | 1564 | w32_set_user_model_id (); |
| 1544 | #endif | 1565 | #endif /* HAVE_NTGUI */ |
| 1545 | 1566 | ||
| 1546 | /* Process options. */ | 1567 | /* Process options. */ |
| 1547 | decode_options (argc, argv); | 1568 | decode_options (argc, argv); |
| @@ -1577,9 +1598,10 @@ main (int argc, char **argv) | |||
| 1577 | fail (); | 1598 | fail (); |
| 1578 | } | 1599 | } |
| 1579 | 1600 | ||
| 1580 | #ifdef WINDOWSNT | 1601 | #ifdef HAVE_NTGUI |
| 1602 | if (display && !strcmp (display, "w32")) | ||
| 1581 | w32_give_focus (); | 1603 | w32_give_focus (); |
| 1582 | #endif | 1604 | #endif /* HAVE_NTGUI */ |
| 1583 | 1605 | ||
| 1584 | /* Send over our environment and current directory. */ | 1606 | /* Send over our environment and current directory. */ |
| 1585 | if (!current_frame) | 1607 | if (!current_frame) |
| @@ -1748,46 +1770,56 @@ main (int argc, char **argv) | |||
| 1748 | if (end_p != NULL) | 1770 | if (end_p != NULL) |
| 1749 | *end_p++ = '\0'; | 1771 | *end_p++ = '\0'; |
| 1750 | 1772 | ||
| 1751 | if (strprefix ("-emacs-pid ", p)) | 1773 | if (strprefix ("-emacs-pid ", p)) |
| 1752 | { | 1774 | { |
| 1753 | /* -emacs-pid PID: The process id of the Emacs process. */ | 1775 | /* -emacs-pid PID: The process id of the Emacs process. */ |
| 1754 | emacs_pid = strtol (p + strlen ("-emacs-pid"), NULL, 10); | 1776 | emacs_pid = strtol (p + strlen ("-emacs-pid"), NULL, 10); |
| 1755 | } | 1777 | } |
| 1756 | else if (strprefix ("-window-system-unsupported ", p)) | 1778 | else if (strprefix ("-window-system-unsupported ", p)) |
| 1757 | { | 1779 | { |
| 1758 | /* -window-system-unsupported: Emacs was compiled without X | 1780 | /* -window-system-unsupported: Emacs was compiled without support |
| 1759 | support. Try again on the terminal. */ | 1781 | for whatever window system we tried. Try the alternate |
| 1760 | nowait = 0; | 1782 | display, or, failing that, try the terminal. */ |
| 1761 | tty = 1; | 1783 | if (alt_display) |
| 1762 | goto retry; | 1784 | { |
| 1763 | } | 1785 | display = alt_display; |
| 1764 | else if (strprefix ("-print ", p)) | 1786 | alt_display = NULL; |
| 1765 | { | 1787 | } |
| 1766 | /* -print STRING: Print STRING on the terminal. */ | 1788 | else |
| 1767 | str = unquote_argument (p + strlen ("-print ")); | 1789 | { |
| 1768 | if (needlf) | 1790 | nowait = 0; |
| 1769 | printf ("\n"); | 1791 | tty = 1; |
| 1770 | printf ("%s", str); | 1792 | } |
| 1771 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; | 1793 | |
| 1772 | } | 1794 | goto retry; |
| 1773 | else if (strprefix ("-print-nonl ", p)) | 1795 | } |
| 1774 | { | 1796 | else if (strprefix ("-print ", p)) |
| 1775 | /* -print-nonl STRING: Print STRING on the terminal. | 1797 | { |
| 1776 | Used to continue a preceding -print command. */ | 1798 | /* -print STRING: Print STRING on the terminal. */ |
| 1777 | str = unquote_argument (p + strlen ("-print-nonl ")); | 1799 | str = unquote_argument (p + strlen ("-print ")); |
| 1778 | printf ("%s", str); | 1800 | if (needlf) |
| 1779 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; | 1801 | printf ("\n"); |
| 1780 | } | 1802 | printf ("%s", str); |
| 1781 | else if (strprefix ("-error ", p)) | 1803 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; |
| 1782 | { | 1804 | } |
| 1783 | /* -error DESCRIPTION: Signal an error on the terminal. */ | 1805 | else if (strprefix ("-print-nonl ", p)) |
| 1784 | str = unquote_argument (p + strlen ("-error ")); | 1806 | { |
| 1785 | if (needlf) | 1807 | /* -print-nonl STRING: Print STRING on the terminal. |
| 1786 | printf ("\n"); | 1808 | Used to continue a preceding -print command. */ |
| 1787 | fprintf (stderr, "*ERROR*: %s", str); | 1809 | str = unquote_argument (p + strlen ("-print-nonl ")); |
| 1788 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; | 1810 | printf ("%s", str); |
| 1789 | exit_status = EXIT_FAILURE; | 1811 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; |
| 1790 | } | 1812 | } |
| 1813 | else if (strprefix ("-error ", p)) | ||
| 1814 | { | ||
| 1815 | /* -error DESCRIPTION: Signal an error on the terminal. */ | ||
| 1816 | str = unquote_argument (p + strlen ("-error ")); | ||
| 1817 | if (needlf) | ||
| 1818 | printf ("\n"); | ||
| 1819 | fprintf (stderr, "*ERROR*: %s", str); | ||
| 1820 | needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; | ||
| 1821 | exit_status = EXIT_FAILURE; | ||
| 1822 | } | ||
| 1791 | #ifdef SIGSTOP | 1823 | #ifdef SIGSTOP |
| 1792 | else if (strprefix ("-suspend ", p)) | 1824 | else if (strprefix ("-suspend ", p)) |
| 1793 | { | 1825 | { |
diff --git a/lib-src/makefile.w32-in b/lib-src/makefile.w32-in index 23ef71de10c..ecc5fb866b3 100644 --- a/lib-src/makefile.w32-in +++ b/lib-src/makefile.w32-in | |||
| @@ -124,7 +124,7 @@ $(BLD)/profile.exe: $(PROFILEOBJS) | |||
| 124 | obj = dosfns.o msdos.o \ | 124 | obj = dosfns.o msdos.o \ |
| 125 | xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \ | 125 | xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \ |
| 126 | fontset.o menu.o \ | 126 | fontset.o menu.o \ |
| 127 | w32.o w32console.o w32fns.o w32heap.o w32inevt.o \ | 127 | w32.o w32console.o w32fns.o w32heap.o w32inevt.o cygw32.o \ |
| 128 | w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \ | 128 | w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \ |
| 129 | font.o w32font.o w32uniscribe.o \ | 129 | font.o w32font.o w32uniscribe.o \ |
| 130 | dispnew.o frame.o scroll.o xdisp.o window.o bidi.o \ | 130 | dispnew.o frame.o scroll.o xdisp.o window.o bidi.o \ |