Skip to content

Commit

Permalink
CGEvent missing function (darlinghq/darling#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hyatt committed Jan 7, 2019
1 parent 46e8401 commit 972b6ec
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 24 deletions.
4 changes: 3 additions & 1 deletion AppKit/X11.backend/X11Event.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#import <AppKit/CGEvent.h>
#import <X11/Xlib.h>

@interface X11Event : CGEvent {
// Does inheriting from CGEvent make sense? The real CG doesn't use any
// objc and our CGEvent class was empty.
@interface X11Event : NSObject {
XEvent _event;
}

Expand Down
13 changes: 0 additions & 13 deletions CoreGraphics/CGEvent.m

This file was deleted.

34 changes: 32 additions & 2 deletions CoreGraphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,44 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
-include math.h \
-include stdlib.h \
-include CoreFoundation/CoreFoundation.h \
-include Foundation/Foundation.h \
-Wno-nonportable-include-path \
-mmacosx-version-min=10.10"
)

find_package(PkgConfig REQUIRED)
pkg_check_modules(PC_CAIRO cairo)

set_property(SOURCE
CGAffineTransform.m
CGBitmapContext.m
CGColor.m
CGColorSpace.m
CGContext.m
CGDataConsumer.m
CGDataProvider.m
CGDirectDisplay.m
CGFont.m
CGFunction.m
CGGeometry.m
CGGradient.m
CGImageDestination.m
CGImage.m
CGImageProperties.m
CGImageSource.m
CGLayer.m
CGLPixelSurface.m
CGPath.m
CGPattern.m
CGPDFContext.m
CGPDFDocument.m
CGPDFPage.m
CGShading.m
CGWindow.m
CGSubWindow.m

APPEND PROPERTY COMPILE_FLAGS "-include Foundation/Foundation.h"
)

include_directories(
${CMAKE_SOURCE_DIR}/src/external/foundation/include
${CMAKE_SOURCE_DIR}/src/external/foundation/include/Foundation
Expand Down Expand Up @@ -48,7 +78,7 @@ set(CoreGraphics_sources
CGDataConsumer.m
CGDataProvider.m
CGDirectDisplay.m
CGEvent.m
src/CGEvent.c
CGFont.m
CGFunction.m
CGGeometry.m
Expand Down
2 changes: 1 addition & 1 deletion CoreGraphics/include/CoreGraphics/CGBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <float.h>

// Moved over from our CoreFoudnation
// Moved over from our CoreFoundation

#ifdef __LP64__
typedef double CGFloat;
Expand Down
28 changes: 21 additions & 7 deletions CoreGraphics/include/CoreGraphics/CGEvent.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
/* Copyright (c) 2006-2007 Christopher J. W. Lloyd
/*
This file is part of Darling.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Copyright (C) 2019 Lubos Dolezel
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Darling is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
Darling is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
#import <Foundation/Foundation.h>
You should have received a copy of the GNU General Public License
along with Darling. If not, see <http://www.gnu.org/licenses/>.
*/

@interface CGEvent : NSObject
#ifndef _CGEVENT_H_
#define _CGEVENT_H_

@end
#include <CoreGraphics/CGEventTypes.h>

extern void CGEventPost(CGEventTapLocation tapLocation, CGEventRef event);

#endif
35 changes: 35 additions & 0 deletions CoreGraphics/include/CoreGraphics/CGEventTypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
This file is part of Darling.
Copyright (C) 2019 Lubos Dolezel
Darling is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Darling is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Darling. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _CGEVENTTYPES_H_
#define _CGEVENTTYPES_H_

#include <CoreFoundation/CFBase.h>
#include <CoreFoundation/CFAvailability.h>
#include <CoreGraphics/CGBase.h>

typedef struct CF_BRIDGED_TYPE(id) __CGEvent *CGEventRef;

typedef CF_ENUM(uint32_t, CGEventTapLocation) {
kCGHIDEventTap = 0,
kCGSessionEventTap,
kCGAnnotatedSessionEventTap
};

#endif
2 changes: 2 additions & 0 deletions CoreGraphics/include/CoreGraphics/CoreGraphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <CoreGraphics/CGShading.h>
#import <CoreGraphics/CGDirectDisplay.h>
#import <CoreGraphics/CGWindowLevel.h>

#include <CoreGraphics/CGEvent.h>
26 changes: 26 additions & 0 deletions CoreGraphics/src/CGEvent.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
This file is part of Darling.
Copyright (C) 2019 Lubos Dolezel
Darling is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Darling is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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/CGEvent.h>
#include <stdio.h>

void CGEventPost(CGEventTapLocation tapLocation, CGEventRef event)
{
printf("STUB CGEventPost called\n");
}

0 comments on commit 972b6ec

Please sign in to comment.