mirror of
https://github.com/darlinghq/darling-cocotron.git
synced 2024-11-23 04:00:00 +00:00
Improve Patch and Format New Code
This commit is contained in:
parent
b6548a202d
commit
e84bc784cd
@ -51,10 +51,10 @@ NSBitmapImageRepPropertyKey NSImageCurrentFrame = @"NSImageCurrentFrame";
|
||||
return [NSArray arrayWithObjects:
|
||||
// Try to order them so the most used ones are at
|
||||
// the top of the list
|
||||
@"png", @"tiff", @"tif", @"jpg", @"jpeg",
|
||||
@"icns", @"gif", @"bmp", @"PNG", @"TIFF",
|
||||
@"TIF", @"JPG", @"JPEG", @"ICNS", @"jpe",
|
||||
@"JPE", @"GIF", @"BMP", nil];
|
||||
@"png", @"tiff", @"tif", @"jpg", @"jpeg", @"icns",
|
||||
@"gif", @"bmp", @"PNG", @"TIFF", @"TIF", @"JPG",
|
||||
@"JPEG", @"ICNS", @"jpe", @"JPE", @"GIF", @"BMP",
|
||||
nil];
|
||||
}
|
||||
|
||||
+ (NSArray *) imageRepsWithContentsOfFile: (NSString *) path {
|
||||
|
@ -681,51 +681,51 @@ enum bidi_state // possible states
|
||||
|
||||
static int stateWeak[][10] = {
|
||||
// N, L, R, AN, EN, AL,NSM, CS, ES, ET,
|
||||
/*xa*/ ao, xl, xr, cn, cn,
|
||||
xa, xa, ao, ao, ao, /* arabic letter */
|
||||
/*xr*/ ro, xl, xr, ra, re,
|
||||
xa, xr, ro, ro, rt, /* right letter */
|
||||
/*xl*/ lo, xl, xr, la, le,
|
||||
xa, xl, lo, lo, lt, /* left letter */
|
||||
/*xa*/ ao, xl, xr, cn, cn, xa,
|
||||
xa, ao, ao, ao, /* arabic letter */
|
||||
/*xr*/ ro, xl, xr, ra, re, xa,
|
||||
xr, ro, ro, rt, /* right letter */
|
||||
/*xl*/ lo, xl, xr, la, le, xa,
|
||||
xl, lo, lo, lt, /* left letter */
|
||||
|
||||
/*ao*/ ao, xl, xr, cn, cn,
|
||||
xa, ao, ao, ao, ao, /* arabic lett. foll by ON*/
|
||||
/*ro*/ ro, xl, xr, ra, re,
|
||||
xa, ro, ro, ro, rt, /* right lett. foll by ON */
|
||||
/*lo*/ lo, xl, xr, la, le,
|
||||
xa, lo, lo, lo, lt, /* left lett. foll by ON */
|
||||
/*ao*/ ao, xl, xr, cn, cn, xa,
|
||||
ao, ao, ao, ao, /* arabic lett. foll by ON*/
|
||||
/*ro*/ ro, xl, xr, ra, re, xa,
|
||||
ro, ro, ro, rt, /* right lett. foll by ON */
|
||||
/*lo*/ lo, xl, xr, la, le, xa,
|
||||
lo, lo, lo, lt, /* left lett. foll by ON */
|
||||
|
||||
/*rt*/ ro, xl, xr, ra, re,
|
||||
xa, rt, ro, ro, rt, /* ET following R */
|
||||
/*lt*/ lo, xl, xr, la, le,
|
||||
xa, lt, lo, lo, lt, /* ET following L */
|
||||
/*rt*/ ro, xl, xr, ra, re, xa,
|
||||
rt, ro, ro, rt, /* ET following R */
|
||||
/*lt*/ lo, xl, xr, la, le, xa,
|
||||
lt, lo, lo, lt, /* ET following L */
|
||||
|
||||
/*cn*/ ao, xl, xr, cn, cn,
|
||||
xa, cn, ac, ao, ao, /* EN, AN following AL */
|
||||
/*ra*/ ro, xl, xr, ra, re,
|
||||
xa, ra, rc, ro, rt, /* arabic number foll R */
|
||||
/*re*/ ro, xl, xr, ra, re,
|
||||
xa, re, rs, rs, ret, /* european number foll R */
|
||||
/*la*/ lo, xl, xr, la, le,
|
||||
xa, la, lc, lo, lt, /* arabic number foll L */
|
||||
/*le*/ lo, xl, xr, la, le,
|
||||
xa, le, ls, ls, let, /* european number foll L */
|
||||
/*cn*/ ao, xl, xr, cn, cn, xa,
|
||||
cn, ac, ao, ao, /* EN, AN following AL */
|
||||
/*ra*/ ro, xl, xr, ra, re, xa,
|
||||
ra, rc, ro, rt, /* arabic number foll R */
|
||||
/*re*/ ro, xl, xr, ra, re, xa,
|
||||
re, rs, rs, ret, /* european number foll R */
|
||||
/*la*/ lo, xl, xr, la, le, xa,
|
||||
la, lc, lo, lt, /* arabic number foll L */
|
||||
/*le*/ lo, xl, xr, la, le, xa,
|
||||
le, ls, ls, let, /* european number foll L */
|
||||
|
||||
/*ac*/ ao, xl, xr, cn, cn,
|
||||
xa, ao, ao, ao, ao, /* CS following cn */
|
||||
/*rc*/ ro, xl, xr, ra, re,
|
||||
xa, ro, ro, ro, rt, /* CS following ra */
|
||||
/*rs*/ ro, xl, xr, ra, re,
|
||||
xa, ro, ro, ro, rt, /* CS,ES following re */
|
||||
/*lc*/ lo, xl, xr, la, le,
|
||||
xa, lo, lo, lo, lt, /* CS following la */
|
||||
/*ls*/ lo, xl, xr, la, le,
|
||||
xa, lo, lo, lo, lt, /* CS,ES following le */
|
||||
/*ac*/ ao, xl, xr, cn, cn, xa,
|
||||
ao, ao, ao, ao, /* CS following cn */
|
||||
/*rc*/ ro, xl, xr, ra, re, xa,
|
||||
ro, ro, ro, rt, /* CS following ra */
|
||||
/*rs*/ ro, xl, xr, ra, re, xa,
|
||||
ro, ro, ro, rt, /* CS,ES following re */
|
||||
/*lc*/ lo, xl, xr, la, le, xa,
|
||||
lo, lo, lo, lt, /* CS following la */
|
||||
/*ls*/ lo, xl, xr, la, le, xa,
|
||||
lo, lo, lo, lt, /* CS,ES following le */
|
||||
|
||||
/*ret*/ ro, xl, xr, ra, re,
|
||||
xa, ret, ro, ro, ret, /* ET following re */
|
||||
/*let*/ lo, xl, xr, la, le,
|
||||
xa, let, lo, lo, let, /* ET following le */
|
||||
/*ret*/ ro, xl, xr, ra, re, xa,
|
||||
ret, ro, ro, ret, /* ET following re */
|
||||
/*let*/ lo, xl, xr, la, le, xa,
|
||||
let, lo, lo, let, /* ET following le */
|
||||
|
||||
};
|
||||
|
||||
@ -1178,8 +1178,8 @@ static void resolveNeutrals(int baselevel, uint8_t *pcls, const uint8_t *plevel,
|
||||
static int addLevel[][4] = {
|
||||
// L, R, AN, EN = cls
|
||||
// level =
|
||||
/* even */ 0, 1, 2, 2, // EVEN
|
||||
/* odd */ 1, 0, 1, 1, // ODD
|
||||
/* even */ 0, 1, 2, 2, // EVEN
|
||||
/* odd */ 1, 0, 1, 1, // ODD
|
||||
|
||||
};
|
||||
|
||||
|
@ -17,198 +17,202 @@
|
||||
along with Darling. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <CoreGraphics/CGEvent.h>
|
||||
#include <stdarg.h>
|
||||
#import <Foundation/NSKeyedArchiver.h>
|
||||
#import "CGEventObjC.h"
|
||||
#include <CoreGraphics/CGEvent.h>
|
||||
#import <Foundation/NSKeyedArchiver.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
CFTypeID CGEventGetTypeID(void)
|
||||
{
|
||||
return (CFTypeID) [CGEvent self];
|
||||
CFTypeID CGEventGetTypeID(void) {
|
||||
return (CFTypeID)[CGEvent self];
|
||||
}
|
||||
|
||||
CGEventRef CGEventCreate(CGEventSourceRef source)
|
||||
{
|
||||
return (CGEventRef) [[CGEvent alloc] initWithSource: (CGEventSource*) source];
|
||||
CGEventRef CGEventCreate(CGEventSourceRef source) {
|
||||
return (CGEventRef)
|
||||
[[CGEvent alloc] initWithSource: (CGEventSource *) source];
|
||||
}
|
||||
|
||||
CGEventRef CGEventCreateCopy(CGEventRef event)
|
||||
{
|
||||
return (CGEventRef) [(CGEvent*)event copy];
|
||||
CGEventRef CGEventCreateCopy(CGEventRef event) {
|
||||
return (CGEventRef)[(CGEvent *) event copy];
|
||||
}
|
||||
|
||||
CFDataRef CGEventCreateData(CFAllocatorRef allocator, CGEventRef event)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
NSKeyedArchiver* archiver = [[NSKeyedArchiver alloc] init];
|
||||
CFDataRef CGEventCreateData(CFAllocatorRef allocator, CGEventRef event) {
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] init];
|
||||
|
||||
[e encodeWithCoder: archiver];
|
||||
[e encodeWithCoder: archiver];
|
||||
|
||||
NSData* data = [[archiver encodedData] retain];
|
||||
[archiver release];
|
||||
NSData *data = [[archiver encodedData] retain];
|
||||
[archiver release];
|
||||
|
||||
return data;
|
||||
return data;
|
||||
}
|
||||
|
||||
CGEventRef CGEventCreateFromData(CFAllocatorRef allocator, CFDataRef data)
|
||||
{
|
||||
NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData: data];
|
||||
|
||||
CGEvent* e = [[CGEvent alloc] initWithCoder: unarchiver];
|
||||
CGEventRef CGEventCreateFromData(CFAllocatorRef allocator, CFDataRef data) {
|
||||
NSKeyedUnarchiver *unarchiver =
|
||||
[[NSKeyedUnarchiver alloc] initForReadingWithData: data];
|
||||
|
||||
[unarchiver finishDecoding];
|
||||
[unarchiver release];
|
||||
|
||||
return (CGEventRef) e;
|
||||
CGEvent *e = [[CGEvent alloc] initWithCoder: unarchiver];
|
||||
|
||||
[unarchiver finishDecoding];
|
||||
[unarchiver release];
|
||||
|
||||
return (CGEventRef) e;
|
||||
}
|
||||
|
||||
CGEventType CGEventGetType(CGEventRef event)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
return e.type;
|
||||
CGEventType CGEventGetType(CGEventRef event) {
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
return e.type;
|
||||
}
|
||||
|
||||
void CGEventSetSource(CGEventRef event, CGEventSourceRef source)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
e.source = (CGEventSource*) source;
|
||||
void CGEventSetSource(CGEventRef event, CGEventSourceRef source) {
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
e.source = (CGEventSource *) source;
|
||||
}
|
||||
|
||||
CGEventSourceRef CGEventCreateSourceFromEvent(CGEventRef event)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
return (CGEventSourceRef) [(CGEventSource*) e.source retain];
|
||||
CGEventSourceRef CGEventCreateSourceFromEvent(CGEventRef event) {
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
return (CGEventSourceRef)[(CGEventSource *) e.source retain];
|
||||
}
|
||||
|
||||
void CGEventSetType(CGEventRef event, CGEventType type)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
e.type = type;
|
||||
void CGEventSetType(CGEventRef event, CGEventType type) {
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
e.type = type;
|
||||
}
|
||||
|
||||
CGEventTimestamp CGEventGetTimestamp(CGEventRef event)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
return e.timestamp;
|
||||
CGEventTimestamp CGEventGetTimestamp(CGEventRef event) {
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
return e.timestamp;
|
||||
}
|
||||
|
||||
void CGEventSetTimestamp(CGEventRef event, CGEventTimestamp timestamp)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
e.timestamp = timestamp;
|
||||
void CGEventSetTimestamp(CGEventRef event, CGEventTimestamp timestamp) {
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
e.timestamp = timestamp;
|
||||
}
|
||||
|
||||
int64_t CGEventGetIntegerValueField(CGEventRef event, CGEventField field)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
NSNumber* value = e.fields[[NSNumber numberWithInt: field]];
|
||||
int64_t CGEventGetIntegerValueField(CGEventRef event, CGEventField field) {
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
NSNumber *value = e.fields[[NSNumber numberWithInt: field]];
|
||||
|
||||
if (!value)
|
||||
return 0;
|
||||
return value.longLongValue;
|
||||
if (!value)
|
||||
return 0;
|
||||
return value.longLongValue;
|
||||
}
|
||||
|
||||
void CGEventSetIntegerValueField(CGEventRef event, CGEventField field, int64_t value)
|
||||
void CGEventSetIntegerValueField(CGEventRef event, CGEventField field,
|
||||
int64_t value)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
e.fields[[NSNumber numberWithInt: field]] = [NSNumber numberWithLongLong: value];
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
e.fields[[NSNumber numberWithInt: field]] =
|
||||
[NSNumber numberWithLongLong: value];
|
||||
}
|
||||
|
||||
double CGEventGetDoubleValueField(CGEventRef event, CGEventField field)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
NSNumber* value = e.fields[[NSNumber numberWithInt: field]];
|
||||
double CGEventGetDoubleValueField(CGEventRef event, CGEventField field) {
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
NSNumber *value = e.fields[[NSNumber numberWithInt: field]];
|
||||
|
||||
if (!value)
|
||||
return 0;
|
||||
return value.doubleValue;
|
||||
if (!value)
|
||||
return 0;
|
||||
return value.doubleValue;
|
||||
}
|
||||
|
||||
void CGEventSetDoubleValueField(CGEventRef event, CGEventField field, double value)
|
||||
void CGEventSetDoubleValueField(CGEventRef event, CGEventField field,
|
||||
double value)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
e.fields[[NSNumber numberWithInt: field]] = [NSNumber numberWithDouble: value];
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
e.fields[[NSNumber numberWithInt: field]] =
|
||||
[NSNumber numberWithDouble: value];
|
||||
}
|
||||
|
||||
CGEventRef CGEventCreateKeyboardEvent(CGEventSourceRef source, CGKeyCode virtualKey, bool keyDown)
|
||||
CGEventRef CGEventCreateKeyboardEvent(CGEventSourceRef source,
|
||||
CGKeyCode virtualKey, bool keyDown)
|
||||
{
|
||||
CGEventType type = keyDown ? kCGEventKeyDown : kCGEventKeyUp;
|
||||
CGEvent* event = [[CGEvent alloc] initWithSource: (CGEventSource*) source type: type];
|
||||
event.virtualKey = virtualKey;
|
||||
CGEventType type = keyDown ? kCGEventKeyDown : kCGEventKeyUp;
|
||||
CGEvent *event = [[CGEvent alloc] initWithSource: (CGEventSource *) source
|
||||
type: type];
|
||||
event.virtualKey = virtualKey;
|
||||
|
||||
return (CGEventRef) event;
|
||||
return (CGEventRef) event;
|
||||
}
|
||||
|
||||
CGEventRef CGEventCreateMouseEvent(CGEventSourceRef source, CGEventType mouseType, CGPoint mouseCursorPosition, CGMouseButton mouseButton)
|
||||
CGEventRef CGEventCreateMouseEvent(CGEventSourceRef source,
|
||||
CGEventType mouseType,
|
||||
CGPoint mouseCursorPosition,
|
||||
CGMouseButton mouseButton)
|
||||
{
|
||||
CGEvent* event = [[CGEvent alloc] initWithSource: (CGEventSource*) source type: mouseType];
|
||||
event.location = mouseCursorPosition;
|
||||
event.mouseButton = mouseButton;
|
||||
return (CGEventRef) event;
|
||||
CGEvent *event = [[CGEvent alloc] initWithSource: (CGEventSource *) source
|
||||
type: mouseType];
|
||||
event.location = mouseCursorPosition;
|
||||
event.mouseButton = mouseButton;
|
||||
return (CGEventRef) event;
|
||||
}
|
||||
|
||||
CGEventRef CGEventCreateScrollWheelEvent(CGEventSourceRef source, CGScrollEventUnit units, uint32_t wheelCount, int32_t wheel1, ...)
|
||||
CGEventRef CGEventCreateScrollWheelEvent(CGEventSourceRef source,
|
||||
CGScrollEventUnit units,
|
||||
uint32_t wheelCount, int32_t wheel1,
|
||||
...)
|
||||
{
|
||||
CGEvent* event = [[CGEvent alloc] initWithSource: (CGEventSource*) source type: kCGEventScrollWheel];
|
||||
event.scrollEventUnit = units;
|
||||
event.wheelCount = wheelCount;
|
||||
event.wheels[0] = wheel1;
|
||||
CGEvent *event = [[CGEvent alloc] initWithSource: (CGEventSource *) source
|
||||
type: kCGEventScrollWheel];
|
||||
event.scrollEventUnit = units;
|
||||
event.wheelCount = wheelCount;
|
||||
event.wheels[0] = wheel1;
|
||||
|
||||
if (wheelCount > 1)
|
||||
{
|
||||
va_list vl;
|
||||
va_start(vl, wheel1);
|
||||
if (wheelCount > 1) {
|
||||
va_list vl;
|
||||
va_start(vl, wheel1);
|
||||
|
||||
event.wheels[1] = va_arg(vl, int32_t);
|
||||
event.wheels[1] = va_arg(vl, int32_t);
|
||||
|
||||
if (wheelCount > 2)
|
||||
event.wheels[2] = va_arg(vl, int32_t);
|
||||
if (wheelCount > 2)
|
||||
event.wheels[2] = va_arg(vl, int32_t);
|
||||
|
||||
va_end(vl);
|
||||
}
|
||||
return (CGEventRef) event;
|
||||
va_end(vl);
|
||||
}
|
||||
return (CGEventRef) event;
|
||||
}
|
||||
|
||||
CGPoint CGEventGetLocation(CGEventRef event)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
return e.location;
|
||||
CGPoint CGEventGetLocation(CGEventRef event) {
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
return e.location;
|
||||
}
|
||||
|
||||
void CGEventSetLocation(CGEventRef event, CGPoint location)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
e.location = location;
|
||||
void CGEventSetLocation(CGEventRef event, CGPoint location) {
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
e.location = location;
|
||||
}
|
||||
|
||||
void CGEventKeyboardGetUnicodeString(CGEventRef event, UniCharCount maxStringLength, UniCharCount *actualStringLength, UniChar *unicodeString)
|
||||
void CGEventKeyboardGetUnicodeString(CGEventRef event,
|
||||
UniCharCount maxStringLength,
|
||||
UniCharCount *actualStringLength,
|
||||
UniChar *unicodeString)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
UniChar* savedString = e.unicodeString;
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
UniChar *savedString = e.unicodeString;
|
||||
|
||||
UniCharCount length = 0;
|
||||
while (length < 5 && savedString[length])
|
||||
length++;
|
||||
|
||||
if (maxStringLength == 0)
|
||||
{
|
||||
*actualStringLength = length;
|
||||
}
|
||||
|
||||
*actualStringLength = length;
|
||||
if (maxStringLength < length)
|
||||
*actualStringLength = maxStringLength;
|
||||
UniCharCount length = 0;
|
||||
while (length < 5 && savedString[length])
|
||||
length++;
|
||||
|
||||
memcpy(unicodeString, savedString, *actualStringLength * sizeof(UniChar));
|
||||
if (maxStringLength == 0) {
|
||||
*actualStringLength = length;
|
||||
}
|
||||
|
||||
*actualStringLength = length;
|
||||
if (maxStringLength < length)
|
||||
*actualStringLength = maxStringLength;
|
||||
|
||||
memcpy(unicodeString, savedString, *actualStringLength * sizeof(UniChar));
|
||||
}
|
||||
|
||||
void CGEventKeyboardSetUnicodeString(CGEventRef event, UniCharCount stringLength, const UniChar *unicodeString)
|
||||
void CGEventKeyboardSetUnicodeString(CGEventRef event,
|
||||
UniCharCount stringLength,
|
||||
const UniChar *unicodeString)
|
||||
{
|
||||
CGEvent* e = (CGEvent*) event;
|
||||
CGEvent *e = (CGEvent *) event;
|
||||
|
||||
// This is the maximum CGEvent can save
|
||||
if (stringLength > 5)
|
||||
stringLength = 5;
|
||||
|
||||
memcpy(e.unicodeString, unicodeString, stringLength * sizeof(UniChar));
|
||||
// This is the maximum CGEvent can save
|
||||
if (stringLength > 5)
|
||||
stringLength = 5;
|
||||
|
||||
memcpy(e.unicodeString, unicodeString, stringLength * sizeof(UniChar));
|
||||
}
|
||||
|
@ -19,49 +19,49 @@
|
||||
|
||||
#ifndef CGEVENT_OBJC_H
|
||||
#define CGEVENT_OBJC_H
|
||||
#include <CoreGraphics/CGEvent.h>
|
||||
#include <CoreFoundation/CFBase.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#include <CoreGraphics/CGEvent.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class CGEventSource;
|
||||
|
||||
@interface CGEvent : NSObject <NSCopying, NSCoding> {
|
||||
CGEventSource* _source;
|
||||
CGEventType _type;
|
||||
CGEventTimestamp _timestamp;
|
||||
CGEventFlags _flags;
|
||||
NSMutableDictionary<NSNumber*, NSNumber*>* _fields;
|
||||
CGEventSource *_source;
|
||||
CGEventType _type;
|
||||
CGEventTimestamp _timestamp;
|
||||
CGEventFlags _flags;
|
||||
NSMutableDictionary<NSNumber *, NSNumber *> *_fields;
|
||||
|
||||
// keyboard events
|
||||
CGKeyCode _virtualKey;
|
||||
UniChar _unicodeString[5];
|
||||
// keyboard events
|
||||
CGKeyCode _virtualKey;
|
||||
UniChar _unicodeString[5];
|
||||
|
||||
// mouse button events
|
||||
CGPoint _location;
|
||||
CGMouseButton _mouseButton;
|
||||
// mouse button events
|
||||
CGPoint _location;
|
||||
CGMouseButton _mouseButton;
|
||||
|
||||
// mouse wheel events
|
||||
CGScrollEventUnit _scrollEventUnit;
|
||||
uint32_t _wheelCount;
|
||||
int32_t _wheels[3];
|
||||
// mouse wheel events
|
||||
CGScrollEventUnit _scrollEventUnit;
|
||||
uint32_t _wheelCount;
|
||||
int32_t _wheels[3];
|
||||
}
|
||||
-(instancetype) initWithSource:(CGEventSource*) source;
|
||||
-(instancetype) initWithSource:(CGEventSource*) source
|
||||
type:(CGEventType) type;
|
||||
-(instancetype) initWithData:(NSData*) data;
|
||||
- (instancetype) initWithSource: (CGEventSource *) source;
|
||||
- (instancetype) initWithSource: (CGEventSource *) source
|
||||
type: (CGEventType) type;
|
||||
- (instancetype) initWithData: (NSData *) data;
|
||||
|
||||
-(void) dealloc;
|
||||
-(id)copy;
|
||||
-(CFTypeID) _cfTypeID;
|
||||
-(NSData*) createData;
|
||||
- (void) dealloc;
|
||||
- (id) copy;
|
||||
- (CFTypeID) _cfTypeID;
|
||||
- (NSData *) createData;
|
||||
|
||||
@property(readwrite) CGEventType type;
|
||||
@property(retain) CGEventSource* source;
|
||||
@property(retain) CGEventSource *source;
|
||||
@property(readwrite) CGEventTimestamp timestamp;
|
||||
@property(readwrite) CGEventFlags flags;
|
||||
@property(readonly) NSMutableDictionary<NSNumber*, NSNumber*>* fields;
|
||||
@property(readonly) NSMutableDictionary<NSNumber *, NSNumber *> *fields;
|
||||
|
||||
@property(readwrite) CGKeyCode virtualKey;
|
||||
|
||||
@ -70,21 +70,21 @@
|
||||
|
||||
@property(readwrite) CGScrollEventUnit scrollEventUnit;
|
||||
@property(readwrite) uint32_t wheelCount;
|
||||
@property(readonly) int32_t* wheels;
|
||||
@property(readonly) UniChar* unicodeString;
|
||||
@property(readonly) int32_t *wheels;
|
||||
@property(readonly) UniChar *unicodeString;
|
||||
|
||||
@end
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
@interface CGEventSource : NSObject {
|
||||
CGEventSourceStateID _stateId;
|
||||
CGEventSourceKeyboardType _keyboardType;
|
||||
int64_t _userData;
|
||||
double _pixelsPerLine;
|
||||
CGEventSourceStateID _stateId;
|
||||
CGEventSourceKeyboardType _keyboardType;
|
||||
int64_t _userData;
|
||||
double _pixelsPerLine;
|
||||
}
|
||||
-(instancetype) initWithState: (CGEventSourceStateID) stateId;
|
||||
-(CFTypeID) _cfTypeID;
|
||||
- (instancetype) initWithState: (CGEventSourceStateID) stateId;
|
||||
- (CFTypeID) _cfTypeID;
|
||||
|
||||
@property CGEventSourceKeyboardType keyboardType;
|
||||
@property CGEventSourceStateID stateID;
|
||||
@ -96,33 +96,32 @@
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
@interface CGEventTap : NSObject {
|
||||
CGEventTapLocation _location;
|
||||
CGEventTapOptions _options;
|
||||
CGEventMask _mask;
|
||||
CGEventTapCallBack _callback;
|
||||
void* _userInfo;
|
||||
Boolean _enabled;
|
||||
CGEventTapLocation _location;
|
||||
CGEventTapOptions _options;
|
||||
CGEventMask _mask;
|
||||
CGEventTapCallBack _callback;
|
||||
void *_userInfo;
|
||||
Boolean _enabled;
|
||||
|
||||
mach_port_t _machPort;
|
||||
mach_port_t _machPort;
|
||||
}
|
||||
|
||||
-(instancetype) initWithLocation: (CGEventTapLocation) location
|
||||
options: (CGEventTapOptions) options
|
||||
mask: (CGEventMask) mask
|
||||
callback: (CGEventTapCallBack) callback
|
||||
userInfo: (void*) userInfo;
|
||||
- (instancetype) initWithLocation: (CGEventTapLocation) location
|
||||
options: (CGEventTapOptions) options
|
||||
mask: (CGEventMask) mask
|
||||
callback: (CGEventTapCallBack) callback
|
||||
userInfo: (void *) userInfo;
|
||||
|
||||
-(void) dealloc;
|
||||
-(CFMachPortRef) createCFMachPort;
|
||||
- (void) dealloc;
|
||||
- (CFMachPortRef) createCFMachPort;
|
||||
|
||||
@property(readonly) mach_port_t machPort;
|
||||
@property(readonly) CGEventTapOptions options;
|
||||
@property(readonly) CGEventMask mask;
|
||||
@property(readonly) CGEventTapCallBack callback;
|
||||
@property(readonly) void* userInfo;
|
||||
@property(readonly) void *userInfo;
|
||||
@property Boolean enabled;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -18,10 +18,10 @@
|
||||
*/
|
||||
#include "CGEventObjC.h"
|
||||
#include "CGEventTapInternal.h"
|
||||
#include <time.h>
|
||||
#include <CoreGraphics/CGEventSource.h>
|
||||
#import <Foundation/NSKeyedArchiver.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#include <time.h>
|
||||
|
||||
@implementation CGEvent
|
||||
|
||||
@ -36,100 +36,92 @@
|
||||
@synthesize scrollEventUnit = _scrollEventUnit;
|
||||
@synthesize wheelCount = _wheelCount;
|
||||
|
||||
-(instancetype) initWithSource:(CGEventSource*) source
|
||||
{
|
||||
return [self initWithSource: source
|
||||
type: kCGEventNull];
|
||||
- (instancetype) initWithSource: (CGEventSource *) source {
|
||||
return [self initWithSource: source type: kCGEventNull];
|
||||
}
|
||||
|
||||
-(instancetype) initWithSource:(CGEventSource*) source
|
||||
type:(CGEventType) type;
|
||||
- (instancetype) initWithSource: (CGEventSource *) source
|
||||
type: (CGEventType) type;
|
||||
{
|
||||
_source = [source retain];
|
||||
_type = type;
|
||||
_fields = [[NSMutableDictionary alloc] initWithCapacity: 0];
|
||||
_timestamp = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
|
||||
return self;
|
||||
_source = [source retain];
|
||||
_type = type;
|
||||
_fields = [[NSMutableDictionary alloc] initWithCapacity: 0];
|
||||
_timestamp = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
|
||||
return self;
|
||||
}
|
||||
|
||||
-(instancetype) initWithCoder:(NSCoder*) coder
|
||||
{
|
||||
NSKeyedUnarchiver* unarchiver = (NSKeyedUnarchiver*) coder;
|
||||
|
||||
// TODO
|
||||
- (instancetype) initWithCoder: (NSCoder *) coder {
|
||||
NSKeyedUnarchiver *unarchiver = (NSKeyedUnarchiver *) coder;
|
||||
|
||||
return self;
|
||||
// TODO
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
[_source release];
|
||||
[_fields release];
|
||||
[super dealloc];
|
||||
- (void) dealloc {
|
||||
[_source release];
|
||||
[_fields release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(id)copy
|
||||
{
|
||||
CGEvent* rv = [[CGEvent alloc] initWithSource: _source type: _type];
|
||||
rv->_timestamp = self->_timestamp;
|
||||
rv->_flags = self->_flags;
|
||||
rv->_fields = [_fields copy];
|
||||
- (id) copy {
|
||||
CGEvent *rv = [[CGEvent alloc] initWithSource: _source type: _type];
|
||||
rv->_timestamp = self->_timestamp;
|
||||
rv->_flags = self->_flags;
|
||||
rv->_fields = [_fields copy];
|
||||
|
||||
rv->_virtualKey = _virtualKey;
|
||||
memcpy(rv->_unicodeString, _unicodeString, sizeof(_unicodeString));
|
||||
rv->_virtualKey = _virtualKey;
|
||||
memcpy(rv->_unicodeString, _unicodeString, sizeof(_unicodeString));
|
||||
|
||||
rv->_location = _location;
|
||||
rv->_mouseButton = _mouseButton;
|
||||
rv->_location = _location;
|
||||
rv->_mouseButton = _mouseButton;
|
||||
|
||||
rv->_scrollEventUnit = _scrollEventUnit;
|
||||
rv->_wheelCount = _wheelCount;
|
||||
memcpy(rv->_wheels, _wheels, sizeof(_wheels));
|
||||
rv->_scrollEventUnit = _scrollEventUnit;
|
||||
rv->_wheelCount = _wheelCount;
|
||||
memcpy(rv->_wheels, _wheels, sizeof(_wheels));
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone
|
||||
{
|
||||
return [self copy];
|
||||
- (id) copyWithZone: (NSZone *) zone {
|
||||
return [self copy];
|
||||
}
|
||||
|
||||
-(CFTypeID) _cfTypeID
|
||||
{
|
||||
return CGEventGetTypeID();
|
||||
- (CFTypeID) _cfTypeID {
|
||||
return CGEventGetTypeID();
|
||||
}
|
||||
|
||||
-(int32_t*) wheels
|
||||
{
|
||||
return _wheels;
|
||||
- (int32_t *) wheels {
|
||||
return _wheels;
|
||||
}
|
||||
|
||||
-(UniChar*) unicodeString
|
||||
{
|
||||
return _unicodeString;
|
||||
- (UniChar *) unicodeString {
|
||||
return _unicodeString;
|
||||
}
|
||||
|
||||
-(void) encodeWithCoder:(NSCoder*) coder
|
||||
{
|
||||
NSKeyedArchiver* archiver = (NSKeyedArchiver*) coder;
|
||||
- (void) encodeWithCoder: (NSCoder *) coder {
|
||||
NSKeyedArchiver *archiver = (NSKeyedArchiver *) coder;
|
||||
|
||||
CGEventSourceStateID stateId = _source.stateID;
|
||||
[archiver encodeInt: stateId forKey:@"stateId"];
|
||||
CGEventSourceStateID stateId = _source.stateID;
|
||||
[archiver encodeInt: stateId forKey: @"stateId"];
|
||||
|
||||
[archiver encodeInt: _type forKey: @"type"];
|
||||
[archiver encodeInt64: _timestamp forKey: @"timestamp"];
|
||||
[archiver encodeObject: _fields forKey: @"fields"];
|
||||
[archiver encodeInt: _virtualKey forKey: @"virtualKey"];
|
||||
[archiver encodeBytes: (uint8_t*) _unicodeString length: sizeof(_unicodeString) forKey: @"unicodeString"];
|
||||
[archiver encodeDouble: _location.x forKey: @"location.x"];
|
||||
[archiver encodeDouble: _location.y forKey: @"location.y"];
|
||||
[archiver encodeInt: _mouseButton forKey: @"mouseButton"];
|
||||
[archiver encodeInt: _scrollEventUnit forKey: @"scrollEventUnit"];
|
||||
[archiver encodeInt: _wheelCount forKey:@"wheelCount"];
|
||||
[archiver encodeInt: _type forKey: @"type"];
|
||||
[archiver encodeInt64: _timestamp forKey: @"timestamp"];
|
||||
[archiver encodeObject: _fields forKey: @"fields"];
|
||||
[archiver encodeInt: _virtualKey forKey: @"virtualKey"];
|
||||
[archiver encodeBytes: (uint8_t *) _unicodeString
|
||||
length: sizeof(_unicodeString)
|
||||
forKey: @"unicodeString"];
|
||||
[archiver encodeDouble: _location.x forKey: @"location.x"];
|
||||
[archiver encodeDouble: _location.y forKey: @"location.y"];
|
||||
[archiver encodeInt: _mouseButton forKey: @"mouseButton"];
|
||||
[archiver encodeInt: _scrollEventUnit forKey: @"scrollEventUnit"];
|
||||
[archiver encodeInt: _wheelCount forKey: @"wheelCount"];
|
||||
|
||||
for (uint32_t i = 0; i < _wheelCount; i++)
|
||||
{
|
||||
[archiver encodeInt: _wheels[i] forKey:[NSString stringWithFormat:@"wheel-%d", i]];
|
||||
}
|
||||
for (uint32_t i = 0; i < _wheelCount; i++) {
|
||||
[archiver encodeInt: _wheels[i]
|
||||
forKey: [NSString stringWithFormat: @"wheel-%d", i]];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@ -141,47 +133,45 @@
|
||||
@synthesize userData = _userData;
|
||||
@synthesize pixelsPerLine = _pixelsPerLine;
|
||||
|
||||
-(instancetype) initWithState: (CGEventSourceStateID) stateId
|
||||
{
|
||||
_stateId = stateId;
|
||||
return self;
|
||||
- (instancetype) initWithState: (CGEventSourceStateID) stateId {
|
||||
_stateId = stateId;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(CFTypeID) _cfTypeID
|
||||
{
|
||||
return CGEventSourceGetTypeID();
|
||||
- (CFTypeID) _cfTypeID {
|
||||
return CGEventSourceGetTypeID();
|
||||
}
|
||||
@end
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
static void cgEventTapCallout(CFMachPortRef mp, void* msg, CFIndex size, void* info)
|
||||
static void cgEventTapCallout(CFMachPortRef mp, void *msg, CFIndex size,
|
||||
void *info)
|
||||
{
|
||||
CGEventTap* tap = (CGEventTap*) info;
|
||||
CGEventTap *tap = (CGEventTap *) info;
|
||||
|
||||
struct TapMachMessage* tapMessage = (struct TapMachMessage*) msg;
|
||||
CGEventRef event = tapMessage->event;
|
||||
struct TapMachMessage *tapMessage = (struct TapMachMessage *) msg;
|
||||
CGEventRef event = tapMessage->event;
|
||||
|
||||
CGEventType type = CGEventGetType(tapMessage->event);
|
||||
if (tap.enabled && (CGEventMaskBit(type) & tap.mask) != 0)
|
||||
{
|
||||
// Invoke callback
|
||||
CGEventRef returned = tap.callback(tapMessage->proxy, type, event, tap.userInfo);
|
||||
CGEventType type = CGEventGetType(tapMessage->event);
|
||||
if (tap.enabled && (CGEventMaskBit(type) & tap.mask) != 0) {
|
||||
// Invoke callback
|
||||
CGEventRef returned =
|
||||
tap.callback(tapMessage->proxy, type, event, tap.userInfo);
|
||||
|
||||
if (!(tap.options & kCGEventTapOptionListenOnly))
|
||||
event = returned;
|
||||
}
|
||||
if (!(tap.options & kCGEventTapOptionListenOnly))
|
||||
event = returned;
|
||||
}
|
||||
|
||||
// Pass the message on
|
||||
if (event != NULL)
|
||||
{
|
||||
CGEventTapPostEvent(tapMessage->proxy, event);
|
||||
// Pass the message on
|
||||
if (event != NULL) {
|
||||
CGEventTapPostEvent(tapMessage->proxy, event);
|
||||
|
||||
if (event != tapMessage->event)
|
||||
CFRelease(event);
|
||||
}
|
||||
if (event != tapMessage->event)
|
||||
CFRelease(event);
|
||||
}
|
||||
|
||||
CFRelease(tapMessage->event);
|
||||
CFRelease(tapMessage->event);
|
||||
}
|
||||
|
||||
@implementation CGEventTap
|
||||
@ -193,53 +183,55 @@ static void cgEventTapCallout(CFMachPortRef mp, void* msg, CFIndex size, void* i
|
||||
@synthesize userInfo = _userInfo;
|
||||
@synthesize enabled = _enabled;
|
||||
|
||||
-(instancetype) initWithLocation: (CGEventTapLocation) location
|
||||
options: (CGEventTapOptions) options
|
||||
mask: (CGEventMask) mask
|
||||
callback: (CGEventTapCallBack) callback
|
||||
userInfo: (void*) userInfo
|
||||
- (instancetype) initWithLocation: (CGEventTapLocation) location
|
||||
options: (CGEventTapOptions) options
|
||||
mask: (CGEventMask) mask
|
||||
callback: (CGEventTapCallBack) callback
|
||||
userInfo: (void *) userInfo
|
||||
{
|
||||
_location = location;
|
||||
_options = options;
|
||||
_mask = mask;
|
||||
_callback = callback;
|
||||
_userInfo = userInfo;
|
||||
_enabled = TRUE;
|
||||
_location = location;
|
||||
_options = options;
|
||||
_mask = mask;
|
||||
_callback = callback;
|
||||
_userInfo = userInfo;
|
||||
_enabled = TRUE;
|
||||
|
||||
kern_return_t ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &_machPort);
|
||||
kern_return_t ret = mach_port_allocate(mach_task_self(),
|
||||
MACH_PORT_RIGHT_RECEIVE, &_machPort);
|
||||
if (KERN_SUCCESS == ret) {
|
||||
ret = mach_port_insert_right(mach_task_self(), _machPort, _machPort, MACH_MSG_TYPE_MAKE_SEND);
|
||||
ret = mach_port_insert_right(mach_task_self(), _machPort, _machPort,
|
||||
MACH_MSG_TYPE_MAKE_SEND);
|
||||
}
|
||||
if (KERN_SUCCESS != ret) {
|
||||
if (MACH_PORT_NULL != _machPort) mach_port_destroy(mach_task_self(), _machPort);
|
||||
[self release];
|
||||
if (MACH_PORT_NULL != _machPort)
|
||||
mach_port_destroy(mach_task_self(), _machPort);
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
_CGEventTapDestroyed(_location, _machPort);
|
||||
mach_port_destroy(mach_task_self(), _machPort);
|
||||
[super dealloc];
|
||||
- (void) dealloc {
|
||||
_CGEventTapDestroyed(_location, _machPort);
|
||||
mach_port_destroy(mach_task_self(), _machPort);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(CFMachPortRef) createCFMachPort
|
||||
{
|
||||
CFMachPortRef mp;
|
||||
CFMachPortContext ctxt = {
|
||||
.copyDescription = NULL,
|
||||
.info = self,
|
||||
.release = CFRelease,
|
||||
.retain = CFRetain,
|
||||
.version = 0,
|
||||
};
|
||||
- (CFMachPortRef) createCFMachPort {
|
||||
CFMachPortRef mp;
|
||||
CFMachPortContext ctxt = {
|
||||
.copyDescription = NULL,
|
||||
.info = self,
|
||||
.release = CFRelease,
|
||||
.retain = CFRetain,
|
||||
.version = 0,
|
||||
};
|
||||
|
||||
mp = CFMachPortCreateWithPort(NULL, _machPort, cgEventTapCallout, &ctxt, NULL);
|
||||
mp = CFMachPortCreateWithPort(NULL, _machPort, cgEventTapCallout, &ctxt,
|
||||
NULL);
|
||||
|
||||
return mp;
|
||||
return mp;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -16,64 +16,59 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Darling. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <CoreGraphics/CGEventSource.h>
|
||||
#include "CGEventObjC.h"
|
||||
#include <CoreGraphics/CGEventSource.h>
|
||||
|
||||
static CGEventFlags g_sourceStates[3];
|
||||
|
||||
CFTypeID CGEventSourceGetTypeID(void)
|
||||
{
|
||||
return (CFTypeID) [CGEventSource self];
|
||||
CFTypeID CGEventSourceGetTypeID(void) {
|
||||
return (CFTypeID)[CGEventSource self];
|
||||
}
|
||||
|
||||
CGEventSourceRef CGEventSourceCreate(CGEventSourceStateID stateID)
|
||||
{
|
||||
return (CGEventSourceRef) [[CGEventSource alloc] initWithState: stateID];
|
||||
CGEventSourceRef CGEventSourceCreate(CGEventSourceStateID stateID) {
|
||||
return (CGEventSourceRef) [[CGEventSource alloc] initWithState: stateID];
|
||||
}
|
||||
|
||||
CGEventSourceKeyboardType CGEventSourceGetKeyboardType(CGEventSourceRef source)
|
||||
{
|
||||
CGEventSource* src = (CGEventSource*) source;
|
||||
return src.keyboardType;
|
||||
CGEventSource *src = (CGEventSource *) source;
|
||||
return src.keyboardType;
|
||||
}
|
||||
|
||||
void CGEventSourceSetKeyboardType(CGEventSourceRef source, CGEventSourceKeyboardType keyboardType)
|
||||
void CGEventSourceSetKeyboardType(CGEventSourceRef source,
|
||||
CGEventSourceKeyboardType keyboardType)
|
||||
{
|
||||
CGEventSource* src = (CGEventSource*) source;
|
||||
src.keyboardType = keyboardType;
|
||||
CGEventSource *src = (CGEventSource *) source;
|
||||
src.keyboardType = keyboardType;
|
||||
}
|
||||
|
||||
CGEventSourceStateID CGEventSourceGetSourceStateID(CGEventSourceRef source)
|
||||
{
|
||||
CGEventSource* src = (CGEventSource*) source;
|
||||
return src.stateID;
|
||||
CGEventSourceStateID CGEventSourceGetSourceStateID(CGEventSourceRef source) {
|
||||
CGEventSource *src = (CGEventSource *) source;
|
||||
return src.stateID;
|
||||
}
|
||||
|
||||
int64_t CGEventSourceGetUserData(CGEventSourceRef source)
|
||||
{
|
||||
CGEventSource* src = (CGEventSource*) source;
|
||||
return src.userData;
|
||||
int64_t CGEventSourceGetUserData(CGEventSourceRef source) {
|
||||
CGEventSource *src = (CGEventSource *) source;
|
||||
return src.userData;
|
||||
}
|
||||
|
||||
void CGEventSourceSetUserData(CGEventSourceRef source, int64_t userData)
|
||||
{
|
||||
CGEventSource* src = (CGEventSource*) source;
|
||||
src.userData = userData;
|
||||
void CGEventSourceSetUserData(CGEventSourceRef source, int64_t userData) {
|
||||
CGEventSource *src = (CGEventSource *) source;
|
||||
src.userData = userData;
|
||||
}
|
||||
|
||||
double CGEventSourceGetPixelsPerLine(CGEventSourceRef source)
|
||||
{
|
||||
CGEventSource* src = (CGEventSource*) source;
|
||||
return src.pixelsPerLine;
|
||||
double CGEventSourceGetPixelsPerLine(CGEventSourceRef source) {
|
||||
CGEventSource *src = (CGEventSource *) source;
|
||||
return src.pixelsPerLine;
|
||||
}
|
||||
|
||||
void CGEventSourceSetPixelsPerLine(CGEventSourceRef source, double pixelsPerLine)
|
||||
void CGEventSourceSetPixelsPerLine(CGEventSourceRef source,
|
||||
double pixelsPerLine)
|
||||
{
|
||||
CGEventSource* src = (CGEventSource*) source;
|
||||
src.pixelsPerLine = pixelsPerLine;
|
||||
CGEventSource *src = (CGEventSource *) source;
|
||||
src.pixelsPerLine = pixelsPerLine;
|
||||
}
|
||||
|
||||
CGEventFlags CGEventSourceFlagsState(CGEventSourceStateID stateID)
|
||||
{
|
||||
return g_sourceStates[stateID+1];
|
||||
CGEventFlags CGEventSourceFlagsState(CGEventSourceStateID stateID) {
|
||||
return g_sourceStates[stateID + 1];
|
||||
}
|
||||
|
@ -17,54 +17,54 @@
|
||||
along with Darling. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <CoreGraphics/CGEvent.h>
|
||||
#import "CGEventObjC.h"
|
||||
#include "CGEventTapInternal.h"
|
||||
#include <CoreGraphics/CGEvent.h>
|
||||
|
||||
void CGEventPost(CGEventTapLocation tap, CGEventRef _Nullable event)
|
||||
{
|
||||
// TODO: Create an appropriate CGEventTapProxy and call CGEventTapPostEvent()
|
||||
void CGEventPost(CGEventTapLocation tap, CGEventRef _Nullable event) {
|
||||
// TODO: Create an appropriate CGEventTapProxy and call
|
||||
// CGEventTapPostEvent()
|
||||
}
|
||||
|
||||
CFMachPortRef CGEventTapCreate(CGEventTapLocation tap, CGEventTapPlacement place,
|
||||
CGEventTapOptions options, CGEventMask eventsOfInterest, CGEventTapCallBack callback, void *userInfo)
|
||||
CFMachPortRef CGEventTapCreate(CGEventTapLocation tap,
|
||||
CGEventTapPlacement place,
|
||||
CGEventTapOptions options,
|
||||
CGEventMask eventsOfInterest,
|
||||
CGEventTapCallBack callback, void *userInfo)
|
||||
{
|
||||
CGEventTap* newTap = [[CGEventTap alloc] initWithLocation: tap
|
||||
options: options
|
||||
mask: eventsOfInterest
|
||||
callback: callback
|
||||
userInfo: userInfo];
|
||||
CGEventTap *newTap = [[CGEventTap alloc] initWithLocation: tap
|
||||
options: options
|
||||
mask: eventsOfInterest
|
||||
callback: callback
|
||||
userInfo: userInfo];
|
||||
|
||||
mach_port_t port = newTap.machPort;
|
||||
mach_port_t port = newTap.machPort;
|
||||
|
||||
// TODO: Save this port to tapping structures
|
||||
// TODO: Save this port to tapping structures
|
||||
|
||||
CFMachPortRef mp = [newTap createCFMachPort];
|
||||
[newTap release]; // CFMachPortRef now holds a ref
|
||||
CFMachPortRef mp = [newTap createCFMachPort];
|
||||
[newTap release]; // CFMachPortRef now holds a ref
|
||||
|
||||
return mp;
|
||||
return mp;
|
||||
}
|
||||
|
||||
void _CGEventTapDestroyed(CGEventTapLocation location, mach_port_t mp)
|
||||
{
|
||||
// TODO: Deregister the tap
|
||||
void _CGEventTapDestroyed(CGEventTapLocation location, mach_port_t mp) {
|
||||
// TODO: Deregister the tap
|
||||
}
|
||||
|
||||
void CGEventTapEnable(CFMachPortRef tap, bool enable)
|
||||
{
|
||||
mach_port_t mp = CFMachPortGetPort(tap);
|
||||
void CGEventTapEnable(CFMachPortRef tap, bool enable) {
|
||||
mach_port_t mp = CFMachPortGetPort(tap);
|
||||
|
||||
// TODO: Lookup CGEventTap instance by mp
|
||||
CGEventTap* tapObj = nil;
|
||||
tapObj.enabled = enable;
|
||||
// TODO: Lookup CGEventTap instance by mp
|
||||
CGEventTap *tapObj = nil;
|
||||
tapObj.enabled = enable;
|
||||
}
|
||||
|
||||
void CGEventTapPostEvent(CGEventTapProxy proxy, CGEventRef event)
|
||||
{
|
||||
|
||||
void CGEventTapPostEvent(CGEventTapProxy proxy, CGEventRef event) {
|
||||
}
|
||||
|
||||
CGError CGGetEventTapList(uint32_t maxNumberOfTaps, CGEventTapInformation *tapList, uint32_t *eventTapCount)
|
||||
CGError CGGetEventTapList(uint32_t maxNumberOfTaps,
|
||||
CGEventTapInformation *tapList,
|
||||
uint32_t *eventTapCount)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -21,11 +21,10 @@
|
||||
|
||||
extern void _CGEventTapDestroyed(CGEventTapLocation loc, mach_port_t mp);
|
||||
|
||||
struct TapMachMessage
|
||||
{
|
||||
mach_msg_header_t header;
|
||||
CGEventTapProxy proxy;
|
||||
CGEventRef event;
|
||||
struct TapMachMessage {
|
||||
mach_msg_header_t header;
|
||||
CGEventTapProxy proxy;
|
||||
CGEventRef event;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -28,23 +28,20 @@ typedef uint32_t CGWheelCount;
|
||||
typedef uint16_t CGCharCode;
|
||||
typedef uint16_t CGKeyCode;
|
||||
|
||||
typedef CF_OPTIONS(uint32_t, CGEventFilterMask)
|
||||
{
|
||||
kCGEventFilterMaskPermitLocalMouseEvents = 0x00000001,
|
||||
kCGEventFilterMaskPermitLocalKeyboardEvents = 0x00000002,
|
||||
kCGEventFilterMaskPermitSystemDefinedEvents = 0x00000004
|
||||
typedef CF_OPTIONS(uint32_t, CGEventFilterMask) {
|
||||
kCGEventFilterMaskPermitLocalMouseEvents = 0x00000001,
|
||||
kCGEventFilterMaskPermitLocalKeyboardEvents = 0x00000002,
|
||||
kCGEventFilterMaskPermitSystemDefinedEvents = 0x00000004
|
||||
};
|
||||
|
||||
typedef CF_ENUM(uint32_t, CGEventSuppressionState)
|
||||
{
|
||||
kCGEventSuppressionStateSuppressionInterval = 0,
|
||||
kCGEventSuppressionStateRemoteMouseDrag,
|
||||
kCGNumberOfEventSuppressionStates
|
||||
typedef CF_ENUM(uint32_t, CGEventSuppressionState) {
|
||||
kCGEventSuppressionStateSuppressionInterval = 0,
|
||||
kCGEventSuppressionStateRemoteMouseDrag,
|
||||
kCGNumberOfEventSuppressionStates
|
||||
};
|
||||
|
||||
#define kCGEventFilterMaskPermitAllEvents (kCGEventFilterMaskPermitLocalMouseEvents | kCGEventFilterMaskPermitLocalKeyboardEvents | kCGEventFilterMaskPermitSystemDefinedEvents)
|
||||
|
||||
|
||||
// TODO: All those deprecated functions
|
||||
|
||||
#endif
|
||||
|
@ -55,11 +55,12 @@
|
||||
}
|
||||
// Try to merge either empty or one-line block if is precedeed by control
|
||||
// statement token
|
||||
@@ -1132,6 +1140,7 @@ unsigned UnwrappedLineFormatter::format(
|
||||
@@ -1132,6 +1134,8 @@ unsigned UnwrappedLineFormatter::format(
|
||||
!Style.JavaScriptWrapImports)) ||
|
||||
(Style.isCSharp() &&
|
||||
TheLine.InPPDirective); // don't split #regions in C#
|
||||
+ FitsIntoOneLine = FitsIntoOneLine && (!TheLine.mightBeFunctionDefinition() || TheLine.endsWith(tok::l_brace));
|
||||
+ bool functionBraceWrapped = TheLine.mightBeFunctionDefinition() && NextLine && NextLine->startsWith(tok::l_brace) && !TheLine.endsWith(tok::l_brace);
|
||||
+ FitsIntoOneLine = FitsIntoOneLine && !functionBraceWrapped;
|
||||
if (Style.ColumnLimit == 0)
|
||||
NoColumnLimitLineFormatter(Indenter, Whitespaces, Style, this)
|
||||
.formatLine(TheLine, NextStartColumn + Indent,
|
||||
|
Loading…
Reference in New Issue
Block a user