├── .gitignore ├── CGSInternal ├── CGSAccessibility.h ├── CGSCIFilter.h ├── CGSConnection.h ├── CGSCursor.h ├── CGSDebug.h ├── CGSDevice.h ├── CGSDisplays.h ├── CGSEvent.h ├── CGSHotKeys.h ├── CGSInternal.h ├── CGSMisc.h ├── CGSRegion.h ├── CGSSession.h ├── CGSSpace.h ├── CGSSurface.h ├── CGSTile.h ├── CGSTransitions.h ├── CGSWindow.h ├── CGSWorkspace.h └── Info.plist ├── DIYWindows.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── GSExample ├── CAContext.h └── main.m ├── GraphicsServices ├── CFBase.c ├── CGSEventTypes.h ├── GSApp.c ├── GSApp.h ├── GSBase.h ├── GSCoreFoundationBridge.h ├── GSEvent.c ├── GSEvent.h ├── GSEventQueue.c ├── GSEventQueue.h ├── GSEventTypes.def ├── GSEventTypes.h ├── GSPrivate.c ├── GSPrivate.h ├── GraphicsServices.h └── Info.plist ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /CGSInternal/CGSAccessibility.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_ACCESSIBILITY_INTERNAL_H 31 | #define CGS_ACCESSIBILITY_INTERNAL_H 32 | 33 | #include "CGSConnection.h" 34 | 35 | 36 | #pragma mark - Display Zoom 37 | 38 | 39 | /// Gets whether the display is zoomed. 40 | CG_EXTERN CGError CGSIsZoomed(CGSConnectionID cid, bool *outIsZoomed); 41 | 42 | 43 | #pragma mark - Invert Colors 44 | 45 | 46 | /// Gets the preference value for inverted colors on the current display. 47 | CG_EXTERN bool CGDisplayUsesInvertedPolarity(void); 48 | 49 | /// Sets the preference value for the state of the inverted colors on the current display. This 50 | /// preference value is monitored by the system, and updating it causes a fairly immediate change 51 | /// in the screen's colors. 52 | /// 53 | /// Internally, this sets and synchronizes `DisplayUseInvertedPolarity` in the 54 | /// "com.apple.CoreGraphics" preferences bundle. 55 | CG_EXTERN void CGDisplaySetInvertedPolarity(bool invertedPolarity); 56 | 57 | 58 | #pragma mark - Use Grayscale 59 | 60 | 61 | /// Gets whether the screen forces all drawing as grayscale. 62 | CG_EXTERN bool CGDisplayUsesForceToGray(void); 63 | 64 | /// Sets whether the screen forces all drawing as grayscale. 65 | CG_EXTERN void CGDisplayForceToGray(bool forceToGray); 66 | 67 | 68 | #pragma mark - Increase Contrast 69 | 70 | 71 | /// Sets the display's contrast. There doesn't seem to be a get version of this function. 72 | CG_EXTERN CGError CGSSetDisplayContrast(CGFloat contrast); 73 | 74 | #endif /* CGS_ACCESSIBILITY_INTERNAL_H */ 75 | -------------------------------------------------------------------------------- /CGSInternal/CGSCIFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_CIFILTER_INTERNAL_H 31 | #define CGS_CIFILTER_INTERNAL_H 32 | 33 | #include "CGSConnection.h" 34 | 35 | typedef enum { 36 | kCGWindowFilterUnderlay = 1, 37 | kCGWindowFilterDock = 0x3001, 38 | } CGSCIFilterID; 39 | 40 | /// Creates a new filter from a filter name. 41 | /// 42 | /// Any valid CIFilter names are valid names for this function. 43 | CG_EXTERN CGError CGSNewCIFilterByName(CGSConnectionID cid, CFStringRef filterName, CGSCIFilterID *outFilter); 44 | 45 | /// Inserts the given filter into the window. 46 | /// 47 | /// The values for the `flags` field is currently unknown. 48 | CG_EXTERN CGError CGSAddWindowFilter(CGSConnectionID cid, CGWindowID wid, CGSCIFilterID filter, int flags); 49 | 50 | /// Removes the given filter from the window. 51 | CG_EXTERN CGError CGSRemoveWindowFilter(CGSConnectionID cid, CGWindowID wid, CGSCIFilterID filter); 52 | 53 | /// Invokes `-[CIFilter setValue:forKey:]` on each entry in the dictionary for the window's filter. 54 | /// 55 | /// The Window Server only checks for the existence of 56 | /// 57 | /// inputPhase 58 | /// inputPhase0 59 | /// inputPhase1 60 | CG_EXTERN CGError CGSSetCIFilterValuesFromDictionary(CGSConnectionID cid, CGSCIFilterID filter, CFDictionaryRef filterValues); 61 | 62 | /// Releases a window's CIFilter. 63 | CG_EXTERN CGError CGSReleaseCIFilter(CGSConnectionID cid, CGSCIFilterID filter); 64 | 65 | #endif /* CGS_CIFILTER_INTERNAL_H */ 66 | -------------------------------------------------------------------------------- /CGSInternal/CGSConnection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_CONNECTION_INTERNAL_H 31 | #define CGS_CONNECTION_INTERNAL_H 32 | 33 | /// The type of connections to the Window Server. 34 | /// 35 | /// Every application is given a singular connection ID through which it can receieve and manipulate 36 | /// values, state, notifications, events, etc. in the Window Server. It 37 | typedef int CGSConnectionID; 38 | 39 | typedef void *CGSNotificationData; 40 | typedef void *CGSNotificationArg; 41 | typedef int CGSTransitionID; 42 | 43 | 44 | #pragma mark - Connection Lifecycle 45 | 46 | 47 | /// Gets the default connection for this process. 48 | CG_EXTERN CGSConnectionID CGSMainConnectionID(void); 49 | 50 | /// Creates a new connection to the Window Server. 51 | CG_EXTERN CGError CGSNewConnection(int unused, CGSConnectionID *outConnection); 52 | 53 | /// Releases a CGSConnection and all CGSWindows owned by it. 54 | CG_EXTERN CGError CGSReleaseConnection(CGSConnectionID cid); 55 | 56 | /// Gets the default connection for the current thread. 57 | CG_EXTERN CGSConnectionID CGSDefaultConnectionForThread(void); 58 | 59 | /// Gets the pid of the process that owns this connection to the Window Server. 60 | CG_EXTERN CGError CGSConnectionGetPID(CGSConnectionID cid, pid_t *outPID); 61 | 62 | /// Gets the connection for the given process serial number. 63 | CG_EXTERN CGError CGSGetConnectionIDForPSN(CGSConnectionID cid, const ProcessSerialNumber *psn, CGSConnectionID *outOwnerCID); 64 | 65 | /// Returns whether the menu bar exists for the given connection ID. 66 | /// 67 | /// For the majority of applications, this function should return true. But at system updates, 68 | /// initialization, and shutdown, the menu bar will be either initially gone then created or 69 | /// hidden and then destroyed. 70 | CG_EXTERN bool CGSMenuBarExists(CGSConnectionID cid); 71 | 72 | /// Closes ALL connections to the Window Server by the current application. 73 | /// 74 | /// The application is effectively turned into a Console-based application after the invocation of 75 | /// this method. 76 | CG_EXTERN CGError CGSShutdownServerConnections(void); 77 | 78 | 79 | #pragma mark - Connection Properties 80 | 81 | 82 | /// Retrieves the value associated with the given key for the given connection. 83 | /// 84 | /// This method is structured so processes can send values through the Window Server to other 85 | /// processes - assuming they know each others connection IDs. The recommended use case for this 86 | /// function appears to be keeping state around for application-level sub-connections. 87 | CG_EXTERN CGError CGSCopyConnectionProperty(CGSConnectionID cid, CGSConnectionID targetCID, CFStringRef key, CFTypeRef *outValue); 88 | 89 | /// Associates a value for the given key on the given connection. 90 | CG_EXTERN CGError CGSSetConnectionProperty(CGSConnectionID cid, CGSConnectionID targetCID, CFStringRef key, CFTypeRef value); 91 | 92 | 93 | #pragma mark - Connection Updates 94 | 95 | 96 | /// Disables updates on a connection 97 | /// 98 | /// Calls to disable updates nest much like `-beginUpdates`/`-endUpdates`. the Window Server will 99 | /// forcibly reenable updates after 1 second if you fail to invoke `CGSReenableUpdate`. 100 | CG_EXTERN CGError CGSDisableUpdate(CGSConnectionID cid); 101 | 102 | /// Re-enables updates on a connection. 103 | /// 104 | /// Calls to enable updates nest much like `-beginUpdates`/`-endUpdates`. 105 | CG_EXTERN CGError CGSReenableUpdate(CGSConnectionID cid); 106 | 107 | 108 | #pragma mark - Connection Notifications 109 | 110 | 111 | typedef void (*CGSNewConnectionNotificationProc)(CGSConnectionID cid); 112 | 113 | /// Registers a function that gets invoked when the application's connection ID is created by the 114 | /// Window Server. 115 | CG_EXTERN CGError CGSRegisterForNewConnectionNotification(CGSNewConnectionNotificationProc proc); 116 | 117 | /// Removes a function that was registered to receive notifications for the creation of the 118 | /// application's connection to the Window Server. 119 | CG_EXTERN CGError CGSRemoveNewConnectionNotification(CGSNewConnectionNotificationProc proc); 120 | 121 | typedef void (*CGSConnectionDeathNotificationProc)(CGSConnectionID cid); 122 | 123 | /// Registers a function that gets invoked when the application's connection ID is destroyed - 124 | /// ideally by the Window Server. 125 | /// 126 | /// Connection death is supposed to be a fatal event that is only triggered when the application 127 | /// terminates or when you have explicitly destroyed a sub-connection to the Window Server. 128 | CG_EXTERN CGError CGSRegisterForConnectionDeathNotification(CGSConnectionDeathNotificationProc proc); 129 | 130 | /// Removes a function that was registered to receive notifications for the destruction of the 131 | /// application's connection to the Window Server. 132 | CG_EXTERN CGError CGSRemoveConnectionDeathNotification(CGSConnectionDeathNotificationProc proc); 133 | 134 | 135 | #pragma mark - Miscellaneous Security Holes 136 | 137 | /// Sets a "Universal Owner" for the connection ID. Currently, that owner is Dock.app, which needs 138 | /// control over the window to provide system features like hiding and showing windows, moving them 139 | /// around, etc. 140 | /// 141 | /// Because the Universal Owner owns every window under this connection, it can manipulate them 142 | /// all as it sees fit. If you can beat the dock, you have total control over the process' 143 | /// connection. 144 | CG_EXTERN CGError CGSSetUniversalOwner(CGSConnectionID cid); 145 | 146 | /// Assuming you have the connection ID of the current universal owner, or are said universal owner, 147 | /// allows you to specify another connection that has total control over the application's windows. 148 | CG_EXTERN CGError CGSSetOtherUniversalConnection(CGSConnectionID cid, CGSConnectionID otherConnection); 149 | 150 | /// Sets the given connection ID as the login window connection ID. Windows for the application are 151 | /// then brought to the fore when the computer logs off or goes to sleep. 152 | /// 153 | /// Why this is still here, I have no idea. Window Server only accepts one process calling this 154 | /// ever. If you attempt to invoke this after loginwindow does you will be yelled at and nothing 155 | /// will happen. If you can manage to beat loginwindow, however, you know what they say: 156 | /// 157 | /// When you teach a man to phish... 158 | CG_EXTERN CGError CGSSetLoginwindowConnection(CGSConnectionID cid) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; 159 | 160 | //! The data sent with kCGSNotificationAppUnresponsive and kCGSNotificationAppResponsive. 161 | typedef struct { 162 | #if __BIG_ENDIAN__ 163 | uint16_t majorVersion; 164 | uint16_t minorVersion; 165 | #else 166 | uint16_t minorVersion; 167 | uint16_t majorVersion; 168 | #endif 169 | 170 | //! The length of the entire notification. 171 | uint32_t length; 172 | 173 | CGSConnectionID cid; 174 | pid_t pid; 175 | ProcessSerialNumber psn; 176 | } CGSProcessNotificationData; 177 | 178 | //! The data sent with kCGSNotificationDebugOptionsChanged. 179 | typedef struct { 180 | int newOptions; 181 | int unknown[2]; // these two seem to be zero 182 | } CGSDebugNotificationData; 183 | 184 | //! The data sent with kCGSNotificationTransitionEnded 185 | typedef struct { 186 | CGSTransitionID transition; 187 | } CGSTransitionNotificationData; 188 | 189 | #endif /* CGS_CONNECTION_INTERNAL_H */ 190 | -------------------------------------------------------------------------------- /CGSInternal/CGSCursor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_CURSOR_INTERNAL_H 31 | #define CGS_CURSOR_INTERNAL_H 32 | 33 | #include "CGSConnection.h" 34 | 35 | typedef enum : NSInteger { 36 | CGSCursorArrow = 0, 37 | CGSCursorIBeam = 1, 38 | CGSCursorIBeamXOR = 2, 39 | CGSCursorAlias = 3, 40 | CGSCursorCopy = 4, 41 | CGSCursorMove = 5, 42 | CGSCursorArrowContext = 6, 43 | CGSCursorWait = 7, 44 | CGSCursorEmpty = 8, 45 | } CGSCursorID; 46 | 47 | 48 | /// Registers a cursor with the given properties. 49 | /// 50 | /// - Parameter cid: The connection ID to register with. 51 | /// - Parameter cursorName: The system-wide name the cursor will be registered under. 52 | /// - Parameter setGlobally: Whether the cursor registration can appear system-wide. 53 | /// - Parameter instantly: Whether the registration of cursor images should occur immediately. Passing false 54 | /// may speed up the call. 55 | /// - Parameter frameCount: The number of images in the cursor image array. 56 | /// - Parameter imageArray: An array of CGImageRefs that are used to display the cursor. Multiple images in 57 | /// conjunction with a non-zero `frameDuration` cause animation. 58 | /// - Parameter cursorSize: The size of the cursor's images. Recommended size is 16x16 points 59 | /// - Parameter hotspot: The location touch events will emanate from. 60 | /// - Parameter seed: The seed for the cursor's registration. 61 | /// - Parameter bounds: The total size of the cursor. 62 | /// - Parameter frameDuration: How long each image will be displayed for. 63 | /// - Parameter repeatCount: Number of times the cursor should repeat cycling its image frames. 64 | CG_EXTERN CGError CGSRegisterCursorWithImages(CGSConnectionID cid, 65 | const char *cursorName, 66 | bool setGlobally, bool instantly, 67 | NSUInteger frameCount, CFArrayRef imageArray, 68 | CGSize cursorSize, CGPoint hotspot, 69 | int *seed, 70 | CGRect bounds, CGFloat frameDuration, 71 | NSInteger repeatCount); 72 | 73 | 74 | #pragma mark - Cursor Registration 75 | 76 | 77 | /// Copies the size of data associated with the cursor registered under the given name. 78 | CG_EXTERN CGError CGSGetRegisteredCursorDataSize(CGSConnectionID cid, const char *cursorName, size_t *outDataSize); 79 | 80 | /// Re-assigns the given cursor name to the cursor represented by the given seed value. 81 | CG_EXTERN CGError CGSSetRegisteredCursor(CGSConnectionID cid, const char *cursorName, int *cursorSeed); 82 | 83 | /// Copies the properties out of the cursor registered under the given name. 84 | CG_EXTERN CGError CGSCopyRegisteredCursorImages(CGSConnectionID cid, const char *cursorName, CGSize *imageSize, CGPoint *hotSpot, NSUInteger *frameCount, CGFloat *frameDuration, CFArrayRef *imageArray); 85 | 86 | /// Re-assigns one of the system-defined cursors to the cursor represented by the given seed value. 87 | CG_EXTERN void CGSSetSystemDefinedCursorWithSeed(CGSConnectionID connection, CGSCursorID systemCursor, int *cursorSeed); 88 | 89 | 90 | #pragma mark - Cursor Display 91 | 92 | 93 | /// Shows the cursor. 94 | CG_EXTERN CGError CGSShowCursor(CGSConnectionID cid); 95 | 96 | /// Hides the cursor. 97 | CG_EXTERN CGError CGSHideCursor(CGSConnectionID cid); 98 | 99 | /// Hides the cursor until the cursor is moved. 100 | CG_EXTERN CGError CGSObscureCursor(CGSConnectionID cid); 101 | 102 | /// Acts as if a mouse moved event occured and that reveals the cursor if it was hidden. 103 | CG_EXTERN CGError CGSRevealCursor(CGSConnectionID cid); 104 | 105 | /// Shows or hides the spinning beachball of death. 106 | /// 107 | /// If you call this, I hate you. 108 | CG_EXTERN CGError CGSForceWaitCursorActive(CGSConnectionID cid, bool showWaitCursor); 109 | 110 | /// Unconditionally sets the location of the cursor on the screen to the given coordinates. 111 | CG_EXTERN CGError CGSWarpCursorPosition(CGSConnectionID cid, CGFloat x, CGFloat y); 112 | 113 | 114 | #pragma mark - Cursor Properties 115 | 116 | 117 | /// Gets the current cursor's seed value. 118 | /// 119 | /// Every time the cursor is updated, the seed changes. 120 | CG_EXTERN int CGSCurrentCursorSeed(void); 121 | 122 | /// Gets the current location of the cursor relative to the screen's coordinates. 123 | CG_EXTERN CGError CGSGetCurrentCursorLocation(CGSConnectionID cid, CGPoint *outPos); 124 | 125 | /// Gets the name (ideally in reverse DNS form) of a system cursor. 126 | CG_EXTERN char *CGSCursorNameForSystemCursor(CGSCursorID cursor); 127 | 128 | /// Gets the scale of the current currsor. 129 | CG_EXTERN CGError CGSGetCursorScale(CGSConnectionID cid, CGFloat *outScale); 130 | 131 | /// Sets the scale of the current cursor. 132 | /// 133 | /// The largest the Universal Access prefpane allows you to go is 4.0. 134 | CG_EXTERN CGError CGSSetCursorScale(CGSConnectionID cid, CGFloat scale); 135 | 136 | 137 | #pragma mark - Cursor Data 138 | 139 | 140 | /// Gets the size of the data for the connection's cursor. 141 | CG_EXTERN CGError CGSGetCursorDataSize(CGSConnectionID cid, size_t *outDataSize); 142 | 143 | /// Gets the data for the connection's cursor. 144 | CG_EXTERN CGError CGSGetCursorData(CGSConnectionID cid, void *outData); 145 | 146 | /// Gets the size of the data for the current cursor. 147 | CG_EXTERN CGError CGSGetGlobalCursorDataSize(CGSConnectionID cid, size_t *outDataSize); 148 | 149 | /// Gets the data for the current cursor. 150 | CG_EXTERN CGError CGSGetGlobalCursorData(CGSConnectionID cid, void *outData, int *outDataSize, int *outRowBytes, CGRect *outRect, CGPoint *outHotSpot, int *outDepth, int *outComponents, int *outBitsPerComponent); 151 | 152 | /// Gets the size of data for a system-defined cursor. 153 | CG_EXTERN CGError CGSGetSystemDefinedCursorDataSize(CGSConnectionID cid, CGSCursorID cursor, size_t *outDataSize); 154 | 155 | /// Gets the data for a system-defined cursor. 156 | CG_EXTERN CGError CGSGetSystemDefinedCursorData(CGSConnectionID cid, CGSCursorID cursor, void *outData, int *outRowBytes, CGRect *outRect, CGPoint *outHotSpot, int *outDepth, int *outComponents, int *outBitsPerComponent); 157 | 158 | #endif /* CGS_CURSOR_INTERNAL_H */ 159 | -------------------------------------------------------------------------------- /CGSInternal/CGSDebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Routines for debugging the Window Server and application drawing. 3 | * 4 | * Copyright (C) 2007-2008 Alacatia Labs 5 | * 6 | * This software is provided 'as-is', without any express or implied 7 | * warranty. In no event will the authors be held liable for any damages 8 | * arising from the use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not 15 | * claim that you wrote the original software. If you use this software 16 | * in a product, an acknowledgment in the product documentation would be 17 | * appreciated but is not required. 18 | * 2. Altered source versions must be plainly marked as such, and must not be 19 | * misrepresented as being the original software. 20 | * 3. This notice may not be removed or altered from any source distribution. 21 | * 22 | * Joe Ranieri joe@alacatia.com 23 | * 24 | */ 25 | 26 | // 27 | // Updated by Robert Widmann. 28 | // Copyright © 2015-2016 CodaFi. All rights reserved. 29 | // Released under the MIT license. 30 | // 31 | 32 | #ifndef CGS_DEBUG_INTERNAL_H 33 | #define CGS_DEBUG_INTERNAL_H 34 | 35 | #include "CGSConnection.h" 36 | 37 | /// The set of options that the Window Server 38 | typedef enum { 39 | /// Clears all flags. 40 | kCGSDebugOptionNone = 0, 41 | 42 | /// All screen updates are flashed in yellow. Regions under a DisableUpdate are flashed in orange. Regions that are hardware accellerated are painted green. 43 | kCGSDebugOptionFlashScreenUpdates = 0x4, 44 | 45 | /// Colors windows green if they are accellerated, otherwise red. Doesn't cause things to refresh properly - leaves excess rects cluttering the screen. 46 | kCGSDebugOptionColorByAccelleration = 0x20, 47 | 48 | /// Disables shadows on all windows. 49 | kCGSDebugOptionNoShadows = 0x4000, 50 | 51 | /// Setting this disables the pause after a flash when using FlashScreenUpdates or FlashIdenticalUpdates. 52 | kCGSDebugOptionNoDelayAfterFlash = 0x20000, 53 | 54 | /// Flushes the contents to the screen after every drawing operation. 55 | kCGSDebugOptionAutoflushDrawing = 0x40000, 56 | 57 | /// Highlights mouse tracking areas. Doesn't cause things to refresh correctly - leaves excess rectangles cluttering the screen. 58 | kCGSDebugOptionShowMouseTrackingAreas = 0x100000, 59 | 60 | /// Flashes identical updates in red. 61 | kCGSDebugOptionFlashIdenticalUpdates = 0x4000000, 62 | 63 | /// Dumps a list of windows to /tmp/WindowServer.winfo.out. This is what Quartz Debug uses to get the window list. 64 | kCGSDebugOptionDumpWindowListToFile = 0x80000001, 65 | 66 | /// Dumps a list of connections to /tmp/WindowServer.cinfo.out. 67 | kCGSDebugOptionDumpConnectionListToFile = 0x80000002, 68 | 69 | /// Dumps a very verbose debug log of the WindowServer to /tmp/CGLog_WinServer_. 70 | kCGSDebugOptionVerboseLogging = 0x80000006, 71 | 72 | /// Dumps a very verbose debug log of all processes to /tmp/CGLog__. 73 | kCGSDebugOptionVerboseLoggingAllApps = 0x80000007, 74 | 75 | /// Dumps a list of hotkeys to /tmp/WindowServer.keyinfo.out. 76 | kCGSDebugOptionDumpHotKeyListToFile = 0x8000000E, 77 | 78 | /// Dumps information about OpenGL extensions, etc to /tmp/WindowServer.glinfo.out. 79 | kCGSDebugOptionDumpOpenGLInfoToFile = 0x80000013, 80 | 81 | /// Dumps a list of shadows to /tmp/WindowServer.shinfo.out. 82 | kCGSDebugOptionDumpShadowListToFile = 0x80000014, 83 | 84 | /// Leopard: Dumps information about caches to `/tmp/WindowServer.scinfo.out`. 85 | kCGSDebugOptionDumpCacheInformationToFile = 0x80000015, 86 | 87 | /// Leopard: Purges some sort of cache - most likely the same caches dummped with `kCGSDebugOptionDumpCacheInformationToFile`. 88 | kCGSDebugOptionPurgeCaches = 0x80000016, 89 | 90 | /// Leopard: Dumps a list of windows to `/tmp/WindowServer.winfo.plist`. This is what Quartz Debug on 10.5 uses to get the window list. 91 | kCGSDebugOptionDumpWindowListToPlist = 0x80000017, 92 | 93 | /// Leopard: DOCUMENTATION PENDING 94 | kCGSDebugOptionEnableSurfacePurging = 0x8000001B, 95 | 96 | // Leopard: 0x8000001C - invalid 97 | 98 | /// Leopard: DOCUMENTATION PENDING 99 | kCGSDebugOptionDisableSurfacePurging = 0x8000001D, 100 | 101 | /// Leopard: Dumps information about an application's resource usage to `/tmp/CGResources__`. 102 | kCGSDebugOptionDumpResourceUsageToFiles = 0x80000020, 103 | 104 | // Leopard: 0x80000022 - something about QuartzGL? 105 | 106 | // Leopard: Returns the magic mirror to its normal mode. The magic mirror is what the Dock uses to draw the screen reflection. For more information, see `CGSSetMagicMirror`. 107 | kCGSDebugOptionSetMagicMirrorModeNormal = 0x80000023, 108 | 109 | /// Leopard: Disables the magic mirror. It still appears but draws black instead of a reflection. 110 | kCGSDebugOptionSetMagicMirrorModeDisabled = 0x80000024, 111 | } CGSDebugOption; 112 | 113 | 114 | /// Gets and sets the debug options. 115 | /// 116 | /// These options are global and are not reset when your application dies! 117 | CG_EXTERN CGError CGSGetDebugOptions(int *outCurrentOptions); 118 | CG_EXTERN CGError CGSSetDebugOptions(int options); 119 | 120 | /// Queries the server about its performance. This is how Quartz Debug gets the FPS meter, but not 121 | /// the CPU meter (for that it uses host_processor_info). Quartz Debug subtracts 25 so that it is at 122 | /// zero with the minimum FPS. 123 | CG_EXTERN CGError CGSGetPerformanceData(CGSConnectionID cid, CGFloat *outFPS, CGFloat *unk, CGFloat *unk2, CGFloat *unk3); 124 | 125 | #endif /* CGS_DEBUG_INTERNAL_H */ 126 | -------------------------------------------------------------------------------- /CGSInternal/CGSDevice.h: -------------------------------------------------------------------------------- 1 | // 2 | // CGSDevice.h 3 | // CGSInternal 4 | // 5 | // Created by Robert Widmann on 9/14/13. 6 | // Copyright (c) 2016 CodaFi. All rights reserved. 7 | // Released under the MIT license. 8 | // 9 | 10 | 11 | #ifndef CGS_DEVICE_INTERNAL_H 12 | #define CGS_DEVICE_INTERNAL_H 13 | 14 | #include "CGSConnection.h" 15 | 16 | /// Actuates the Taptic Engine underneath the user's fingers. 17 | /// 18 | /// Valid patterns are in the range 0x1-0x6 and 0xf-0x10 inclusive. 19 | /// 20 | /// Currently, deviceID and strength must be 0 as non-zero configurations are not 21 | /// yet supported 22 | CG_EXTERN CGError CGSActuateDeviceWithPattern(CGSConnectionID cid, int deviceID, int pattern, int strength) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 23 | 24 | /// Overrides the current pressure configuration with the given configuration. 25 | CG_EXTERN CGError CGSSetPressureConfigurationOverride(CGSConnectionID cid, int deviceID, void *config) AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER; 26 | 27 | #endif /* CGSDevice_h */ 28 | -------------------------------------------------------------------------------- /CGSInternal/CGSDisplays.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * Ryan Govostes ryan@alacatia.com 22 | * 23 | */ 24 | 25 | // 26 | // Updated by Robert Widmann. 27 | // Copyright © 2015-2016 CodaFi. All rights reserved. 28 | // Released under the MIT license. 29 | // 30 | 31 | #ifndef CGS_DISPLAYS_INTERNAL_H 32 | #define CGS_DISPLAYS_INTERNAL_H 33 | 34 | #include "CGSRegion.h" 35 | 36 | typedef enum { 37 | CGSDisplayQueryMirrorStatus = 9, 38 | } CGSDisplayQuery; 39 | 40 | typedef struct { 41 | uint32_t mode; 42 | uint32_t flags; 43 | uint32_t width; 44 | uint32_t height; 45 | uint32_t depth; 46 | uint32_t dc2[42]; 47 | uint16_t dc3; 48 | uint16_t freq; 49 | uint8_t dc4[16]; 50 | CGFloat scale; 51 | } CGSDisplayModeDescription; 52 | 53 | typedef int CGSDisplayMode; 54 | 55 | 56 | /// Gets the main display. 57 | CG_EXTERN CGDirectDisplayID CGSMainDisplayID(void); 58 | 59 | 60 | #pragma mark - Display Properties 61 | 62 | 63 | /// Gets the number of displays known to the system. 64 | CG_EXTERN uint32_t CGSGetNumberOfDisplays(void); 65 | 66 | /// Gets the depth of a display. 67 | CG_EXTERN CGError CGSGetDisplayDepth(CGDirectDisplayID display, int *outDepth); 68 | 69 | /// Gets the displays at a point. Note that multiple displays can have the same point - think mirroring. 70 | CG_EXTERN CGError CGSGetDisplaysWithPoint(const CGPoint *point, int maxDisplayCount, CGDirectDisplayID *outDisplays, int *outDisplayCount); 71 | 72 | /// Gets the displays which contain a rect. Note that multiple displays can have the same bounds - think mirroring. 73 | CG_EXTERN CGError CGSGetDisplaysWithRect(const CGRect *point, int maxDisplayCount, CGDirectDisplayID *outDisplays, int *outDisplayCount); 74 | 75 | /// Gets the bounds for the display. Note that multiple displays can have the same bounds - think mirroring. 76 | CG_EXTERN CGError CGSGetDisplayRegion(CGDirectDisplayID display, CGSRegionRef *outRegion); 77 | CG_EXTERN CGError CGSGetDisplayBounds(CGDirectDisplayID display, CGRect *outRect); 78 | 79 | /// Gets the number of bytes per row. 80 | CG_EXTERN CGError CGSGetDisplayRowBytes(CGDirectDisplayID display, int *outRowBytes); 81 | 82 | /// Returns an array of dictionaries describing the spaces each screen contains. 83 | CG_EXTERN CFArrayRef CGSCopyManagedDisplaySpaces(CGSConnectionID cid); 84 | 85 | /// Gets the current display mode for the display. 86 | CG_EXTERN CGError CGSGetCurrentDisplayMode(CGDirectDisplayID display, int *modeNum); 87 | 88 | /// Gets the number of possible display modes for the display. 89 | CG_EXTERN CGError CGSGetNumberOfDisplayModes(CGDirectDisplayID display, int *nModes); 90 | 91 | /// Gets a description of the mode of the display. 92 | CG_EXTERN CGError CGSGetDisplayModeDescriptionOfLength(CGDirectDisplayID display, int idx, CGSDisplayModeDescription *desc, int length); 93 | 94 | /// Sets a display's configuration mode. 95 | CG_EXTERN CGError CGSConfigureDisplayMode(CGDisplayConfigRef config, CGDirectDisplayID display, int modeNum); 96 | 97 | /// Gets a list of on line displays */ 98 | CG_EXTERN CGDisplayErr CGSGetOnlineDisplayList(CGDisplayCount maxDisplays, CGDirectDisplayID *displays, CGDisplayCount *outDisplayCount); 99 | 100 | /// Gets a list of active displays */ 101 | CG_EXTERN CGDisplayErr CGSGetActiveDisplayList(CGDisplayCount maxDisplays, CGDirectDisplayID *displays, CGDisplayCount *outDisplayCount); 102 | 103 | 104 | #pragma mark - Display Configuration 105 | 106 | 107 | /// Begins a new display configuration transacation. 108 | CG_EXTERN CGDisplayErr CGSBeginDisplayConfiguration(CGDisplayConfigRef *config); 109 | 110 | /// Sets the origin of a display relative to the main display. The main display is at (0, 0) and contains the menubar. 111 | CG_EXTERN CGDisplayErr CGSConfigureDisplayOrigin(CGDisplayConfigRef config, CGDirectDisplayID display, int32_t x, int32_t y); 112 | 113 | /// Applies the configuration changes made in this transaction. 114 | CG_EXTERN CGDisplayErr CGSCompleteDisplayConfiguration(CGDisplayConfigRef config); 115 | 116 | /// Drops the configuration changes made in this transaction. 117 | CG_EXTERN CGDisplayErr CGSCancelDisplayConfiguration(CGDisplayConfigRef config); 118 | 119 | 120 | #pragma mark - Querying for Display Status 121 | 122 | 123 | /// Queries the Window Server about the status of the query. 124 | CG_EXTERN CGError CGSDisplayStatusQuery(CGDirectDisplayID display, CGSDisplayQuery query); 125 | 126 | #endif /* CGS_DISPLAYS_INTERNAL_H */ 127 | -------------------------------------------------------------------------------- /CGSInternal/CGSEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // CGSEvent.h 3 | // CGSInternal 4 | // 5 | // Created by Robert Widmann on 9/14/13. 6 | // Copyright (c) 2015-2016 CodaFi. All rights reserved. 7 | // Released under the MIT license. 8 | // 9 | 10 | #ifndef CGS_EVENT_INTERNAL_H 11 | #define CGS_EVENT_INTERNAL_H 12 | 13 | #include "CGSWindow.h" 14 | 15 | typedef unsigned long CGSByteCount; 16 | typedef unsigned short CGSEventRecordVersion; 17 | typedef unsigned long long CGSEventRecordTime; /* nanosecond timer */ 18 | typedef unsigned long CGSEventFlag; 19 | typedef unsigned long CGSError; 20 | 21 | typedef enum : unsigned int { 22 | kCGSDisplayWillReconfigure = 100, 23 | kCGSDisplayDidReconfigure = 101, 24 | kCGSDisplayWillSleep = 102, 25 | kCGSDisplayDidWake = 103, 26 | kCGSDisplayIsCaptured = 106, 27 | kCGSDisplayIsReleased = 107, 28 | kCGSDisplayAllDisplaysReleased = 108, 29 | kCGSDisplayHardwareChanged = 111, 30 | kCGSDisplayDidReconfigure2 = 115, 31 | kCGSDisplayFullScreenAppRunning = 116, 32 | kCGSDisplayFullScreenAppDone = 117, 33 | kCGSDisplayReconfigureHappened = 118, 34 | kCGSDisplayColorProfileChanged = 119, 35 | kCGSDisplayZoomStateChanged = 120, 36 | kCGSDisplayAcceleratorChanged = 121, 37 | kCGSDebugOptionsChangedNotification = 200, 38 | kCGSDebugPrintResourcesNotification = 203, 39 | kCGSDebugPrintResourcesMemoryNotification = 205, 40 | kCGSDebugPrintResourcesContextNotification = 206, 41 | kCGSDebugPrintResourcesImageNotification = 208, 42 | kCGSServerConnDirtyScreenNotification = 300, 43 | kCGSServerLoginNotification = 301, 44 | kCGSServerShutdownNotification = 302, 45 | kCGSServerUserPreferencesLoadedNotification = 303, 46 | kCGSServerUpdateDisplayNotification = 304, 47 | kCGSServerCAContextDidCommitNotification = 305, 48 | kCGSServerUpdateDisplayCompletedNotification = 306, 49 | 50 | kCPXForegroundProcessSwitched = 400, 51 | kCPXSpecialKeyPressed = 401, 52 | kCPXForegroundProcessSwitchRequestedButRedundant = 402, 53 | 54 | kCGSSpecialKeyEventNotification = 700, 55 | 56 | kCGSEventNotificationNullEvent = 710, 57 | kCGSEventNotificationLeftMouseDown = 711, 58 | kCGSEventNotificationLeftMouseUp = 712, 59 | kCGSEventNotificationRightMouseDown = 713, 60 | kCGSEventNotificationRightMouseUp = 714, 61 | kCGSEventNotificationMouseMoved = 715, 62 | kCGSEventNotificationLeftMouseDragged = 716, 63 | kCGSEventNotificationRightMouseDragged = 717, 64 | kCGSEventNotificationMouseEntered = 718, 65 | kCGSEventNotificationMouseExited = 719, 66 | 67 | kCGSEventNotificationKeyDown = 720, 68 | kCGSEventNotificationKeyUp = 721, 69 | kCGSEventNotificationFlagsChanged = 722, 70 | kCGSEventNotificationKitDefined = 723, 71 | kCGSEventNotificationSystemDefined = 724, 72 | kCGSEventNotificationApplicationDefined = 725, 73 | kCGSEventNotificationTimer = 726, 74 | kCGSEventNotificationCursorUpdate = 727, 75 | kCGSEventNotificationSuspend = 729, 76 | kCGSEventNotificationResume = 730, 77 | kCGSEventNotificationNotification = 731, 78 | kCGSEventNotificationScrollWheel = 732, 79 | kCGSEventNotificationTabletPointer = 733, 80 | kCGSEventNotificationTabletProximity = 734, 81 | kCGSEventNotificationOtherMouseDown = 735, 82 | kCGSEventNotificationOtherMouseUp = 736, 83 | kCGSEventNotificationOtherMouseDragged = 737, 84 | kCGSEventNotificationZoom = 738, 85 | kCGSEventNotificationAppIsUnresponsive = 750, 86 | kCGSEventNotificationAppIsNoLongerUnresponsive = 751, 87 | 88 | kCGSEventSecureTextInputIsActive = 752, 89 | kCGSEventSecureTextInputIsOff = 753, 90 | 91 | kCGSEventNotificationSymbolicHotKeyChanged = 760, 92 | kCGSEventNotificationSymbolicHotKeyDisabled = 761, 93 | kCGSEventNotificationSymbolicHotKeyEnabled = 762, 94 | kCGSEventNotificationHotKeysGloballyDisabled = 763, 95 | kCGSEventNotificationHotKeysGloballyEnabled = 764, 96 | kCGSEventNotificationHotKeysExceptUniversalAccessGloballyDisabled = 765, 97 | kCGSEventNotificationHotKeysExceptUniversalAccessGloballyEnabled = 766, 98 | 99 | kCGSWindowIsObscured = 800, 100 | kCGSWindowIsUnobscured = 801, 101 | kCGSWindowIsOrderedIn = 802, 102 | kCGSWindowIsOrderedOut = 803, 103 | kCGSWindowIsTerminated = 804, 104 | kCGSWindowIsChangingScreens = 805, 105 | kCGSWindowDidMove = 806, 106 | kCGSWindowDidResize = 807, 107 | kCGSWindowDidChangeOrder = 808, 108 | kCGSWindowGeometryDidChange = 809, 109 | kCGSWindowMonitorDataPending = 810, 110 | kCGSWindowDidCreate = 811, 111 | kCGSWindowRightsGrantOffered = 812, 112 | kCGSWindowRightsGrantCompleted = 813, 113 | kCGSWindowRecordForTermination = 814, 114 | kCGSWindowIsVisible = 815, 115 | kCGSWindowIsInvisible = 816, 116 | 117 | kCGSLikelyUnbalancedDisableUpdateNotification = 902, 118 | 119 | kCGSConnectionWindowsBecameVisible = 904, 120 | kCGSConnectionWindowsBecameOccluded = 905, 121 | kCGSConnectionWindowModificationsStarted = 906, 122 | kCGSConnectionWindowModificationsStopped = 907, 123 | 124 | kCGSWindowBecameVisible = 912, 125 | kCGSWindowBecameOccluded = 913, 126 | 127 | kCGSServerWindowDidCreate = 1000, 128 | kCGSServerWindowWillTerminate = 1001, 129 | kCGSServerWindowOrderDidChange = 1002, 130 | kCGSServerWindowDidTerminate = 1003, 131 | 132 | kCGSWindowWasMovedByDockEvent = 1205, 133 | kCGSWindowWasResizedByDockEvent = 1207, 134 | kCGSWindowDidBecomeManagedByDockEvent = 1208, 135 | 136 | kCGSServerMenuBarCreated = 1300, 137 | kCGSServerHidBackstopMenuBar = 1301, 138 | kCGSServerShowBackstopMenuBar = 1302, 139 | kCGSServerMenuBarDrawingStyleChanged = 1303, 140 | kCGSServerPersistentAppsRegistered = 1304, 141 | kCGSServerPersistentCheckinComplete = 1305, 142 | 143 | kCGSPackagesWorkspacesDisabled = 1306, 144 | kCGSPackagesWorkspacesEnabled = 1307, 145 | kCGSPackagesStatusBarSpaceChanged = 1308, 146 | 147 | kCGSWorkspaceWillChange = 1400, 148 | kCGSWorkspaceDidChange = 1401, 149 | kCGSWorkspaceWindowIsViewable = 1402, 150 | kCGSWorkspaceWindowIsNotViewable = 1403, 151 | kCGSWorkspaceWindowDidMove = 1404, 152 | kCGSWorkspacePrefsDidChange = 1405, 153 | kCGSWorkspacesWindowDragDidStart = 1411, 154 | kCGSWorkspacesWindowDragDidEnd = 1412, 155 | kCGSWorkspacesWindowDragWillEnd = 1413, 156 | kCGSWorkspacesShowSpaceForProcess = 1414, 157 | kCGSWorkspacesWindowDidOrderInOnNonCurrentManagedSpacesOnly = 1415, 158 | kCGSWorkspacesWindowDidOrderOutOnNonCurrentManagedSpaces = 1416, 159 | 160 | kCGSessionConsoleConnect = 1500, 161 | kCGSessionConsoleDisconnect = 1501, 162 | kCGSessionRemoteConnect = 1502, 163 | kCGSessionRemoteDisconnect = 1503, 164 | kCGSessionLoggedOn = 1504, 165 | kCGSessionLoggedOff = 1505, 166 | kCGSessionConsoleWillDisconnect = 1506, 167 | kCGXWillCreateSession = 1550, 168 | kCGXDidCreateSession = 1551, 169 | kCGXWillDestroySession = 1552, 170 | kCGXDidDestroySession = 1553, 171 | kCGXWorkspaceConnected = 1554, 172 | kCGXSessionReleased = 1555, 173 | 174 | kCGSTransitionDidFinish = 1700, 175 | 176 | kCGXServerDisplayHardwareWillReset = 1800, 177 | kCGXServerDesktopShapeChanged = 1801, 178 | kCGXServerDisplayConfigurationChanged = 1802, 179 | kCGXServerDisplayAcceleratorOffline = 1803, 180 | kCGXServerDisplayAcceleratorDeactivate = 1804, 181 | } CGSEventType; 182 | 183 | 184 | #pragma mark - System-Level Event Notification Registration 185 | 186 | 187 | typedef void (*CGSNotifyProcPtr)(CGSEventType type, void *data, unsigned int dataLength, void *userData); 188 | 189 | /// Registers a function to receive notifications for system-wide events. 190 | CG_EXTERN CGError CGSRegisterNotifyProc(CGSNotifyProcPtr proc, CGSEventType type, void *userData); 191 | 192 | /// Unregisters a function that was registered to receive notifications for system-wide events. 193 | CG_EXTERN CGError CGSRemoveNotifyProc(CGSNotifyProcPtr proc, CGSEventType type, void *userData); 194 | 195 | 196 | #pragma mark - Application-Level Event Notification Registration 197 | 198 | 199 | typedef void (*CGConnectionNotifyProc)(CGSEventType type, CGSNotificationData notificationData, size_t dataLength, CGSNotificationArg userParameter, CGSConnectionID); 200 | 201 | /// Registers a function to receive notifications for connection-level events. 202 | CG_EXTERN CGError CGSRegisterConnectionNotifyProc(CGSConnectionID cid, CGConnectionNotifyProc function, CGSEventType event, void *userData); 203 | 204 | /// Unregisters a function that was registered to receive notifications for connection-level events. 205 | CG_EXTERN CGError CGSRemoveConnectionNotifyProc(CGSConnectionID cid, CGConnectionNotifyProc function, CGSEventType event, void *userData); 206 | 207 | 208 | typedef struct _CGSEventRecord { 209 | CGSEventRecordVersion major; /*0x0*/ 210 | CGSEventRecordVersion minor; /*0x2*/ 211 | CGSByteCount length; /*0x4*/ /* Length of complete event record */ 212 | CGSEventType type; /*0x8*/ /* An event type from above */ 213 | CGPoint location; /*0x10*/ /* Base coordinates (global), from upper-left */ 214 | CGPoint windowLocation; /*0x20*/ /* Coordinates relative to window */ 215 | CGSEventRecordTime time; /*0x30*/ /* nanoseconds since startup */ 216 | CGSEventFlag flags; /* key state flags */ 217 | CGWindowID window; /* window number of assigned window */ 218 | CGSConnectionID connection; /* connection the event came from */ 219 | struct __CGEventSourceData { 220 | int source; 221 | unsigned int sourceUID; 222 | unsigned int sourceGID; 223 | unsigned int flags; 224 | unsigned long long userData; 225 | unsigned int sourceState; 226 | unsigned short localEventSuppressionInterval; 227 | unsigned char suppressionIntervalFlags; 228 | unsigned char remoteMouseDragFlags; 229 | unsigned long long serviceID; 230 | } eventSource; 231 | struct _CGEventProcess { 232 | int pid; 233 | unsigned int psnHi; 234 | unsigned int psnLo; 235 | unsigned int targetID; 236 | unsigned int flags; 237 | } eventProcess; 238 | NXEventData eventData; 239 | SInt32 _padding[4]; 240 | void *ioEventData; 241 | unsigned short _field16; 242 | unsigned short _field17; 243 | struct _CGSEventAppendix { 244 | unsigned short windowHeight; 245 | unsigned short mainDisplayHeight; 246 | unsigned short *unicodePayload; 247 | unsigned int eventOwner; 248 | unsigned char passedThrough; 249 | } *appendix; 250 | unsigned int _field18; 251 | bool passedThrough; 252 | CFDataRef data; 253 | } CGSEventRecord; 254 | 255 | /// Gets the event record for a given `CGEventRef`. 256 | /// 257 | /// For Carbon events, use `GetEventPlatformEventRecord`. 258 | CG_EXTERN CGError CGEventGetEventRecord(CGEventRef event, CGSEventRecord *outRecord, size_t recSize); 259 | 260 | /// Gets the main event port for the connection ID. 261 | CG_EXTERN OSErr CGSGetEventPort(CGSConnectionID identifier, mach_port_t *port); 262 | 263 | /// Getter and setter for the background event mask. 264 | CG_EXTERN void CGSGetBackgroundEventMask(CGSConnectionID cid, int *outMask); 265 | CG_EXTERN CGError CGSSetBackgroundEventMask(CGSConnectionID cid, int mask); 266 | 267 | 268 | /// Returns `True` if the application has been deemed unresponsive for a certain amount of time. 269 | CG_EXTERN bool CGSEventIsAppUnresponsive(CGSConnectionID cid, const ProcessSerialNumber *psn); 270 | 271 | /// Sets the amount of time it takes for an application to be considered unresponsive. 272 | CG_EXTERN CGError CGSEventSetAppIsUnresponsiveNotificationTimeout(CGSConnectionID cid, double theTime); 273 | 274 | #pragma mark input 275 | 276 | // Gets and sets the status of secure input. When secure input is enabled, keyloggers, etc are harder to do. 277 | CG_EXTERN bool CGSIsSecureEventInputSet(void); 278 | CG_EXTERN CGError CGSSetSecureEventInput(CGSConnectionID cid, bool useSecureInput); 279 | 280 | #endif /* CGS_EVENT_INTERNAL_H */ 281 | -------------------------------------------------------------------------------- /CGSInternal/CGSHotKeys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_HOTKEYS_INTERNAL_H 31 | #define CGS_HOTKEYS_INTERNAL_H 32 | 33 | #include "CGSConnection.h" 34 | 35 | /// The system defines a limited number of "symbolic" hot keys that are remembered system-wide. The 36 | /// original intent is to have a common registry for the action of function keys and numerous 37 | /// other event-generating system gestures. 38 | typedef enum { 39 | // full keyboard access hotkeys 40 | kCGSHotKeyToggleFullKeyboardAccess = 12, 41 | kCGSHotKeyFocusMenubar = 7, 42 | kCGSHotKeyFocusDock = 8, 43 | kCGSHotKeyFocusNextGlobalWindow = 9, 44 | kCGSHotKeyFocusToolbar = 10, 45 | kCGSHotKeyFocusFloatingWindow = 11, 46 | kCGSHotKeyFocusApplicationWindow = 27, 47 | kCGSHotKeyFocusNextControl = 13, 48 | kCGSHotKeyFocusDrawer = 51, 49 | kCGSHotKeyFocusStatusItems = 57, 50 | 51 | // screenshot hotkeys 52 | kCGSHotKeyScreenshot = 28, 53 | kCGSHotKeyScreenshotToClipboard = 29, 54 | kCGSHotKeyScreenshotRegion = 30, 55 | kCGSHotKeyScreenshotRegionToClipboard = 31, 56 | 57 | // universal access 58 | kCGSHotKeyToggleZoom = 15, 59 | kCGSHotKeyZoomOut = 19, 60 | kCGSHotKeyZoomIn = 17, 61 | kCGSHotKeyZoomToggleSmoothing = 23, 62 | kCGSHotKeyIncreaseContrast = 25, 63 | kCGSHotKeyDecreaseContrast = 26, 64 | kCGSHotKeyInvertScreen = 21, 65 | kCGSHotKeyToggleVoiceOver = 59, 66 | 67 | // Dock 68 | kCGSHotKeyToggleDockAutohide = 52, 69 | kCGSHotKeyExposeAllWindows = 32, 70 | kCGSHotKeyExposeAllWindowsSlow = 34, 71 | kCGSHotKeyExposeApplicationWindows = 33, 72 | kCGSHotKeyExposeApplicationWindowsSlow = 35, 73 | kCGSHotKeyExposeDesktop = 36, 74 | kCGSHotKeyExposeDesktopsSlow = 37, 75 | kCGSHotKeyDashboard = 62, 76 | kCGSHotKeyDashboardSlow = 63, 77 | 78 | // spaces (Leopard and later) 79 | kCGSHotKeySpaces = 75, 80 | kCGSHotKeySpacesSlow = 76, 81 | // 77 - fn F7 (disabled) 82 | // 78 - ⇧fn F7 (disabled) 83 | kCGSHotKeySpaceLeft = 79, 84 | kCGSHotKeySpaceLeftSlow = 80, 85 | kCGSHotKeySpaceRight = 81, 86 | kCGSHotKeySpaceRightSlow = 82, 87 | kCGSHotKeySpaceDown = 83, 88 | kCGSHotKeySpaceDownSlow = 84, 89 | kCGSHotKeySpaceUp = 85, 90 | kCGSHotKeySpaceUpSlow = 86, 91 | 92 | // input 93 | kCGSHotKeyToggleCharacterPallette = 50, 94 | kCGSHotKeySelectPreviousInputSource = 60, 95 | kCGSHotKeySelectNextInputSource = 61, 96 | 97 | // Spotlight 98 | kCGSHotKeySpotlightSearchField = 64, 99 | kCGSHotKeySpotlightWindow = 65, 100 | 101 | kCGSHotKeyToggleFrontRow = 73, 102 | kCGSHotKeyLookUpWordInDictionary = 70, 103 | kCGSHotKeyHelp = 98, 104 | 105 | // displays - not verified 106 | kCGSHotKeyDecreaseDisplayBrightness = 53, 107 | kCGSHotKeyIncreaseDisplayBrightness = 54, 108 | } CGSSymbolicHotKey; 109 | 110 | /// The possible operating modes of a hot key. 111 | typedef enum { 112 | /// All hot keys are enabled app-wide. 113 | kCGSGlobalHotKeyEnable = 0, 114 | /// All hot keys are disabled app-wide. 115 | kCGSGlobalHotKeyDisable = 1, 116 | /// Hot keys are disabled app-wide, but exceptions are made for Accessibility. 117 | kCGSGlobalHotKeyDisableAllButUniversalAccess = 2, 118 | } CGSGlobalHotKeyOperatingMode; 119 | 120 | /// Options representing device-independent bits found in event modifier flags: 121 | typedef enum : unsigned int { 122 | /// Set if Caps Lock key is pressed. 123 | kCGSAlphaShiftKeyMask = 1 << 16, 124 | /// Set if Shift key is pressed. 125 | kCGSShiftKeyMask = 1 << 17, 126 | /// Set if Control key is pressed. 127 | kCGSControlKeyMask = 1 << 18, 128 | /// Set if Option or Alternate key is pressed. 129 | kCGSAlternateKeyMask = 1 << 19, 130 | /// Set if Command key is pressed. 131 | kCGSCommandKeyMask = 1 << 20, 132 | /// Set if any key in the numeric keypad is pressed. 133 | kCGSNumericPadKeyMask = 1 << 21, 134 | /// Set if the Help key is pressed. 135 | kCGSHelpKeyMask = 1 << 22, 136 | /// Set if any function key is pressed. 137 | kCGSFunctionKeyMask = 1 << 23, 138 | /// Used to retrieve only the device-independent modifier flags, allowing applications to mask 139 | /// off the device-dependent modifier flags, including event coalescing information. 140 | kCGSDeviceIndependentModifierFlagsMask = 0xffff0000U 141 | } CGSModifierFlags; 142 | 143 | 144 | #pragma mark - Symbolic Hot Keys 145 | 146 | 147 | /// Gets the current global hot key operating mode for the application. 148 | CG_EXTERN CGError CGSGetGlobalHotKeyOperatingMode(CGSConnectionID cid, CGSGlobalHotKeyOperatingMode *outMode); 149 | 150 | /// Sets the current operating mode for the application. 151 | /// 152 | /// This function can be used to enable and disable all hot key events on the given connection. 153 | CG_EXTERN CGError CGSSetGlobalHotKeyOperatingMode(CGSConnectionID cid, CGSGlobalHotKeyOperatingMode mode); 154 | 155 | 156 | #pragma mark - Symbol Hot Key Properties 157 | 158 | 159 | /// Returns whether the symbolic hot key represented by the given UID is enabled. 160 | CG_EXTERN bool CGSIsSymbolicHotKeyEnabled(CGSSymbolicHotKey hotKey); 161 | 162 | /// Sets whether the symbolic hot key represented by the given UID is enabled. 163 | CG_EXTERN CGError CGSSetSymbolicHotKeyEnabled(CGSSymbolicHotKey hotKey, bool isEnabled); 164 | 165 | /// Returns the values the symbolic hot key represented by the given UID is configured with. 166 | CG_EXTERN CGError CGSGetSymbolicHotKeyValue(CGSSymbolicHotKey hotKey, unichar *outKeyEquivalent, unichar *outVirtualKeyCode, CGSModifierFlags *outModifiers); 167 | 168 | 169 | #pragma mark - Custom Hot Keys 170 | 171 | 172 | /// Sets the value of the configuration options for the hot key represented by the given UID, 173 | /// creating a hot key if needed. 174 | /// 175 | /// If the given UID is unique and not in use, a hot key will be instantiated for you under it. 176 | CG_EXTERN void CGSSetHotKey(CGSConnectionID cid, int uid, unichar options, unichar key, CGSModifierFlags modifierFlags); 177 | 178 | /// Functions like `CGSSetHotKey` but with an exclusion value. 179 | /// 180 | /// The exact function of the exclusion value is unknown. Working theory: It is supposed to be 181 | /// passed the UID of another existing hot key that it supresses. Why can only one can be passed, tho? 182 | CG_EXTERN void CGSSetHotKeyWithExclusion(CGSConnectionID cid, int uid, unichar options, unichar key, CGSModifierFlags modifierFlags, int exclusion); 183 | 184 | /// Returns the value of the configured options for the hot key represented by the given UID. 185 | CG_EXTERN bool CGSGetHotKey(CGSConnectionID cid, int uid, unichar *options, unichar *key, CGSModifierFlags *modifierFlags); 186 | 187 | /// Removes a previously created hot key. 188 | CG_EXTERN void CGSRemoveHotKey(CGSConnectionID cid, int uid); 189 | 190 | 191 | #pragma mark - Custom Hot Key Properties 192 | 193 | 194 | /// Returns whether the hot key represented by the given UID is enabled. 195 | CG_EXTERN BOOL CGSIsHotKeyEnabled(CGSConnectionID cid, int uid); 196 | 197 | /// Sets whether the hot key represented by the given UID is enabled. 198 | CG_EXTERN void CGSSetHotKeyEnabled(CGSConnectionID cid, int uid, bool enabled); 199 | 200 | #endif /* CGS_HOTKEYS_INTERNAL_H */ 201 | -------------------------------------------------------------------------------- /CGSInternal/CGSInternal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_INTERNAL_API_H 31 | #define CGS_INTERNAL_API_H 32 | 33 | #include 34 | #include 35 | 36 | // WARNING: CGSInternal contains PRIVATE FUNCTIONS and should NOT BE USED in shipping applications! 37 | 38 | #include "CGSAccessibility.h" 39 | #include "CGSCIFilter.h" 40 | #include "CGSConnection.h" 41 | #include "CGSCursor.h" 42 | #include "CGSDebug.h" 43 | #include "CGSDevice.h" 44 | #include "CGSDisplays.h" 45 | #include "CGSEvent.h" 46 | #include "CGSHotKeys.h" 47 | #include "CGSMisc.h" 48 | #include "CGSRegion.h" 49 | #include "CGSSession.h" 50 | #include "CGSSpace.h" 51 | #include "CGSSurface.h" 52 | #include "CGSTile.h" 53 | #include "CGSTransitions.h" 54 | #include "CGSWindow.h" 55 | #include "CGSWorkspace.h" 56 | 57 | #endif /* CGS_INTERNAL_API_H */ 58 | -------------------------------------------------------------------------------- /CGSInternal/CGSMisc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_MISC_INTERNAL_H 31 | #define CGS_MISC_INTERNAL_H 32 | 33 | #include "CGSConnection.h" 34 | 35 | /// Is someone watching this screen? Applies to Apple's remote desktop only? 36 | CG_EXTERN bool CGSIsScreenWatcherPresent(void); 37 | 38 | #pragma mark - Error Logging 39 | 40 | /// Logs an error and returns `err`. 41 | CG_EXTERN CGError CGSGlobalError(CGError err, const char *msg); 42 | 43 | /// Logs an error and returns `err`. 44 | CG_EXTERN CGError CGSGlobalErrorv(CGError err, const char *msg, ...); 45 | 46 | /// Gets the error message for an error code. 47 | CG_EXTERN char *CGSErrorString(CGError error); 48 | 49 | #endif /* CGS_MISC_INTERNAL_H */ 50 | -------------------------------------------------------------------------------- /CGSInternal/CGSRegion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_REGION_INTERNAL_H 31 | #define CGS_REGION_INTERNAL_H 32 | 33 | typedef CFTypeRef CGSRegionRef; 34 | typedef CFTypeRef CGSRegionEnumeratorRef; 35 | 36 | 37 | #pragma mark - Region Lifecycle 38 | 39 | 40 | /// Creates a region from a `CGRect`. 41 | CG_EXTERN CGError CGSNewRegionWithRect(const CGRect *rect, CGSRegionRef *outRegion); 42 | 43 | /// Creates a region from a list of `CGRect`s. 44 | CG_EXTERN CGError CGSNewRegionWithRectList(const CGRect *rects, int rectCount, CGSRegionRef *outRegion); 45 | 46 | /// Creates a new region from a QuickDraw region. 47 | CG_EXTERN CGError CGSNewRegionWithQDRgn(RgnHandle region, CGSRegionRef *outRegion); 48 | 49 | /// Creates an empty region. 50 | CG_EXTERN CGError CGSNewEmptyRegion(CGSRegionRef *outRegion); 51 | 52 | /// Releases a region. 53 | CG_EXTERN CGError CGSReleaseRegion(CGSRegionRef region); 54 | 55 | 56 | #pragma mark - Creating Complex Regions 57 | 58 | 59 | /// Created a new region by changing the origin an existing one. 60 | CG_EXTERN CGError CGSOffsetRegion(CGSRegionRef region, CGFloat offsetLeft, CGFloat offsetTop, CGSRegionRef *outRegion); 61 | 62 | /// Creates a new region by copying an existing one. 63 | CG_EXTERN CGError CGSCopyRegion(CGSRegionRef region, CGSRegionRef *outRegion); 64 | 65 | /// Creates a new region by combining two regions together. 66 | CG_EXTERN CGError CGSUnionRegion(CGSRegionRef region1, CGSRegionRef region2, CGSRegionRef *outRegion); 67 | 68 | /// Creates a new region by combining a region and a rect. 69 | CG_EXTERN CGError CGSUnionRegionWithRect(CGSRegionRef region, CGRect *rect, CGSRegionRef *outRegion); 70 | 71 | /// Creates a region by XORing two regions together. 72 | CG_EXTERN CGError CGSXorRegion(CGSRegionRef region1, CGSRegionRef region2, CGSRegionRef *outRegion); 73 | 74 | /// Creates a `CGRect` from a region. 75 | CG_EXTERN CGError CGSGetRegionBounds(CGSRegionRef region, CGRect *outRect); 76 | 77 | /// Creates a rect from the difference of two regions. 78 | CG_EXTERN CGError CGSDiffRegion(CGSRegionRef region1, CGSRegionRef region2, CGSRegionRef *outRegion); 79 | 80 | 81 | #pragma mark - Comparing Regions 82 | 83 | 84 | /// Determines if two regions are equal. 85 | CG_EXTERN bool CGSRegionsEqual(CGSRegionRef region1, CGSRegionRef region2); 86 | 87 | /// Determines if a region is inside of a region. 88 | CG_EXTERN bool CGSRegionInRegion(CGSRegionRef region1, CGSRegionRef region2); 89 | 90 | /// Determines if a region intersects a region. 91 | CG_EXTERN bool CGSRegionIntersectsRegion(CGSRegionRef region1, CGSRegionRef region2); 92 | 93 | /// Determines if a rect intersects a region. 94 | CG_EXTERN bool CGSRegionIntersectsRect(CGSRegionRef obj, const CGRect *rect); 95 | 96 | 97 | #pragma mark - Checking for Membership 98 | 99 | 100 | /// Determines if a point in a region. 101 | CG_EXTERN bool CGSPointInRegion(CGSRegionRef region, const CGPoint *point); 102 | 103 | /// Determines if a rect is in a region. 104 | CG_EXTERN bool CGSRectInRegion(CGSRegionRef region, const CGRect *rect); 105 | 106 | 107 | #pragma mark - Checking Region Characteristics 108 | 109 | 110 | /// Determines if the region is empty. 111 | CG_EXTERN bool CGSRegionIsEmpty(CGSRegionRef region); 112 | 113 | /// Determines if the region is rectangular. 114 | CG_EXTERN bool CGSRegionIsRectangular(CGSRegionRef region); 115 | 116 | 117 | #pragma mark - Region Enumerators 118 | 119 | 120 | /// Gets the enumerator for a region. 121 | CG_EXTERN CGSRegionEnumeratorRef CGSRegionEnumerator(CGSRegionRef region); 122 | 123 | /// Releases a region enumerator. 124 | CG_EXTERN void CGSReleaseRegionEnumerator(CGSRegionEnumeratorRef enumerator); 125 | 126 | /// Gets the next rect of a region. 127 | CG_EXTERN CGRect *CGSNextRect(CGSRegionEnumeratorRef enumerator); 128 | 129 | 130 | /// DOCUMENTATION PENDING */ 131 | CG_EXTERN CGError CGSFetchDirtyScreenRegion(CGSConnectionID cid, CGSRegionRef *outDirtyRegion); 132 | 133 | #endif /* CGS_REGION_INTERNAL_H */ 134 | -------------------------------------------------------------------------------- /CGSInternal/CGSSession.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_SESSION_INTERNAL_H 31 | #define CGS_SESSION_INTERNAL_H 32 | 33 | #include "CGSInternal.h" 34 | 35 | typedef int CGSSessionID; 36 | 37 | /// Creates a new "blank" login session. 38 | /// 39 | /// Switches to the LoginWindow. This does NOT check to see if fast user switching is enabled! 40 | CG_EXTERN CGError CGSCreateLoginSession(CGSSessionID *outSession); 41 | 42 | /// Releases a session. 43 | CG_EXTERN CGError CGSReleaseSession(CGSSessionID session); 44 | 45 | /// Gets information about the current login session. 46 | /// 47 | /// As of OS X 10.6, the following keys appear in this dictionary: 48 | /// 49 | /// kCGSSessionGroupIDKey : CFNumberRef 50 | /// kCGSSessionOnConsoleKey : CFBooleanRef 51 | /// kCGSSessionIDKey : CFNumberRef 52 | /// kCGSSessionUserNameKey : CFStringRef 53 | /// kCGSessionLongUserNameKey : CFStringRef 54 | /// kCGSessionLoginDoneKey : CFBooleanRef 55 | /// kCGSSessionUserIDKey : CFNumberRef 56 | /// kCGSSessionSecureInputPID : CFNumberRef 57 | CG_EXTERN CFDictionaryRef CGSCopyCurrentSessionDictionary(void); 58 | 59 | /// Gets a list of session dictionaries. 60 | /// 61 | /// Each session dictionary is in the format returned by `CGSCopyCurrentSessionDictionary`. 62 | CG_EXTERN CFArrayRef CGSCopySessionList(void); 63 | 64 | #endif /* CGS_SESSION_INTERNAL_H */ 65 | -------------------------------------------------------------------------------- /CGSInternal/CGSSpace.h: -------------------------------------------------------------------------------- 1 | // 2 | // CGSSpace.h 3 | // CGSInternal 4 | // 5 | // Created by Robert Widmann on 9/14/13. 6 | // Copyright © 2015-2016 CodaFi. All rights reserved. 7 | // Released under the MIT license. 8 | // 9 | 10 | #ifndef CGS_SPACE_INTERNAL_H 11 | #define CGS_SPACE_INTERNAL_H 12 | 13 | #include "CGSConnection.h" 14 | #include "CGSRegion.h" 15 | 16 | typedef size_t CGSSpaceID; 17 | 18 | /// Representations of the possible types of spaces the system can create. 19 | typedef enum { 20 | /// User-created desktop spaces. 21 | CGSSpaceTypeUser = 0, 22 | /// Fullscreen spaces. 23 | CGSSpaceTypeFullscreen = 1, 24 | /// System spaces e.g. Dashboard. 25 | CGSSpaceTypeSystem = 2, 26 | } CGSSpaceType; 27 | 28 | /// Flags that can be applied to queries for spaces. 29 | typedef enum { 30 | CGSSpaceIncludesCurrent = 1 << 0, 31 | CGSSpaceIncludesOthers = 1 << 1, 32 | CGSSpaceIncludesUser = 1 << 2, 33 | 34 | CGSSpaceVisible = 1 << 16, 35 | 36 | kCGSCurrentSpaceMask = CGSSpaceIncludesUser | CGSSpaceIncludesCurrent, 37 | kCGSOtherSpacesMask = CGSSpaceIncludesOthers | CGSSpaceIncludesCurrent, 38 | kCGSAllSpacesMask = CGSSpaceIncludesUser | CGSSpaceIncludesOthers | CGSSpaceIncludesCurrent, 39 | KCGSAllVisibleSpacesMask = CGSSpaceVisible | kCGSAllSpacesMask, 40 | } CGSSpaceMask; 41 | 42 | typedef enum { 43 | /// Each display manages a single contiguous space. 44 | kCGSPackagesSpaceManagementModeNone = 0, 45 | /// Each display manages a separate stack of spaces. 46 | kCGSPackagesSpaceManagementModePerDesktop = 1, 47 | } CGSSpaceManagementMode; 48 | 49 | #pragma mark - Space Lifecycle 50 | 51 | 52 | /// Creates a new space with the given options dictionary. 53 | /// 54 | /// Valid keys are: 55 | /// 56 | /// "type": CFNumberRef 57 | /// "uuid": CFStringRef 58 | CG_EXTERN CGSSpaceID CGSSpaceCreate(CGSConnectionID cid, void *null, CFDictionaryRef options); 59 | 60 | /// Removes and destroys the space corresponding to the given space ID. 61 | CG_EXTERN void CGSSpaceDestroy(CGSConnectionID cid, CGSSpaceID sid); 62 | 63 | 64 | #pragma mark - Configuring Spaces 65 | 66 | 67 | /// Get and set the human-readable name of a space. 68 | CG_EXTERN CFStringRef CGSSpaceCopyName(CGSConnectionID cid, CGSSpaceID sid); 69 | CG_EXTERN CGError CGSSpaceSetName(CGSConnectionID cid, CGSSpaceID sid, CFStringRef name); 70 | 71 | /// Get and set the affine transform of a space. 72 | CG_EXTERN CGAffineTransform CGSSpaceGetTransform(CGSConnectionID cid, CGSSpaceID space); 73 | CG_EXTERN void CGSSpaceSetTransform(CGSConnectionID cid, CGSSpaceID space, CGAffineTransform transform); 74 | 75 | /// Gets and sets the region the space occupies. You are responsible for releasing the region object. 76 | CG_EXTERN void CGSSpaceSetShape(CGSConnectionID cid, CGSSpaceID space, CGSRegionRef shape); 77 | CG_EXTERN CGSRegionRef CGSSpaceCopyShape(CGSConnectionID cid, CGSSpaceID space); 78 | 79 | 80 | 81 | #pragma mark - Space Properties 82 | 83 | 84 | /// Copies and returns a region the space occupies. You are responsible for releasing the region object. 85 | CG_EXTERN CGSRegionRef CGSSpaceCopyManagedShape(CGSConnectionID cid, CGSSpaceID sid); 86 | 87 | /// Gets the type of a space. 88 | CG_EXTERN CGSSpaceType CGSSpaceGetType(CGSConnectionID cid, CGSSpaceID sid); 89 | 90 | /// Gets the current space management mode. 91 | /// 92 | /// This method reflects whether the “Displays have separate Spaces” option is 93 | /// enabled in Mission Control system preference. You might use the return value 94 | /// to determine how to present your app when in fullscreen mode. 95 | CG_EXTERN CGSSpaceManagementMode CGSGetSpaceManagementMode(CGSConnectionID cid) AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER; 96 | 97 | /// Sets the current space management mode. 98 | CG_EXTERN CGError CGSSetSpaceManagementMode(CGSConnectionID cid, CGSSpaceManagementMode mode) AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER; 99 | 100 | #pragma mark - Global Space Properties 101 | 102 | 103 | /// Gets the ID of the space currently visible to the user. 104 | CG_EXTERN CGSSpaceID CGSGetActiveSpace(CGSConnectionID cid); 105 | 106 | /// Returns an array of PIDs of applications that have ownership of a given space. 107 | CG_EXTERN CFArrayRef CGSSpaceCopyOwners(CGSConnectionID cid, CGSSpaceID sid); 108 | 109 | /// Returns an array of all space IDs. 110 | CG_EXTERN CFArrayRef CGSCopySpaces(CGSConnectionID cid, CGSSpaceMask mask); 111 | 112 | /// Given an array of window numbers, returns the IDs of the spaces those windows lie on. 113 | CG_EXTERN CFArrayRef CGSCopySpacesForWindows(CGSConnectionID cid, CGSSpaceMask mask, CFArrayRef windowIDs); 114 | 115 | 116 | #pragma mark - Space-Local State 117 | 118 | 119 | /// Connection-local data in a given space. 120 | CG_EXTERN CFDictionaryRef CGSSpaceCopyValues(CGSConnectionID cid, CGSSpaceID space); 121 | CG_EXTERN CGError CGSSpaceSetValues(CGSConnectionID cid, CGSSpaceID sid, CFDictionaryRef values); 122 | CG_EXTERN CGError CGSSpaceRemoveValuesForKeys(CGSConnectionID cid, CGSSpaceID sid, CFArrayRef values); 123 | 124 | 125 | #pragma mark - Displaying Spaces 126 | 127 | 128 | /// Given an array of space IDs, each space is shown to the user. 129 | CG_EXTERN void CGSShowSpaces(CGSConnectionID cid, CFArrayRef spaces); 130 | 131 | /// Given an array of space IDs, each space is hidden from the user. 132 | CG_EXTERN void CGSHideSpaces(CGSConnectionID cid, CFArrayRef spaces); 133 | 134 | /// Given an array of window numbers and an array of space IDs, adds each window to each space. 135 | CG_EXTERN void CGSAddWindowsToSpaces(CGSConnectionID cid, CFArrayRef windows, CFArrayRef spaces); 136 | 137 | /// Given an array of window numbers and an array of space IDs, removes each window from each space. 138 | CG_EXTERN void CGSRemoveWindowsFromSpaces(CGSConnectionID cid, CFArrayRef windows, CFArrayRef spaces); 139 | 140 | CG_EXTERN CFStringRef kCGSPackagesMainDisplayIdentifier; 141 | 142 | /// Changes the active space for a given display. 143 | CG_EXTERN void CGSManagedDisplaySetCurrentSpace(CGSConnectionID cid, CFStringRef display, CGSSpaceID space); 144 | 145 | #endif /// CGS_SPACE_INTERNAL_H */ 146 | 147 | -------------------------------------------------------------------------------- /CGSInternal/CGSSurface.h: -------------------------------------------------------------------------------- 1 | // 2 | // CGSSurface.h 3 | // CGSInternal 4 | // 5 | // Created by Robert Widmann on 9/14/13. 6 | // Copyright © 2015-2016 CodaFi. All rights reserved. 7 | // Released under the MIT license. 8 | // 9 | 10 | #ifndef CGS_SURFACE_INTERNAL_H 11 | #define CGS_SURFACE_INTERNAL_H 12 | 13 | #include "CGSWindow.h" 14 | 15 | typedef int CGSSurfaceID; 16 | 17 | 18 | #pragma mark - Surface Lifecycle 19 | 20 | 21 | /// Adds a drawable surface to a window. 22 | CG_EXTERN CGError CGSAddSurface(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID *outSID); 23 | 24 | /// Removes a drawable surface from a window. 25 | CG_EXTERN CGError CGSRemoveSurface(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID sid); 26 | 27 | /// Binds a CAContext to a surface. 28 | /// 29 | /// Pass ctx the result of invoking -[CAContext contextId]. 30 | CG_EXTERN CGError CGSBindSurface(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID sid, int x, int y, unsigned int ctx); 31 | 32 | #pragma mark - Surface Properties 33 | 34 | 35 | /// Sets the bounds of a surface. 36 | CG_EXTERN CGError CGSSetSurfaceBounds(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID sid, CGRect bounds); 37 | 38 | /// Gets the smallest rectangle a surface's frame fits in. 39 | CG_EXTERN CGError CGSGetSurfaceBounds(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID sid, CGFloat *bounds); 40 | 41 | /// Sets the opacity of the surface 42 | CG_EXTERN CGError CGSSetSurfaceOpacity(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID sid, bool isOpaque); 43 | 44 | /// Sets a surface's color space. 45 | CG_EXTERN CGError CGSSetSurfaceColorSpace(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID surface, CGColorSpaceRef colorSpace); 46 | 47 | /// Tunes a number of properties the Window Server uses when rendering a layer-backed surface. 48 | CG_EXTERN CGError CGSSetSurfaceLayerBackingOptions(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID surface, CGFloat flattenDelay, CGFloat decelerationDelay, CGFloat discardDelay); 49 | 50 | /// Sets the order of a surface relative to another surface. 51 | CG_EXTERN CGError CGSOrderSurface(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID surface, CGSSurfaceID otherSurface, int place); 52 | 53 | /// Currently does nothing. 54 | CG_EXTERN CGError CGSSetSurfaceBackgroundBlur(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID sid, CGFloat blur) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 55 | 56 | /// Sets the drawing resolution of the surface. 57 | CG_EXTERN CGError CGSSetSurfaceResolution(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID sid, CGFloat scale) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 58 | 59 | 60 | #pragma mark - Window Surface Properties 61 | 62 | 63 | /// Gets the count of all drawable surfaces on a window. 64 | CG_EXTERN CGError CGSGetSurfaceCount(CGSConnectionID cid, CGWindowID wid, int *outCount); 65 | 66 | /// Gets a list of surfaces owned by a window. 67 | CG_EXTERN CGError CGSGetSurfaceList(CGSConnectionID cid, CGWindowID wid, int countIds, CGSSurfaceID *ids, int *outCount); 68 | 69 | 70 | #pragma mark - Drawing Surfaces 71 | 72 | 73 | /// Flushes a surface to its window. 74 | CG_EXTERN CGError CGSFlushSurface(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID surface, int param); 75 | 76 | #endif /* CGS_SURFACE_INTERNAL_H */ 77 | -------------------------------------------------------------------------------- /CGSInternal/CGSTile.h: -------------------------------------------------------------------------------- 1 | // 2 | // CGSTile.h 3 | // NUIKit 4 | // 5 | // Created by Robert Widmann on 10/9/15. 6 | // Copyright © 2015-2016 CodaFi. All rights reserved. 7 | // Released under the MIT license. 8 | // 9 | 10 | #ifndef CGS_TILE_INTERNAL_H 11 | #define CGS_TILE_INTERNAL_H 12 | 13 | #include "CGSSurface.h" 14 | 15 | typedef size_t CGSTileID; 16 | 17 | 18 | #pragma mark - Proposed Tile Properties 19 | 20 | 21 | /// Returns true if the space ID and connection admit the creation of a new tile. 22 | CG_EXTERN bool CGSSpaceCanCreateTile(CGSConnectionID cid, CGSSpaceID sid) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 23 | 24 | /// Returns the recommended size for a tile that could be added to the given space. 25 | CG_EXTERN CGError CGSSpaceGetSizeForProposedTile(CGSConnectionID cid, CGSSpaceID sid, CGSize *outSize) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 26 | 27 | 28 | #pragma mark - Tile Creation 29 | 30 | 31 | /// Creates a new tile ID in the given space. 32 | CG_EXTERN CGError CGSSpaceCreateTile(CGSConnectionID cid, CGSSpaceID sid, CGSTileID *outTID) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 33 | 34 | 35 | #pragma mark - Tile Spaces 36 | 37 | 38 | /// Returns an array of CFNumberRefs of CGSSpaceIDs. 39 | CG_EXTERN CFArrayRef CGSSpaceCopyTileSpaces(CGSConnectionID cid, CGSSpaceID sid) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 40 | 41 | 42 | #pragma mark - Tile Properties 43 | 44 | 45 | /// Returns the size of the inter-tile spacing between tiles in the given space ID. 46 | CG_EXTERN CGFloat CGSSpaceGetInterTileSpacing(CGSConnectionID cid, CGSSpaceID sid) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 47 | /// Sets the size of the inter-tile spacing for the given space ID. 48 | CG_EXTERN CGError CGSSpaceSetInterTileSpacing(CGSConnectionID cid, CGSSpaceID sid, CGFloat spacing) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 49 | 50 | /// Gets the space ID for the given tile space. 51 | CG_EXTERN CGSSpaceID CGSTileSpaceResizeRecordGetSpaceID(CGSSpaceID sid) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 52 | /// Gets the space ID for the parent of the given tile space. 53 | CG_EXTERN CGSSpaceID CGSTileSpaceResizeRecordGetParentSpaceID(CGSSpaceID sid) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 54 | 55 | /// Returns whether the current tile space is being resized. 56 | CG_EXTERN bool CGSTileSpaceResizeRecordIsLiveResizing(CGSSpaceID sid) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 57 | 58 | /// 59 | CG_EXTERN CGSTileID CGSTileOwnerChangeRecordGetTileID(CGSConnectionID ownerID) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 60 | /// 61 | CG_EXTERN CGSSpaceID CGSTileOwnerChangeRecordGetManagedSpaceID(CGSConnectionID ownerID) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 62 | 63 | /// 64 | CG_EXTERN CGSTileID CGSTileEvictionRecordGetTileID(CGSConnectionID ownerID) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 65 | /// 66 | CG_EXTERN CGSSpaceID CGSTileEvictionRecordGetManagedSpaceID(CGSConnectionID ownerID) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 67 | 68 | /// 69 | CG_EXTERN CGSSpaceID CGSTileOwnerChangeRecordGetNewOwner(CGSConnectionID ownerID) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 70 | /// 71 | CG_EXTERN CGSSpaceID CGSTileOwnerChangeRecordGetOldOwner(CGSConnectionID ownerID) AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER; 72 | 73 | #endif /* CGS_TILE_INTERNAL_H */ 74 | -------------------------------------------------------------------------------- /CGSInternal/CGSTransitions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_TRANSITIONS_INTERNAL_H 31 | #define CGS_TRANSITIONS_INTERNAL_H 32 | 33 | #include "CGSConnection.h" 34 | 35 | typedef enum { 36 | /// No animation is performed during the transition. 37 | kCGSTransitionNone, 38 | /// The window's content fades as it becomes visible or hidden. 39 | kCGSTransitionFade, 40 | /// The window's content zooms in or out as it becomes visible or hidden. 41 | kCGSTransitionZoom, 42 | /// The window's content is revealed gradually in the direction specified by the transition subtype. 43 | kCGSTransitionReveal, 44 | /// The window's content slides in or out along the direction specified by the transition subtype. 45 | kCGSTransitionSlide, 46 | /// 47 | kCGSTransitionWarpFade, 48 | kCGSTransitionSwap, 49 | /// The window's content is aligned to the faces of a cube and rotated in or out along the 50 | /// direction specified by the transition subtype. 51 | kCGSTransitionCube, 52 | /// 53 | kCGSTransitionWarpSwitch, 54 | /// The window's content is flipped along its midpoint like a page being turned over along the 55 | /// direction specified by the transition subtype. 56 | kCGSTransitionFlip 57 | } CGSTransitionType; 58 | 59 | typedef enum { 60 | /// Directions bits for the transition. Some directions don't apply to some transitions. 61 | kCGSTransitionDirectionLeft = 1 << 0, 62 | kCGSTransitionDirectionRight = 1 << 1, 63 | kCGSTransitionDirectionDown = 1 << 2, 64 | kCGSTransitionDirectionUp = 1 << 3, 65 | kCGSTransitionDirectionCenter = 1 << 4, 66 | 67 | /// Reverses a transition. Doesn't apply for all transitions. 68 | kCGSTransitionFlagReversed = 1 << 5, 69 | 70 | /// Ignore the background color and only transition the window. 71 | kCGSTransitionFlagTransparent = 1 << 7, 72 | } CGSTransitionFlags; 73 | 74 | typedef struct CGSTransitionSpec { 75 | int version; // always set to zero 76 | CGSTransitionType type; 77 | CGSTransitionFlags options; 78 | CGWindowID wid; /* 0 means a full screen transition. */ 79 | CGFloat *backColor; /* NULL means black. */ 80 | } *CGSTransitionSpecRef; 81 | 82 | /// Creates a new transition from a `CGSTransitionSpec`. 83 | CG_EXTERN CGError CGSNewTransition(CGSConnectionID cid, const CGSTransitionSpecRef spec, CGSTransitionID *outTransition); 84 | 85 | /// Invokes a transition asynchronously. Note that `duration` is in seconds. 86 | CG_EXTERN CGError CGSInvokeTransition(CGSConnectionID cid, CGSTransitionID transition, CGFloat duration); 87 | 88 | /// Releases a transition. 89 | CG_EXTERN CGError CGSReleaseTransition(CGSConnectionID cid, CGSTransitionID transition); 90 | 91 | #endif /* CGS_TRANSITIONS_INTERNAL_H */ 92 | -------------------------------------------------------------------------------- /CGSInternal/CGSWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_WINDOW_INTERNAL_H 31 | #define CGS_WINDOW_INTERNAL_H 32 | 33 | #include "CGSConnection.h" 34 | #include "CGSRegion.h" 35 | 36 | typedef CFTypeRef CGSAnimationRef; 37 | typedef CFTypeRef CGSWindowBackdropRef; 38 | typedef struct CGSWarpPoint CGSWarpPoint; 39 | 40 | #define kCGSRealMaximumTagSize (sizeof(void *) * 8) 41 | 42 | typedef enum { 43 | kCGSSharingNone, 44 | kCGSSharingReadOnly, 45 | kCGSSharingReadWrite 46 | } CGSSharingState; 47 | 48 | typedef enum { 49 | kCGSOrderBelow = -1, 50 | kCGSOrderOut, /* hides the window */ 51 | kCGSOrderAbove, 52 | kCGSOrderIn /* shows the window */ 53 | } CGSWindowOrderingMode; 54 | 55 | typedef enum { 56 | kCGSBackingNonRetianed, 57 | kCGSBackingRetained, 58 | kCGSBackingBuffered, 59 | } CGSBackingType; 60 | 61 | typedef enum { 62 | CGSWindowSaveWeightingDontReuse, 63 | CGSWindowSaveWeightingTopLeft, 64 | CGSWindowSaveWeightingTopRight, 65 | CGSWindowSaveWeightingBottomLeft, 66 | CGSWindowSaveWeightingBottomRight, 67 | CGSWindowSaveWeightingClip, 68 | } CGSWindowSaveWeighting; 69 | typedef enum : int { 70 | // Lo bits 71 | 72 | /// The window appears in the default style of OS X windows. "Document" is most likely a 73 | /// historical name. 74 | kCGSDocumentWindowTagBit = 1 << 0, 75 | /// The window appears floating over other windows. This mask is often combined with other 76 | /// non-activating bits to enable floating panels. 77 | kCGSFloatingWindowTagBit = 1 << 1, 78 | 79 | /// Disables the window's badging when it is minimized into its Dock Tile. 80 | kCGSDoNotShowBadgeInDockTagBit = 1 << 2, 81 | 82 | /// The window will be displayed without a shadow, and will ignore any given shadow parameters. 83 | kCGSDisableShadowTagBit = 1 << 3, 84 | 85 | /// Causes the Window Server to resample the window at a higher rate. While this may lead to an 86 | /// improvement in the look of the window, it can lead to performance issues. 87 | kCGSHighQualityResamplingTagBit = 1 << 4, 88 | 89 | /// The window may set the cursor when the application is not active. Useful for windows that 90 | /// present controls like editable text fields. 91 | kCGSSetsCursorInBackgroundTagBit = 1 << 5, 92 | 93 | /// The window continues to operate while a modal run loop has been pushed. 94 | kCGSWorksWhenModalTagBit = 1 << 6, 95 | 96 | /// The window is anchored to another window. 97 | kCGSAttachedWindowTagBit = 1 << 7, 98 | 99 | /// When dragging, the window will ignore any alpha and appear 100% opaque. 100 | kCGSIgnoreAlphaForDraggingTagBit = 1 << 8, 101 | 102 | /// The window appears transparent to events. Mouse events will pass through it to the next 103 | /// eligible responder. This bit or kCGSOpaqueForEventsTagBit must be exclusively set. 104 | kCGSIgnoreForEventsTagBit = 1 << 9, 105 | /// The window appears opaque to events. Mouse events will be intercepted by the window when 106 | /// necessary. This bit or kCGSIgnoreForEventsTagBit must be exclusively set. 107 | kCGSOpaqueForEventsTagBit = 1 << 10, 108 | 109 | /// The window appears on all workspaces regardless of where it was created. This bit is used 110 | /// for QuickLook panels. 111 | kCGSOnAllWorkspacesTagBit = 1 << 11, 112 | 113 | /// 114 | kCGSPointerEventsAvoidCPSTagBit = 1 << 12, 115 | 116 | /// 117 | kCGSKitVisibleTagBit = 1 << 13, 118 | 119 | /// On application deactivation the window disappears from the window list. 120 | kCGSHideOnDeactivateTagBit = 1 << 14, 121 | 122 | /// When the window appears it will not bring the application to the forefront. 123 | kCGSAvoidsActivationTagBit = 1 << 15, 124 | /// When the window is selected it will not bring the application to the forefront. 125 | kCGSPreventsActivationTagBit = 1 << 16, 126 | 127 | /// 128 | kCGSIgnoresOptionTagBit = 1 << 17, 129 | 130 | /// The window ignores the window cycling mechanism. 131 | kCGSIgnoresCycleTagBit = 1 << 18, 132 | 133 | /// 134 | kCGSDefersOrderingTagBit = 1 << 19, 135 | 136 | /// 137 | kCGSDefersActivationTagBit = 1 << 20, 138 | 139 | /// WindowServer will ignore all requests to order this window front. 140 | kCGSIgnoreAsFrontWindowTagBit = 1 << 21, 141 | 142 | /// The WindowServer will control the movement of the window on the screen using its given 143 | /// dragging rects. This enables windows to be movable even when the application stalls. 144 | kCGSEnableServerSideDragTagBit = 1 << 22, 145 | 146 | /// 147 | kCGSMouseDownEventsGrabbedTagBit = 1 << 23, 148 | 149 | /// The window ignores all requests to hide. 150 | kCGSDontHideTagBit = 1 << 24, 151 | 152 | /// 153 | kCGSDontDimWindowDisplayTagBit = 1 << 25, 154 | 155 | /// The window converts all pointers, no matter if they are mice or tablet pens, to its pointer 156 | /// type when they enter the window. 157 | kCGSInstantMouserWindowTagBit = 1 << 26, 158 | 159 | /// The window appears only on active spaces, and will follow when the user changes said active 160 | /// space. 161 | kCGSWindowOwnerFollowsForegroundTagBit = 1 << 27, 162 | 163 | /// 164 | kCGSActivationWindowLevelTagBit = 1 << 28, 165 | 166 | /// The window brings its owning application to the forefront when it is selected. 167 | kCGSBringOwningApplicationForwardTagBit = 1 << 29, 168 | 169 | /// The window is allowed to appear when over login screen. 170 | kCGSPermittedBeforeLoginTagBit = 1 << 30, 171 | 172 | /// The window is modal. 173 | kCGSModalWindowTagBit = 1 << 31, 174 | 175 | // Hi bits 176 | 177 | /// The window draws itself like the dock -the "Magic Mirror". 178 | kCGSWindowIsMagicMirrorTagBit = 1 << 1, 179 | 180 | /// 181 | kCGSFollowsUserTagBit = 1 << 2, 182 | 183 | /// 184 | kCGSWindowDoesNotCastMirrorReflectionTagBit = 1 << 3, 185 | 186 | /// 187 | kCGSMeshedWindowTagBit = 1 << 4, 188 | 189 | /// Bit is set when CoreDrag has dragged something to the window. 190 | kCGSCoreDragIsDraggingWindowTagBit = 1 << 5, 191 | 192 | /// 193 | kCGSAvoidsCaptureTagBit = 1 << 6, 194 | 195 | /// The window is ignored for expose and does not change its appearance in any way when it is 196 | /// activated. 197 | kCGSIgnoreForExposeTagBit = 1 << 7, 198 | 199 | /// The window is hidden. 200 | kCGSHiddenTagBit = 1 << 8, 201 | 202 | /// The window is explicitly included in the window cycling mechanism. 203 | kCGSIncludeInCycleTagBit = 1 << 9, 204 | 205 | /// The window captures gesture events even when the application is not in the foreground. 206 | kCGSWantGesturesInBackgroundTagBit = 1 << 10, 207 | 208 | /// The window is fullscreen. 209 | kCGSFullScreenTagBit = 1 << 11, 210 | 211 | /// 212 | kCGSWindowIsMagicZoomTagBit = 1 << 12, 213 | 214 | /// 215 | kCGSSuperStickyTagBit = 1 << 13, 216 | 217 | /// The window is attached to the menu bar. This is used for NSMenus presented by menu bar 218 | /// apps. 219 | kCGSAttachesToMenuBarTagBit = 1 << 14, 220 | 221 | /// The window appears on the menu bar. This is used for all menu bar items. 222 | kCGSMergesWithMenuBarTagBit = 1 << 15, 223 | 224 | /// 225 | kCGSNeverStickyTagBit = 1 << 16, 226 | 227 | /// The window appears at the level of the desktop picture. 228 | kCGSDesktopPictureTagBit = 1 << 17, 229 | 230 | /// When the window is redrawn it moves forward. Useful for debugging, annoying in practice. 231 | kCGSOrdersForwardWhenSurfaceFlushedTagBit = 1 << 18, 232 | 233 | /// 234 | kCGSDragsMovementGroupParentTagBit = 1 << 19, 235 | kCGSNeverFlattenSurfacesDuringSwipesTagBit = 1 << 20, 236 | kCGSFullScreenCapableTagBit = 1 << 21, 237 | kCGSFullScreenTileCapableTagBit = 1 << 22, 238 | } CGSWindowTagBit; 239 | 240 | struct CGSWarpPoint { 241 | CGPoint localPoint; 242 | CGPoint globalPoint; 243 | }; 244 | 245 | 246 | #pragma mark - Creating Windows 247 | 248 | 249 | /// Creates a new CGSWindow. 250 | /// 251 | /// The real window top/left is the sum of the region's top/left and the top/left parameters. 252 | CG_EXTERN CGError CGSNewWindow(CGSConnectionID cid, CGSBackingType backingType, CGFloat left, CGFloat top, CGSRegionRef region, CGWindowID *outWID); 253 | 254 | /// Creates a new CGSWindow. 255 | /// 256 | /// The real window top/left is the sum of the region's top/left and the top/left parameters. 257 | CG_EXTERN CGError CGSNewWindowWithOpaqueShape(CGSConnectionID cid, CGSBackingType backingType, CGFloat left, CGFloat top, CGSRegionRef region, CGSRegionRef opaqueShape, int unknown, CGSWindowTagBit *tags, int tagSize, CGWindowID *outWID); 258 | 259 | /// Releases a CGSWindow. 260 | CG_EXTERN CGError CGSReleaseWindow(CGSConnectionID cid, CGWindowID wid); 261 | 262 | 263 | #pragma mark - Configuring Windows 264 | 265 | 266 | /// Gets the value associated with the specified window property as a CoreFoundation object. 267 | CG_EXTERN CGError CGSGetWindowProperty(CGSConnectionID cid, CGWindowID wid, CFStringRef key, CFTypeRef *outValue); 268 | CG_EXTERN CGError CGSSetWindowProperty(CGSConnectionID cid, CGWindowID wid, CFStringRef key, CFTypeRef value); 269 | 270 | /// Sets the window's title. 271 | /// 272 | /// A window's title and what is displayed on its titlebar are often distinct strings. The value 273 | /// passed to this method is used to identify the window in spaces. 274 | /// 275 | /// Internally this calls `CGSSetWindowProperty(cid, wid, kCGSWindowTitle, title)`. 276 | CG_EXTERN CGError CGSSetWindowTitle(CGSConnectionID cid, CGWindowID wid, CFStringRef title); 277 | 278 | 279 | /// Returns the window’s alpha value. 280 | CG_EXTERN CGError CGSGetWindowAlpha(CGSConnectionID cid, CGWindowID wid, CGFloat *outAlpha); 281 | 282 | /// Sets the window's alpha value. 283 | CG_EXTERN CGError CGSSetWindowAlpha(CGSConnectionID cid, CGWindowID wid, CGFloat alpha); 284 | 285 | /// Sets the shape of the window and describes how to redraw if the bounding 286 | /// boxes don't match. 287 | CG_EXTERN CGError CGSSetWindowShapeWithWeighting(CGSConnectionID cid, CGWindowID wid, CGFloat offsetX, CGFloat offsetY, CGSRegionRef shape, CGSWindowSaveWeighting weight); 288 | 289 | /// Sets the shape of the window. 290 | CG_EXTERN CGError CGSSetWindowShape(CGSConnectionID cid, CGWindowID wid, CGFloat offsetX, CGFloat offsetY, CGSRegionRef shape); 291 | 292 | /// Gets and sets a Boolean value indicating whether the window is opaque. 293 | CG_EXTERN CGError CGSGetWindowOpacity(CGSConnectionID cid, CGWindowID wid, bool *outIsOpaque); 294 | CG_EXTERN CGError CGSSetWindowOpacity(CGSConnectionID cid, CGWindowID wid, bool isOpaque); 295 | 296 | /// Gets and sets the window's color space. 297 | CG_EXTERN CGError CGSCopyWindowColorSpace(CGSConnectionID cid, CGWindowID wid, CGColorSpaceRef *outColorSpace); 298 | CG_EXTERN CGError CGSSetWindowColorSpace(CGSConnectionID cid, CGWindowID wid, CGColorSpaceRef colorSpace); 299 | 300 | /// Gets and sets the window's clip shape. 301 | CG_EXTERN CGError CGSCopyWindowClipShape(CGSConnectionID cid, CGWindowID wid, CGSRegionRef *outRegion); 302 | CG_EXTERN CGError CGSSetWindowClipShape(CGWindowID wid, CGSRegionRef shape); 303 | 304 | /// Gets and sets the window's transform. 305 | /// 306 | /// Severe restrictions are placed on transformation: 307 | /// - Transformation Matrices may only include a singular transform. 308 | /// - Transformations involving scale may not scale upwards past the window's frame. 309 | /// - Transformations involving rotation must be followed by translation or the window will fall offscreen. 310 | CG_EXTERN CGError CGSGetWindowTransform(CGSConnectionID cid, CGWindowID wid, const CGAffineTransform *outTransform); 311 | CG_EXTERN CGError CGSSetWindowTransform(CGSConnectionID cid, CGWindowID wid, CGAffineTransform transform); 312 | 313 | /// Gets and sets the window's transform in place. 314 | /// 315 | /// Severe restrictions are placed on transformation: 316 | /// - Transformation Matrices may only include a singular transform. 317 | /// - Transformations involving scale may not scale upwards past the window's frame. 318 | /// - Transformations involving rotation must be followed by translation or the window will fall offscreen. 319 | CG_EXTERN CGError CGSGetWindowTransformAtPlacement(CGSConnectionID cid, CGWindowID wid, const CGAffineTransform *outTransform); 320 | CG_EXTERN CGError CGSSetWindowTransformAtPlacement(CGSConnectionID cid, CGWindowID wid, CGAffineTransform transform); 321 | 322 | /// Gets and sets the `CGConnectionID` that owns this window. Only the owner can change most properties of the window. 323 | CG_EXTERN CGError CGSGetWindowOwner(CGSConnectionID cid, CGWindowID wid, CGSConnectionID *outOwner); 324 | CG_EXTERN CGError CGSSetWindowOwner(CGSConnectionID cid, CGWindowID wid, CGSConnectionID owner); 325 | 326 | /// Sets the background color of the window. 327 | CG_EXTERN CGError CGSSetWindowAutofillColor(CGSConnectionID cid, CGWindowID wid, CGFloat red, CGFloat green, CGFloat blue); 328 | 329 | /// Sets the warp for the window. The mesh maps a local (window) point to a point on screen. 330 | CG_EXTERN CGError CGSSetWindowWarp(CGSConnectionID cid, CGWindowID wid, int warpWidth, int warpHeight, const CGSWarpPoint *warp); 331 | 332 | /// Gets or sets whether the Window Server should auto-fill the window's background. 333 | CG_EXTERN CGError CGSGetWindowAutofill(CGSConnectionID cid, CGWindowID wid, bool *outShouldAutoFill); 334 | CG_EXTERN CGError CGSSetWindowAutofill(CGSConnectionID cid, CGWindowID wid, bool shouldAutoFill); 335 | 336 | /// Gets and sets the window level for a window. 337 | CG_EXTERN CGError CGSGetWindowLevel(CGSConnectionID cid, CGWindowID wid, CGWindowLevel *outLevel); 338 | CG_EXTERN CGError CGSSetWindowLevel(CGSConnectionID cid, CGWindowID wid, CGWindowLevel level); 339 | 340 | /// Gets and sets the sharing state. This determines the level of access other applications have over this window. 341 | CG_EXTERN CGError CGSGetWindowSharingState(CGSConnectionID cid, CGWindowID wid, CGSSharingState *outState); 342 | CG_EXTERN CGError CGSSetWindowSharingState(CGSConnectionID cid, CGWindowID wid, CGSSharingState state); 343 | 344 | /// Sets whether this window is ignored in the global window cycle (Control-F4 by default). There is no Get version? */ 345 | CG_EXTERN CGError CGSSetIgnoresCycle(CGSConnectionID cid, CGWindowID wid, bool ignoresCycle); 346 | 347 | 348 | #pragma mark - Managing Window Key State 349 | 350 | 351 | /// Forces a window to acquire key window status. 352 | CG_EXTERN CGError CGSSetMouseFocusWindow(CGSConnectionID cid, CGWindowID wid); 353 | 354 | /// Forces a window to draw with its key appearance. 355 | CG_EXTERN CGError CGSSetWindowHasKeyAppearance(CGSConnectionID cid, CGWindowID wid, bool hasKeyAppearance); 356 | 357 | /// Forces a window to be active. 358 | CG_EXTERN CGError CGSSetWindowActive(CGSConnectionID cid, CGWindowID wid, bool isActive); 359 | 360 | 361 | #pragma mark - Handling Events 362 | 363 | /// DEPRECATED: Sets the shape over which the window can capture events in its frame rectangle. 364 | CG_EXTERN CGError CGSSetWindowEventShape(CGSConnectionID cid, CGSBackingType backingType, CGSRegionRef *shape); 365 | 366 | /// Gets and sets the window's event mask. 367 | CG_EXTERN CGError CGSGetWindowEventMask(CGSConnectionID cid, CGWindowID wid, CGEventMask *mask); 368 | CG_EXTERN CGError CGSSetWindowEventMask(CGSConnectionID cid, CGWindowID wid, CGEventMask mask); 369 | 370 | /// Sets whether a window can recieve mouse events. If no, events will pass to the next window that can receive the event. 371 | CG_EXTERN CGError CGSSetMouseEventEnableFlags(CGSConnectionID cid, CGWindowID wid, bool shouldEnable); 372 | 373 | 374 | 375 | /// Gets the screen rect for a window. 376 | CG_EXTERN CGError CGSGetScreenRectForWindow(CGSConnectionID cid, CGWindowID wid, CGRect *outRect); 377 | 378 | 379 | #pragma mark - Drawing Windows 380 | 381 | /// Creates a graphics context for the window. 382 | /// 383 | /// Acceptable keys options: 384 | /// 385 | /// - CGWindowContextShouldUseCA : CFBooleanRef 386 | CG_EXTERN CGContextRef CGWindowContextCreate(CGSConnectionID cid, CGWindowID wid, CFDictionaryRef options); 387 | 388 | /// Flushes a window's buffer to the screen. 389 | CG_EXTERN CGError CGSFlushWindow(CGSConnectionID cid, CGWindowID wid, CGSRegionRef flushRegion); 390 | 391 | 392 | #pragma mark - Window Order 393 | 394 | 395 | /// Sets the order of a window. 396 | CG_EXTERN CGError CGSOrderWindow(CGSConnectionID cid, CGWindowID wid, CGSWindowOrderingMode mode, CGWindowID relativeToWID); 397 | 398 | CG_EXTERN CGError CGSOrderFrontConditionally(CGSConnectionID cid, CGWindowID wid, bool force); 399 | 400 | 401 | #pragma mark - Sizing Windows 402 | 403 | 404 | /// Sets the origin (top-left) of a window. 405 | CG_EXTERN CGError CGSMoveWindow(CGSConnectionID cid, CGWindowID wid, const CGPoint *origin); 406 | 407 | /// Sets the origin (top-left) of a window relative to another window's origin. 408 | CG_EXTERN CGError CGSSetWindowOriginRelativeToWindow(CGSConnectionID cid, CGWindowID wid, CGWindowID relativeToWID, CGFloat offsetX, CGFloat offsetY); 409 | 410 | /// Sets the frame and position of a window. Updates are grouped for the sake of animation. 411 | CG_EXTERN CGError CGSMoveWindowWithGroup(CGSConnectionID cid, CGWindowID wid, CGRect *newFrame); 412 | 413 | /// Gets the mouse's current location inside the bounds rectangle of the window. 414 | CG_EXTERN CGError CGSGetWindowMouseLocation(CGSConnectionID cid, CGWindowID wid, CGPoint *outPos); 415 | 416 | 417 | #pragma mark - Window Shadows 418 | 419 | 420 | /// Sets the shadow information for a window. 421 | /// 422 | /// Calls through to `CGSSetWindowShadowAndRimParameters` passing 1 for `flags`. 423 | CG_EXTERN CGError CGSSetWindowShadowParameters(CGSConnectionID cid, CGWindowID wid, CGFloat standardDeviation, CGFloat density, int offsetX, int offsetY); 424 | 425 | /// Gets and sets the shadow information for a window. 426 | /// 427 | /// Values for `flags` are unknown. Calls `CGSSetWindowShadowAndRimParametersWithStretch`. 428 | CG_EXTERN CGError CGSSetWindowShadowAndRimParameters(CGSConnectionID cid, CGWindowID wid, CGFloat standardDeviation, CGFloat density, int offsetX, int offsetY, int flags); 429 | CG_EXTERN CGError CGSGetWindowShadowAndRimParameters(CGSConnectionID cid, CGWindowID wid, CGFloat *outStandardDeviation, CGFloat *outDensity, int *outOffsetX, int *outOffsetY, int *outFlags); 430 | 431 | /// Sets the shadow information for a window. 432 | CG_EXTERN CGError CGSSetWindowShadowAndRimParametersWithStretch(CGSConnectionID cid, CGWindowID wid, CGFloat standardDeviation, CGFloat density, int offsetX, int offsetY, int stretch_x, int stretch_y, unsigned int flags); 433 | 434 | /// Invalidates a window's shadow. 435 | CG_EXTERN CGError CGSInvalidateWindowShadow(CGSConnectionID cid, CGWindowID wid); 436 | 437 | /// Sets a window's shadow properties. 438 | /// 439 | /// Acceptable keys: 440 | /// 441 | /// - com.apple.WindowShadowDensity - (0.0 - 1.0) Opacity of the window's shadow. 442 | /// - com.apple.WindowShadowRadius - The radius of the shadow around the window's corners. 443 | /// - com.apple.WindowShadowVerticalOffset - Vertical offset of the shadow. 444 | /// - com.apple.WindowShadowRimDensity - (0.0 - 1.0) Opacity of the black rim around the window. 445 | /// - com.apple.WindowShadowRimStyleHard - Sets a hard black rim around the window. 446 | CG_EXTERN CGError CGSWindowSetShadowProperties(CGWindowID wid, CFDictionaryRef properties); 447 | 448 | 449 | #pragma mark - Window Lists 450 | 451 | 452 | /// Gets the number of windows the `targetCID` owns. 453 | CG_EXTERN CGError CGSGetWindowCount(CGSConnectionID cid, CGSConnectionID targetCID, int *outCount); 454 | 455 | /// Gets a list of windows owned by `targetCID`. 456 | CG_EXTERN CGError CGSGetWindowList(CGSConnectionID cid, CGSConnectionID targetCID, int count, CGWindowID *list, int *outCount); 457 | 458 | /// Gets the number of windows owned by `targetCID` that are on screen. 459 | CG_EXTERN CGError CGSGetOnScreenWindowCount(CGSConnectionID cid, CGSConnectionID targetCID, int *outCount); 460 | 461 | /// Gets a list of windows oned by `targetCID` that are on screen. 462 | CG_EXTERN CGError CGSGetOnScreenWindowList(CGSConnectionID cid, CGSConnectionID targetCID, int count, CGWindowID *list, int *outCount); 463 | 464 | /// Sets the alpha of a group of windows over a period of time. Note that `duration` is in seconds. 465 | CG_EXTERN CGError CGSSetWindowListAlpha(CGSConnectionID cid, const CGWindowID *widList, int widCount, CGFloat alpha, CGFloat duration); 466 | 467 | 468 | #pragma mark - Window Activation Regions 469 | 470 | 471 | /// Sets the shape over which the window can capture events in its frame rectangle. 472 | CG_EXTERN CGError CGSAddActivationRegion(CGSConnectionID cid, CGWindowID wid, CGSRegionRef region); 473 | 474 | /// Sets the shape over which the window can recieve mouse drag events. 475 | CG_EXTERN CGError CGSAddDragRegion(CGSConnectionID cid, CGWindowID wid, CGSRegionRef region); 476 | 477 | /// Removes any shapes over which the window can be dragged. 478 | CG_EXTERN CGError CGSClearDragRegion(CGSConnectionID cid, CGWindowID wid); 479 | 480 | CG_EXTERN CGError CGSDragWindowRelativeToMouse(CGSConnectionID cid, CGWindowID wid, CGPoint point); 481 | 482 | 483 | #pragma mark - Window Animations 484 | 485 | 486 | /// Creates a Dock-style genie animation that goes from `wid` to `destinationWID`. 487 | CG_EXTERN CGError CGSCreateGenieWindowAnimation(CGSConnectionID cid, CGWindowID wid, CGWindowID destinationWID, CGSAnimationRef *outAnimation); 488 | 489 | /// Creates a sheet animation that's used when the parent window is brushed metal. Oddly enough, seems to be the only one used, even if the parent window isn't metal. 490 | CG_EXTERN CGError CGSCreateMetalSheetWindowAnimationWithParent(CGSConnectionID cid, CGWindowID wid, CGWindowID parentWID, CGSAnimationRef *outAnimation); 491 | 492 | /// Sets the progress of an animation. 493 | CG_EXTERN CGError CGSSetWindowAnimationProgress(CGSAnimationRef animation, CGFloat progress); 494 | 495 | /// DOCUMENTATION PENDING */ 496 | CG_EXTERN CGError CGSWindowAnimationChangeLevel(CGSAnimationRef animation, CGWindowLevel level); 497 | 498 | /// DOCUMENTATION PENDING */ 499 | CG_EXTERN CGError CGSWindowAnimationSetParent(CGSAnimationRef animation, CGWindowID parent) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; 500 | 501 | /// Releases a window animation. 502 | CG_EXTERN CGError CGSReleaseWindowAnimation(CGSAnimationRef animation); 503 | 504 | 505 | #pragma mark - Window Accelleration 506 | 507 | 508 | /// Gets the state of accelleration for the window. 509 | CG_EXTERN CGError CGSWindowIsAccelerated(CGSConnectionID cid, CGWindowID wid, bool *outIsAccelerated); 510 | 511 | /// Gets and sets if this window can be accellerated. I don't know if playing with this is safe. 512 | CG_EXTERN CGError CGSWindowCanAccelerate(CGSConnectionID cid, CGWindowID wid, bool *outCanAccelerate); 513 | CG_EXTERN CGError CGSWindowSetCanAccelerate(CGSConnectionID cid, CGWindowID wid, bool canAccelerate); 514 | 515 | 516 | #pragma mark - Status Bar Windows 517 | 518 | 519 | /// Registers or unregisters a window as a global status item (see `NSStatusItem`, `NSMenuExtra`). 520 | /// Once a window is registered, the Window Server takes care of placing it in the apropriate location. 521 | CG_EXTERN CGError CGSSystemStatusBarRegisterWindow(CGSConnectionID cid, CGWindowID wid, int priority); 522 | CG_EXTERN CGError CGSUnregisterWindowWithSystemStatusBar(CGSConnectionID cid, CGWindowID wid); 523 | 524 | /// Rearranges items in the system status bar. You should call this after registering or unregistering a status item or changing the window's width. 525 | CG_EXTERN CGError CGSAdjustSystemStatusBarWindows(CGSConnectionID cid); 526 | 527 | 528 | #pragma mark - Window Tags 529 | 530 | 531 | /// Get the given tags for a window. Pass kCGSRealMaximumTagSize to maxTagSize. 532 | /// 533 | /// Tags are represented server-side as 64-bit integers, but CoreGraphics maintains compatibility 534 | /// with 32-bit clients by requiring 2 32-bit options tags to be specified. The first entry in the 535 | /// options array populates the lower 32 bits, the last populates the upper 32 bits. 536 | CG_EXTERN CGError CGSGetWindowTags(CGSConnectionID cid, CGWindowID wid, const CGSWindowTagBit tags[2], size_t maxTagSize); 537 | 538 | /// Set the given tags for a window. Pass kCGSRealMaximumTagSize to maxTagSize. 539 | /// 540 | /// Tags are represented server-side as 64-bit integers, but CoreGraphics maintains compatibility 541 | /// with 32-bit clients by requiring 2 32-bit options tags to be specified. The first entry in the 542 | /// options array populates the lower 32 bits, the last populates the upper 32 bits. 543 | CG_EXTERN CGError CGSSetWindowTags(CGSConnectionID cid, CGWindowID wid, const CGSWindowTagBit tags[2], size_t maxTagSize); 544 | 545 | /// Clear the given tags for a window. Pass kCGSRealMaximumTagSize to maxTagSize. 546 | /// 547 | /// Tags are represented server-side as 64-bit integers, but CoreGraphics maintains compatibility 548 | /// with 32-bit clients by requiring 2 32-bit options tags to be specified. The first entry in the 549 | /// options array populates the lower 32 bits, the last populates the upper 32 bits. 550 | CG_EXTERN CGError CGSClearWindowTags(CGSConnectionID cid, CGWindowID wid, const CGSWindowTagBit tags[2], size_t maxTagSize); 551 | 552 | 553 | #pragma mark - Window Backdrop 554 | 555 | 556 | /// Creates a new window backdrop with a given material and frame. 557 | /// 558 | /// the Window Server will apply the backdrop's material effect to the window using the 559 | /// application's default connection. 560 | CG_EXTERN CGSWindowBackdropRef CGSWindowBackdropCreateWithLevel(CGWindowID wid, CFStringRef materialName, CGWindowLevel level, CGRect frame) AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER; 561 | 562 | /// Releases a window backdrop object. 563 | CG_EXTERN void CGSWindowBackdropRelease(CGSWindowBackdropRef backdrop) AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER; 564 | 565 | /// Activates the backdrop's effect. OS X currently only makes the key window's backdrop active. 566 | CG_EXTERN void CGSWindowBackdropActivate(CGSWindowBackdropRef backdrop) AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER; 567 | CG_EXTERN void CGSWindowBackdropDeactivate(CGSWindowBackdropRef backdrop) AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER; 568 | 569 | /// Sets the saturation of the backdrop. For certain material types this can imitate the "vibrancy" effect in AppKit. 570 | CG_EXTERN void CGSWindowBackdropSetSaturation(CGSWindowBackdropRef backdrop, CGFloat saturation) AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER; 571 | 572 | /// Sets the bleed for the window's backdrop effect. Vibrant NSWindows use ~0.2. 573 | CG_EXTERN void CGSWindowSetBackdropBackgroundBleed(CGWindowID wid, CGFloat bleedAmount) AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER; 574 | 575 | #endif /* CGS_WINDOW_INTERNAL_H */ 576 | -------------------------------------------------------------------------------- /CGSInternal/CGSWorkspace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Alacatia Labs 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * Joe Ranieri joe@alacatia.com 21 | * 22 | */ 23 | 24 | // 25 | // Updated by Robert Widmann. 26 | // Copyright © 2015-2016 CodaFi. All rights reserved. 27 | // Released under the MIT license. 28 | // 29 | 30 | #ifndef CGS_WORKSPACE_INTERNAL_H 31 | #define CGS_WORKSPACE_INTERNAL_H 32 | 33 | #include "CGSConnection.h" 34 | #include "CGSWindow.h" 35 | #include "CGSTransitions.h" 36 | 37 | typedef unsigned int CGSWorkspaceID; 38 | 39 | /// The space ID given when we're switching spaces. 40 | static const CGSWorkspaceID kCGSTransitioningWorkspaceID = 65538; 41 | 42 | /// Gets and sets the current workspace. 43 | CG_EXTERN CGError CGSGetWorkspace(CGSConnectionID cid, CGSWorkspaceID *outWorkspace); 44 | CG_EXTERN CGError CGSSetWorkspace(CGSConnectionID cid, CGSWorkspaceID workspace); 45 | 46 | /// Transitions to a workspace asynchronously. Note that `duration` is in seconds. 47 | CG_EXTERN CGError CGSSetWorkspaceWithTransition(CGSConnectionID cid, CGSWorkspaceID workspace, CGSTransitionType transition, CGSTransitionFlags options, CGFloat duration); 48 | 49 | /// Gets and sets the workspace for a window. 50 | CG_EXTERN CGError CGSGetWindowWorkspace(CGSConnectionID cid, CGWindowID wid, CGSWorkspaceID *outWorkspace); 51 | CG_EXTERN CGError CGSSetWindowWorkspace(CGSConnectionID cid, CGWindowID wid, CGSWorkspaceID workspace); 52 | 53 | /// Gets the number of windows in the workspace. 54 | CG_EXTERN CGError CGSGetWorkspaceWindowCount(CGSConnectionID cid, int workspaceNumber, int *outCount); 55 | CG_EXTERN CGError CGSGetWorkspaceWindowList(CGSConnectionID cid, int workspaceNumber, int count, CGWindowID *list, int *outCount); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /CGSInternal/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSHumanReadableCopyright 22 | Copyright © 2017 CodaFi. All rights reserved. 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /DIYWindows.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4838E5F91F95DBFA00FF7321 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4838E5F81F95DBFA00FF7321 /* CoreGraphics.framework */; }; 11 | 4838E5FD1F95DC2300FF7321 /* SkyLight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4838E5FC1F95DC2300FF7321 /* SkyLight.framework */; }; 12 | 4838E6051F95DD4800FF7321 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4838E6041F95DD4800FF7321 /* main.m */; }; 13 | 4838E6091F95DD8100FF7321 /* GraphicsServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 829F155A1B6C5FAB00F8E692 /* GraphicsServices.framework */; }; 14 | 48B55D371F99BA060023326F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4838E5F81F95DBFA00FF7321 /* CoreGraphics.framework */; }; 15 | 48B55D381F99BA190023326F /* SkyLight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4838E5FC1F95DC2300FF7321 /* SkyLight.framework */; }; 16 | 48B55D391F99BA200023326F /* CGSInternal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 48B55D1C1F99B9C80023326F /* CGSInternal.framework */; }; 17 | 48B55D3C1F99BA770023326F /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 48B55D3B1F99BA770023326F /* QuartzCore.framework */; }; 18 | 48B55D3D1F99BAAD0023326F /* CGSAccessibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D251F99B9E90023326F /* CGSAccessibility.h */; settings = {ATTRIBUTES = (Public, ); }; }; 19 | 48B55D3E1F99BAAD0023326F /* CGSCIFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D361F99B9EA0023326F /* CGSCIFilter.h */; settings = {ATTRIBUTES = (Public, ); }; }; 20 | 48B55D3F1F99BAAD0023326F /* CGSConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D2B1F99B9E90023326F /* CGSConnection.h */; settings = {ATTRIBUTES = (Public, ); }; }; 21 | 48B55D401F99BAAD0023326F /* CGSCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D311F99B9EA0023326F /* CGSCursor.h */; settings = {ATTRIBUTES = (Public, ); }; }; 22 | 48B55D411F99BAAD0023326F /* CGSDebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D241F99B9E80023326F /* CGSDebug.h */; settings = {ATTRIBUTES = (Public, ); }; }; 23 | 48B55D421F99BAAD0023326F /* CGSDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D2F1F99B9E90023326F /* CGSDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; 24 | 48B55D431F99BAAD0023326F /* CGSDisplays.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D2E1F99B9E90023326F /* CGSDisplays.h */; settings = {ATTRIBUTES = (Public, ); }; }; 25 | 48B55D441F99BAAD0023326F /* CGSEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D261F99B9E90023326F /* CGSEvent.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26 | 48B55D451F99BAAD0023326F /* CGSHotKeys.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D281F99B9E90023326F /* CGSHotKeys.h */; settings = {ATTRIBUTES = (Public, ); }; }; 27 | 48B55D461F99BAAD0023326F /* CGSInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D2C1F99B9E90023326F /* CGSInternal.h */; settings = {ATTRIBUTES = (Public, ); }; }; 28 | 48B55D471F99BAAD0023326F /* CGSMisc.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D341F99B9EA0023326F /* CGSMisc.h */; settings = {ATTRIBUTES = (Public, ); }; }; 29 | 48B55D481F99BAAD0023326F /* CGSRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D2A1F99B9E90023326F /* CGSRegion.h */; settings = {ATTRIBUTES = (Public, ); }; }; 30 | 48B55D491F99BAAD0023326F /* CGSSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D2D1F99B9E90023326F /* CGSSession.h */; settings = {ATTRIBUTES = (Public, ); }; }; 31 | 48B55D4A1F99BAAD0023326F /* CGSSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D271F99B9E90023326F /* CGSSpace.h */; settings = {ATTRIBUTES = (Public, ); }; }; 32 | 48B55D4B1F99BAAD0023326F /* CGSSurface.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D321F99B9EA0023326F /* CGSSurface.h */; settings = {ATTRIBUTES = (Public, ); }; }; 33 | 48B55D4C1F99BAAD0023326F /* CGSTile.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D291F99B9E90023326F /* CGSTile.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34 | 48B55D4D1F99BAAD0023326F /* CGSTransitions.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D301F99B9EA0023326F /* CGSTransitions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 35 | 48B55D4E1F99BAAD0023326F /* CGSWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D331F99B9EA0023326F /* CGSWindow.h */; settings = {ATTRIBUTES = (Public, ); }; }; 36 | 48B55D4F1F99BAAD0023326F /* CGSWorkspace.h in Headers */ = {isa = PBXBuildFile; fileRef = 48B55D351F99B9EA0023326F /* CGSWorkspace.h */; settings = {ATTRIBUTES = (Public, ); }; }; 37 | 82573C601BDD64AD00549861 /* GSEventTypes.def in Headers */ = {isa = PBXBuildFile; fileRef = 82573C5F1BDD64AD00549861 /* GSEventTypes.def */; settings = {ATTRIBUTES = (Public, ); }; }; 38 | 82573C621BDD65FD00549861 /* GSEventTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 82573C611BDD64C700549861 /* GSEventTypes.h */; settings = {ATTRIBUTES = (Public, ); }; }; 39 | 829F155E1B6C5FAB00F8E692 /* GraphicsServices.h in Headers */ = {isa = PBXBuildFile; fileRef = 829F155D1B6C5FAB00F8E692 /* GraphicsServices.h */; settings = {ATTRIBUTES = (Public, ); }; }; 40 | 829F15661B6C5FCD00F8E692 /* GSBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 829F15651B6C5FCD00F8E692 /* GSBase.h */; settings = {ATTRIBUTES = (Public, ); }; }; 41 | 829F15691B6C600900F8E692 /* GSEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = 829F15671B6C600900F8E692 /* GSEvent.c */; }; 42 | 829F156A1B6C600900F8E692 /* GSEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 829F15681B6C600900F8E692 /* GSEvent.h */; settings = {ATTRIBUTES = (Public, ); }; }; 43 | 829F156C1B6C60A300F8E692 /* GSCoreFoundationBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 829F156B1B6C60A300F8E692 /* GSCoreFoundationBridge.h */; }; 44 | 829F156F1B6C67D800F8E692 /* GSPrivate.c in Sources */ = {isa = PBXBuildFile; fileRef = 829F156D1B6C67D800F8E692 /* GSPrivate.c */; }; 45 | 829F15701B6C67D800F8E692 /* GSPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 829F156E1B6C67D800F8E692 /* GSPrivate.h */; }; 46 | 829F15721B6C85EA00F8E692 /* CFBase.c in Sources */ = {isa = PBXBuildFile; fileRef = 829F15711B6C85EA00F8E692 /* CFBase.c */; }; 47 | 829F15751B6D3D7B00F8E692 /* GSEventQueue.c in Sources */ = {isa = PBXBuildFile; fileRef = 829F15731B6D3D7B00F8E692 /* GSEventQueue.c */; }; 48 | 829F15761B6D3D7B00F8E692 /* GSEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 829F15741B6D3D7B00F8E692 /* GSEventQueue.h */; }; 49 | 829F157E1B6D4CFD00F8E692 /* GSApp.c in Sources */ = {isa = PBXBuildFile; fileRef = 829F157C1B6D4CFD00F8E692 /* GSApp.c */; }; 50 | 829F157F1B6D4CFD00F8E692 /* GSApp.h in Headers */ = {isa = PBXBuildFile; fileRef = 829F157D1B6D4CFD00F8E692 /* GSApp.h */; settings = {ATTRIBUTES = (Public, ); }; }; 51 | /* End PBXBuildFile section */ 52 | 53 | /* Begin PBXCopyFilesBuildPhase section */ 54 | 4838E6001F95DD4800FF7321 /* CopyFiles */ = { 55 | isa = PBXCopyFilesBuildPhase; 56 | buildActionMask = 2147483647; 57 | dstPath = /usr/share/man/man1/; 58 | dstSubfolderSpec = 0; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 1; 62 | }; 63 | /* End PBXCopyFilesBuildPhase section */ 64 | 65 | /* Begin PBXFileReference section */ 66 | 4838E5F81F95DBFA00FF7321 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 67 | 4838E5FA1F95DC1A00FF7321 /* SkyLight */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = SkyLight; path = ../../../../System/Library/PrivateFrameworks/SkyLight.framework/Versions/A/SkyLight; sourceTree = ""; }; 68 | 4838E5FC1F95DC2300FF7321 /* SkyLight.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SkyLight.framework; path = ../../../../System/Library/PrivateFrameworks/SkyLight.framework; sourceTree = ""; }; 69 | 4838E6021F95DD4800FF7321 /* GSExample */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = GSExample; sourceTree = BUILT_PRODUCTS_DIR; }; 70 | 4838E6041F95DD4800FF7321 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 71 | 48B55D1C1F99B9C80023326F /* CGSInternal.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CGSInternal.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 72 | 48B55D1F1F99B9C80023326F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 73 | 48B55D241F99B9E80023326F /* CGSDebug.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSDebug.h; sourceTree = ""; }; 74 | 48B55D251F99B9E90023326F /* CGSAccessibility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSAccessibility.h; sourceTree = ""; }; 75 | 48B55D261F99B9E90023326F /* CGSEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSEvent.h; sourceTree = ""; }; 76 | 48B55D271F99B9E90023326F /* CGSSpace.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSSpace.h; sourceTree = ""; }; 77 | 48B55D281F99B9E90023326F /* CGSHotKeys.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSHotKeys.h; sourceTree = ""; }; 78 | 48B55D291F99B9E90023326F /* CGSTile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSTile.h; sourceTree = ""; }; 79 | 48B55D2A1F99B9E90023326F /* CGSRegion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSRegion.h; sourceTree = ""; }; 80 | 48B55D2B1F99B9E90023326F /* CGSConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSConnection.h; sourceTree = ""; }; 81 | 48B55D2C1F99B9E90023326F /* CGSInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSInternal.h; sourceTree = ""; }; 82 | 48B55D2D1F99B9E90023326F /* CGSSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSSession.h; sourceTree = ""; }; 83 | 48B55D2E1F99B9E90023326F /* CGSDisplays.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSDisplays.h; sourceTree = ""; }; 84 | 48B55D2F1F99B9E90023326F /* CGSDevice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSDevice.h; sourceTree = ""; }; 85 | 48B55D301F99B9EA0023326F /* CGSTransitions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSTransitions.h; sourceTree = ""; }; 86 | 48B55D311F99B9EA0023326F /* CGSCursor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSCursor.h; sourceTree = ""; }; 87 | 48B55D321F99B9EA0023326F /* CGSSurface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSSurface.h; sourceTree = ""; }; 88 | 48B55D331F99B9EA0023326F /* CGSWindow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSWindow.h; sourceTree = ""; }; 89 | 48B55D341F99B9EA0023326F /* CGSMisc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSMisc.h; sourceTree = ""; }; 90 | 48B55D351F99B9EA0023326F /* CGSWorkspace.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSWorkspace.h; sourceTree = ""; }; 91 | 48B55D361F99B9EA0023326F /* CGSCIFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGSCIFilter.h; sourceTree = ""; }; 92 | 48B55D3A1F99BA5F0023326F /* CAContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CAContext.h; sourceTree = ""; }; 93 | 48B55D3B1F99BA770023326F /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 94 | 48D3083B1FEDFFFB0031C74A /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 95 | 48D3083C1FEE00020031C74A /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 96 | 82573C5F1BDD64AD00549861 /* GSEventTypes.def */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = GSEventTypes.def; sourceTree = ""; }; 97 | 82573C611BDD64C700549861 /* GSEventTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GSEventTypes.h; sourceTree = ""; }; 98 | 829F155A1B6C5FAB00F8E692 /* GraphicsServices.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GraphicsServices.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 99 | 829F155D1B6C5FAB00F8E692 /* GraphicsServices.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsServices.h; sourceTree = ""; }; 100 | 829F155F1B6C5FAB00F8E692 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 101 | 829F15651B6C5FCD00F8E692 /* GSBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GSBase.h; sourceTree = ""; }; 102 | 829F15671B6C600900F8E692 /* GSEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = GSEvent.c; sourceTree = ""; }; 103 | 829F15681B6C600900F8E692 /* GSEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GSEvent.h; sourceTree = ""; }; 104 | 829F156B1B6C60A300F8E692 /* GSCoreFoundationBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GSCoreFoundationBridge.h; sourceTree = ""; }; 105 | 829F156D1B6C67D800F8E692 /* GSPrivate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = GSPrivate.c; sourceTree = ""; }; 106 | 829F156E1B6C67D800F8E692 /* GSPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GSPrivate.h; sourceTree = ""; }; 107 | 829F15711B6C85EA00F8E692 /* CFBase.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFBase.c; sourceTree = ""; }; 108 | 829F15731B6D3D7B00F8E692 /* GSEventQueue.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = GSEventQueue.c; sourceTree = ""; }; 109 | 829F15741B6D3D7B00F8E692 /* GSEventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GSEventQueue.h; sourceTree = ""; }; 110 | 829F157C1B6D4CFD00F8E692 /* GSApp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = GSApp.c; sourceTree = ""; }; 111 | 829F157D1B6D4CFD00F8E692 /* GSApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GSApp.h; sourceTree = ""; }; 112 | /* End PBXFileReference section */ 113 | 114 | /* Begin PBXFrameworksBuildPhase section */ 115 | 4838E5FF1F95DD4800FF7321 /* Frameworks */ = { 116 | isa = PBXFrameworksBuildPhase; 117 | buildActionMask = 2147483647; 118 | files = ( 119 | 48B55D391F99BA200023326F /* CGSInternal.framework in Frameworks */, 120 | 4838E6091F95DD8100FF7321 /* GraphicsServices.framework in Frameworks */, 121 | 48B55D3C1F99BA770023326F /* QuartzCore.framework in Frameworks */, 122 | ); 123 | runOnlyForDeploymentPostprocessing = 0; 124 | }; 125 | 48B55D181F99B9C80023326F /* Frameworks */ = { 126 | isa = PBXFrameworksBuildPhase; 127 | buildActionMask = 2147483647; 128 | files = ( 129 | 48B55D381F99BA190023326F /* SkyLight.framework in Frameworks */, 130 | 48B55D371F99BA060023326F /* CoreGraphics.framework in Frameworks */, 131 | ); 132 | runOnlyForDeploymentPostprocessing = 0; 133 | }; 134 | 829F15561B6C5FAB00F8E692 /* Frameworks */ = { 135 | isa = PBXFrameworksBuildPhase; 136 | buildActionMask = 2147483647; 137 | files = ( 138 | 4838E5FD1F95DC2300FF7321 /* SkyLight.framework in Frameworks */, 139 | 4838E5F91F95DBFA00FF7321 /* CoreGraphics.framework in Frameworks */, 140 | ); 141 | runOnlyForDeploymentPostprocessing = 0; 142 | }; 143 | /* End PBXFrameworksBuildPhase section */ 144 | 145 | /* Begin PBXGroup section */ 146 | 4838E5F71F95DBFA00FF7321 /* Frameworks */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | 48B55D3B1F99BA770023326F /* QuartzCore.framework */, 150 | 4838E5FC1F95DC2300FF7321 /* SkyLight.framework */, 151 | 4838E5FA1F95DC1A00FF7321 /* SkyLight */, 152 | 4838E5F81F95DBFA00FF7321 /* CoreGraphics.framework */, 153 | ); 154 | name = Frameworks; 155 | sourceTree = ""; 156 | }; 157 | 4838E6031F95DD4800FF7321 /* GSExample */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 48B55D3A1F99BA5F0023326F /* CAContext.h */, 161 | 4838E6041F95DD4800FF7321 /* main.m */, 162 | ); 163 | path = GSExample; 164 | sourceTree = ""; 165 | }; 166 | 48B55D1D1F99B9C80023326F /* CGSInternal */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | 48B55D251F99B9E90023326F /* CGSAccessibility.h */, 170 | 48B55D361F99B9EA0023326F /* CGSCIFilter.h */, 171 | 48B55D2B1F99B9E90023326F /* CGSConnection.h */, 172 | 48B55D311F99B9EA0023326F /* CGSCursor.h */, 173 | 48B55D241F99B9E80023326F /* CGSDebug.h */, 174 | 48B55D2F1F99B9E90023326F /* CGSDevice.h */, 175 | 48B55D2E1F99B9E90023326F /* CGSDisplays.h */, 176 | 48B55D261F99B9E90023326F /* CGSEvent.h */, 177 | 48B55D281F99B9E90023326F /* CGSHotKeys.h */, 178 | 48B55D2C1F99B9E90023326F /* CGSInternal.h */, 179 | 48B55D341F99B9EA0023326F /* CGSMisc.h */, 180 | 48B55D2A1F99B9E90023326F /* CGSRegion.h */, 181 | 48B55D2D1F99B9E90023326F /* CGSSession.h */, 182 | 48B55D271F99B9E90023326F /* CGSSpace.h */, 183 | 48B55D321F99B9EA0023326F /* CGSSurface.h */, 184 | 48B55D291F99B9E90023326F /* CGSTile.h */, 185 | 48B55D301F99B9EA0023326F /* CGSTransitions.h */, 186 | 48B55D331F99B9EA0023326F /* CGSWindow.h */, 187 | 48B55D351F99B9EA0023326F /* CGSWorkspace.h */, 188 | 48B55D1F1F99B9C80023326F /* Info.plist */, 189 | ); 190 | path = CGSInternal; 191 | sourceTree = ""; 192 | }; 193 | 829F15501B6C5FAB00F8E692 = { 194 | isa = PBXGroup; 195 | children = ( 196 | 48D3083B1FEDFFFB0031C74A /* README.md */, 197 | 48D3083C1FEE00020031C74A /* LICENSE */, 198 | 4838E6031F95DD4800FF7321 /* GSExample */, 199 | 829F155C1B6C5FAB00F8E692 /* GraphicsServices */, 200 | 48B55D1D1F99B9C80023326F /* CGSInternal */, 201 | 829F155B1B6C5FAB00F8E692 /* Products */, 202 | 4838E5F71F95DBFA00FF7321 /* Frameworks */, 203 | ); 204 | sourceTree = ""; 205 | }; 206 | 829F155B1B6C5FAB00F8E692 /* Products */ = { 207 | isa = PBXGroup; 208 | children = ( 209 | 829F155A1B6C5FAB00F8E692 /* GraphicsServices.framework */, 210 | 4838E6021F95DD4800FF7321 /* GSExample */, 211 | 48B55D1C1F99B9C80023326F /* CGSInternal.framework */, 212 | ); 213 | name = Products; 214 | sourceTree = ""; 215 | }; 216 | 829F155C1B6C5FAB00F8E692 /* GraphicsServices */ = { 217 | isa = PBXGroup; 218 | children = ( 219 | 829F155D1B6C5FAB00F8E692 /* GraphicsServices.h */, 220 | 829F156B1B6C60A300F8E692 /* GSCoreFoundationBridge.h */, 221 | 829F15711B6C85EA00F8E692 /* CFBase.c */, 222 | 829F15651B6C5FCD00F8E692 /* GSBase.h */, 223 | 829F157C1B6D4CFD00F8E692 /* GSApp.c */, 224 | 829F157D1B6D4CFD00F8E692 /* GSApp.h */, 225 | 829F15671B6C600900F8E692 /* GSEvent.c */, 226 | 829F15681B6C600900F8E692 /* GSEvent.h */, 227 | 82573C611BDD64C700549861 /* GSEventTypes.h */, 228 | 82573C5F1BDD64AD00549861 /* GSEventTypes.def */, 229 | 829F15731B6D3D7B00F8E692 /* GSEventQueue.c */, 230 | 829F15741B6D3D7B00F8E692 /* GSEventQueue.h */, 231 | 829F156D1B6C67D800F8E692 /* GSPrivate.c */, 232 | 829F156E1B6C67D800F8E692 /* GSPrivate.h */, 233 | 829F157B1B6D4C9A00F8E692 /* Supporting Files */, 234 | ); 235 | path = GraphicsServices; 236 | sourceTree = ""; 237 | }; 238 | 829F157B1B6D4C9A00F8E692 /* Supporting Files */ = { 239 | isa = PBXGroup; 240 | children = ( 241 | 829F155F1B6C5FAB00F8E692 /* Info.plist */, 242 | ); 243 | name = "Supporting Files"; 244 | sourceTree = ""; 245 | }; 246 | /* End PBXGroup section */ 247 | 248 | /* Begin PBXHeadersBuildPhase section */ 249 | 48B55D191F99B9C80023326F /* Headers */ = { 250 | isa = PBXHeadersBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | 48B55D3D1F99BAAD0023326F /* CGSAccessibility.h in Headers */, 254 | 48B55D3E1F99BAAD0023326F /* CGSCIFilter.h in Headers */, 255 | 48B55D3F1F99BAAD0023326F /* CGSConnection.h in Headers */, 256 | 48B55D401F99BAAD0023326F /* CGSCursor.h in Headers */, 257 | 48B55D411F99BAAD0023326F /* CGSDebug.h in Headers */, 258 | 48B55D421F99BAAD0023326F /* CGSDevice.h in Headers */, 259 | 48B55D431F99BAAD0023326F /* CGSDisplays.h in Headers */, 260 | 48B55D441F99BAAD0023326F /* CGSEvent.h in Headers */, 261 | 48B55D451F99BAAD0023326F /* CGSHotKeys.h in Headers */, 262 | 48B55D461F99BAAD0023326F /* CGSInternal.h in Headers */, 263 | 48B55D471F99BAAD0023326F /* CGSMisc.h in Headers */, 264 | 48B55D481F99BAAD0023326F /* CGSRegion.h in Headers */, 265 | 48B55D491F99BAAD0023326F /* CGSSession.h in Headers */, 266 | 48B55D4A1F99BAAD0023326F /* CGSSpace.h in Headers */, 267 | 48B55D4B1F99BAAD0023326F /* CGSSurface.h in Headers */, 268 | 48B55D4C1F99BAAD0023326F /* CGSTile.h in Headers */, 269 | 48B55D4D1F99BAAD0023326F /* CGSTransitions.h in Headers */, 270 | 48B55D4E1F99BAAD0023326F /* CGSWindow.h in Headers */, 271 | 48B55D4F1F99BAAD0023326F /* CGSWorkspace.h in Headers */, 272 | ); 273 | runOnlyForDeploymentPostprocessing = 0; 274 | }; 275 | 829F15571B6C5FAB00F8E692 /* Headers */ = { 276 | isa = PBXHeadersBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | 82573C601BDD64AD00549861 /* GSEventTypes.def in Headers */, 280 | 829F157F1B6D4CFD00F8E692 /* GSApp.h in Headers */, 281 | 829F155E1B6C5FAB00F8E692 /* GraphicsServices.h in Headers */, 282 | 82573C621BDD65FD00549861 /* GSEventTypes.h in Headers */, 283 | 829F156C1B6C60A300F8E692 /* GSCoreFoundationBridge.h in Headers */, 284 | 829F15661B6C5FCD00F8E692 /* GSBase.h in Headers */, 285 | 829F15701B6C67D800F8E692 /* GSPrivate.h in Headers */, 286 | 829F15761B6D3D7B00F8E692 /* GSEventQueue.h in Headers */, 287 | 829F156A1B6C600900F8E692 /* GSEvent.h in Headers */, 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | }; 291 | /* End PBXHeadersBuildPhase section */ 292 | 293 | /* Begin PBXNativeTarget section */ 294 | 4838E6011F95DD4800FF7321 /* GSExample */ = { 295 | isa = PBXNativeTarget; 296 | buildConfigurationList = 4838E6061F95DD4800FF7321 /* Build configuration list for PBXNativeTarget "GSExample" */; 297 | buildPhases = ( 298 | 4838E5FE1F95DD4800FF7321 /* Sources */, 299 | 4838E5FF1F95DD4800FF7321 /* Frameworks */, 300 | 4838E6001F95DD4800FF7321 /* CopyFiles */, 301 | ); 302 | buildRules = ( 303 | ); 304 | dependencies = ( 305 | ); 306 | name = GSExample; 307 | productName = GSExample; 308 | productReference = 4838E6021F95DD4800FF7321 /* GSExample */; 309 | productType = "com.apple.product-type.tool"; 310 | }; 311 | 48B55D1B1F99B9C80023326F /* CGSInternal */ = { 312 | isa = PBXNativeTarget; 313 | buildConfigurationList = 48B55D231F99B9C80023326F /* Build configuration list for PBXNativeTarget "CGSInternal" */; 314 | buildPhases = ( 315 | 48B55D171F99B9C80023326F /* Sources */, 316 | 48B55D181F99B9C80023326F /* Frameworks */, 317 | 48B55D191F99B9C80023326F /* Headers */, 318 | 48B55D1A1F99B9C80023326F /* Resources */, 319 | ); 320 | buildRules = ( 321 | ); 322 | dependencies = ( 323 | ); 324 | name = CGSInternal; 325 | productName = CGSInternal; 326 | productReference = 48B55D1C1F99B9C80023326F /* CGSInternal.framework */; 327 | productType = "com.apple.product-type.framework"; 328 | }; 329 | 829F15591B6C5FAB00F8E692 /* GraphicsServices */ = { 330 | isa = PBXNativeTarget; 331 | buildConfigurationList = 829F15621B6C5FAB00F8E692 /* Build configuration list for PBXNativeTarget "GraphicsServices" */; 332 | buildPhases = ( 333 | 829F15551B6C5FAB00F8E692 /* Sources */, 334 | 829F15561B6C5FAB00F8E692 /* Frameworks */, 335 | 829F15571B6C5FAB00F8E692 /* Headers */, 336 | 829F15581B6C5FAB00F8E692 /* Resources */, 337 | ); 338 | buildRules = ( 339 | ); 340 | dependencies = ( 341 | ); 342 | name = GraphicsServices; 343 | productName = GraphicsServices; 344 | productReference = 829F155A1B6C5FAB00F8E692 /* GraphicsServices.framework */; 345 | productType = "com.apple.product-type.framework"; 346 | }; 347 | /* End PBXNativeTarget section */ 348 | 349 | /* Begin PBXProject section */ 350 | 829F15511B6C5FAB00F8E692 /* Project object */ = { 351 | isa = PBXProject; 352 | attributes = { 353 | LastUpgradeCheck = 0900; 354 | ORGANIZATIONNAME = CodaFi; 355 | TargetAttributes = { 356 | 4838E6011F95DD4800FF7321 = { 357 | CreatedOnToolsVersion = 9.0; 358 | DevelopmentTeam = 2754ZHC8VE; 359 | ProvisioningStyle = Automatic; 360 | }; 361 | 48B55D1B1F99B9C80023326F = { 362 | CreatedOnToolsVersion = 9.0; 363 | DevelopmentTeam = 2754ZHC8VE; 364 | ProvisioningStyle = Automatic; 365 | }; 366 | 829F15591B6C5FAB00F8E692 = { 367 | CreatedOnToolsVersion = 7.0; 368 | }; 369 | }; 370 | }; 371 | buildConfigurationList = 829F15541B6C5FAB00F8E692 /* Build configuration list for PBXProject "DIYWindows" */; 372 | compatibilityVersion = "Xcode 3.2"; 373 | developmentRegion = English; 374 | hasScannedForEncodings = 0; 375 | knownRegions = ( 376 | en, 377 | ); 378 | mainGroup = 829F15501B6C5FAB00F8E692; 379 | productRefGroup = 829F155B1B6C5FAB00F8E692 /* Products */; 380 | projectDirPath = ""; 381 | projectRoot = ""; 382 | targets = ( 383 | 4838E6011F95DD4800FF7321 /* GSExample */, 384 | 829F15591B6C5FAB00F8E692 /* GraphicsServices */, 385 | 48B55D1B1F99B9C80023326F /* CGSInternal */, 386 | ); 387 | }; 388 | /* End PBXProject section */ 389 | 390 | /* Begin PBXResourcesBuildPhase section */ 391 | 48B55D1A1F99B9C80023326F /* Resources */ = { 392 | isa = PBXResourcesBuildPhase; 393 | buildActionMask = 2147483647; 394 | files = ( 395 | ); 396 | runOnlyForDeploymentPostprocessing = 0; 397 | }; 398 | 829F15581B6C5FAB00F8E692 /* Resources */ = { 399 | isa = PBXResourcesBuildPhase; 400 | buildActionMask = 2147483647; 401 | files = ( 402 | ); 403 | runOnlyForDeploymentPostprocessing = 0; 404 | }; 405 | /* End PBXResourcesBuildPhase section */ 406 | 407 | /* Begin PBXSourcesBuildPhase section */ 408 | 4838E5FE1F95DD4800FF7321 /* Sources */ = { 409 | isa = PBXSourcesBuildPhase; 410 | buildActionMask = 2147483647; 411 | files = ( 412 | 4838E6051F95DD4800FF7321 /* main.m in Sources */, 413 | ); 414 | runOnlyForDeploymentPostprocessing = 0; 415 | }; 416 | 48B55D171F99B9C80023326F /* Sources */ = { 417 | isa = PBXSourcesBuildPhase; 418 | buildActionMask = 2147483647; 419 | files = ( 420 | ); 421 | runOnlyForDeploymentPostprocessing = 0; 422 | }; 423 | 829F15551B6C5FAB00F8E692 /* Sources */ = { 424 | isa = PBXSourcesBuildPhase; 425 | buildActionMask = 2147483647; 426 | files = ( 427 | 829F157E1B6D4CFD00F8E692 /* GSApp.c in Sources */, 428 | 829F15691B6C600900F8E692 /* GSEvent.c in Sources */, 429 | 829F15751B6D3D7B00F8E692 /* GSEventQueue.c in Sources */, 430 | 829F156F1B6C67D800F8E692 /* GSPrivate.c in Sources */, 431 | 829F15721B6C85EA00F8E692 /* CFBase.c in Sources */, 432 | ); 433 | runOnlyForDeploymentPostprocessing = 0; 434 | }; 435 | /* End PBXSourcesBuildPhase section */ 436 | 437 | /* Begin XCBuildConfiguration section */ 438 | 4838E6071F95DD4800FF7321 /* Debug */ = { 439 | isa = XCBuildConfiguration; 440 | buildSettings = { 441 | CLANG_ANALYZER_NONNULL = YES; 442 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 443 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 444 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 445 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 446 | CODE_SIGN_IDENTITY = "Mac Developer"; 447 | CODE_SIGN_STYLE = Automatic; 448 | DEVELOPMENT_TEAM = 2754ZHC8VE; 449 | GCC_C_LANGUAGE_STANDARD = gnu11; 450 | MACOSX_DEPLOYMENT_TARGET = 10.13; 451 | PRODUCT_NAME = "$(TARGET_NAME)"; 452 | }; 453 | name = Debug; 454 | }; 455 | 4838E6081F95DD4800FF7321 /* Release */ = { 456 | isa = XCBuildConfiguration; 457 | buildSettings = { 458 | CLANG_ANALYZER_NONNULL = YES; 459 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 460 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 461 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 462 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 463 | CODE_SIGN_IDENTITY = "Mac Developer"; 464 | CODE_SIGN_STYLE = Automatic; 465 | DEVELOPMENT_TEAM = 2754ZHC8VE; 466 | GCC_C_LANGUAGE_STANDARD = gnu11; 467 | MACOSX_DEPLOYMENT_TARGET = 10.13; 468 | PRODUCT_NAME = "$(TARGET_NAME)"; 469 | }; 470 | name = Release; 471 | }; 472 | 48B55D211F99B9C80023326F /* Debug */ = { 473 | isa = XCBuildConfiguration; 474 | buildSettings = { 475 | CLANG_ANALYZER_NONNULL = YES; 476 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 477 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 478 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 479 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 480 | CODE_SIGN_IDENTITY = "Mac Developer"; 481 | CODE_SIGN_STYLE = Automatic; 482 | COMBINE_HIDPI_IMAGES = YES; 483 | DEFINES_MODULE = YES; 484 | DEVELOPMENT_TEAM = 2754ZHC8VE; 485 | DYLIB_COMPATIBILITY_VERSION = 1; 486 | DYLIB_CURRENT_VERSION = 1; 487 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 488 | FRAMEWORK_SEARCH_PATHS = ( 489 | "$(inherited)", 490 | "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", 491 | ); 492 | FRAMEWORK_VERSION = A; 493 | GCC_C_LANGUAGE_STANDARD = gnu11; 494 | INFOPLIST_FILE = CGSInternal/Info.plist; 495 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 496 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 497 | MACOSX_DEPLOYMENT_TARGET = 10.13; 498 | PRODUCT_BUNDLE_IDENTIFIER = com.avaidyam.CGSInternal; 499 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 500 | SKIP_INSTALL = YES; 501 | }; 502 | name = Debug; 503 | }; 504 | 48B55D221F99B9C80023326F /* Release */ = { 505 | isa = XCBuildConfiguration; 506 | buildSettings = { 507 | CLANG_ANALYZER_NONNULL = YES; 508 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 509 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 510 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 511 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 512 | CODE_SIGN_IDENTITY = "Mac Developer"; 513 | CODE_SIGN_STYLE = Automatic; 514 | COMBINE_HIDPI_IMAGES = YES; 515 | DEFINES_MODULE = YES; 516 | DEVELOPMENT_TEAM = 2754ZHC8VE; 517 | DYLIB_COMPATIBILITY_VERSION = 1; 518 | DYLIB_CURRENT_VERSION = 1; 519 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 520 | FRAMEWORK_SEARCH_PATHS = ( 521 | "$(inherited)", 522 | "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", 523 | ); 524 | FRAMEWORK_VERSION = A; 525 | GCC_C_LANGUAGE_STANDARD = gnu11; 526 | INFOPLIST_FILE = CGSInternal/Info.plist; 527 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 528 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 529 | MACOSX_DEPLOYMENT_TARGET = 10.13; 530 | PRODUCT_BUNDLE_IDENTIFIER = com.avaidyam.CGSInternal; 531 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 532 | SKIP_INSTALL = YES; 533 | }; 534 | name = Release; 535 | }; 536 | 829F15601B6C5FAB00F8E692 /* Debug */ = { 537 | isa = XCBuildConfiguration; 538 | buildSettings = { 539 | ALWAYS_SEARCH_USER_PATHS = NO; 540 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 541 | CLANG_CXX_LIBRARY = "libc++"; 542 | CLANG_ENABLE_MODULES = YES; 543 | CLANG_ENABLE_OBJC_ARC = YES; 544 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 545 | CLANG_WARN_BOOL_CONVERSION = YES; 546 | CLANG_WARN_COMMA = YES; 547 | CLANG_WARN_CONSTANT_CONVERSION = YES; 548 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 549 | CLANG_WARN_EMPTY_BODY = YES; 550 | CLANG_WARN_ENUM_CONVERSION = YES; 551 | CLANG_WARN_INFINITE_RECURSION = YES; 552 | CLANG_WARN_INT_CONVERSION = YES; 553 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 554 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 555 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 556 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 557 | CLANG_WARN_STRICT_PROTOTYPES = YES; 558 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 559 | CLANG_WARN_UNREACHABLE_CODE = YES; 560 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 561 | COPY_PHASE_STRIP = NO; 562 | CURRENT_PROJECT_VERSION = 1; 563 | DEBUG_INFORMATION_FORMAT = dwarf; 564 | ENABLE_STRICT_OBJC_MSGSEND = YES; 565 | ENABLE_TESTABILITY = YES; 566 | GCC_C_LANGUAGE_STANDARD = gnu99; 567 | GCC_DYNAMIC_NO_PIC = NO; 568 | GCC_NO_COMMON_BLOCKS = YES; 569 | GCC_OPTIMIZATION_LEVEL = 0; 570 | GCC_PREPROCESSOR_DEFINITIONS = ( 571 | "DEBUG=1", 572 | "$(inherited)", 573 | ); 574 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 575 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 576 | GCC_WARN_UNDECLARED_SELECTOR = YES; 577 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 578 | GCC_WARN_UNUSED_FUNCTION = YES; 579 | GCC_WARN_UNUSED_VARIABLE = YES; 580 | MACOSX_DEPLOYMENT_TARGET = 10.10; 581 | MTL_ENABLE_DEBUG_INFO = YES; 582 | ONLY_ACTIVE_ARCH = YES; 583 | SDKROOT = macosx; 584 | VERSIONING_SYSTEM = "apple-generic"; 585 | VERSION_INFO_PREFIX = ""; 586 | }; 587 | name = Debug; 588 | }; 589 | 829F15611B6C5FAB00F8E692 /* Release */ = { 590 | isa = XCBuildConfiguration; 591 | buildSettings = { 592 | ALWAYS_SEARCH_USER_PATHS = NO; 593 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 594 | CLANG_CXX_LIBRARY = "libc++"; 595 | CLANG_ENABLE_MODULES = YES; 596 | CLANG_ENABLE_OBJC_ARC = YES; 597 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 598 | CLANG_WARN_BOOL_CONVERSION = YES; 599 | CLANG_WARN_COMMA = YES; 600 | CLANG_WARN_CONSTANT_CONVERSION = YES; 601 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 602 | CLANG_WARN_EMPTY_BODY = YES; 603 | CLANG_WARN_ENUM_CONVERSION = YES; 604 | CLANG_WARN_INFINITE_RECURSION = YES; 605 | CLANG_WARN_INT_CONVERSION = YES; 606 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 607 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 608 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 609 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 610 | CLANG_WARN_STRICT_PROTOTYPES = YES; 611 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 612 | CLANG_WARN_UNREACHABLE_CODE = YES; 613 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 614 | COPY_PHASE_STRIP = NO; 615 | CURRENT_PROJECT_VERSION = 1; 616 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 617 | ENABLE_NS_ASSERTIONS = NO; 618 | ENABLE_STRICT_OBJC_MSGSEND = YES; 619 | GCC_C_LANGUAGE_STANDARD = gnu99; 620 | GCC_NO_COMMON_BLOCKS = YES; 621 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 622 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 623 | GCC_WARN_UNDECLARED_SELECTOR = YES; 624 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 625 | GCC_WARN_UNUSED_FUNCTION = YES; 626 | GCC_WARN_UNUSED_VARIABLE = YES; 627 | MACOSX_DEPLOYMENT_TARGET = 10.10; 628 | MTL_ENABLE_DEBUG_INFO = NO; 629 | SDKROOT = macosx; 630 | VERSIONING_SYSTEM = "apple-generic"; 631 | VERSION_INFO_PREFIX = ""; 632 | }; 633 | name = Release; 634 | }; 635 | 829F15631B6C5FAB00F8E692 /* Debug */ = { 636 | isa = XCBuildConfiguration; 637 | buildSettings = { 638 | COMBINE_HIDPI_IMAGES = YES; 639 | DEFINES_MODULE = YES; 640 | DYLIB_COMPATIBILITY_VERSION = 1; 641 | DYLIB_CURRENT_VERSION = 1; 642 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 643 | FRAMEWORK_SEARCH_PATHS = ( 644 | "$(inherited)", 645 | "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", 646 | ); 647 | FRAMEWORK_VERSION = A; 648 | INFOPLIST_FILE = GraphicsServices/Info.plist; 649 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 650 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 651 | LIBRARY_SEARCH_PATHS = ( 652 | "$(inherited)", 653 | "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks/SkyLight.framework/Versions/A", 654 | ); 655 | PRODUCT_BUNDLE_IDENTIFIER = com.CodaFi.GraphicsServices; 656 | PRODUCT_NAME = "$(TARGET_NAME)"; 657 | SKIP_INSTALL = YES; 658 | }; 659 | name = Debug; 660 | }; 661 | 829F15641B6C5FAB00F8E692 /* Release */ = { 662 | isa = XCBuildConfiguration; 663 | buildSettings = { 664 | COMBINE_HIDPI_IMAGES = YES; 665 | DEFINES_MODULE = YES; 666 | DYLIB_COMPATIBILITY_VERSION = 1; 667 | DYLIB_CURRENT_VERSION = 1; 668 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 669 | FRAMEWORK_SEARCH_PATHS = ( 670 | "$(inherited)", 671 | "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", 672 | ); 673 | FRAMEWORK_VERSION = A; 674 | INFOPLIST_FILE = GraphicsServices/Info.plist; 675 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 676 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 677 | LIBRARY_SEARCH_PATHS = ( 678 | "$(inherited)", 679 | "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks/SkyLight.framework/Versions/A", 680 | ); 681 | PRODUCT_BUNDLE_IDENTIFIER = com.CodaFi.GraphicsServices; 682 | PRODUCT_NAME = "$(TARGET_NAME)"; 683 | SKIP_INSTALL = YES; 684 | }; 685 | name = Release; 686 | }; 687 | /* End XCBuildConfiguration section */ 688 | 689 | /* Begin XCConfigurationList section */ 690 | 4838E6061F95DD4800FF7321 /* Build configuration list for PBXNativeTarget "GSExample" */ = { 691 | isa = XCConfigurationList; 692 | buildConfigurations = ( 693 | 4838E6071F95DD4800FF7321 /* Debug */, 694 | 4838E6081F95DD4800FF7321 /* Release */, 695 | ); 696 | defaultConfigurationIsVisible = 0; 697 | defaultConfigurationName = Release; 698 | }; 699 | 48B55D231F99B9C80023326F /* Build configuration list for PBXNativeTarget "CGSInternal" */ = { 700 | isa = XCConfigurationList; 701 | buildConfigurations = ( 702 | 48B55D211F99B9C80023326F /* Debug */, 703 | 48B55D221F99B9C80023326F /* Release */, 704 | ); 705 | defaultConfigurationIsVisible = 0; 706 | defaultConfigurationName = Release; 707 | }; 708 | 829F15541B6C5FAB00F8E692 /* Build configuration list for PBXProject "DIYWindows" */ = { 709 | isa = XCConfigurationList; 710 | buildConfigurations = ( 711 | 829F15601B6C5FAB00F8E692 /* Debug */, 712 | 829F15611B6C5FAB00F8E692 /* Release */, 713 | ); 714 | defaultConfigurationIsVisible = 0; 715 | defaultConfigurationName = Release; 716 | }; 717 | 829F15621B6C5FAB00F8E692 /* Build configuration list for PBXNativeTarget "GraphicsServices" */ = { 718 | isa = XCConfigurationList; 719 | buildConfigurations = ( 720 | 829F15631B6C5FAB00F8E692 /* Debug */, 721 | 829F15641B6C5FAB00F8E692 /* Release */, 722 | ); 723 | defaultConfigurationIsVisible = 0; 724 | defaultConfigurationName = Release; 725 | }; 726 | /* End XCConfigurationList section */ 727 | }; 728 | rootObject = 829F15511B6C5FAB00F8E692 /* Project object */; 729 | } 730 | -------------------------------------------------------------------------------- /DIYWindows.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GSExample/CAContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface CAContext: NSObject 4 | 5 | @property BOOL colorMatchUntaggedContent; 6 | @property struct CGColorSpace *colorSpace; 7 | @property(copy) NSString *contentsFormat; 8 | @property(readonly) NSUInteger contextId; 9 | @property NSUInteger displayMask; 10 | @property NSUInteger displayNumber; 11 | @property NSUInteger eventMask; 12 | @property(retain) CALayer *layer; 13 | @property(readonly) NSDictionary *options; 14 | @property int restrictedHostProcessId; 15 | @property(readonly) BOOL valid; 16 | 17 | + (id)objectForSlot:(NSUInteger)arg1; 18 | + (BOOL)allowsCGSConnections; 19 | + (void)setAllowsCGSConnections:(BOOL)arg1; 20 | + (id)contextWithCGSConnection:(NSUInteger)arg1 options:(id)arg2; 21 | + (void)setClientPort:(NSUInteger)arg1; 22 | + (id)remoteContextWithOptions:(id)arg1; 23 | + (id)remoteContext; 24 | + (id)localContextWithOptions:(id)arg1; 25 | + (id)localContext; 26 | + (id)currentContext; 27 | + (id)allContexts; 28 | 29 | - (void)setObject:(id)arg1 forSlot:(NSUInteger)arg2; 30 | - (void)deleteSlot:(NSUInteger)arg1; 31 | - (NSUInteger)createSlot; 32 | - (void)invalidateFences; 33 | - (void)setFence:(NSUInteger)arg1 count:(NSUInteger)arg2; 34 | - (void)setFencePort:(NSUInteger)arg1 commitHandler:(id)arg2; 35 | - (void)setFencePort:(NSUInteger)arg1; 36 | - (NSUInteger)createFencePort; 37 | - (void)invalidate; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /GSExample/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | 6 | #import "CAContext.h" 7 | 8 | // We need to locally declare this since GraphicsServices and CGSInternal don't. 9 | extern CGEventRef CGEventCreateNextEvent(CGSConnectionID); 10 | 11 | // Initialize the app and grab our main CGSConnection. 12 | static CGSConnectionID cid = 0; 13 | static CGWindowID wid = 0; 14 | 15 | int main(int argc, const char *argv[]) { 16 | cid = CGSMainConnectionID(); 17 | GSInitialize(); 18 | GSAppInitialize(); 19 | 20 | // Register a default event callback to handle anything for our CGSWindow. 21 | GSAppRegisterEventCallBack(^(GSEventRef eventRef) { 22 | CGEventRef event = GSEventGetCGEvent(eventRef); 23 | CGEventType type = CGEventGetType(event); 24 | 25 | // If the event type does not match or it's for the wrong window, bail. 26 | if (type != NX_KEYDOWN && type != NX_OMOUSEDOWN && type != NX_OMOUSEUP && type != NX_OMOUSEDRAGGED && 27 | type != NX_LMOUSEUP && type != NX_LMOUSEDOWN && type != NX_RMOUSEUP && type != NX_RMOUSEDOWN && 28 | type != NX_MOUSEMOVED && type != NX_LMOUSEDRAGGED && type != NX_RMOUSEDRAGGED) 29 | return; 30 | int64_t d = CGEventGetIntegerValueField(event, kCGMouseEventWindowUnderMousePointer); 31 | if (d != wid) return; 32 | 33 | // If the window was dragged, match the drag to an on-screen move. 34 | if (type == NX_LMOUSEDRAGGED) { 35 | CGRect rect = CGRectMake(0, 0, 0, 0); 36 | CGSGetScreenRectForWindow(cid, wid, &rect); 37 | rect.origin.x += CGEventGetIntegerValueField(event, kCGMouseEventDeltaX); 38 | rect.origin.y += CGEventGetIntegerValueField(event, kCGMouseEventDeltaY); 39 | CGSMoveWindow(cid, wid, &rect.origin); 40 | } 41 | 42 | // If the window was right-clicked, order it out (close it). 43 | if (type == NX_RMOUSEUP) { 44 | CGSOrderWindow(cid, wid, kCGSOrderOut, 0); 45 | } 46 | 47 | // If the window was left-clicked, order it in (show it). 48 | if (type == NX_LMOUSEUP) { 49 | CGSOrderWindow(cid, wid, kCGSOrderIn, 0); 50 | } 51 | }); 52 | 53 | CGRect outRect = {0, 0, 0, 0}; 54 | CGSGetDisplayBounds(CGMainDisplayID(), &outRect); 55 | CGRect rect = CGRectInset(outRect, outRect.size.width / 3.0, outRect.size.height / 3.0); 56 | 57 | // Create the region (a CGRect, really) first. 58 | //CGRect rect = {0, 0, CGImageGetWidth(backgroundImage), CGImageGetHeight(backgroundImage)}; 59 | CGSRegionRef region = NULL; 60 | CGSNewRegionWithRect(&rect, ®ion); 61 | rect.origin = (CGPoint){ 0, 0 }; // to get bounds 62 | 63 | // Create a CGSWindow to display above everything. 64 | CGSNewWindow(cid, kCGSBackingBuffered, 0, 0, region, &wid); 65 | CGSSetWindowLevel(cid, wid, kCGUtilityWindowLevel); 66 | 67 | // Wrap all CALayer-related activities into CATransactions. 68 | [CATransaction begin]; { 69 | CAContext *ctx; 70 | CALayer *layer; 71 | CGSSurfaceID sid; 72 | //CGContextRef context; 73 | 74 | { // Create the CALayer and its matching CAContext. 75 | ctx = [CAContext contextWithCGSConnection:cid options:nil]; 76 | layer = [[CALayer alloc] init]; 77 | layer.frame = rect; 78 | layer.backgroundColor = CGColorCreateGenericRGB(1, 0, 0, 1); 79 | //layer.contents = (__bridge id)backgroundImage; 80 | ctx.layer = layer; 81 | } 82 | { // Add a CGSSurface to the CGSWindow to host the CALayer. 83 | CGSAddSurface(cid, wid, &sid); 84 | CGSSetSurfaceBounds(cid, wid, sid, rect); 85 | CGSSetSurfaceResolution(cid, wid, sid, 2.0); 86 | CGSSetSurfaceColorSpace(cid, wid, sid, ctx.colorSpace); 87 | } 88 | /*{ // Optional: manually render the layer into the CGSWindow. 89 | CGContextRef context = CGWindowContextCreate(cid, wid, 0); 90 | CGContextClearRect(context, rect); 91 | [layer renderInContext:context]; 92 | CGContextFlush(context); 93 | }*/ 94 | { // Bind and order the CGSSurface onto the CGSWindow. 95 | CGSBindSurface(cid, wid, sid, 0x4, 0x0, (unsigned int)ctx.contextId); 96 | CGSOrderSurface(cid, wid, sid, 0x1, 0x0); 97 | //CGSOrderSurface is incorrect; param 4 is order (like windows), 5 is the relative surface 98 | //CGSFlushSurface(cid, wid, sid, 0); 99 | } 100 | /*{ // Optional: configure opacity of the window and surface. 101 | CGSSetWindowOpacity(cid, wid, false); 102 | CGSSetWindowShadowAndRimParameters(cid, wid, 0.0, 0.0, 0, 0, 0); 103 | CGSSetSurfaceOpacity(cid, wid, sid, false); 104 | layer.opacity = 0.5; 105 | }*/ 106 | [CATransaction begin]; { // Animate something! 107 | CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"backgroundColor"]; 108 | anim.duration = 10.0; 109 | anim.toValue = (__bridge id _Nullable)(CGColorCreateGenericRGB(0, 0, 1, 1)); 110 | [layer addAnimation:anim forKey:nil]; 111 | } [CATransaction commit]; 112 | } [CATransaction commit]; 113 | 114 | // Order the CGSWindow on-screen. 115 | CGSOrderWindow(cid, wid, kCGSOrderIn, 0); 116 | 117 | { // HACK: Set a background event mask so we can listen to CGSConnection events. 118 | 119 | CGEventMask keyboardMask = CGEventMaskBit(kCGEventKeyDown) | CGEventMaskBit(kCGEventKeyUp); 120 | CGEventMask mouseMask = CGEventMaskBit(kCGEventMouseMoved) | CGEventMaskBit(kCGEventLeftMouseDown) | 121 | CGEventMaskBit(kCGEventRightMouseDown) | CGEventMaskBit(kCGEventLeftMouseUp) | 122 | CGEventMaskBit(kCGEventRightMouseUp) | CGEventMaskBit(kCGEventLeftMouseDragged); 123 | 124 | CGEventMask mask = keyboardMask | mouseMask; //0xffffffff; 125 | CGSSetWindowEventMask(cid, wid, mask); 126 | CGSSetBackgroundEventMask(cid, (int)mask); 127 | } 128 | 129 | // Begin the event pump! 130 | GSAppPushRunLoopMode(kGSEventReceiveRunLoopMode); 131 | GSAppRun(); 132 | return 0; 133 | } 134 | -------------------------------------------------------------------------------- /GraphicsServices/CFBase.c: -------------------------------------------------------------------------------- 1 | // 2 | // CFBase.c 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 7/31/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #include "GSPrivate.h" 10 | 11 | const CFStringRef kGSEventReceiveRunLoopMode = CFSTR("GSEventReceiveRunLoopMode"); 12 | 13 | void GSInitialize() { 14 | static bool initOnce; 15 | if (initOnce == false) { 16 | _GSEventClassInitialize(); 17 | initOnce = true; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /GraphicsServices/CGSEventTypes.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSEventTypes.h 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 10/25/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #ifndef GSEVENT_TYPES_H 10 | #define GSEVENT_TYPES_H 11 | 12 | #include "GSEventTypes.def" 13 | 14 | typedef enum { 15 | #define X(EVT, VAL) EVT = VAL, 16 | GS_EVENT_TYPES_TABLE 17 | #undef X 18 | } CGSEventType; 19 | 20 | 21 | #endif /* GSEVENT_TYPES_H */ 22 | -------------------------------------------------------------------------------- /GraphicsServices/GSApp.c: -------------------------------------------------------------------------------- 1 | // 2 | // GSApp.c 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 8/1/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #include "GSApp.h" 10 | #include "GSPrivate.h" 11 | #include 12 | 13 | void GSAppRun() { 14 | GSAppRunModal(false); 15 | } 16 | 17 | void GSAppRegisterEventCallBack(void (^callback)(GSEventRef)) { 18 | ___eventCallBack = callback; 19 | } 20 | 21 | static CFMutableArrayRef ___runLoopModeStack; 22 | static bool ___exitRunModal; 23 | 24 | void GSAppPushRunLoopMode(CFStringRef mode) { 25 | if (___runLoopModeStack == NULL) { 26 | ___runLoopModeStack = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); 27 | } 28 | CFArrayAppendValue(___runLoopModeStack, mode); 29 | CFRunLoopStop(___eventRunLoop); 30 | } 31 | 32 | void GSAppPopRunLoopMode(CFStringRef mode) { 33 | if ((___runLoopModeStack == NULL) || (CFArrayGetCount(___runLoopModeStack) <= 0)) { 34 | CFRunLoopStop(___eventRunLoop); 35 | return; 36 | } 37 | 38 | CFStringRef topLoopMode = CFArrayGetValueAtIndex(___runLoopModeStack, CFArrayGetCount(___runLoopModeStack) - 1); 39 | if ((topLoopMode != NULL) && (CFStringCompare(mode, topLoopMode, 0) == kCFCompareEqualTo)) { 40 | CFArrayRemoveValueAtIndex(___runLoopModeStack, CFArrayGetCount(___runLoopModeStack) - 1); 41 | } 42 | CFRunLoopStop(___eventRunLoop); 43 | } 44 | 45 | void GSAppRunModal(bool disallowsRestarts) { 46 | while (true) { 47 | if (disallowsRestarts == false) { 48 | if ((___runLoopModeStack == NULL) || (CFArrayGetCount(___runLoopModeStack) <= 0)) { 49 | fprintf(stderr, "%s: NULL run loop mode. Exiting loop\n", "GSAppRunModal"); 50 | ___exitRunModal = false; 51 | return; 52 | } 53 | } 54 | 55 | if (___exitRunModal) { 56 | ___exitRunModal = false; 57 | return; 58 | } 59 | 60 | CFStringRef topRunLoopMode = CFArrayGetValueAtIndex(___runLoopModeStack, CFArrayGetCount(___runLoopModeStack) - 1); 61 | if (topRunLoopMode == NULL) { 62 | fprintf(stderr, "%s: NULL run loop mode. Exiting loop\n", "GSAppRunModal"); 63 | ___exitRunModal = false; 64 | return; 65 | } 66 | 67 | CFRunLoopRunInMode(topRunLoopMode, kCFAbsoluteTimeIntervalSince1970, disallowsRestarts); 68 | } 69 | } 70 | 71 | void GSAppStopModal() { 72 | ___exitRunModal = true; 73 | CFRunLoopStop(CFRunLoopGetCurrent()); 74 | } 75 | 76 | static mach_port_t ___applicationPort; 77 | extern CGError CGSGetEventPort(int64_t, mach_port_t *); 78 | extern int64_t CGSMainConnectionID(void); 79 | 80 | void __GSEventInitializeApp(dispatch_queue_t queue) { 81 | static bool _initialized; 82 | 83 | if (_initialized == true) { 84 | return; 85 | } 86 | _initialized = true; 87 | 88 | __GSEventInitializeShared(queue); 89 | 90 | int64_t context = CGSMainConnectionID(); 91 | if (CGSGetEventPort(context, &___applicationPort) != kCGErrorSuccess) { 92 | fprintf(stderr, "Fatal: failed to create main application connection port"); 93 | abort(); 94 | } 95 | 96 | if (queue != NULL) { 97 | mach_port_limits_t qlimits; 98 | qlimits.mpl_qlimit = 0x100; 99 | mach_port_set_attributes(mach_task_self(), ___applicationPort, MACH_PORT_LIMITS_INFO, (mach_port_info_t)&qlimits, MACH_PORT_LIMITS_INFO_COUNT); 100 | _GSAddSourceForEventPort(___applicationPort, queue, context); 101 | } 102 | 103 | if (___eventRunLoop != NULL) { 104 | _GSAddRunLoopSourceForEventPort(___applicationPort, kCFRunLoopCommonModes, context); 105 | _GSAddRunLoopSourceForEventPort(___applicationPort, kGSEventReceiveRunLoopMode, context); 106 | } 107 | // int err = mach_port_insert_right(mach_task_self(), ___applicationPort, ___applicationPort, MACH_MSG_TYPE_MAKE_SEND); 108 | // if (err != KERN_SUCCESS) { 109 | // fprintf(stderr, "mach_port_insert_right() error: %s\n", mach_error_string(err)); 110 | // abort(); 111 | // } 112 | } 113 | 114 | void GSAppInitialize() { 115 | __GSEventInitializeApp(NULL); 116 | } 117 | -------------------------------------------------------------------------------- /GraphicsServices/GSApp.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSApp.h 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 8/1/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #ifndef GSAPP_H 10 | #define GSAPP_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | #pragma mark - Application Initialization 19 | 20 | 21 | /// Initializes the event pump. 22 | CF_EXPORT void GSAppInitialize(void); 23 | 24 | 25 | #pragma mark - Run Loops 26 | 27 | 28 | /// The run loop mode GraphicsServices spins the event loop in. 29 | CF_EXPORT const CFStringRef kGSEventReceiveRunLoopMode; 30 | 31 | /// Spins the runloop in the current mode. 32 | CF_EXPORT void GSAppRun(void); 33 | 34 | /// Pushes a new run loop mode onto the top of the stack. 35 | CF_EXPORT void GSAppPushRunLoopMode(CFStringRef mode); 36 | 37 | /// Pops the topmost run loop mode from the stack. 38 | /// 39 | /// If there are no modes or the last mode has been popped the application will terminate. 40 | CF_EXPORT void GSAppPopRunLoopMode(CFStringRef mode); 41 | 42 | /// Spins the runloop in the topmost mode by initiating a modal session in the previous runloop. 43 | /// 44 | /// If the `disallowsRestarts` flag is set the runloop will not automatically restart once it has 45 | /// stopped. 46 | CF_EXPORT void GSAppRunModal(bool disallowsRestarts); 47 | 48 | /// Stops the topmost runloop and transfers control to the initiator of the modal session. 49 | CF_EXPORT void GSAppStopModal(void); 50 | 51 | 52 | #pragma mark - Callbacks 53 | 54 | 55 | /// Registers a callback with the event pump. 56 | CF_EXPORT void GSAppRegisterEventCallBack(void (^callback)(GSEventRef)); 57 | 58 | 59 | 60 | #endif /* GSAPP_H */ 61 | -------------------------------------------------------------------------------- /GraphicsServices/GSBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSBase.h 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 7/31/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #ifndef GSBASE_H 10 | #define GSBASE_H 11 | 12 | #include 13 | 14 | /// Sets up initial state. 15 | /// 16 | /// This function should be invoked before interacting with any other part of GraphicsServices. 17 | CF_EXPORT void GSInitialize(void); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /GraphicsServices/GSCoreFoundationBridge.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSCoreFoundationBridge.h 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 7/31/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #ifndef GSCOREFOUNDATIONBRIDGE_H 10 | #define GSCOREFOUNDATIONBRIDGE_H 11 | 12 | enum { 13 | _kCFRuntimeNotATypeID = 0 14 | }; 15 | 16 | typedef struct __CFRuntimeBase { 17 | uintptr_t _cfisa; 18 | uint8_t _cfinfo[4]; 19 | #if __LP64__ 20 | uint32_t _rc; 21 | #endif 22 | } CFRuntimeBase; 23 | 24 | typedef struct __CFRuntimeClass { // Version 0 struct 25 | CFIndex version; 26 | const char *className; 27 | void (*init)(CFTypeRef cf); 28 | CFTypeRef (*copy)(CFAllocatorRef allocator, CFTypeRef cf); 29 | #if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED 30 | void (*finalize)(CFTypeRef cf); 31 | #else 32 | void (*dealloc)(CFTypeRef cf); 33 | #endif 34 | Boolean (*equal)(CFTypeRef cf1, CFTypeRef cf2); 35 | CFHashCode (*hash)(CFTypeRef cf); 36 | CFStringRef (*copyFormattingDesc)(CFTypeRef cf, CFDictionaryRef formatOptions); // str with retain 37 | CFStringRef (*copyDebugDesc)(CFTypeRef cf); // str with retain 38 | #if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED 39 | #define CF_RECLAIM_AVAILABLE 1 40 | void (*reclaim)(CFTypeRef cf); 41 | #endif 42 | } CFRuntimeClass; 43 | 44 | CF_EXPORT CFTypeID _CFRuntimeRegisterClass(const CFRuntimeClass * const cls); 45 | CF_EXPORT CFTypeRef _CFRuntimeCreateInstance(CFAllocatorRef allocator, CFTypeID typeID, CFIndex extraBytes, unsigned char *category); 46 | 47 | #endif /* GSCOREFOUNDATIONBRIDGE_H */ 48 | -------------------------------------------------------------------------------- /GraphicsServices/GSEvent.c: -------------------------------------------------------------------------------- 1 | // 2 | // GSEvent.c 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 7/31/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #include "GSEvent.h" 10 | #include "GSCoreFoundationBridge.h" 11 | #include "GSPrivate.h" 12 | 13 | CFTypeRef _GSEventCopy(CFAllocatorRef, CFTypeRef); 14 | CFStringRef _GSEventCopyDescription(CFTypeRef); 15 | Boolean _GSEventEqualToEvent(CFTypeRef, CFTypeRef); 16 | 17 | static CFTypeID kGSEventTypeID = _kCFRuntimeNotATypeID; 18 | 19 | static const CFRuntimeClass _GSEventClass = { 20 | 0, 21 | "GSEventClass", 22 | NULL, // init 23 | _GSEventCopy, // copy 24 | NULL, // dealloc 25 | _GSEventEqualToEvent, // isEqual 26 | NULL, // hash 27 | NULL, // formatting description 28 | _GSEventCopyDescription, // description 29 | }; 30 | 31 | 32 | struct __GSEvent { 33 | CFRuntimeBase _base; // 0x0 34 | CGSEventType type; // 0x10 35 | // 36 | // 37 | // 38 | CGFloat windowLocationX; // 0x28 39 | CGFloat windowLocationY; // 0x30 40 | // 41 | CFAbsoluteTime timestamp; // 0x40 42 | CGWindowID windowID; 43 | CGEventRef cgEvent; 44 | }; 45 | 46 | void _GSEventClassInitialize() { 47 | kGSEventTypeID = _CFRuntimeRegisterClass(&_GSEventClass); 48 | } 49 | 50 | CFTypeRef _GSEventCopy(CFAllocatorRef allocator, CFTypeRef cf) { 51 | GSEventRef copiedEvent = (GSEventRef)_CFRuntimeCreateInstance(NULL, kGSEventTypeID, /*cf->usagePage*/ 0, 0); 52 | if (copiedEvent != NULL) { 53 | memcpy(copiedEvent + sizeof(CFRuntimeBase), cf + sizeof(CFRuntimeBase), sizeof(struct __GSEvent) - sizeof(CFRuntimeBase)); 54 | } 55 | return copiedEvent; 56 | } 57 | 58 | static const char *GSEventTypeTable[] = { 59 | #define X(EVT, VAL, IDX) #EVT, 60 | GS_EVENT_TYPES_TABLE 61 | #undef X 62 | }; 63 | 64 | static const uint32_t GSEventIndexTable[][2] = { 65 | #define X(EVT, VAL, IDX) { VAL, IDX }, 66 | GS_EVENT_TYPES_TABLE 67 | #undef X 68 | }; 69 | 70 | static const char *CGSDescribeType(CGSEventType type) { 71 | for (uint32_t i = 0; i < kCGSEventCount; i++) { 72 | const uint32_t *tpp = GSEventIndexTable[i]; 73 | if (tpp[0] == type) { 74 | return GSEventTypeTable[tpp[1]]; 75 | } 76 | } 77 | return NULL; 78 | } 79 | 80 | CFStringRef _GSEventCopyDescription(CFTypeRef t) { 81 | struct __GSEvent *evt = (struct __GSEvent *)t; 82 | return CFStringCreateWithFormat(CFGetAllocator(t), NULL, CFSTR("{type = %s, windowLoc = (%f, %f)}"), t, CGSDescribeType(evt->type), evt->windowLocationX, evt->windowLocationY); 83 | } 84 | 85 | Boolean _GSEventEqualToEvent(CFTypeRef cf1, CFTypeRef cf2) { 86 | if (cf1 == NULL || cf2 == NULL) { 87 | return false; 88 | } 89 | 90 | struct __GSEvent *evt1 = (struct __GSEvent *)cf1; 91 | struct __GSEvent *evt2 = (struct __GSEvent *)cf2; 92 | return (evt1->type == evt2->type) && (evt1->timestamp == evt2->timestamp) && (evt1->windowID == evt2->windowID); 93 | } 94 | 95 | CFTypeID GSEventGetTypeID() { 96 | return kGSEventTypeID; 97 | } 98 | 99 | GSEventRef GSEventCreateWithCGEvent(CFAllocatorRef allocator, CGEventRef event) { 100 | if (event == NULL) { 101 | return NULL; 102 | } 103 | 104 | CGSEventRecord record; 105 | if (SLEventGetEventRecord(event, &record, sizeof(record)) != kCGErrorSuccess) { 106 | return NULL; 107 | } 108 | 109 | uint32_t size = sizeof(struct __GSEvent) - sizeof(CFRuntimeBase); 110 | GSEventRef memory = (void *)_CFRuntimeCreateInstance(allocator, GSEventGetTypeID(), size, NULL); 111 | if (memory == NULL) { 112 | return NULL; 113 | } 114 | 115 | memory->type = record.type; 116 | memory->cgEvent = (CGEventRef)CFRetain(event); 117 | memory->windowID = record.window; 118 | memory->windowLocationX = record.windowLocation.x; 119 | memory->windowLocationY = record.windowLocation.y; 120 | return memory; 121 | } 122 | 123 | CGSEventType GSEventGetType(GSEventRef ref) { 124 | if (ref == NULL) { 125 | return -1; 126 | } 127 | return ref->type; 128 | } 129 | 130 | CGPoint GSEventGetLocationInWindow(GSEventRef ref) { 131 | if (ref == NULL) { 132 | return CGPointZero; 133 | } 134 | return (CGPoint){ ref->windowLocationX, ref->windowLocationY }; 135 | } 136 | 137 | CFAbsoluteTime GSEventGetTimestamp(GSEventRef ref) { 138 | if (ref == NULL) { 139 | return 0; 140 | } 141 | return ref->timestamp; 142 | } 143 | 144 | CGWindowID GSEventGetWindowID(GSEventRef ref) { 145 | if (ref == NULL) { 146 | return 0; 147 | } 148 | return ref->windowID; 149 | } 150 | 151 | CGEventRef GSEventGetCGEvent(GSEventRef ref) { 152 | if (ref == NULL) { 153 | return 0; 154 | } 155 | return ref->cgEvent; 156 | } 157 | -------------------------------------------------------------------------------- /GraphicsServices/GSEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSEvent.h 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 7/31/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #ifndef GSEVENT_H 10 | #define GSEVENT_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | typedef struct __GSEvent *GSEventRef; 19 | 20 | /// Returns the type identifier for the GSEvent opaque type. 21 | CF_EXPORT CFTypeID GSEventGetTypeID(void); 22 | 23 | /// 24 | CF_EXPORT GSEventRef GSEventCreateWithCGEvent(CFAllocatorRef allocator, CGEventRef event); 25 | 26 | /// Returns the type of the given event. 27 | CF_EXPORT CGSEventType GSEventGetType(GSEventRef); 28 | 29 | /// Returns the location of the given event in the base coordinate system of the associated window. 30 | CF_EXPORT CGPoint GSEventGetLocationInWindow(GSEventRef); 31 | 32 | /// The time when the event occurred in seconds since system startup. 33 | CF_EXPORT CFAbsoluteTime GSEventGetTimestamp(GSEventRef); 34 | 35 | /// The window ID the event was dispatched to. 36 | CF_EXPORT CGWindowID GSEventGetWindowID(GSEventRef); 37 | 38 | /// The underlying CGEvent for this event ref. 39 | CF_EXPORT CGEventRef GSEventGetCGEvent(GSEventRef); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /GraphicsServices/GSEventQueue.c: -------------------------------------------------------------------------------- 1 | // 2 | // GSEventQueue.c 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 8/1/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #include "GSEventQueue.h" 10 | #include 11 | 12 | static pthread_once_t GSThreadLocalContextOnce = PTHREAD_ONCE_INIT; 13 | static pthread_key_t GSThreadLocalContextKey; 14 | 15 | static void GSFreeContextStack(void *queue) { 16 | GSPurpleQueueRef queueref = (GSPurpleQueueRef)queue; 17 | while (!GSEventQueueIsEmpty(queueref)) { 18 | GSEventQueuePopEvent(); 19 | } 20 | free(queueref); 21 | } 22 | 23 | static void GSCreateContextOnceKey() { 24 | pthread_key_create(&GSThreadLocalContextKey, GSFreeContextStack); 25 | } 26 | 27 | GSPurpleQueueRef GSEventQueueGetThreadLocalQueue() { 28 | pthread_once(&GSThreadLocalContextOnce, GSCreateContextOnceKey); 29 | GSPurpleQueueRef contexts = pthread_getspecific(GSThreadLocalContextKey); 30 | if (contexts == NULL) { 31 | GSPurpleQueueRef queue; 32 | 33 | queue = malloc(sizeof(*queue)); 34 | queue->front = queue->back = NULL; 35 | pthread_setspecific(GSThreadLocalContextKey, queue); 36 | 37 | return queue; 38 | } 39 | return contexts; 40 | } 41 | 42 | bool GSEventQueueIsEmpty(GSPurpleQueueRef queue) { 43 | return (queue == NULL) || (queue->front == NULL); 44 | } 45 | 46 | GSEventRef GSEventQueueGetCurrentEvent() { 47 | GSPurpleQueueRef queue = GSEventQueueGetThreadLocalQueue(); 48 | if (queue->front == NULL) { 49 | return NULL; 50 | } 51 | return queue->front->event; 52 | } 53 | 54 | void GSEventQueuePopEvent() { 55 | GSPurpleQueueRef queue = GSEventQueueGetThreadLocalQueue(); 56 | GSPurpleEventPairRef deadNode = queue->front; 57 | 58 | if (queue->front == NULL) { 59 | return; 60 | } 61 | 62 | if (queue->front == queue->back) { 63 | queue->front = queue->back = NULL; 64 | } else { 65 | queue->front = queue->front->next; 66 | } 67 | 68 | if (deadNode->event != NULL) { 69 | CFRelease(deadNode->event); 70 | } 71 | free(deadNode); 72 | } 73 | 74 | void GSEventQueuePushEvent(GSEventRef event) { 75 | GSPurpleQueueRef queue = GSEventQueueGetThreadLocalQueue(); 76 | GSPurpleEventPairRef pair; 77 | 78 | pair = malloc(sizeof(*pair)); 79 | pair->event = (GSEventRef)CFRetain(event); 80 | pair->next = NULL; 81 | 82 | if (queue->front == NULL) { 83 | queue->front = queue->back = pair; 84 | } else { 85 | queue->back->next = pair; 86 | queue->back = pair; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /GraphicsServices/GSEventQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSEventQueue.h 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 8/1/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #ifndef GSEVENTQUEUE_H 10 | #define GSEVENTQUEUE_H 11 | 12 | #include "GSEvent.h" 13 | 14 | typedef struct GSPurpleEventPair { 15 | GSEventRef event; 16 | struct GSPurpleEventPair *next; 17 | } *GSPurpleEventPairRef; 18 | 19 | typedef struct GSPurpleQueue { 20 | GSPurpleEventPairRef front; 21 | GSPurpleEventPairRef back; 22 | } *GSPurpleQueueRef; 23 | 24 | /// Returns the event queue local to the current thread of execution. 25 | CF_EXPORT GSPurpleQueueRef GSEventQueueGetThreadLocalQueue(void); 26 | 27 | /// Returns true iff the given queue is empty, else false. 28 | CF_EXPORT bool GSEventQueueIsEmpty(GSPurpleQueueRef); 29 | 30 | /// Pushes an event to the back of the thread's event queue. 31 | CF_EXPORT void GSEventQueuePushEvent(GSEventRef event); 32 | 33 | /// Pops and deallocates an event from the front of the thread's event queue. 34 | CF_EXPORT void GSEventQueuePopEvent(void); 35 | 36 | /// Peeks at the event at the front of the thread's event queue. 37 | CF_EXPORT GSEventRef GSEventQueueGetCurrentEvent(void); 38 | 39 | #endif /* GSEVENTQUEUE_H */ 40 | -------------------------------------------------------------------------------- /GraphicsServices/GSEventTypes.def: -------------------------------------------------------------------------------- 1 | #define GS_EVENT_TYPES_TABLE \ 2 | X(kCGSDisplayWillReconfigure, 100, 0) \ 3 | X(kCGSDisplayDidReconfigure, 101, 1) \ 4 | X(kCGSDisplayWillSleep, 102, 2) \ 5 | X(kCGSDisplayDidWake, 103, 3) \ 6 | X(kCGSDisplayIsCaptured, 106, 4) \ 7 | X(kCGSDisplayIsReleased, 107, 5) \ 8 | X(kCGSDisplayAllDisplaysReleased, 108, 6) \ 9 | X(kCGSDisplayHardwareChanged, 111, 7) \ 10 | X(kCGSDisplayDidReconfigure2, 115, 8) \ 11 | X(kCGSDisplayFullScreenAppRunning, 116, 9) \ 12 | X(kCGSDisplayFullScreenAppDone, 117, 10) \ 13 | X(kCGSDisplayReconfigureHappened, 118, 11) \ 14 | X(kCGSDisplayColorProfileChanged, 119, 12) \ 15 | X(kCGSDisplayZoomStateChanged, 120, 13) \ 16 | X(kCGSDisplayAcceleratorChanged, 121, 14) \ 17 | X(kCGSDebugOptionsChangedNotification, 200, 15) \ 18 | X(kCGSDebugPrintResourcesNotification, 203, 16) \ 19 | X(kCGSDebugPrintResourcesMemoryNotification, 205, 17) \ 20 | X(kCGSDebugPrintResourcesContextNotification, 206, 18) \ 21 | X(kCGSDebugPrintResourcesImageNotification, 208, 19) \ 22 | X(kCGSServerConnDirtyScreenNotification, 300, 20) \ 23 | X(kCGSServerLoginNotification, 301, 21) \ 24 | X(kCGSServerShutdownNotification, 302, 22) \ 25 | X(kCGSServerUserPreferencesLoadedNotification, 303, 23) \ 26 | X(kCGSServerUpdateDisplayNotification, 304, 24) \ 27 | X(kCGSServerCAContextDidCommitNotification, 305, 25) \ 28 | X(kCGSServerUpdateDisplayCompletedNotification, 306, 26) \ 29 | X(kCPXForegroundProcessSwitched, 400, 27) \ 30 | X(kCPXSpecialKeyPressed, 401, 28) \ 31 | X(kCPXForegroundProcessSwitchRequestedButRedundant, 402, 29) \ 32 | X(kCGSSpecialKeyEventNotification, 700, 30) \ 33 | X(kCGSEventNotificationNullEvent, 710, 31) \ 34 | X(kCGSEventNotificationLeftMouseDown, 711, 32) \ 35 | X(kCGSEventNotificationLeftMouseUp, 712, 33) \ 36 | X(kCGSEventNotificationRightMouseDown, 713, 34) \ 37 | X(kCGSEventNotificationRightMouseUp, 714, 35) \ 38 | X(kCGSEventNotificationMouseMoved, 715, 36) \ 39 | X(kCGSEventNotificationLeftMouseDragged, 716, 37) \ 40 | X(kCGSEventNotificationRightMouseDragged, 717, 38) \ 41 | X(kCGSEventNotificationMouseEntered, 718, 39) \ 42 | X(kCGSEventNotificationMouseExited, 719, 40) \ 43 | X(kCGSEventNotificationKeyDown, 720, 41) \ 44 | X(kCGSEventNotificationKeyUp, 721, 42) \ 45 | X(kCGSEventNotificationFlagsChanged, 722, 43) \ 46 | X(kCGSEventNotificationKitDefined, 723, 44) \ 47 | X(kCGSEventNotificationSystemDefined, 724, 45) \ 48 | X(kCGSEventNotificationApplicationDefined, 725, 46) \ 49 | X(kCGSEventNotificationTimer, 726, 47) \ 50 | X(kCGSEventNotificationCursorUpdate, 727, 48) \ 51 | X(kCGSEventNotificationSuspend, 729, 49) \ 52 | X(kCGSEventNotificationResume, 730, 50) \ 53 | X(kCGSEventNotificationNotification, 731, 51) \ 54 | X(kCGSEventNotificationScrollWheel, 732, 52) \ 55 | X(kCGSEventNotificationTabletPointer, 733, 53) \ 56 | X(kCGSEventNotificationTabletProximity, 734, 54) \ 57 | X(kCGSEventNotificationOtherMouseDown, 735, 55) \ 58 | X(kCGSEventNotificationOtherMouseUp, 736, 56) \ 59 | X(kCGSEventNotificationOtherMouseDragged, 737, 57) \ 60 | X(kCGSEventNotificationZoom, 738, 58) \ 61 | X(kCGSEventNotificationAppIsUnresponsive, 750, 59) \ 62 | X(kCGSEventNotificationAppIsNoLongerUnresponsive, 751, 60) \ 63 | X(kCGSEventSecureTextInputIsActive, 752, 61) \ 64 | X(kCGSEventSecureTextInputIsOff, 753, 62) \ 65 | X(kCGSEventNotificationSymbolicHotKeyChanged, 760, 63) \ 66 | X(kCGSEventNotificationSymbolicHotKeyDisabled, 761, 64) \ 67 | X(kCGSEventNotificationSymbolicHotKeyEnabled, 762, 65) \ 68 | X(kCGSEventNotificationHotKeysGloballyDisabled, 763, 66) \ 69 | X(kCGSEventNotificationHotKeysGloballyEnabled, 764, 67) \ 70 | X(kCGSEventNotificationHotKeysExceptUniversalAccessGloballyDisabled, 765, 68) \ 71 | X(kCGSEventNotificationHotKeysExceptUniversalAccessGloballyEnabled, 766, 69) \ 72 | X(kCGSWindowIsObscured, 800, 70) \ 73 | X(kCGSWindowIsUnobscured, 801, 71) \ 74 | X(kCGSWindowIsOrderedIn, 802, 72) \ 75 | X(kCGSWindowIsOrderedOut, 803, 73) \ 76 | X(kCGSWindowIsTerminated, 804, 74) \ 77 | X(kCGSWindowIsChangingScreens, 805, 75) \ 78 | X(kCGSWindowDidMove, 806, 76) \ 79 | X(kCGSWindowDidResize, 807, 77) \ 80 | X(kCGSWindowDidChangeOrder, 808, 78) \ 81 | X(kCGSWindowGeometryDidChange, 809, 79) \ 82 | X(kCGSWindowMonitorDataPending, 810, 80) \ 83 | X(kCGSWindowDidCreate, 811, 81) \ 84 | X(kCGSWindowRightsGrantOffered, 812, 82) \ 85 | X(kCGSWindowRightsGrantCompleted, 813, 83) \ 86 | X(kCGSWindowRecordForTermination, 814, 84) \ 87 | X(kCGSWindowIsVisible, 815, 85) \ 88 | X(kCGSWindowIsInvisible, 816, 86) \ 89 | X(kCGSLikelyUnbalancedDisableUpdateNotification, 902, 87) \ 90 | X(kCGSConnectionWindowsBecameVisible, 904, 88) \ 91 | X(kCGSConnectionWindowsBecameOccluded, 905, 89) \ 92 | X(kCGSConnectionWindowModificationsStarted, 906, 90) \ 93 | X(kCGSConnectionWindowModificationsStopped, 907, 91) \ 94 | X(kCGSWindowBecameVisible, 912, 92) \ 95 | X(kCGSWindowBecameOccluded, 913, 93) \ 96 | X(kCGSServerWindowDidCreate, 1000, 94) \ 97 | X(kCGSServerWindowWillTerminate, 1001, 95) \ 98 | X(kCGSServerWindowOrderDidChange, 1002, 96) \ 99 | X(kCGSServerWindowDidTerminate, 1003, 97) \ 100 | X(kCGSServerMenuBarCreated, 1300, 98) \ 101 | X(kCGSServerHidBackstopMenuBar, 1301, 99) \ 102 | X(kCGSServerShowBackstopMenuBar, 1302, 100) \ 103 | X(kCGSServerMenuBarDrawingStyleChanged, 1303, 101) \ 104 | X(kCGSServerPersistentAppsRegistered, 1304, 102) \ 105 | X(kCGSServerPersistentCheckinComplete, 1305, 103) \ 106 | X(kCGSPackagesWorkspacesDisabled, 1306, 104) \ 107 | X(kCGSPackagesWorkspacesEnabled, 1307, 105) \ 108 | X(kCGSPackagesStatusBarSpaceChanged, 1308, 106) \ 109 | X(kCGSWorkspaceWillChange, 1400, 107) \ 110 | X(kCGSWorkspaceDidChange, 1401, 108) \ 111 | X(kCGSWorkspaceWindowIsViewable, 1402, 109) \ 112 | X(kCGSWorkspaceWindowIsNotViewable, 1403, 110) \ 113 | X(kCGSWorkspaceWindowDidMove, 1404, 111) \ 114 | X(kCGSWorkspacePrefsDidChange, 1405, 112) \ 115 | X(kCGSWorkspacesWindowDragDidStart, 1411, 113) \ 116 | X(kCGSWorkspacesWindowDragDidEnd, 1412, 114) \ 117 | X(kCGSWorkspacesWindowDragWillEnd, 1413, 115) \ 118 | X(kCGSWorkspacesShowSpaceForProcess, 1414, 116) \ 119 | X(kCGSWorkspacesWindowDidOrderInOnNonCurrentManagedSpacesOnly, 1415, 117) \ 120 | X(kCGSWorkspacesWindowDidOrderOutOnNonCurrentManagedSpaces, 1416, 118) \ 121 | X(kCGSessionConsoleConnect, 1500, 119) \ 122 | X(kCGSessionConsoleDisconnect, 1501, 120) \ 123 | X(kCGSessionRemoteConnect, 1502, 121) \ 124 | X(kCGSessionRemoteDisconnect, 1503, 122) \ 125 | X(kCGSessionLoggedOn, 1504, 123) \ 126 | X(kCGSessionLoggedOff, 1505, 124) \ 127 | X(kCGSessionConsoleWillDisconnect, 1506, 125) \ 128 | X(kCGXWillCreateSession, 1550, 126) \ 129 | X(kCGXDidCreateSession, 1551, 127) \ 130 | X(kCGXWillDestroySession, 1552, 128) \ 131 | X(kCGXDidDestroySession, 1553, 129) \ 132 | X(kCGXWorkspaceConnected, 1554, 130) \ 133 | X(kCGXSessionReleased, 1555, 131) \ 134 | X(kCGSTransitionDidFinish, 1700, 132) \ 135 | X(kCGXServerDisplayHardwareWillReset, 1800, 133) \ 136 | X(kCGXServerDesktopShapeChanged, 1801, 134) \ 137 | X(kCGXServerDisplayConfigurationChanged, 1802, 135) \ 138 | X(kCGXServerDisplayAcceleratorOffline, 1803, 136) \ 139 | X(kCGXServerDisplayAcceleratorDeactivate, 1804, 137) \ 140 | X(kCGSEventCount, 138, 138) 141 | -------------------------------------------------------------------------------- /GraphicsServices/GSEventTypes.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSEventTypes.h 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 10/25/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #ifndef GSEVENT_TYPES_H 10 | #define GSEVENT_TYPES_H 11 | 12 | #include "GSEventTypes.def" 13 | 14 | typedef enum { 15 | #define X(EVT, VAL, IDX) EVT = VAL, 16 | GS_EVENT_TYPES_TABLE 17 | #undef X 18 | } CGSEventType; 19 | 20 | #endif /* GSEVENT_TYPES_H */ 21 | -------------------------------------------------------------------------------- /GraphicsServices/GSPrivate.c: -------------------------------------------------------------------------------- 1 | // 2 | // GSPrivate.c 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 7/31/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #include "GSPrivate.h" 10 | #include "GSApp.h" 11 | #include "GSEvent.h" 12 | #include "GSEventQueue.h" 13 | 14 | mach_port_name_t ___lastRecievedPort; 15 | static CFRunLoopSourceRef ___signalRunLoopSource; 16 | CFRunLoopRef ___eventRunLoop; 17 | static dispatch_queue_t ___eventDeliveryQueue; 18 | void (^___eventCallBack)(GSEventRef); 19 | 20 | static void _ReceiveEvent(CFMachPortRef port, void *msg, CFIndex size, void *info); 21 | static void _PurpleEventSignalCallback(void *context); 22 | static void __PurpleEventCallback(GSEventRef event); 23 | 24 | void _GSAddRunLoopSourceForEventPort(mach_port_t p, CFStringRef mode, int64_t contextID) { 25 | CFMachPortContext context = (CFMachPortContext){ 26 | 1, 27 | (void *)contextID, 28 | NULL, 29 | NULL, 30 | NULL, 31 | }; 32 | CFMachPortRef port = CFMachPortCreateWithPort(NULL, p, _ReceiveEvent, &context, NULL); 33 | CFRunLoopSourceRef eventSource = CFMachPortCreateRunLoopSource(NULL, port, -1); 34 | CFRunLoopAddSource(___eventRunLoop, eventSource, mode); 35 | CFRelease(eventSource); 36 | } 37 | 38 | void _GSAddSourceForEventPort(mach_port_t eport, dispatch_queue_t queue, int64_t contextID) { 39 | if (queue != NULL) { 40 | dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, (mach_port_name_t)eport, 0, queue); 41 | dispatch_source_set_event_handler(source, ^{ 42 | mach_port_name_t port = (mach_port_name_t)dispatch_source_get_handle(source); 43 | if (port != 0) { 44 | ___lastRecievedPort = port; 45 | } 46 | _ReceiveEvent(NULL, NULL, 0, NULL); 47 | do { 48 | // __PurpleEventCallback(receivedEvent); 49 | if (GSEventQueueIsEmpty(GSEventQueueGetThreadLocalQueue())) { 50 | break; 51 | } 52 | } while (true); 53 | return; 54 | }); 55 | dispatch_resume(source); 56 | } else { 57 | _GSAddRunLoopSourceForEventPort(eport, kCFRunLoopCommonModes, contextID); 58 | _GSAddRunLoopSourceForEventPort(eport, kGSEventReceiveRunLoopMode, contextID); 59 | } 60 | } 61 | 62 | // Note: be sure to pop off all of the remaining CGEvents in the server queue. 63 | static void _ReceiveEvent(CFMachPortRef port, void *msg, CFIndex size, void *info) { 64 | CGEventRef nextEventRef; 65 | while((nextEventRef = CGEventCreateNextEvent((int64_t)info)) != NULL) { 66 | GSEventRef gsEvent = GSEventCreateWithCGEvent(NULL, nextEventRef); 67 | if (gsEvent == NULL) continue; 68 | 69 | // CALLOUT_TO_CLIENT 70 | __PurpleEventCallback(gsEvent); 71 | } 72 | } 73 | 74 | void __GSEventInitializeShared(dispatch_queue_t callbackQueue) { 75 | if (callbackQueue != NULL) { 76 | ___eventDeliveryQueue = callbackQueue; 77 | dispatch_retain(___eventDeliveryQueue); 78 | } else { 79 | ___eventRunLoop = CFRunLoopGetCurrent(); 80 | CFRetain(___eventRunLoop); 81 | } 82 | if (___eventRunLoop != NULL) { 83 | CFRunLoopSourceContext context = (CFRunLoopSourceContext){ 84 | .perform = _PurpleEventSignalCallback, 85 | }; 86 | ___signalRunLoopSource = CFRunLoopSourceCreate(NULL, -1, &context); 87 | CFRunLoopAddSource(___eventRunLoop, ___signalRunLoopSource, kCFRunLoopCommonModes); 88 | CFRunLoopAddSource(___eventRunLoop, ___signalRunLoopSource, kGSEventReceiveRunLoopMode); 89 | } 90 | } 91 | 92 | static void _PurpleEventSignalCallback(void *context) { 93 | __PurpleEventCallback(NULL); 94 | } 95 | 96 | static void __PurpleEventCallback(GSEventRef event) { 97 | if (event != NULL) { 98 | GSEventQueuePushEvent(event); 99 | } 100 | 101 | 102 | if (___lastRecievedPort != 0) { 103 | // CGEventRef recievedEvent = NULL; 104 | // while ((recievedEvent = CGEventCreateNextEvent()) != NULL) { 105 | // GSEventRef evt = GSEventCreateWithCGEvent(NULL, recievedEvent); 106 | // if (evt != NULL) { 107 | // GSEventQueuePushEvent(evt); 108 | // } 109 | // } 110 | } 111 | 112 | event = GSEventQueueGetCurrentEvent(); 113 | if (event == NULL) { 114 | goto fail; 115 | } 116 | 117 | if (___eventCallBack != NULL) { 118 | ___eventCallBack(event); 119 | } 120 | 121 | CFRelease(event); 122 | 123 | fail: 124 | GSEventQueuePopEvent(); 125 | if (___signalRunLoopSource != NULL) { 126 | CFRunLoopSourceSignal(___signalRunLoopSource); 127 | } 128 | } 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /GraphicsServices/GSPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSPrivate.h 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 7/31/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #ifndef GSPRIVATE_H 10 | #define GSPRIVATE_H 11 | 12 | #include 13 | #include "GSEvent.h" 14 | #include "GSEventQueue.h" 15 | 16 | CF_EXPORT CFRunLoopRef ___eventRunLoop; 17 | CF_EXPORT mach_port_name_t ___lastRecievedPort; 18 | CF_EXPORT void (^___eventCallBack)(GSEventRef); 19 | 20 | CF_EXPORT 21 | void __GSEventInitializeShared(dispatch_queue_t); 22 | 23 | CF_EXPORT 24 | void _GSEventClassInitialize(void); 25 | 26 | CF_EXPORT 27 | void _GSAddRunLoopSourceForEventPort(mach_port_t port, CFStringRef mode, int64_t contextID); 28 | 29 | CF_EXPORT 30 | void _GSAddSourceForEventPort(mach_port_t port, dispatch_queue_t queue, int64_t contextID); 31 | 32 | CF_EXPORT 33 | CGEventRef CGEventCreateNextEvent(int64_t); 34 | 35 | typedef unsigned short CGSEventRecordVersion; 36 | typedef unsigned long long CGSEventRecordTime; /* nanosecond timer */ 37 | typedef unsigned long CGSEventFlag; 38 | typedef unsigned long CGSByteCount; 39 | typedef uint32_t CGSConnectionID; 40 | 41 | typedef struct { 42 | NXEventData eventData; 43 | SInt32 _padding[4]; 44 | } CGSEventRecordData; 45 | 46 | typedef struct _CGSEventRecord { 47 | CGSEventRecordVersion major; /*0x0*/ 48 | CGSEventRecordVersion minor; /*0x2*/ 49 | CGSByteCount length; /*0x4*/ /* Length of complete event record */ 50 | CGSEventType type; /*0x8*/ /* An event type from above */ 51 | CGPoint location; /*0x10*/ /* Base coordinates (global), from upper-left */ 52 | CGPoint windowLocation; /*0x20*/ /* Coordinates relative to window */ 53 | CGSEventRecordTime time; /*0x30*/ /* nanoseconds since startup */ 54 | CGSEventFlag flags; /* key state flags */ 55 | CGWindowID window; /* window number of assigned window */ 56 | CGSConnectionID connection; /* connection the event came from */ 57 | struct __CGEventSourceData { 58 | int source; 59 | unsigned int sourceUID; 60 | unsigned int sourceGID; 61 | unsigned int flags; 62 | unsigned long long userData; 63 | unsigned int sourceState; 64 | unsigned short localEventSuppressionInterval; 65 | unsigned char suppressionIntervalFlags; 66 | unsigned char remoteMouseDragFlags; 67 | unsigned long long serviceID; 68 | } eventSource; 69 | struct _CGEventProcess { 70 | int pid; 71 | unsigned int psnHi; 72 | unsigned int psnLo; 73 | unsigned int targetID; 74 | unsigned int flags; 75 | } eventProcess; 76 | NXEventData eventData; 77 | SInt32 _padding[4]; 78 | void *ioEventData; 79 | unsigned short _field16; 80 | unsigned short _field17; 81 | struct _CGSEventAppendix { 82 | unsigned short windowHeight; 83 | unsigned short mainDisplayHeight; 84 | unsigned short *unicodePayload; 85 | unsigned int eventOwner; 86 | unsigned char passedThrough; 87 | } *appendix; 88 | unsigned int _field18; 89 | bool passedThrough; 90 | CFDataRef data; 91 | } CGSEventRecord; 92 | 93 | /// Gets the event record for a given `CGEventRef`. 94 | /// 95 | /// For Carbon events, use `GetEventPlatformEventRecord`. 96 | CG_EXTERN CGError SLEventGetEventRecord(CGEventRef event, CGSEventRecord *outRecord, size_t recSize); 97 | 98 | #endif /* GSPRIVATE_H */ 99 | -------------------------------------------------------------------------------- /GraphicsServices/GraphicsServices.h: -------------------------------------------------------------------------------- 1 | // 2 | // GraphicsServices.h 3 | // GraphicsServices 4 | // 5 | // Created by Robert Widmann on 7/31/15. 6 | // Copyright © 2015 CodaFi. All rights reserved. 7 | // 8 | 9 | #ifndef GRAPHICS_SERVICES_H 10 | #define GRAPHICS_SERVICES_H 11 | 12 | #include "GSBase.h" 13 | #include "GSApp.h" 14 | #include "GSEvent.h" 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /GraphicsServices/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSHumanReadableCopyright 24 | Copyright © 2015 CodaFi. All rights reserved. 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DIYWindows 2 | Utilizing `CGSInternal` and `GraphicsServices` for macOS (both great projects from @CodaFi), 3 | this is a quick demo as to what is possible - a completely native non-Cocoa window with 4 | a `CALayer`-backing, that supports all typical interaction. Lots must be done if one wishes to 5 | turn this into something like a `UIView`, however. There are a few bugs - see if you can fix them! 6 | --------------------------------------------------------------------------------