aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib-src/ChangeLog7
-rw-r--r--lib-src/emacsclient.c46
-rw-r--r--nt/ChangeLog5
-rw-r--r--nt/runemacs.c31
-rw-r--r--src/ChangeLog6
-rw-r--r--src/w32term.c28
6 files changed, 113 insertions, 10 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 590af7692ef..4969b93734d 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,10 @@
12009-06-30 Jason Rumney <jasonr@gnu.org>
2
3 * emacsclient.c (w32_give_focus): Use GetModuleHandle for library
4 that is already loaded.
5 (w32_set_user_model_id): New function.
6 (main): Use it to associate emacsclient with emacs (bug#1849).
7
12009-06-29 Jim Meyering <meyering@redhat.com> 82009-06-29 Jim Meyering <meyering@redhat.com>
2 9
3 Remove useless if-before-free test. 10 Remove useless if-before-free test.
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index a451c1b9ba4..5e6db54a902 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -392,6 +392,33 @@ w32_getenv (envvar)
392 return NULL; 392 return NULL;
393} 393}
394 394
395void
396w32_set_user_model_id ()
397{
398 HMODULE shell;
399 HRESULT (WINAPI * set_user_model) (PWCSTR);
400
401 /* On Windows 7 and later, we need to set the user model ID
402 to associate emacsclient launched files with Emacs frames
403 in the UI. */
404 shell = LoadLibrary("shell32.dll");
405 if (shell)
406 {
407 set_user_model
408 = (void *) GetProcAddress (shell,
409 "SetCurrentProcessExplicitAppUserModelID");
410 /* If the function is defined, then we are running on Windows 7
411 or newer, and the UI uses this to group related windows
412 together. Since emacs, runemacs, emacsclient are related, we
413 want them grouped even though the executables are different,
414 so we need to set a consistent ID between them. */
415 if (set_user_model)
416 set_user_model (L"GNU.Emacs");
417
418 FreeLibrary (shell);
419 }
420}
421
395int 422int
396w32_window_app () 423w32_window_app ()
397{ 424{
@@ -1415,22 +1442,23 @@ w32_find_emacs_process (hWnd, lParam)
1415void 1442void
1416w32_give_focus () 1443w32_give_focus ()
1417{ 1444{
1418 HMODULE hUser32; 1445 HANDLE user32;
1419 1446
1420 /* It shouldn't happen when dealing with TCP sockets. */ 1447 /* It shouldn't happen when dealing with TCP sockets. */
1421 if (!emacs_pid) return; 1448 if (!emacs_pid) return;
1422 1449
1423 if (!(hUser32 = LoadLibrary ("user32.dll"))) return; 1450 user32 = GetModuleHandle ("user32.dll");
1451
1452 if (!user32)
1453 return;
1424 1454
1425 /* Modern Windows restrict which processes can set the foreground window. 1455 /* Modern Windows restrict which processes can set the foreground window.
1426 emacsclient can allow Emacs to grab the focus by calling the function 1456 emacsclient can allow Emacs to grab the focus by calling the function
1427 AllowSetForegroundWindow. Unfortunately, older Windows (W95, W98 and 1457 AllowSetForegroundWindow. Unfortunately, older Windows (W95, W98 and
1428 NT) lack this function, so we have to check its availability. */ 1458 NT) lack this function, so we have to check its availability. */
1429 if ((set_fg = GetProcAddress (hUser32, "AllowSetForegroundWindow")) 1459 if ((set_fg = GetProcAddress (user32, "AllowSetForegroundWindow"))
1430 && (get_wc = GetProcAddress (hUser32, "RealGetWindowClassA"))) 1460 && (get_wc = GetProcAddress (user32, "RealGetWindowClassA")))
1431 EnumWindows (w32_find_emacs_process, (LPARAM) 0); 1461 EnumWindows (w32_find_emacs_process, (LPARAM) 0);
1432
1433 FreeLibrary (hUser32);
1434} 1462}
1435#endif 1463#endif
1436 1464
@@ -1501,6 +1529,12 @@ main (argc, argv)
1501 main_argv = argv; 1529 main_argv = argv;
1502 progname = argv[0]; 1530 progname = argv[0];
1503 1531
1532#ifdef WINDOWSNT
1533 /* On Windows 7 and later, we need to explicitly associate emacsclient
1534 with emacs so the UI behaves sensibly. */
1535 w32_set_user_model_id ();
1536#endif
1537
1504 /* Process options. */ 1538 /* Process options. */
1505 decode_options (argc, argv); 1539 decode_options (argc, argv);
1506 1540
diff --git a/nt/ChangeLog b/nt/ChangeLog
index d8f9685587c..e4c95671aff 100644
--- a/nt/ChangeLog
+++ b/nt/ChangeLog
@@ -1,3 +1,8 @@
12009-06-30 Jason Rumney <jasonr@gnu.org>
2
3 * runemacs.c (set_user_model_id): New function.
4 (WinMain): Use it.
5
12009-06-21 Chong Yidong <cyd@stupidchicken.com> 62009-06-21 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * Branch for 23.1. 8 * Branch for 23.1.
diff --git a/nt/runemacs.c b/nt/runemacs.c
index 55a520f7bc7..aba1d439957 100644
--- a/nt/runemacs.c
+++ b/nt/runemacs.c
@@ -43,6 +43,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
43#include <string.h> 43#include <string.h>
44#include <malloc.h> 44#include <malloc.h>
45 45
46static void set_user_model_id ();
47
46int WINAPI 48int WINAPI
47WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow) 49WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
48{ 50{
@@ -56,6 +58,8 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
56 char *p; 58 char *p;
57 char modname[MAX_PATH]; 59 char modname[MAX_PATH];
58 60
61 set_user_model_id ();
62
59 if (!GetModuleFileName (NULL, modname, MAX_PATH)) 63 if (!GetModuleFileName (NULL, modname, MAX_PATH))
60 goto error; 64 goto error;
61 if ((p = strrchr (modname, '\\')) == NULL) 65 if ((p = strrchr (modname, '\\')) == NULL)
@@ -170,5 +174,32 @@ error:
170 return 1; 174 return 1;
171} 175}
172 176
177void set_user_model_id ()
178{
179 HMODULE shell;
180 HRESULT (WINAPI * set_user_model) (PCWSTR);
181
182 /* On Windows 7 and later, we need to set the user model ID
183 to associate emacsclient launched files with Emacs frames
184 in the UI. */
185 shell = LoadLibrary ("shell32.dll");
186 if (shell)
187 {
188 set_user_model
189 = (void *) GetProcAddress (shell,
190 "SetCurrentProcessExplicitAppUserModelID");
191
192 /* If the function is defined, then we are running on Windows 7
193 or newer, and the UI uses this to group related windows
194 together. Since emacs, runemacs, emacsclient are related, we
195 want them grouped even though the executables are different,
196 so we need to set a consistent ID between them. */
197 if (set_user_model)
198 set_user_model (L"GNU.Emacs");
199
200 FreeLibrary (shell);
201 }
202}
203
173/* arch-tag: 7e02df73-4df7-4aa0-baea-99c6d047a384 204/* arch-tag: 7e02df73-4df7-4aa0-baea-99c6d047a384
174 (do not change this comment) */ 205 (do not change this comment) */
diff --git a/src/ChangeLog b/src/ChangeLog
index dcf58c7f631..b06bf4fac8c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12009-06-30 Jason Rumney <jasonr@gnu.org>
2
3 * w32term.c (w32_initialize): Use GetModuleHandle for library that
4 is already loaded.
5 Set user model ID if supported (bug#1849).
6
12009-06-29 Jim Meyering <meyering@redhat.com> 72009-06-29 Jim Meyering <meyering@redhat.com>
2 8
3 Remove useless if-before-xfree test. 9 Remove useless if-before-xfree test.
diff --git a/src/w32term.c b/src/w32term.c
index 209e86edc8b..c3cfc341169 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -138,7 +138,7 @@ typedef struct tagGLYPHSET
138#endif 138#endif
139 139
140/* Dynamic linking to SetLayeredWindowAttribute (only since 2000). */ 140/* Dynamic linking to SetLayeredWindowAttribute (only since 2000). */
141BOOL (PASCAL *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD); 141BOOL (WINAPI *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
142 142
143#ifndef LWA_ALPHA 143#ifndef LWA_ALPHA
144#define LWA_ALPHA 0x02 144#define LWA_ALPHA 0x02
@@ -6340,6 +6340,9 @@ DWORD WINAPI w32_msg_worker (void * arg);
6340static void 6340static void
6341w32_initialize () 6341w32_initialize ()
6342{ 6342{
6343 HANDLE shell;
6344 HRESULT (WINAPI * set_user_model) (PCWSTR);
6345
6343 baud_rate = 19200; 6346 baud_rate = 19200;
6344 6347
6345 w32_system_caret_hwnd = NULL; 6348 w32_system_caret_hwnd = NULL;
@@ -6347,6 +6350,25 @@ w32_initialize ()
6347 w32_system_caret_x = 0; 6350 w32_system_caret_x = 0;
6348 w32_system_caret_y = 0; 6351 w32_system_caret_y = 0;
6349 6352
6353 /* On Windows 7 and later, we need to set the user model ID
6354 to associate emacsclient launched files with Emacs frames
6355 in the UI. */
6356 shell = GetModuleHandle ("shell32.dll");
6357 if (shell)
6358 {
6359 set_user_model
6360 = (void *) GetProcAddress (shell,
6361 "SetCurrentProcessExplicitAppUserModelID");
6362
6363 /* If the function is defined, then we are running on Windows 7
6364 or newer, and the UI uses this to group related windows
6365 together. Since emacs, runemacs, emacsclient are related, we
6366 want them grouped even though the executables are different,
6367 so we need to set a consistent ID between them. */
6368 if (set_user_model)
6369 set_user_model (L"GNU.Emacs");
6370 }
6371
6350 /* Initialize w32_use_visible_system_caret based on whether a screen 6372 /* Initialize w32_use_visible_system_caret based on whether a screen
6351 reader is in use. */ 6373 reader is in use. */
6352 if (!SystemParametersInfo (SPI_GETSCREENREADER, 0, 6374 if (!SystemParametersInfo (SPI_GETSCREENREADER, 0,
@@ -6400,7 +6422,7 @@ w32_initialize ()
6400 6422
6401 /* Dynamically link to optional system components. */ 6423 /* Dynamically link to optional system components. */
6402 { 6424 {
6403 HANDLE user_lib = LoadLibrary ("user32.dll"); 6425 HMODULE user_lib = GetModuleHandle ("user32.dll");
6404 6426
6405#define LOAD_PROC(lib, fn) pfn##fn = (void *) GetProcAddress (lib, #fn) 6427#define LOAD_PROC(lib, fn) pfn##fn = (void *) GetProcAddress (lib, #fn)
6406 6428
@@ -6408,8 +6430,6 @@ w32_initialize ()
6408 6430
6409#undef LOAD_PROC 6431#undef LOAD_PROC
6410 6432
6411 FreeLibrary (user_lib);
6412
6413 /* Ensure scrollbar handle is at least 5 pixels. */ 6433 /* Ensure scrollbar handle is at least 5 pixels. */
6414 vertical_scroll_bar_min_handle = 5; 6434 vertical_scroll_bar_min_handle = 5;
6415 6435