changeset 11109:e864311d97e6

8211304: [macOS] Crash on focus loss from dialog on macOS 10.14 Mojave Reviewed-by: arajkumar, mbilla
author kcr
date Wed, 07 Nov 2018 11:46:17 -0800
parents 900cc6ee40b4
children cc9e1b1af0b2
files modules/javafx.graphics/src/main/native-glass/mac/GlassTouches.m
diffstat 1 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/main/native-glass/mac/GlassTouches.m	Mon Nov 05 20:29:34 2018 +0530
+++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassTouches.m	Wed Nov 07 11:46:17 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -107,21 +107,30 @@
 static CGEventRef listenTouchEvents(CGEventTapProxy proxy, CGEventType type,
                              CGEventRef event, void* refcon)
 {
-    if (type == kCGEventTapDisabledByTimeout)
-    {   // OS may disable event tap if it handles events too slowly.
+    if (type == kCGEventTapDisabledByTimeout ||
+        type == kCGEventTapDisabledByUserInput)
+    {
+        // OS may disable event tap if it handles events too slowly
+        // or for some other reason based on user input.
         // This is undesirable, so enable event tap after such a reset.
         [glassTouches enableTouchInputEventTap];
-        LOG("TOUCHES: listenTouchEvents: recover after timeout\n");
+        LOG("TOUCHES: listenTouchEvents: re-enable event tap, type = %d\n", type);
         return event;
     }
 
-    NSEvent* theEvent = [NSEvent eventWithCGEvent:event];
-    if (theEvent)
+    if (type == NSEventTypeGesture)
     {
-        if (glassTouches)
+        LOG("TOUCHES: listenTouchEvents: process NSEventTypeGesture\n");
+        NSEvent* theEvent = [NSEvent eventWithCGEvent:event];
+        if (theEvent)
         {
-            [glassTouches sendJavaTouchEvent:theEvent];
+            if (glassTouches)
+            {
+                [glassTouches sendJavaTouchEvent:theEvent];
+            }
         }
+    } else {
+        LOG("TOUCHES: listenTouchEvents: unknown event ignored, type = %d\n", type);
     }
 
     return event;