diff options
author | Jason Rumney <jasonr@gnu.org> | 2009-06-30 15:48:23 +0000 |
---|---|---|
committer | Jason Rumney <jasonr@gnu.org> | 2009-06-30 15:48:23 +0000 |
commit | ff90fbdecc6ffb1e34fe5ee9c1f080106c0739df (patch) | |
tree | 220a6ca0665b2ed33868247c02949704fa510335 /lib-src | |
parent | 974647ac913e1280e7142321a19e3b7eaabefc25 (diff) | |
download | emacs-ff90fbdecc6ffb1e34fe5ee9c1f080106c0739df.tar.gz emacs-ff90fbdecc6ffb1e34fe5ee9c1f080106c0739df.tar.bz2 emacs-ff90fbdecc6ffb1e34fe5ee9c1f080106c0739df.zip |
bug#1849 - Windows 7 Taskbar Support
* w32term.c (w32_initialize): Use GetModuleHandle for library that
is already loaded.
Set user model ID if supported (bug#1849).
* runemacs.c (set_user_model_id): New function.
(WinMain): Use it.
* emacsclient.c (w32_give_focus): Use GetModuleHandle for library
that is already loaded.
(w32_set_user_model_id): New function.
(main): Use it to associate emacsclient with emacs (bug#1849).
Diffstat (limited to 'lib-src')
-rw-r--r-- | lib-src/ChangeLog | 7 | ||||
-rw-r--r-- | lib-src/emacsclient.c | 46 |
2 files changed, 47 insertions, 6 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 @@ +2009-06-30 Jason Rumney <jasonr@gnu.org> + + * emacsclient.c (w32_give_focus): Use GetModuleHandle for library + that is already loaded. + (w32_set_user_model_id): New function. + (main): Use it to associate emacsclient with emacs (bug#1849). + 2009-06-29 Jim Meyering <meyering@redhat.com> 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) return NULL; } +void +w32_set_user_model_id () +{ + HMODULE shell; + HRESULT (WINAPI * set_user_model) (PWCSTR); + + /* On Windows 7 and later, we need to set the user model ID + to associate emacsclient launched files with Emacs frames + in the UI. */ + shell = LoadLibrary("shell32.dll"); + if (shell) + { + set_user_model + = (void *) GetProcAddress (shell, + "SetCurrentProcessExplicitAppUserModelID"); + /* If the function is defined, then we are running on Windows 7 + or newer, and the UI uses this to group related windows + together. Since emacs, runemacs, emacsclient are related, we + want them grouped even though the executables are different, + so we need to set a consistent ID between them. */ + if (set_user_model) + set_user_model (L"GNU.Emacs"); + + FreeLibrary (shell); + } +} + int w32_window_app () { @@ -1415,22 +1442,23 @@ w32_find_emacs_process (hWnd, lParam) void w32_give_focus () { - HMODULE hUser32; + HANDLE user32; /* It shouldn't happen when dealing with TCP sockets. */ if (!emacs_pid) return; - if (!(hUser32 = LoadLibrary ("user32.dll"))) return; + user32 = GetModuleHandle ("user32.dll"); + + if (!user32) + return; /* Modern Windows restrict which processes can set the foreground window. emacsclient can allow Emacs to grab the focus by calling the function AllowSetForegroundWindow. Unfortunately, older Windows (W95, W98 and NT) lack this function, so we have to check its availability. */ - if ((set_fg = GetProcAddress (hUser32, "AllowSetForegroundWindow")) - && (get_wc = GetProcAddress (hUser32, "RealGetWindowClassA"))) + if ((set_fg = GetProcAddress (user32, "AllowSetForegroundWindow")) + && (get_wc = GetProcAddress (user32, "RealGetWindowClassA"))) EnumWindows (w32_find_emacs_process, (LPARAM) 0); - - FreeLibrary (hUser32); } #endif @@ -1501,6 +1529,12 @@ main (argc, argv) main_argv = argv; progname = argv[0]; +#ifdef WINDOWSNT + /* On Windows 7 and later, we need to explicitly associate emacsclient + with emacs so the UI behaves sensibly. */ + w32_set_user_model_id (); +#endif + /* Process options. */ decode_options (argc, argv); |