< prev index next > modules/javafx.graphics/src/main/native-glass/mac/GlassTouches.m
Print this page
/*
! * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
/*
! * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
glassTouches = nil;
}
- (id)init
{
self = [super init];
if (self != nil)
{
self->curConsumer = nil;
self->eventTap = nil;
self->runLoopSource = nil;
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);
}
}
return self;
}
glassTouches = nil;
}
- (id)init
{
+ BOOL useEventTap = YES;
+ if (@available(macOS 10.15, *)) {
+ useEventTap = NO;
+ }
+
self = [super init];
if (self != nil)
{
self->curConsumer = nil;
self->eventTap = nil;
self->runLoopSource = nil;
self->touches = nil;
self->lastTouchId = 0;
! 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;
}
@implementation GlassTouches (hidden)
- (void)terminateImpl
{
! 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->eventTap)
! {
! CFRelease(self->eventTap);
! self->eventTap = nil;
! }
[self releaseTouches];
}
- (void)enableTouchInputEventTap
{
! CGEventTapEnable(self->eventTap, true);
}
- (void)sendJavaTouchEvent:(NSEvent *)theEvent
{
jint modifiers = GetJavaModifiers(theEvent);
@implementation GlassTouches (hidden)
- (void)terminateImpl
{
! BOOL useEventTap = YES;
! if (@available(macOS 10.15, *)) {
! useEventTap = NO;
}
! 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->eventTap)
+ {
+ CFRelease(self->eventTap);
+ self->eventTap = nil;
+ }
+ }
[self releaseTouches];
}
- (void)enableTouchInputEventTap
{
! BOOL useEventTap = YES;
+ if (@available(macOS 10.15, *)) {
+ useEventTap = NO;
+ }
+
+ if (useEventTap) {
+ CGEventTapEnable(self->eventTap, true);
+ }
}
- (void)sendJavaTouchEvent:(NSEvent *)theEvent
{
jint modifiers = GetJavaModifiers(theEvent);
< prev index next >