vcl/win/window/salframe.cxx |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

New commits:
commit 724ba1e455d4ae47a00248586487443347f1be96
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Jul 25 09:50:08 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Jul 27 22:54:44 2023 +0200

    tdf#156459: fix WM_UNICHAR implementation
    
    It was implemented in commit c62f48790047014d7d718f949ef6298961100e6f
    (INTEGRATION: CWS vcl07 (1.89.2.5.20); FILE MERGED, 2003-04-11), but
    handling of non-BMP codepoints was done incorrectly: high surrogate
    was calculated, but not used; and SALEVENT_KEYINPUT / SALEVENT_KEYUP
    pair used a default value of the SalKeyEvent's mnCharCode. Then the
    unused variable, and the macro taking its value, were commented out
    in commit fd3e69a1c0d311515eb8db92dd1a72657b405a25 (INTEGRATION: CWS
    warnings01 (1.125.6); FILE MERGED, 2006-06-19).
    
    I have no idea if WM_UNICHAR is used in the wild, but *some* sources
    suggest that some third-party IMEs could use it [1]; so just fix it.
    
    [1] http://archives.miloush.net/michkap/archive/2012/05/21/10308135.html
    
    Change-Id: I58190afd9fe295e62cb08acaefd32e99c1f383bb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154996
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index d68178ea022f..25c2e2b3b281 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -3606,6 +3606,9 @@ static bool ImplHandleKeyMsg( HWND hWnd, UINT nMsg,
             return true;    // ...but this will only avoid calling the 
defwindowproc
         }
 
+        if (!rtl::isUnicodeCodePoint(wParam))
+            return false;
+
         SalKeyEvent aKeyEvt;
         aKeyEvt.mnCode     = nModCode; // Or should it be 0? - as this is 
always a character returned
         aKeyEvt.mnRepeat   = 0;
@@ -3613,12 +3616,12 @@ static bool ImplHandleKeyMsg( HWND hWnd, UINT nMsg,
         if( wParam >= Uni_SupplementaryPlanesStart )
         {
             // character is supplementary char in UTF-32 format - must be 
converted to UTF-16 supplementary pair
-            // sal_Unicode ch = (sal_Unicode) Uni_UTF32ToSurrogate1(wParam);
-             nLastChar = 0;
-             nLastVKChar = 0;
-             pFrame->CallCallback( SalEvent::KeyInput, &aKeyEvt );
-             pFrame->CallCallback( SalEvent::KeyUp, &aKeyEvt );
-             wParam = rtl::getLowSurrogate( wParam );
+            aKeyEvt.mnCharCode = rtl::getHighSurrogate(wParam);
+            nLastChar = 0;
+            nLastVKChar = 0;
+            pFrame->CallCallback(SalEvent::KeyInput, &aKeyEvt);
+            pFrame->CallCallback(SalEvent::KeyUp, &aKeyEvt);
+            wParam = rtl::getLowSurrogate(wParam);
         }
 
         aKeyEvt.mnCharCode = static_cast<sal_Unicode>(wParam);

Reply via email to