aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/out
diff options
context:
space:
mode:
authorGravatar pavelxdd <pavel.otchertsov@gmail.com>2017-11-15 04:50:00 +0300
committerGravatar James Ross-Gowan <rossy@jrg.systems>2017-11-15 22:54:54 +1100
commit35d74e1612be458173507db3fbee719aa7f42321 (patch)
treec290f17988c98736e6145980ab473a6d27ed9871 /video/out
parent3471e27efb8cd200857bbbe5e91ca623c518088f (diff)
w32_common: move imm32.dll function to w32->api struct
For consistency with already implemented shcore.dll function loading in w32->api: Moved loading of imm32.dll to w32_api_load, and declare pImmDisableIME function pointer in the w32->api struct. Removed unloading of imm32.dll.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/w32_common.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index b93a4fdaa6..6e15101093 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -64,6 +64,7 @@ typedef enum MONITOR_DPI_TYPE {
struct w32_api {
HRESULT (WINAPI *pGetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*);
+ BOOL (WINAPI *pImmDisableIME)(DWORD);
};
struct vo_w32_state {
@@ -1320,25 +1321,18 @@ void vo_w32_config(struct vo *vo)
mp_dispatch_run(w32->dispatch, gui_thread_reconfig, w32);
}
-static void thread_disable_ime(void)
-{
- // Disables the IME for windows on this thread. imm32.dll must be loaded
- // dynamically to account for machines without East Asian language support.
- HMODULE imm32 = LoadLibraryW(L"imm32.dll");
- if (!imm32)
- return;
- BOOL (WINAPI *pImmDisableIME)(DWORD) = (BOOL (WINAPI*)(DWORD))
- GetProcAddress(imm32, "ImmDisableIME");
- if (pImmDisableIME)
- pImmDisableIME(0);
- FreeLibrary(imm32);
-}
-
static void w32_api_load(struct vo_w32_state *w32)
{
HMODULE shcore_dll = LoadLibraryW(L"shcore.dll");
+ // Available since Win8.1
w32->api.pGetDpiForMonitor = !shcore_dll ? NULL :
(void *)GetProcAddress(shcore_dll, "GetDpiForMonitor");
+
+ // imm32.dll must be loaded dynamically
+ // to account for machines without East Asian language support
+ HMODULE imm32_dll = LoadLibraryW(L"imm32.dll");
+ w32->api.pImmDisableIME = !imm32_dll ? NULL :
+ (void *)GetProcAddress(imm32_dll, "ImmDisableIME");
}
static void *gui_thread(void *ptr)
@@ -1350,7 +1344,10 @@ static void *gui_thread(void *ptr)
mpthread_set_name("win32 window");
w32_api_load(w32);
- thread_disable_ime();
+
+ // Disables the IME for windows on this thread
+ if (w32->api.pImmDisableIME)
+ w32->api.pImmDisableIME(0);
if (w32->opts->WinID >= 0)
w32->parent = (HWND)(intptr_t)(w32->opts->WinID);