Improve Patch and Format New Code

This commit is contained in:
TheBrokenRail 2020-05-13 11:33:22 -04:00
parent b6548a202d
commit e84bc784cd
10 changed files with 424 additions and 437 deletions

View File

@ -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 {

View File

@ -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 */
};

View File

@ -17,28 +17,25 @@
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)
{
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)
{
CGEventRef CGEventCreateCopy(CGEventRef event) {
return (CGEventRef)[(CGEvent *) event copy];
}
CFDataRef CGEventCreateData(CFAllocatorRef allocator, CGEventRef event)
{
CFDataRef CGEventCreateData(CFAllocatorRef allocator, CGEventRef event) {
CGEvent *e = (CGEvent *) event;
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] init];
@ -50,9 +47,9 @@ CFDataRef CGEventCreateData(CFAllocatorRef allocator, CGEventRef event)
return data;
}
CGEventRef CGEventCreateFromData(CFAllocatorRef allocator, CFDataRef data)
{
NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData: data];
CGEventRef CGEventCreateFromData(CFAllocatorRef allocator, CFDataRef data) {
NSKeyedUnarchiver *unarchiver =
[[NSKeyedUnarchiver alloc] initForReadingWithData: data];
CGEvent *e = [[CGEvent alloc] initWithCoder: unarchiver];
@ -62,44 +59,37 @@ CGEventRef CGEventCreateFromData(CFAllocatorRef allocator, CFDataRef data)
return (CGEventRef) e;
}
CGEventType CGEventGetType(CGEventRef event)
{
CGEventType CGEventGetType(CGEventRef event) {
CGEvent *e = (CGEvent *) event;
return e.type;
}
void CGEventSetSource(CGEventRef event, CGEventSourceRef source)
{
void CGEventSetSource(CGEventRef event, CGEventSourceRef source) {
CGEvent *e = (CGEvent *) event;
e.source = (CGEventSource *) source;
}
CGEventSourceRef CGEventCreateSourceFromEvent(CGEventRef event)
{
CGEventSourceRef CGEventCreateSourceFromEvent(CGEventRef event) {
CGEvent *e = (CGEvent *) event;
return (CGEventSourceRef)[(CGEventSource *) e.source retain];
}
void CGEventSetType(CGEventRef event, CGEventType type)
{
void CGEventSetType(CGEventRef event, CGEventType type) {
CGEvent *e = (CGEvent *) event;
e.type = type;
}
CGEventTimestamp CGEventGetTimestamp(CGEventRef event)
{
CGEventTimestamp CGEventGetTimestamp(CGEventRef event) {
CGEvent *e = (CGEvent *) event;
return e.timestamp;
}
void CGEventSetTimestamp(CGEventRef event, CGEventTimestamp timestamp)
{
void CGEventSetTimestamp(CGEventRef event, CGEventTimestamp timestamp) {
CGEvent *e = (CGEvent *) event;
e.timestamp = timestamp;
}
int64_t CGEventGetIntegerValueField(CGEventRef event, CGEventField field)
{
int64_t CGEventGetIntegerValueField(CGEventRef event, CGEventField field) {
CGEvent *e = (CGEvent *) event;
NSNumber *value = e.fields[[NSNumber numberWithInt: field]];
@ -108,14 +98,15 @@ int64_t CGEventGetIntegerValueField(CGEventRef event, CGEventField field)
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];
e.fields[[NSNumber numberWithInt: field]] =
[NSNumber numberWithLongLong: value];
}
double CGEventGetDoubleValueField(CGEventRef event, CGEventField field)
{
double CGEventGetDoubleValueField(CGEventRef event, CGEventField field) {
CGEvent *e = (CGEvent *) event;
NSNumber *value = e.fields[[NSNumber numberWithInt: field]];
@ -124,38 +115,49 @@ double CGEventGetDoubleValueField(CGEventRef event, CGEventField field)
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];
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];
CGEvent *event = [[CGEvent alloc] initWithSource: (CGEventSource *) source
type: type];
event.virtualKey = virtualKey;
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];
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];
CGEvent *event = [[CGEvent alloc] initWithSource: (CGEventSource *) source
type: kCGEventScrollWheel];
event.scrollEventUnit = units;
event.wheelCount = wheelCount;
event.wheels[0] = wheel1;
if (wheelCount > 1)
{
if (wheelCount > 1) {
va_list vl;
va_start(vl, wheel1);
@ -169,19 +171,20 @@ CGEventRef CGEventCreateScrollWheelEvent(CGEventSourceRef source, CGScrollEventU
return (CGEventRef) event;
}
CGPoint CGEventGetLocation(CGEventRef event)
{
CGPoint CGEventGetLocation(CGEventRef event) {
CGEvent *e = (CGEvent *) event;
return e.location;
}
void CGEventSetLocation(CGEventRef event, CGPoint 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;
@ -190,8 +193,7 @@ void CGEventKeyboardGetUnicodeString(CGEventRef event, UniCharCount maxStringLen
while (length < 5 && savedString[length])
length++;
if (maxStringLength == 0)
{
if (maxStringLength == 0) {
*actualStringLength = length;
}
@ -202,7 +204,9 @@ void CGEventKeyboardGetUnicodeString(CGEventRef event, UniCharCount maxStringLen
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;

View File

@ -19,11 +19,11 @@
#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;
@ -125,4 +125,3 @@
@end
#endif

View File

@ -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,10 +36,8 @@
@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
@ -52,8 +50,7 @@
return self;
}
-(instancetype) initWithCoder:(NSCoder*) coder
{
- (instancetype) initWithCoder: (NSCoder *) coder {
NSKeyedUnarchiver *unarchiver = (NSKeyedUnarchiver *) coder;
// TODO
@ -61,15 +58,13 @@
return self;
}
-(void) dealloc
{
- (void) dealloc {
[_source release];
[_fields release];
[super dealloc];
}
-(id)copy
{
- (id) copy {
CGEvent *rv = [[CGEvent alloc] initWithSource: _source type: _type];
rv->_timestamp = self->_timestamp;
rv->_flags = self->_flags;
@ -88,28 +83,23 @@
return rv;
}
- (id)copyWithZone:(NSZone *)zone
{
- (id) copyWithZone: (NSZone *) zone {
return [self copy];
}
-(CFTypeID) _cfTypeID
{
- (CFTypeID) _cfTypeID {
return CGEventGetTypeID();
}
-(int32_t*) wheels
{
- (int32_t *) wheels {
return _wheels;
}
-(UniChar*) unicodeString
{
- (UniChar *) unicodeString {
return _unicodeString;
}
-(void) encodeWithCoder:(NSCoder*) coder
{
- (void) encodeWithCoder: (NSCoder *) coder {
NSKeyedArchiver *archiver = (NSKeyedArchiver *) coder;
CGEventSourceStateID stateId = _source.stateID;
@ -119,16 +109,18 @@
[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 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,21 +133,20 @@
@synthesize userData = _userData;
@synthesize pixelsPerLine = _pixelsPerLine;
-(instancetype) initWithState: (CGEventSourceStateID) stateId
{
- (instancetype) initWithState: (CGEventSourceStateID) stateId {
_stateId = stateId;
return self;
}
-(CFTypeID) _cfTypeID
{
- (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;
@ -163,18 +154,17 @@ static void cgEventTapCallout(CFMachPortRef mp, void* msg, CFIndex size, void* i
CGEventRef event = tapMessage->event;
CGEventType type = CGEventGetType(tapMessage->event);
if (tap.enabled && (CGEventMaskBit(type) & tap.mask) != 0)
{
if (tap.enabled && (CGEventMaskBit(type) & tap.mask) != 0) {
// Invoke callback
CGEventRef returned = tap.callback(tapMessage->proxy, type, event, tap.userInfo);
CGEventRef returned =
tap.callback(tapMessage->proxy, type, event, tap.userInfo);
if (!(tap.options & kCGEventTapOptionListenOnly))
event = returned;
}
// Pass the message on
if (event != NULL)
{
if (event != NULL) {
CGEventTapPostEvent(tapMessage->proxy, event);
if (event != tapMessage->event)
@ -206,12 +196,15 @@ static void cgEventTapCallout(CFMachPortRef mp, void* msg, CFIndex size, void* i
_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);
if (MACH_PORT_NULL != _machPort)
mach_port_destroy(mach_task_self(), _machPort);
[self release];
return nil;
}
@ -219,15 +212,13 @@ static void cgEventTapCallout(CFMachPortRef mp, void* msg, CFIndex size, void* i
return self;
}
-(void) dealloc
{
- (void) dealloc {
_CGEventTapDestroyed(_location, _machPort);
mach_port_destroy(mach_task_self(), _machPort);
[super dealloc];
}
-(CFMachPortRef) createCFMachPort
{
- (CFMachPortRef) createCFMachPort {
CFMachPortRef mp;
CFMachPortContext ctxt = {
.copyDescription = NULL,
@ -237,7 +228,8 @@ static void cgEventTapCallout(CFMachPortRef mp, void* msg, CFIndex size, void* i
.version = 0,
};
mp = CFMachPortCreateWithPort(NULL, _machPort, cgEventTapCallout, &ctxt, NULL);
mp = CFMachPortCreateWithPort(NULL, _machPort, cgEventTapCallout, &ctxt,
NULL);
return mp;
}

View File

@ -16,18 +16,16 @@
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)
{
CFTypeID CGEventSourceGetTypeID(void) {
return (CFTypeID)[CGEventSource self];
}
CGEventSourceRef CGEventSourceCreate(CGEventSourceStateID stateID)
{
CGEventSourceRef CGEventSourceCreate(CGEventSourceStateID stateID) {
return (CGEventSourceRef) [[CGEventSource alloc] initWithState: stateID];
}
@ -37,43 +35,40 @@ CGEventSourceKeyboardType CGEventSourceGetKeyboardType(CGEventSourceRef source)
return src.keyboardType;
}
void CGEventSourceSetKeyboardType(CGEventSourceRef source, CGEventSourceKeyboardType keyboardType)
void CGEventSourceSetKeyboardType(CGEventSourceRef source,
CGEventSourceKeyboardType keyboardType)
{
CGEventSource *src = (CGEventSource *) source;
src.keyboardType = keyboardType;
}
CGEventSourceStateID CGEventSourceGetSourceStateID(CGEventSourceRef source)
{
CGEventSourceStateID CGEventSourceGetSourceStateID(CGEventSourceRef source) {
CGEventSource *src = (CGEventSource *) source;
return src.stateID;
}
int64_t CGEventSourceGetUserData(CGEventSourceRef source)
{
int64_t CGEventSourceGetUserData(CGEventSourceRef source) {
CGEventSource *src = (CGEventSource *) source;
return src.userData;
}
void CGEventSourceSetUserData(CGEventSourceRef source, int64_t userData)
{
void CGEventSourceSetUserData(CGEventSourceRef source, int64_t userData) {
CGEventSource *src = (CGEventSource *) source;
src.userData = userData;
}
double CGEventSourceGetPixelsPerLine(CGEventSourceRef source)
{
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;
}
CGEventFlags CGEventSourceFlagsState(CGEventSourceStateID stateID)
{
CGEventFlags CGEventSourceFlagsState(CGEventSourceStateID stateID) {
return g_sourceStates[stateID + 1];
}

View File

@ -17,17 +17,20 @@
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
@ -45,13 +48,11 @@ CFMachPortRef CGEventTapCreate(CGEventTapLocation tap, CGEventTapPlacement place
return mp;
}
void _CGEventTapDestroyed(CGEventTapLocation location, mach_port_t mp)
{
void _CGEventTapDestroyed(CGEventTapLocation location, mach_port_t mp) {
// TODO: Deregister the tap
}
void CGEventTapEnable(CFMachPortRef tap, bool enable)
{
void CGEventTapEnable(CFMachPortRef tap, bool enable) {
mach_port_t mp = CFMachPortGetPort(tap);
// TODO: Lookup CGEventTap instance by mp
@ -59,12 +60,11 @@ void CGEventTapEnable(CFMachPortRef tap, bool enable)
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)
{
}

View File

@ -21,8 +21,7 @@
extern void _CGEventTapDestroyed(CGEventTapLocation loc, mach_port_t mp);
struct TapMachMessage
{
struct TapMachMessage {
mach_msg_header_t header;
CGEventTapProxy proxy;
CGEventRef event;

View File

@ -28,15 +28,13 @@ typedef uint32_t CGWheelCount;
typedef uint16_t CGCharCode;
typedef uint16_t CGKeyCode;
typedef CF_OPTIONS(uint32_t, CGEventFilterMask)
{
typedef CF_OPTIONS(uint32_t, CGEventFilterMask) {
kCGEventFilterMaskPermitLocalMouseEvents = 0x00000001,
kCGEventFilterMaskPermitLocalKeyboardEvents = 0x00000002,
kCGEventFilterMaskPermitSystemDefinedEvents = 0x00000004
};
typedef CF_ENUM(uint32_t, CGEventSuppressionState)
{
typedef CF_ENUM(uint32_t, CGEventSuppressionState) {
kCGEventSuppressionStateSuppressionInterval = 0,
kCGEventSuppressionStateRemoteMouseDrag,
kCGNumberOfEventSuppressionStates
@ -44,7 +42,6 @@ typedef CF_ENUM(uint32_t, CGEventSuppressionState)
#define kCGEventFilterMaskPermitAllEvents (kCGEventFilterMaskPermitLocalMouseEvents | kCGEventFilterMaskPermitLocalKeyboardEvents | kCGEventFilterMaskPermitSystemDefinedEvents)
// TODO: All those deprecated functions
#endif

View File

@ -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,