freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 6785655: [graph/win32] Fix up the key event han


From: Werner Lemberg
Subject: [freetype2-demos] master 6785655: [graph/win32] Fix up the key event handling.
Date: Sat, 15 Jan 2022 22:25:20 -0500 (EST)

branch: master
commit 67856557f95259517987240ad46e3164565d4b6d
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [graph/win32] Fix up the key event handling.
    
    * graph/win32/grwin32.c (key_translators): Do not translate the keys
    that Windows translates.  We used to by-pass the system.
    (gr_win32_surface_listen_event): Move custom translations from here...
    (Message_Process): ... to here, which reduces the message posting.
---
 graph/win32/grwin32.c | 37 ++++++++++++++++---------------------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/graph/win32/grwin32.c b/graph/win32/grwin32.c
index 1840d91..8a6ad67 100644
--- a/graph/win32/grwin32.c
+++ b/graph/win32/grwin32.c
@@ -71,10 +71,6 @@
   static
   Translator  key_translators[] =
   {
-    { VK_BACK,      grKeyBackSpace },
-    { VK_TAB,       grKeyTab       },
-    { VK_RETURN,    grKeyReturn    },
-    { VK_ESCAPE,    grKeyEsc       },
     { VK_HOME,      grKeyHome      },
     { VK_LEFT,      grKeyLeft      },
     { VK_UP,        grKeyUp        },
@@ -398,23 +394,6 @@ gr_win32_surface_listen_event( grWin32Surface*  surface,
       }
       break;
 
-    case WM_KEYDOWN:
-    case WM_SYSKEYDOWN:
-      {
-        Translator*  trans = key_translators;
-        Translator*  limit = trans + sizeof( key_translators ) /
-                                     sizeof( key_translators[0] );
-        for ( ; trans < limit; trans++ )
-          if ( msg.wParam == trans->winkey )
-          {
-            grevent->type = gr_event_key;
-            grevent->key  = trans->grkey;
-            LOG(( "KeyPress: VK = 0x%02x\n", msg.wParam ));
-            return;
-          }
-      }
-      break;
-
     case WM_CHAR:
       {
         grevent->type = gr_event_key;
@@ -680,6 +659,22 @@ LRESULT CALLBACK Message_Process( HWND handle, UINT mess,
 
     case WM_KEYDOWN:
     case WM_SYSKEYDOWN:
+      {
+        Translator*  trans = key_translators;
+        Translator*  limit = trans + sizeof( key_translators ) /
+                                     sizeof( key_translators[0] );
+
+        for ( ; trans < limit; trans++ )
+          if ( wParam == trans->winkey )
+          {
+            /* repost to the main thread */
+            PostThreadMessage( surface->host, WM_CHAR, trans->grkey, 0 );
+            LOG(( "KeyPress: VK = 0x%02x\n", wParam ));
+            break;
+          }
+      }
+      break;
+
     case WM_CHAR:
       /* repost to the main thread */
       PostThreadMessage( surface->host, mess, wParam, lParam );



reply via email to

[Prev in Thread] Current Thread [Next in Thread]