summaryrefslogtreecommitdiff
path: root/src/w32term.c
diff options
context:
space:
mode:
authorJason Rumney <jasonr@gnu.org>2009-06-30 15:48:23 +0000
committerJason Rumney <jasonr@gnu.org>2009-06-30 15:48:23 +0000
commit2c7b6eb6d60875f4c2af3bd59c77a3a437f24847 (patch)
treeed46da6c6463e4076a100cc99c421f573e15c30c /src/w32term.c
parentc69d6a8d54d75d316549ad734ad8cdb148052624 (diff)
downloademacs-2c7b6eb6d60875f4c2af3bd59c77a3a437f24847.tar.gz
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 'src/w32term.c')
-rw-r--r--src/w32term.c28
1 files changed, 24 insertions, 4 deletions
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
#endif
/* Dynamic linking to SetLayeredWindowAttribute (only since 2000). */
-BOOL (PASCAL *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
+BOOL (WINAPI *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
#ifndef LWA_ALPHA
#define LWA_ALPHA 0x02
@@ -6340,6 +6340,9 @@ DWORD WINAPI w32_msg_worker (void * arg);
static void
w32_initialize ()
{
+ HANDLE shell;
+ HRESULT (WINAPI * set_user_model) (PCWSTR);
+
baud_rate = 19200;
w32_system_caret_hwnd = NULL;
@@ -6347,6 +6350,25 @@ w32_initialize ()
w32_system_caret_x = 0;
w32_system_caret_y = 0;
+ /* 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 = GetModuleHandle ("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");
+ }
+
/* Initialize w32_use_visible_system_caret based on whether a screen
reader is in use. */
if (!SystemParametersInfo (SPI_GETSCREENREADER, 0,
@@ -6400,7 +6422,7 @@ w32_initialize ()
/* Dynamically link to optional system components. */
{
- HANDLE user_lib = LoadLibrary ("user32.dll");
+ HMODULE user_lib = GetModuleHandle ("user32.dll");
#define LOAD_PROC(lib, fn) pfn##fn = (void *) GetProcAddress (lib, #fn)
@@ -6408,8 +6430,6 @@ w32_initialize ()
#undef LOAD_PROC
- FreeLibrary (user_lib);
-
/* Ensure scrollbar handle is at least 5 pixels. */
vertical_scroll_bar_min_handle = 5;