Skip to content
Permalink
Browse files

8231513: JavaFX cause Keystroke Receiving prompt on MacOS 10.15 (Cata…

…lina)

Reviewed-by: prr, jvos
  • Loading branch information
kevinrushforth committed Feb 1, 2020
1 parent 1823f6e commit 2ab40c1cd4496143b0b4391b1f3312a7bc34c921
Showing with 56 additions and 45 deletions.
  1. +56 −45 modules/javafx.graphics/src/main/native-glass/mac/GlassTouches.m
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, 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
@@ -42,6 +42,7 @@


static GlassTouches* glassTouches = nil;
static BOOL useEventTap = NO;


@interface GlassTouches (hidden)
@@ -176,6 +177,11 @@ + (void)terminate

- (id)init
{
useEventTap = YES;
if (@available(macOS 10.15, *)) {
useEventTap = NO;
}

self = [super init];
if (self != nil)
{
@@ -185,35 +191,37 @@ - (id)init
self->touches = nil;
self->lastTouchId = 0;

//
// Notes after fixing RT-23199:
//
// Don't use NSMachPort and NSRunLoop to integrate CFMachPortRef
// instance into run loop.
//
// Ignoring the above "don't"s results into performance degradation
// referenced in the bug.
//

self->eventTap = CGEventTapCreate(kCGHIDEventTap,
kCGHeadInsertEventTap,
kCGEventTapOptionListenOnly,
CGEventMaskBit(NSEventTypeGesture),
listenTouchEvents, nil);

LOG("TOUCHES: eventTap=%p\n", self->eventTap);

if (self->eventTap)
{ // Create a run loop source.
self->runLoopSource = CFMachPortCreateRunLoopSource(
kCFAllocatorDefault,
self->eventTap, 0);

LOG("TOUCHES: runLoopSource=%p\n", self->runLoopSource);

// Add to the current run loop.
CFRunLoopAddSource(CFRunLoopGetCurrent(), self->runLoopSource,
kCFRunLoopCommonModes);
if (useEventTap) {
//
// Notes after fixing RT-23199:
//
// Don't use NSMachPort and NSRunLoop to integrate CFMachPortRef
// instance into run loop.
//
// Ignoring the above "don't"s results into performance degradation
// referenced in the bug.
//

self->eventTap = CGEventTapCreate(kCGHIDEventTap,
kCGHeadInsertEventTap,
kCGEventTapOptionListenOnly,
CGEventMaskBit(NSEventTypeGesture),
listenTouchEvents, nil);

LOG("TOUCHES: eventTap=%p\n", self->eventTap);

if (self->eventTap)
{ // Create a run loop source.
self->runLoopSource = CFMachPortCreateRunLoopSource(
kCFAllocatorDefault,
self->eventTap, 0);

LOG("TOUCHES: runLoopSource=%p\n", self->runLoopSource);

// Add to the current run loop.
CFRunLoopAddSource(CFRunLoopGetCurrent(), self->runLoopSource,
kCFRunLoopCommonModes);
}
}
}
return self;
@@ -225,29 +233,32 @@ - (id)init
@implementation GlassTouches (hidden)
- (void)terminateImpl
{
LOG("TOUCHES: terminateImpl eventTap=%p runLoopSource=%p\n", self->eventTap,
self->runLoopSource);
if (useEventTap) {
LOG("TOUCHES: terminateImpl eventTap=%p runLoopSource=%p\n", self->eventTap,
self->runLoopSource);

if (self->runLoopSource)
{
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), self->runLoopSource,
kCFRunLoopCommonModes);
CFRelease(self->runLoopSource);
self->runLoopSource = nil;
}
if (self->runLoopSource)
{
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), self->runLoopSource,
kCFRunLoopCommonModes);
CFRelease(self->runLoopSource);
self->runLoopSource = nil;
}

if (self->eventTap)
{
CFRelease(self->eventTap);
self->eventTap = nil;
if (self->eventTap)
{
CFRelease(self->eventTap);
self->eventTap = nil;
}
}

[self releaseTouches];
}

- (void)enableTouchInputEventTap
{
CGEventTapEnable(self->eventTap, true);
if (useEventTap) {
CGEventTapEnable(self->eventTap, true);
}
}

- (void)sendJavaTouchEvent:(NSEvent *)theEvent

1 comment on commit 2ab40c1

@nicolabeghin

This comment has been minimized.

Copy link

nicolabeghin commented on 2ab40c1 Feb 3, 2020

following!

Please sign in to comment.
You can’t perform that action at this time.