changeset 6784:2fd20c3558dd

RT-35870: [Windows] PRINTSCREEN generates KEY_RELEASED without KEY_PRESSED Summary: Synthesize the missing event
author Anthony Petrov <anthony.petrov@oracle.com>
date Wed, 16 Apr 2014 22:47:36 +0400
parents 1217e36a9a32
children 7d608e7acf22
files modules/graphics/src/main/native-glass/win/ViewContainer.cpp
diffstat 1 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-glass/win/ViewContainer.cpp	Wed Apr 16 21:10:39 2014 +0400
+++ b/modules/graphics/src/main/native-glass/win/ViewContainer.cpp	Wed Apr 16 22:47:36 2014 +0400
@@ -468,11 +468,24 @@
             CheckAndClearException(env);
         }
 
-        env->CallVoidMethod(GetView(), javaIDs.View.notifyKey,
-                            (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN) ?
-                            com_sun_glass_events_KeyEvent_PRESS : com_sun_glass_events_KeyEvent_RELEASE,
-                            jKeyCode, jKeyChars, jModifiers);
-        CheckAndClearException(env);
+        if (jKeyCode == com_sun_glass_events_KeyEvent_VK_PRINTSCREEN &&
+                (msg == WM_KEYUP || msg == WM_SYSKEYUP))
+        {
+            // MS Windows doesn't send WM_KEYDOWN for the PrintScreen key,
+            // so we synthesize one
+            env->CallVoidMethod(GetView(), javaIDs.View.notifyKey,
+                    com_sun_glass_events_KeyEvent_PRESS,
+                    jKeyCode, jKeyChars, jModifiers);
+            CheckAndClearException(env);
+        }
+
+        if (GetGlassView()) {
+            env->CallVoidMethod(GetView(), javaIDs.View.notifyKey,
+                    (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN) ?
+                    com_sun_glass_events_KeyEvent_PRESS : com_sun_glass_events_KeyEvent_RELEASE,
+                    jKeyCode, jKeyChars, jModifiers);
+            CheckAndClearException(env);
+        }
 
         env->DeleteLocalRef(jKeyChars);
     }