mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
MacOS: One more fix for Mac OS 10.11
This commit is contained in:
parent
80e935eda1
commit
ba408ec1d3
|
@ -5,6 +5,11 @@
|
||||||
#include <Foundation/NSAutoreleasePool.h>
|
#include <Foundation/NSAutoreleasePool.h>
|
||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#ifndef MAC_OS_X_VERSION_10_11
|
||||||
|
#define kAXValueTypeCGPoint kAXValueCGPointType
|
||||||
|
#define kAXValueTypeCFRange kAXValueCFRangeType
|
||||||
|
#endif
|
||||||
|
|
||||||
const int mouseOverInterval = 300;
|
const int mouseOverInterval = 300;
|
||||||
|
|
||||||
CGEventRef eventCallback( CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon )
|
CGEventRef eventCallback( CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon )
|
||||||
|
@ -146,7 +151,7 @@ void MacMouseOver::handlePosition()
|
||||||
|
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
{
|
{
|
||||||
CFTypeRef parameter = AXValueCreate( kAXValueCGPointType, &pt );
|
CFTypeRef parameter = AXValueCreate( kAXValueTypeCGPoint, &pt );
|
||||||
CFTypeRef rangeValue;
|
CFTypeRef rangeValue;
|
||||||
err = AXUIElementCopyParameterizedAttributeNames( elem, &names );
|
err = AXUIElementCopyParameterizedAttributeNames( elem, &names );
|
||||||
if( err != kAXErrorSuccess )
|
if( err != kAXErrorSuccess )
|
||||||
|
@ -165,7 +170,7 @@ void MacMouseOver::handlePosition()
|
||||||
CFStringRef stringValue;
|
CFStringRef stringValue;
|
||||||
|
|
||||||
CFRange decodedRange = CFRangeMake( 0, 0 );
|
CFRange decodedRange = CFRangeMake( 0, 0 );
|
||||||
bool b = AXValueGetValue( (AXValueRef)rangeValue, kAXValueCFRangeType, &decodedRange );
|
bool b = AXValueGetValue( (AXValueRef)rangeValue, kAXValueTypeCFRange, &decodedRange );
|
||||||
CFRelease( rangeValue );
|
CFRelease( rangeValue );
|
||||||
if( b )
|
if( b )
|
||||||
{
|
{
|
||||||
|
@ -175,7 +180,7 @@ void MacMouseOver::handlePosition()
|
||||||
int wordPos = decodedRange.location - fromPos; // Cursor position in result string
|
int wordPos = decodedRange.location - fromPos; // Cursor position in result string
|
||||||
|
|
||||||
CFRange range = CFRangeMake( fromPos, wordPos + 1 );
|
CFRange range = CFRangeMake( fromPos, wordPos + 1 );
|
||||||
parameter = AXValueCreate( kAXValueCFRangeType, &range );
|
parameter = AXValueCreate( kAXValueTypeCFRange, &range );
|
||||||
err = AXUIElementCopyParameterizedAttributeValue( elem, kAXStringForRangeParameterizedAttribute,
|
err = AXUIElementCopyParameterizedAttributeValue( elem, kAXStringForRangeParameterizedAttribute,
|
||||||
parameter, (CFTypeRef *)&stringValue );
|
parameter, (CFTypeRef *)&stringValue );
|
||||||
CFRelease( parameter );
|
CFRelease( parameter );
|
||||||
|
@ -189,7 +194,7 @@ void MacMouseOver::handlePosition()
|
||||||
for( int i = 1; i < 128; i++ )
|
for( int i = 1; i < 128; i++ )
|
||||||
{
|
{
|
||||||
range = CFRangeMake( decodedRange.location + i, 1 );
|
range = CFRangeMake( decodedRange.location + i, 1 );
|
||||||
parameter = AXValueCreate( kAXValueCFRangeType, &range );
|
parameter = AXValueCreate( kAXValueTypeCFRange, &range );
|
||||||
err = AXUIElementCopyParameterizedAttributeValue( elem, kAXStringForRangeParameterizedAttribute,
|
err = AXUIElementCopyParameterizedAttributeValue( elem, kAXStringForRangeParameterizedAttribute,
|
||||||
parameter, (CFTypeRef *)&stringValue );
|
parameter, (CFTypeRef *)&stringValue );
|
||||||
CFRelease( parameter );
|
CFRelease( parameter );
|
||||||
|
|
Loading…
Reference in a new issue