From 309ddbf08e9a31ca16c2e2acf57181481d5adbcc Mon Sep 17 00:00:00 2001 From: stax76 Date: Fri, 8 Apr 2022 19:16:18 +0200 Subject: [PATCH] Fix #398 keyboard layout change not working --- docs/Changelog.md | 6 ++++-- src/Misc/CorePlayer.cs | 15 --------------- src/Misc/MainForm.cs | 3 +++ src/Native/Native.cs | 3 +++ 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 20bd93d..3805dc3 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,9 +1,11 @@ +- Fix keyboard layout change not working. + 5.8.0.0 Beta (2022-04-02) - Fix crash on Windows 7 systems without PowerShell. - Fix showing incorrect timestamps in About dialog of Store version. -- Fix Store page showing non existant ARM and x86 support. +- Fix Store page showing non-existent ARM and x86 support. - Fix opening zip files. - The list of available input commands is like before shown by the text editor, so it's like everything else searchable. @@ -18,7 +20,7 @@ - Workaround not reproducible logo drawing crash. - Info command shows the length. - New mpv.net specific option `show-logo` that allows to disable - the drawing of the blue mpv.net logo ontop of the native OSC logo. + the drawing of the blue mpv.net logo on top of the native OSC logo. - MediaInfo 22.03 diff --git a/src/Misc/CorePlayer.cs b/src/Misc/CorePlayer.cs index 134b10e..133c2a0 100644 --- a/src/Misc/CorePlayer.cs +++ b/src/Misc/CorePlayer.cs @@ -413,23 +413,8 @@ KP1 script-binding delete_current_file/confirm mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event)); if (WindowHandle == IntPtr.Zero) - { WindowHandle = Native.FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null); - if (WindowHandle != IntPtr.Zero) - { - int GWL_STYLE = -16; - - uint WS_CHILD = 0x40000000; - uint WS_CLIPSIBLINGS = 0x04000000; - uint WS_DISABLED = 0x08000000; - uint WS_VISIBLE = 0x10000000; - - Native.SetWindowLong(WindowHandle, GWL_STYLE, - WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS); - } - } - try { switch (evt.event_id) diff --git a/src/Misc/MainForm.cs b/src/Misc/MainForm.cs index 12d662b..9b138b3 100644 --- a/src/Misc/MainForm.cs +++ b/src/Misc/MainForm.cs @@ -815,6 +815,9 @@ namespace mpvnet if (Core.WindowHandle != IntPtr.Zero) m.Result = SendMessage(Core.WindowHandle, m.Msg, m.WParam, m.LParam); break; + case 0x051: // WM_INPUTLANGCHANGE + ActivateKeyboardLayout(m.LParam, 0x00000100u /*KLF_SETFORPROCESS*/); + break; case 0x319: // WM_APPCOMMAND { string value = Input.WM_APPCOMMAND_to_mpv_key((int)(m.LParam.ToInt64() >> 16 & ~0xf000)); diff --git a/src/Native/Native.cs b/src/Native/Native.cs index 13d4bd3..df545fb 100644 --- a/src/Native/Native.cs +++ b/src/Native/Native.cs @@ -18,6 +18,9 @@ namespace mpvnet [DllImport("kernel32.dll")] public static extern IntPtr LoadLibrary(string path); + [DllImport("user32.dll")] + public static extern uint ActivateKeyboardLayout(IntPtr hkl, uint flags); + [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindowEx( IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);