From: Joseph Spiros Date: Wed, 13 May 2009 05:11:00 +0000 (-0400) Subject: First Revision (from Archive) X-Git-Url: http://git.ithinksw.org/~jspiros/WindowBlur.git/commitdiff_plain/eda6452792ea372d3a6ef6e876845c55f41fbd93 First Revision (from Archive) --- eda6452792ea372d3a6ef6e876845c55f41fbd93 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ab810ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.pbxuser +*.mode1v3 +.DS_Store diff --git a/CGSInternal/CGSAccessibility.h b/CGSInternal/CGSAccessibility.h new file mode 100644 index 0000000..cd3dde4 --- /dev/null +++ b/CGSInternal/CGSAccessibility.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSConnection.h" + +CG_EXTERN_C_BEGIN + +/*! Gets whether the display is zoomed. I'm not sure why there's two calls that appear to do the same thing - I think CGSIsZoomed calls through to CGSDisplayIsZoomed. */ +CG_EXTERN bool CGSDisplayIsZoomed(void); +CG_EXTERN CGError CGSIsZoomed(CGSConnectionID cid, bool *outIsZoomed); + +/*! Gets and sets the cursor scale. The largest the Universal Access prefpane allows you to go is 4.0. */ +CG_EXTERN CGError CGSGetCursorScale(CGSConnectionID cid, float *outScale); +CG_EXTERN CGError CGSSetCursorScale(CGSConnectionID cid, float scale); + +/*! Gets and sets the state of screen inversion. */ +CG_EXTERN bool CGDisplayUsesInvertedPolarity(void); +CG_EXTERN void CGDisplaySetInvertedPolarity(bool invertedPolarity); + +/*! Gets and sets whether the screen is grayscale. */ +CG_EXTERN bool CGDisplayUsesForceToGray(void); +CG_EXTERN void CGDisplayForceToGray(bool forceToGray); + +/*! Sets the display's contrast. There doesn't seem to be a get version of this function. */ +CG_EXTERN CGError CGSSetDisplayContrast(float contrast); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSCIFilter.h b/CGSInternal/CGSCIFilter.h new file mode 100644 index 0000000..7a646a0 --- /dev/null +++ b/CGSInternal/CGSCIFilter.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSConnection.h" +#include "CGSWindow.h" + +typedef int CGSCIFilterID; + +/*! Creates a new CGSCIFilter from a filter name. These names are the same as you'd usually use for CIFilters. */ +CG_EXTERN CGError CGSNewCIFilterByName(CGSConnectionID cid, CFStringRef filterName, CGSCIFilterID *outFilter); + +/*! Adds or removes a CIFilter to a window. Flags are currently unknown (the Dock uses 0x3001). + Note: This stuff is VERY crashy under 10.4.10 - make sure to remove the filter before minimizing the window or closing it. */ +CG_EXTERN CGError CGSAddWindowFilter(CGSConnectionID cid, CGSWindowID wid, CGSCIFilterID filter, int flags); +CG_EXTERN CGError CGSRemoveWindowFilter(CGSConnectionID cid, CGSWindowID wid, CGSCIFilterID filter); + +enum { + kCGWindowFilterUnderlay = 1, + kCGWindowFilterDock = 0x3001, +}; + +/*! Loads a set of values into the CIFilter. */ +CG_EXTERN CGError CGSSetCIFilterValuesFromDictionary(CGSConnectionID cid, CGSCIFilterID filter, CFDictionaryRef filterValues); + +/*! Releases a CIFilter. */ +CG_EXTERN CGError CGSReleaseCIFilter(CGSConnectionID cid, CGSCIFilterID filter); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSConnection.h b/CGSInternal/CGSConnection.h new file mode 100644 index 0000000..6cd7812 --- /dev/null +++ b/CGSInternal/CGSConnection.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once + +typedef int CGSConnectionID; +static const CGSConnectionID kCGSNullConnectionID = 0; + + +CG_EXTERN_C_BEGIN + +/*! DOCUMENTATION PENDING - verify this is Leopard only! */ +CG_EXTERN CGError CGSSetLoginwindowConnection(CGSConnectionID cid) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; +CG_EXTERN CGError CGSSetLoginwindowConnectionWithOptions(CGSConnectionID cid, CFDictionaryRef options) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; + +/*! Enables or disables updates on a connection. The WindowServer will forcibly reenable updates after 1 second. */ +CG_EXTERN CGError CGSDisableUpdate(CGSConnectionID cid); +CG_EXTERN CGError CGSReenableUpdate(CGSConnectionID cid); + +/*! Is there a menubar associated with this connection? */ +CG_EXTERN bool CGSMenuBarExists(CGSConnectionID cid); + + + +#pragma mark notifications +/*! Registers or removes a function to get notified when a connection is created. Only gets notified for connections created in the current application. */ +typedef void (*CGSNewConnectionNotificationProc)(CGSConnectionID cid); +CG_EXTERN CGError CGSRegisterForNewConnectionNotification(CGSNewConnectionNotificationProc proc); +CG_EXTERN CGError CGSRemoveNewConnectionNotification(CGSNewConnectionNotificationProc proc); + +/*! Registers or removes a function to get notified when a connection is released. Only gets notified for connections created in the current application. */ +typedef void (*CGSConnectionDeathNotificationProc)(CGSConnectionID cid); +CG_EXTERN CGError CGSRegisterForConnectionDeathNotification(CGSConnectionDeathNotificationProc proc); +CG_EXTERN CGError CGSRemoveConnectionDeathNotification(CGSConnectionDeathNotificationProc proc); + +/*! Creates a new connection to the window server. */ +CG_EXTERN CGError CGSNewConnection(int unused, CGSConnectionID *outConnection); + +/*! Releases a CGSConnection and all CGSWindows owned by it. */ +CG_EXTERN CGError CGSReleaseConnection(CGSConnectionID cid); + +/*! Gets the default connection for this process. `CGSMainConnectionID` is just a more modern name. */ +CG_EXTERN CGSConnectionID _CGSDefaultConnection(void); +CG_EXTERN CGSConnectionID CGSMainConnectionID(void); + +/*! Gets the default connection for the current thread. */ +CG_EXTERN CGSConnectionID CGSDefaultConnectionForThread(void); + +/* Gets the `pid` that owns this CGSConnection. */ +CG_EXTERN CGError CGSConnectionGetPID(CGSConnectionID cid, pid_t *outPID); + +/*! Gets the CGSConnection for the PSN. */ +CG_EXTERN CGError CGSGetConnectionIDForPSN(CGSConnectionID cid, const ProcessSerialNumber *psn, CGSConnectionID *outOwnerCID); + +/*! Gets and sets a connection's property. */ +CG_EXTERN CGError CGSGetConnectionProperty(CGSConnectionID cid, CGSConnectionID targetCID, CFStringRef key, CFTypeRef *outValue); +CG_EXTERN CGError CGSSetConnectionProperty(CGSConnectionID cid, CGSConnectionID targetCID, CFStringRef key, CFTypeRef value); + +/*! Closes ALL connections used by the current application. Essentially, it turns it into a console application. */ +CG_EXTERN CGError CGSShutdownServerConnections(void); + +/*! Only the owner of a window can manipulate it. So, Apple has the concept of a universal owner that owns all windows and can manipulate them all. There can only be one universal owner at a time (the Dock). */ +CG_EXTERN CGError CGSSetUniversalOwner(CGSConnectionID cid); + +/*! Sets a connection to be a universal owner. This call requires `cid` be a universal connection. */ +CG_EXTERN CGError CGSSetOtherUniversalConnection(CGSConnectionID cid, CGSConnectionID otherConnection); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSCursor.h b/CGSInternal/CGSCursor.h new file mode 100644 index 0000000..c28b937 --- /dev/null +++ b/CGSInternal/CGSCursor.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSConnection.h" + +typedef int CGSCursorID; + + +CG_EXTERN_C_BEGIN + +/*! Does the system support hardware cursors? */ +CG_EXTERN CGError CGSSystemSupportsHardwareCursor(CGSConnectionID cid, bool *outSupportsHardwareCursor); + +/*! Does the system support hardware color cursors? */ +CG_EXTERN CGError CGSSystemSupportsColorHardwareCursor(CGSConnectionID cid, bool *outSupportsHardwareCursor); + +/*! Shows the cursor. */ +CG_EXTERN CGError CGSShowCursor(CGSConnectionID cid); + +/*! Hides the cursor. */ +CG_EXTERN CGError CGSHideCursor(CGSConnectionID cid); + +/*! Hides the cursor until the mouse is moved. */ +CG_EXTERN CGError CGSObscureCursor(CGSConnectionID cid); + +/*! Gets the cursor location. */ +CG_EXTERN CGError CGSGetCurrentCursorLocation(CGSConnectionID cid, CGPoint *outPos); + +/*! Gets the name (in reverse DNS form) of a system cursor. */ +CG_EXTERN char *CGSCursorNameForSystemCursor(CGSCursorID cursor); + +/*! Gets the size of the data for the connection's cursor. */ +CG_EXTERN CGError CGSGetCursorDataSize(CGSConnectionID cid, int *outDataSize); + +/*! Gets the data for the connection's cursor. */ +CG_EXTERN CGError CGSGetCursorData(CGSConnectionID cid, void *outData); + +/*! Gets the size of the data for the current cursor. */ +CG_EXTERN CGError CGSGetGlobalCursorDataSize(CGSConnectionID cid, int *outDataSize); + +/*! Gets the data for the current cursor. */ +CG_EXTERN CGError CGSGetGlobalCursorData(CGSConnectionID cid, void *outData, int *outRowBytes, CGRect *outRect, CGRect *outHotSpot, int *outDepth, int *outComponents, int *outBitsPerComponent); + +/*! Gets the size of data for a system-defined cursor. */ +CG_EXTERN CGError CGSGetSystemDefinedCursorDataSize(CGSConnectionID cid, CGSCursorID cursor, int *outDataSize); + +/*! Gets the data for a system-defined cursor. */ +CG_EXTERN CGError CGSGetSystemDefinedCursorData(CGSConnectionID cid, CGSCursorID cursor, void *outData, int *outRowBytes, CGRect *outRect, CGRect *outHotSpot, int *outDepth, int *outComponents, int *outBitsPerComponent); + +/*! Gets the cursor 'seed'. Every time the cursor is updated, the seed changes. */ +CG_EXTERN int CGSCurrentCursorSeed(void); + +/*! Shows or hides the spinning beachball of death. */ +CG_EXTERN CGError CGSForceWaitCursorActive(CGSConnectionID cid, bool showWaitCursor); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSDebug.h b/CGSInternal/CGSDebug.h new file mode 100644 index 0000000..a26f136 --- /dev/null +++ b/CGSInternal/CGSDebug.h @@ -0,0 +1,114 @@ +/* + * Routines for debugging the window server and application drawing. + * + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSConnection.h" + +typedef enum { + /*! Clears all flags. */ + kCGSDebugOptionNone = 0, + + /*! All screen updates are flashed in yellow. Regions under a DisableUpdate are flashed in orange. Regions that are hardware accellerated are painted green. */ + kCGSDebugOptionFlashScreenUpdates = 0x4, + + /*! Colors windows green if they are accellerated, otherwise red. Doesn't cause things to refresh properly - leaves excess rects cluttering the screen. */ + kCGSDebugOptionColorByAccelleration = 0x20, + + /*! Disables shadows on all windows. */ + kCGSDebugOptionNoShadows = 0x4000, + + /*! Setting this disables the pause after a flash when using FlashScreenUpdates or FlashIdenticalUpdates. */ + kCGSDebugOptionNoDelayAfterFlash = 0x20000, + + /*! Flushes the contents to the screen after every drawing operation. */ + kCGSDebugOptionAutoflushDrawing = 0x40000, + + /*! Highlights mouse tracking areas. Doesn't cause things to refresh correctly - leaves excess rectangles cluttering the screen. */ + kCGSDebugOptionShowMouseTrackingAreas = 0x100000, + + /*! Flashes identical updates in red. */ + kCGSDebugOptionFlashIdenticalUpdates = 0x4000000, + + /*! Dumps a list of windows to /tmp/WindowServer.winfo.out. This is what Quartz Debug uses to get the window list. */ + kCGSDebugOptionDumpWindowListToFile = 0x80000001, + + /*! Dumps a list of connections to /tmp/WindowServer.cinfo.out. */ + kCGSDebugOptionDumpConnectionListToFile = 0x80000002, + + /*! Dumps a very verbose debug log of the WindowServer to /tmp/CGLog_WinServer_. */ + kCGSDebugOptionVerboseLogging = 0x80000006, + + /*! Dumps a very verbose debug log of all processes to /tmp/CGLog__. */ + kCGSDebugOptionVerboseLoggingAllApps = 0x80000007, + + /*! Dumps a list of hotkeys to /tmp/WindowServer.keyinfo.out. */ + kCGSDebugOptionDumpHotKeyListToFile = 0x8000000E, + + /*! Dumps information about OpenGL extensions, etc to /tmp/WindowServer.glinfo.out. */ + kCGSDebugOptionDumpOpenGLInfoToFile = 0x80000013, + + /*! Dumps a list of shadows to /tmp/WindowServer.shinfo.out. */ + kCGSDebugOptionDumpShadowListToFile = 0x80000014, + + /*! Leopard: Dumps information about caches to `/tmp/WindowServer.scinfo.out`. */ + kCGSDebugOptionDumpCacheInformationToFile = 0x80000015, + + /*! Leopard: Purges some sort of cache - most likely the same caches dummped with `kCGSDebugOptionDumpCacheInformationToFile`. */ + kCGSDebugOptionPurgeCaches = 0x80000016, + + /*! 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. */ + kCGSDebugOptionDumpWindowListToPlist = 0x80000017, + + /*! Leopard: DOCUMENTATION PENDING */ + kCGSDebugOptionEnableSurfacePurging = 0x8000001B, + + // Leopard: 0x8000001C - invalid + + /*! Leopard: DOCUMENTATION PENDING */ + kCGSDebugOptionDisableSurfacePurging = 0x8000001D, + + /*! Leopard: Dumps information about an application's resource usage to `/tmp/CGResources__`. */ + kCGSDebugOptionDumpResourceUsageToFiles = 0x80000020, + + // Leopard: 0x80000022 - something about QuartzGL? + + // 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`. */ + kCGSDebugOptionSetMagicMirrorModeNormal = 0x80000023, + + /*! Leopard: Disables the magic mirror. It still appears but draws black instead of a reflection. */ + kCGSDebugOptionSetMagicMirrorModeDisabled = 0x80000024, +} CGSDebugOption; + + +CG_EXTERN_C_BEGIN + +/*! Gets and sets the debug options. These options are global and are not reset when your application dies! */ +CG_EXTERN CGError CGSGetDebugOptions(int *outCurrentOptions); +CG_EXTERN CGError CGSSetDebugOptions(int options); + +/*! Queries the server about its performance. This is how Quartz Debug gets the FPS meter, but not the CPU meter (for that it uses host_processor_info). Quartz Debug subtracts 25 so that it is at zero with the minimum FPS. */ +CG_EXTERN CGError CGSGetPerformanceData(CGSConnectionID cid, float *outFPS, float *unk, float *unk2, float *unk3); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSDisplays.h b/CGSInternal/CGSDisplays.h new file mode 100644 index 0000000..3876425 --- /dev/null +++ b/CGSInternal/CGSDisplays.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * Ryan Govostes ryan@alacatia.com + * + */ + +#pragma once + +CG_EXTERN_C_BEGIN + +/*! Begins a new display configuration transacation. */ +CG_EXTERN CGDisplayErr CGSBeginDisplayConfiguration(CGDisplayConfigRef *config); + +/*! Sets the origin of a display relative to the main display. The main display is at (0, 0) and contains the menubar. */ +CG_EXTERN CGDisplayErr CGSConfigureDisplayOrigin(CGDisplayConfigRef config, CGDirectDisplayID display, CGDisplayCoord x, CGDisplayCoord y); + +/*! Applies the configuration changes made in this transaction. */ +CG_EXTERN CGDisplayErr CGSCompleteDisplayConfiguration(CGDisplayConfigRef config); + +/*! Gets the main display. */ +CG_EXTERN CGDirectDisplayID CGSMainDisplayID(void); + +/*! Drops the configuration changes made in this transaction. */ +CG_EXTERN CGDisplayErr CGSCancelDisplayConfiguration(CGDisplayConfigRef config); + +/*! Gets a list of on line displays */ +CG_EXTERN CGDisplayErr CGSGetOnlineDisplayList(CGDisplayCount maxDisplays, CGDirectDisplayID *displays, CGDisplayCount *outDisplayCount); + +/*! Gets a list of active displays */ +CG_EXTERN CGDisplayErr CGSGetActiveDisplayList(CGDisplayCount maxDisplays, CGDirectDisplayID *displays, CGDisplayCount *outDisplayCount); + +/*! Gets the depth of a display. */ +CG_EXTERN CGError CGSGetDisplayDepth(CGDirectDisplayID display, int *outDepth); + +/*! Gets the displays at a point. Note that multiple displays can have the same point - think mirroring. */ +CG_EXTERN CGError CGSGetDisplaysWithPoint(const CGPoint *point, int maxDisplayCount, CGDirectDisplayID *outDisplays, int *outDisplayCount); + +/*! Gets the displays which contain a rect. Note that multiple displays can have the same bounds - think mirroring. */ +CG_EXTERN CGError CGSGetDisplaysWithRect(const CGRect *point, int maxDisplayCount, CGDirectDisplayID *outDisplays, int *outDisplayCount); + +/*! Gets the bounds for the display. Note that multiple displays can have the same bounds - think mirroring. */ +CG_EXTERN CGError CGSGetDisplayRegion(CGDirectDisplayID display, CGSRegionObj *outRegion); +CG_EXTERN CGError CGSGetDisplayBounds(CGDirectDisplayID display, CGRect *outRect); + +/*! Gets the number of bytes per row. */ +CG_EXTERN CGError CGSGetDisplayRowBytes(CGDirectDisplayID display, int *outRowBytes); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSHotKeys.h b/CGSInternal/CGSHotKeys.h new file mode 100644 index 0000000..eb54301 --- /dev/null +++ b/CGSInternal/CGSHotKeys.h @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSConnection.h" + +// A symbolic hotkey is basically a named hotkey which is remembered between application launches. +typedef enum { + // full keyboard access hotkeys + kCGSHotKeyToggleFullKeyboardAccess = 12, + kCGSHotKeyFocusMenubar = 7, + kCGSHotKeyFocusDock = 8, + kCGSHotKeyFocusNextGlobalWindow = 9, + kCGSHotKeyFocusToolbar = 10, + kCGSHotKeyFocusFloatingWindow = 11, + kCGSHotKeyFocusApplicationWindow = 27, + kCGSHotKeyFocusNextControl = 13, + kCGSHotKeyFocusDrawer = 51, + kCGSHotKeyFocusStatusItems = 57, + + // screenshot hotkeys + kCGSHotKeyScreenshot = 28, + kCGSHotKeyScreenshotToClipboard = 29, + kCGSHotKeyScreenshotRegion = 30, + kCGSHotKeyScreenshotRegionToClipboard = 31, + + // universal access + kCGSHotKeyToggleZoom = 15, + kCGSHotKeyZoomOut = 19, + kCGSHotKeyZoomIn = 17, + kCGSHotKeyZoomToggleSmoothing = 23, + kCGSHotKeyIncreaseContrast = 25, + kCGSHotKeyDecreaseContrast = 26, + kCGSHotKeyInvertScreen = 21, + kCGSHotKeyToggleVoiceOver = 59, + + // Dock + kCGSHotKeyToggleDockAutohide = 52, + kCGSHotKeyExposeAllWindows = 32, + kCGSHotKeyExposeAllWindowsSlow = 34, + kCGSHotKeyExposeApplicationWindows = 33, + kCGSHotKeyExposeApplicationWindowsSlow = 35, + kCGSHotKeyExposeDesktop = 36, + kCGSHotKeyExposeDesktopsSlow = 37, + kCGSHotKeyDashboard = 62, + kCGSHotKeyDashboardSlow = 63, + + // spaces (Leopard and later) + kCGSHotKeySpaces = 75, + kCGSHotKeySpacesSlow = 76, + // 77 - fn F7 (disabled) + // 78 - ⇧fn F7 (disabled) + kCGSHotKeySpaceLeft = 79, + kCGSHotKeySpaceLeftSlow = 80, + kCGSHotKeySpaceRight = 81, + kCGSHotKeySpaceRightSlow = 82, + kCGSHotKeySpaceDown = 83, + kCGSHotKeySpaceDownSlow = 84, + kCGSHotKeySpaceUp = 85, + kCGSHotKeySpaceUpSlow = 86, + + // input + kCGSHotKeyToggleCharacterPallette = 50, + kCGSHotKeySelectPreviousInputSource = 60, + kCGSHotKeySelectNextInputSource = 61, + + // Spotlight + kCGSHotKeySpotlightSearchField = 64, + kCGSHotKeySpotlightWindow = 65, + + kCGSHotKeyToggleFrontRow = 73, + kCGSHotKeyLookUpWordInDictionary = 70, + kCGSHotKeyHelp = 98, //AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER + + // displays - not verified + kCGSHotKeyDecreaseDisplayBrightness = 53, + kCGSHotKeyIncreaseDisplayBrightness = 54, +} CGSSymbolicHotKey; + +typedef enum { + kCGSGlobalHotKeyEnable, + kCGSGlobalHotKeyDisable, + kCGSGlobalHotKeyDisableAllButUniversalAccess +} CGSGlobalHotKeyOperatingMode; + + +CG_EXTERN_C_BEGIN + +/*! DOCUMENTATION PENDING */ +CG_EXTERN CGError CGSGetSymbolicHotKeyValue(CGSSymbolicHotKey hotKey, int *unknown, int *outVirtualKeyCode, int *outModifiers); + +/*! Gets and sets whether a symbolic hot key is enabled. */ +CG_EXTERN bool CGSIsSymbolicHotKeyEnabled(CGSSymbolicHotKey hotKey); +CG_EXTERN CGError CGSSetSymbolicHotKeyEnabled(CGSSymbolicHotKey hotKey, bool isEnabled); + +/*! Gets and sets the global hotkey operating mode. This can be used to disable all hotkeys. */ +CG_EXTERN CGError CGSGetGlobalHotKeyOperatingMode(CGSConnectionID cid, CGSGlobalHotKeyOperatingMode *outMode); +CG_EXTERN CGError CGSSetGlobalHotKeyOperatingMode(CGSConnectionID cid, CGSGlobalHotKeyOperatingMode mode); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSInternal.h b/CGSInternal/CGSInternal.h new file mode 100644 index 0000000..dea6cc0 --- /dev/null +++ b/CGSInternal/CGSInternal.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include +#include + +#warning CGSInternal contains PRIVATE FUNCTIONS and should NOT BE USED in shipping applications! + +#ifndef MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER UNAVAILABLE_ATTRIBUTE + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +#include "CarbonHelpers.h" +#include "CGSAccessibility.h" +#include "CGSCIFilter.h" +#include "CGSConnection.h" +#include "CGSCursor.h" +#include "CGSDebug.h" +#include "CGSDisplays.h" +#include "CGSHotKeys.h" +#include "CGSNotifications.h" +#include "CGSMisc.h" +#include "CGSRegion.h" +#include "CGSSession.h" +#include "CGSTransitions.h" +#include "CGSWindow.h" +#include "CGSWorkspace.h" diff --git a/CGSInternal/CGSMisc.h b/CGSInternal/CGSMisc.h new file mode 100644 index 0000000..049669a --- /dev/null +++ b/CGSInternal/CGSMisc.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSInternal.h" + +CG_EXTERN_C_BEGIN + +/*! DOCUMENTATION PENDING */ +CG_EXTERN CGError CGSFetchDirtyScreenRegion(CGSConnectionID cid, CGSRegionObj *outDirtyRegion); + +/*! Is someone watching this screen? Applies to Apple's remote desktop only? */ +CG_EXTERN bool CGSIsScreenWatcherPresent(void); + +/*! Returns `True` if the application has been deemed unresponsive for a certain amount of time. */ +CG_EXTERN bool CGSEventIsAppUnresponsive(CGSConnectionID cid, const ProcessSerialNumber *psn); + +/*! Sets the amount of time it takes for an application to be considered unresponsive. */ +CG_EXTERN CGError CGSEventSetAppIsUnresponsiveNotificationTimeout(CGSConnectionID cid, double time); + +/*! Sets the cursor position. */ +CG_EXTERN CGError CGSWarpCursorPosition(CGSConnectionID cid, float x, float y); + +/*! DOCUMENTATION PENDING */ +CG_EXTERN CGError CGSHideBackstopMenuBar(CGSConnectionID cid); +CG_EXTERN CGError CGSShowBackstopMenuBar(CGSConnectionID cid); + +/*! Determines if this computer is portable. Internally this just checks to see if it has a battery. */ +CG_EXTERN bool CGSIsPortableMachine(void); + +/*! Sets the area taken up by the dock. Requires the caller to be a universal owner. */ +CG_EXTERN CGError CGSSetDockRect(CGSConnectionID cid, float x, float y, float width, float height); + +/*! DOCUMENTATION PENDING - returns false. Perhaps related to the CGSTBE_QDACCEL env variable. */ +CG_EXTERN bool CGSIsClassicBuffered(void); + +#pragma mark errors +/* Logs an error and returns `err`. */ +CG_EXTERN CGError CGSGlobalError(CGError err, const char *msg); + +/* Logs an error and returns `err`. */ +CG_EXTERN CGError CGSGlobalErrorv(CGError err, const char *msg, ...); + +/*! Gets the error message for an error code. */ +CG_EXTERN char *CGSErrorString(CGError error); + +#pragma mark input +/*! Gets and sets the status of secure input. When secure input is enabled, keyloggers, etc are harder to do. */ +CG_EXTERN bool CGSIsSecureEventInputSet(void); +CG_EXTERN CGError CGSSetSecureEventInput(CGSConnectionID cid, bool useSecureInput); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSNotifications.h b/CGSInternal/CGSNotifications.h new file mode 100644 index 0000000..178e77f --- /dev/null +++ b/CGSInternal/CGSNotifications.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSInternal.h" +#include "CGSTransitions.h" + +typedef enum { + kCGSNotificationDebugOptionsChanged = 200, + + kCGSNotificationMouseMoved = 715, + + kCGSNotificationTrackingRegionEntered = 718, + kCGSNotificationTrackingRegionExited = 719, + + // 724 - keyboard preferences changed + + // 729, 730 seem to be process deactivated / activated - but only for this process + // 731 seems to be this process hidden or shown + + kCGSNotificationAppUnresponsive = 750, + kCGSNotificationAppResponsive = 751, + + // 761 - hotkey disabled + // 762 - hotkey enabled (do these two fire twice?) + + // 763 - hotkey begins editing + // 764 - hotkey ends editing + + // 765, 766 seem to be about the hotkey state (all disabled, etc) + + kCGSNotificationWorkspaceChanged = 1401, + + kCGSNotificationTransitionEnded = 1700, +} CGSNotificationType; + +//! The data sent with kCGSNotificationAppUnresponsive and kCGSNotificationAppResponsive. +typedef struct { +#if __BIG_ENDIAN__ + uint16_t majorVersion; + uint16_t minorVersion; +#else + uint16_t minorVersion; + uint16_t majorVersion; +#endif + + //! The length of the entire notification. + uint32_t length; + + CGSConnectionID cid; + pid_t pid; + ProcessSerialNumber psn; +} CGSProcessNotificationData; + +//! The data sent with kCGSNotificationDebugOptionsChanged. +typedef struct { + int newOptions; + int unknown[2]; // these two seem to be zero +} CGSDebugNotificationData; + +//! The data sent with kCGSNotificationTransitionEnded +typedef struct { + CGSTransitionID transition; +} CGSTransitionNotificationData; + + +typedef void (*CGSNotifyProcPtr)(CGSNotificationType type, void *data, unsigned int dataLength, void *userData); + +CG_EXTERN_C_BEGIN + +//! Registers a function to receive notifications. +CG_EXTERN CGError CGSRegisterNotifyProc(CGSNotifyProcPtr proc, CGSNotificationType type, void *userData); + +//! Unregisters a function that was registered to receive notifications. +CG_EXTERN CGError CGSRemoveNotifyProc(CGSNotifyProcPtr proc, CGSNotificationType type, void *userData); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSRegion.h b/CGSInternal/CGSRegion.h new file mode 100644 index 0000000..b275c4d --- /dev/null +++ b/CGSInternal/CGSRegion.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once + +#pragma mark types +#if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED + // on Leopard and up these are CFTypes + typedef CFTypeRef CGSRegionObj; + typedef CFTypeRef CGSRegionEnumeratorObj; +#else + // but opaque types under 10.4 + typedef int CGSRegionObj; + typedef int CGSRegionEnumeratorObj; +#endif + +CG_EXTERN_C_BEGIN + +/*! Creates a region from a `CGRect`. */ +CG_EXTERN CGError CGSNewRegionWithRect(const CGRect *rect, CGSRegionObj *outRegion); + +/*! Creates a region from a list of `CGRect`s. */ +CG_EXTERN CGError CGSNewRegionWithRectList(const CGRect *rects, int rectCount, CGSRegionObj *outRegion); + +/*! Creates a new region from a QuickDraw region. */ +CG_EXTERN CGError CGSNewRegionWithQDRgn(RgnHandle region, CGSRegionObj *outRegion); + +/*! Creates an empty region. */ +CG_EXTERN CGError CGSNewEmptyRegion(CGSRegionObj *outRegion); + +/*! Releases a region. */ +CG_EXTERN CGError CGSReleaseRegion(CGSRegionObj region); + +/*! Creates a `CGRect` from a region. */ +CG_EXTERN CGError CGSGetRegionBounds(CGSRegionObj region, CGRect *outRect); + +/*! Determines if two regions are equal. */ +CG_EXTERN bool CGSRegionsEqual(CGSRegionObj region1, CGSRegionObj region2); + +/* Created a new region by changing the origin an existing one. */ +CG_EXTERN CGError CGSOffsetRegion(CGSRegionObj region, float offsetLeft, float offsetTop, CGSRegionObj *outRegion); + +/*! Creates a new region by copying an existing one. */ +CG_EXTERN CGError CGSCopyRegion(CGSRegionObj region, CGSRegionObj *outRegion); + +/*! Creates a new region by combining two regions together. */ +CG_EXTERN CGError CGSUnionRegion(CGSRegionObj region1, CGSRegionObj region2, CGSRegionObj *outRegion); + +/*! Creates a new region by combining a region and a rect. */ +CG_EXTERN CGError CGSUnionRegionWithRect(CGSRegionObj region, CGRect *rect, CGSRegionObj *outRegion); + +/*! Creates a region by XORing two regions together. */ +CG_EXTERN CGError CGSXorRegion(CGSRegionObj region1, CGSRegionObj region2, CGSRegionObj *outRegion); + +/*! Determines if the region is empty. */ +CG_EXTERN bool CGSRegionIsEmpty(CGSRegionObj region); + +/*! Determines if the region is rectangular. */ +CG_EXTERN bool CGSRegionIsRectangular(CGSRegionObj region); + +/*! Determines if a point in a region. */ +CG_EXTERN bool CGSPointInRegion(CGSRegionObj region, const CGPoint *point); + +/*! Determines if a rect is in a region. */ +CG_EXTERN bool CGSRectInRegion(CGSRegionObj region, const CGRect *rect); + +/*! Determines if a region is inside of a region. */ +CG_EXTERN bool CGSRegionInRegion(CGSRegionObj region1, CGSRegionObj region2); + +/*! Determines if a rect intersects a region. */ +CG_EXTERN bool CGSRegionIntersectsRect(CGSRegionObj obj, const CGRect *rect); + +/*! Determines if a region intersects a region. */ +CG_EXTERN bool CGSRegionIntersectsRegion(CGSRegionObj region1, CGSRegionObj region2); + +/*! Creates a rect from the difference of two regions. */ +CG_EXTERN CGError CGSDiffRegion(CGSRegionObj region1, CGSRegionObj region2, CGSRegionObj *outRegion); + + +#pragma mark region enumerators +/*! Gets the enumerator for a region. */ +CG_EXTERN CGSRegionEnumeratorObj CGSRegionEnumerator(CGSRegionObj region); + +/*! Releases a region enumerator. */ +CG_EXTERN void CGSReleaseRegionEnumerator(CGSRegionEnumeratorObj enumerator); + +/*! Gets the next rect of a region. */ +CG_EXTERN CGRect* CGSNextRect(CGSRegionEnumeratorObj enumerator); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSSession.h b/CGSInternal/CGSSession.h new file mode 100644 index 0000000..75607c7 --- /dev/null +++ b/CGSInternal/CGSSession.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSInternal.h" + +typedef int CGSSessionID; + +CG_EXTERN_C_BEGIN + +/*! Gets information about the current login session. Keys as of 10.4: + kCGSSessionGroupIDKey + kCGSSessionOnConsoleKey + kCGSSessionIDKey + kCGSSessionUserNameKey + kCGSessionLoginDoneKey + kCGSessionLongUserNameKey + kCGSSessionSystemSafeBoot + kCGSSessionLoginwindowSafeLogin + kCGSSessionConsoleSetKey + kCGSSessionUserIDKey + */ +CG_EXTERN CFDictionaryRef CGSCopyCurrentSessionDictionary(void); + +/*! Creates a new "blank" login session. Switches to the LoginWindow. This does NOT check to see if fast user switching is enabled! */ +CG_EXTERN CGError CGSCreateLoginSession(CGSSessionID *outSession); + +/*! Releases a session. */ +CG_EXTERN CGError CGSReleaseSession(CGSSessionID session); + +/*! Gets a list of sessions. Each session dictionary is in the format returned by `CGSCopyCurrentSessionDictionary`. */ +CG_EXTERN CFArrayRef CGSCopySessionList(void); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSTransitions.h b/CGSInternal/CGSTransitions.h new file mode 100644 index 0000000..40f902b --- /dev/null +++ b/CGSInternal/CGSTransitions.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSConnection.h" + +typedef int CGSTransitionID; + +typedef enum { + kCGSTransitionNone, + kCGSTransitionFade, + kCGSTransitionZoom, + kCGSTransitionReveal, + kCGSTransitionSlide, + kCGSTransitionWarpFade, + kCGSTransitionSwap, + kCGSTransitionCube, + kCGSTransitionWarpSwitch, + kCGSTransitionFlip +} CGSTransitionType; + +typedef enum { + /*! Directions for the transition. Some directions don't apply to some transitions. */ + kCGSTransitionDirectionLeft = 1 << 0, + kCGSTransitionDirectionRight = 1 << 1, + kCGSTransitionDirectionDown = 1 << 2, + kCGSTransitionDirectionUp = 1 << 3, + kCGSTransitionDirectionCenter = 1 << 4, + + /*! Reverses a transition. Doesn't apply for all transitions. */ + kCGSTransitionFlagReversed = 1 << 5, + + /*! Ignore the background color and only transition the window. */ + kCGSTransitionFlagTransparent = 1 << 7, +} CGSTransitionFlags; + +typedef struct { + int unknown; // always set to zero + CGSTransitionType type; + CGSTransitionFlags options; + CGSWindowID wid; /* 0 means a full screen transition. */ + float *backColor; /* NULL means black. */ +} CGSTransitionSpec; + +CG_EXTERN_C_BEGIN + +/*! Creates a new transition from a `CGSTransitionSpec`. */ +CG_EXTERN CGError CGSNewTransition(CGSConnectionID cid, const CGSTransitionSpec *spec, CGSTransitionID *outTransition); + +/*! Invokes a transition asynchronously. Note that `duration` is in seconds. */ +CG_EXTERN CGError CGSInvokeTransition(CGSConnectionID cid, CGSTransitionID transition, float duration); + +/*! Releases a transition. */ +CG_EXTERN CGError CGSReleaseTransition(CGSConnectionID cid, CGSTransitionID transition); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSWindow.h b/CGSInternal/CGSWindow.h new file mode 100644 index 0000000..cc72e0b --- /dev/null +++ b/CGSInternal/CGSWindow.h @@ -0,0 +1,196 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSConnection.h" +#include "CGSRegion.h" + +typedef int CGSWindowID; +typedef int CGSAnimationObj; +typedef struct { CGPoint localPoint; CGPoint globalPoint; } CGSWarpPoint; + +typedef enum { + kCGSSharingNone, + kCGSSharingReadOnly, + kCGSSharingReadWrite +} CGSSharingState; + +typedef enum { + kCGSOrderBelow = -1, + kCGSOrderOut, /* hides the window */ + kCGSOrderAbove, + kCGSOrderIn /* shows the window */ +} CGSWindowOrderingMode; + +typedef enum { + kCGSBackingNonRetianed, + kCGSBackingRetained, + kCGSBackingBuffered, +} CGSBackingType; + + +CG_EXTERN_C_BEGIN + +/*! Switches to the next (or previous) window in the global list. */ +CG_EXTERN CGError CGSCycleWindows(CGSConnectionID cid, CGSWindowOrderingMode order); + +/*! Gets and sets the desktop window. Not sure what happens if more than one process sets the desktop window. */ +CG_EXTERN CGError CGSDesktopWindow(CGSConnectionID cid, CGSWindowID *outWID); +CG_EXTERN CGError CGSSetDesktopWindow(CGSConnectionID cid, CGSWindowID wid); + +/*! Sets the window's title. Internally this simply calls `CGSSetWindowProperty(cid, wid, kCGSWindowTitle, title)`. */ +CG_EXTERN CGError CGSSetWindowTitle(CGSConnectionID cid, CGSWindowID wid, CFStringRef title); + +/*! Gets and sets a property for a window. */ +CG_EXTERN CGError CGSGetWindowProperty(CGSConnectionID cid, CGSWindowID wid, CFStringRef key, CFTypeRef *outValue); +CG_EXTERN CGError CGSSetWindowProperty(CGSConnectionID cid, CGSWindowID wid, CFStringRef key, CFTypeRef value); + +/*! Gets and sets the window's transparency. */ +CG_EXTERN CGError CGSGetWindowAlpha(CGSConnectionID cid, CGSWindowID wid, float *outAlpha); +CG_EXTERN CGError CGSSetWindowAlpha(CGSConnectionID cid, CGSWindowID wid, float alpha); + +/*! Sets the alpha of a group of windows over a period of time. Note that `duration` is in seconds. */ +CG_EXTERN CGError CGSSetWindowListAlpha(CGSConnectionID cid, const CGSWindowID *widList, int widCount, float alpha, float duration); + +/*! Gets and sets the `CGConnectionID` that owns this window. Only the owner can change most properties of the window. */ +CG_EXTERN CGError CGSGetWindowOwner(CGSConnectionID cid, CGSWindowID wid, CGSConnectionID *outOwner); +CG_EXTERN CGError CGSSetWindowOwner(CGSConnectionID cid, CGSWindowID wid, CGSConnectionID owner); + +/*! Sets the background color of the window. */ +CG_EXTERN CGError CGSSetWindowAutofillColor(CGSConnectionID cid, CGSWindowID wid, float red, float green, float blue); + +/*! Locks a window to the cursor, so that whenever the cursor moves, the window moves with it. There doesn't seem to be a way to unlock the window from the cursor. */ +CG_EXTERN CGError CGSLockWindowToCursor(CGSConnectionID cid, CGSWindowID wid, float offsetLeft, float offsetTop); + +/*! Sets the warp for the window. The mesh maps a local (window) point to a point on screen. */ +CG_EXTERN CGError CGSSetWindowWarp(CGSConnectionID cid, CGSWindowID wid, int warpWidth, int warpHeight, const CGSWarpPoint *warp); + +/*! Gets or sets whether the window server should auto-fill the window's background. */ +CG_EXTERN CGError CGSGetWindowAutofill(CGSConnectionID cid, CGSWindowID wid, bool *outShouldAutoFill); +CG_EXTERN CGError CGSSetWindowAutofill(CGSConnectionID cid, CGSWindowID wid, bool shouldAutoFill); + +/*! Gets the screen rect for a window. */ +CG_EXTERN CGError CGSGetScreenRectForWindow(CGSConnectionID cid, CGSWindowID wid, CGRect *outRect); + +/*! Gets and sets the window level for a window. */ +CG_EXTERN CGError CGSGetWindowLevel(CGSConnectionID cid, CGSWindowID wid, CGWindowLevel *outLevel); +CG_EXTERN CGError CGSSetWindowLevel(CGSConnectionID cid, CGSWindowID wid, CGWindowLevel level); + +/*! Gets and sets the sharing state. This determines the level of access other applications have over this window. */ +CG_EXTERN CGError CGSGetWindowSharingState(CGSConnectionID cid, CGSWindowID wid, CGSSharingState *outState); +CG_EXTERN CGError CGSSetWindowSharingState(CGSConnectionID cid, CGSWindowID wid, CGSSharingState state); + +/*! Sets whether this window is ignored in the global window cycle (Control-F4 by default). There is no Get version? */ +CG_EXTERN CGError CGSSetIgnoresCycle(CGSConnectionID cid, CGSWindowID wid, bool ignoresCycle); + +/*! Creates a graphics context for the window. */ +CG_EXTERN CGContextRef CGWindowContextCreate(CGSConnectionID cid, CGSWindowID wid, int unknown); + +/*! Sets the order of a window */ +CG_EXTERN CGError CGSOrderWindow(CGSConnectionID cid, CGSWindowID wid, CGSWindowOrderingMode mode, CGSWindowID relativeToWID); + +/*! Sets the origin (top-left) of a window */ +CG_EXTERN CGError CGSMoveWindow(CGSConnectionID cid, CGSWindowID wid, const CGPoint *origin); + +/*! Sets the origin (top-left) of a window relative to another window's origin. */ +CG_EXTERN CGError CGSSetWindowOriginRelativeToWindow(CGSConnectionID cid, CGSWindowID wid, CGSWindowID relativeToWID, float offsetX, float offsetY); + +/* Flushes a window's buffer to the screen. */ +CG_EXTERN CGError CGSFlushWindow(CGSConnectionID cid, CGSWindowID wid, CGSRegionObj flushRegion); + + +#pragma mark shadows +/*! Gets and sets the shadow information for a window. Values for `flags` are unknown. */ +CG_EXTERN CGError CGSSetWindowShadowAndRimParameters(CGSConnectionID cid, CGSWindowID wid, float standardDeviation, float density, int offsetX, int offsetY, int flags); +CG_EXTERN CGError CGSGetWindowShadowAndRimParameters(CGSConnectionID cid, CGSWindowID wid, float *outStandardDeviation, float *outDensity, int *outOffsetX, int *outOffsetY, int *outFlags); + +/*! Sets the shadow information for a window. Simply calls through to `CGSSetWindowShadowAndRimParameters` passing 1 for `flags`. */ +CG_EXTERN CGError CGSSetWindowShadowParameters(CGSConnectionID cid, CGSWindowID wid, float standardDeviation, float density, int offsetX, int offsetY); + +/*! Invalidates a window's shadow. */ +CG_EXTERN CGError CGSInvalidateWindowShadow(CGSConnectionID cid, CGSWindowID wid); + + +#pragma mark window lists +/*! Gets the number of windows the `targetCID` owns. */ +CG_EXTERN CGError CGSGetWindowCount(CGSConnectionID cid, CGSConnectionID targetCID, int *outCount); + +/*! Gets a list of windows owned by `targetCID`. */ +CG_EXTERN CGError CGSGetWindowList(CGSConnectionID cid, CGSConnectionID targetCID, int count, CGSWindowID *list, int *outCount); + +/*! Gets the number of windows owned by `targetCID` that are on screen. */ +CG_EXTERN CGError CGSGetOnScreenWindowCount(CGSConnectionID cid, CGSConnectionID targetCID, int *outCount); + +/*! Gets a list of windows oned by `targetCID` that are on screen. */ +CG_EXTERN CGError CGSGetOnScreenWindowList(CGSConnectionID cid, CGSConnectionID targetCID, int count, CGSWindowID *list, int *outCount); + + +#pragma mark window management +/*! Creates a new CGSWindow. The real window top/left is the sum of the region's top/left and the top/left parameters. */ +CG_EXTERN CGError CGSNewWindow(CGSConnectionID cid, CGSBackingType backingType, float left, float top, CGSRegionObj region, CGSWindowID *outWID); + +/*! Creates a new CGSWindow. The real window top/left is the sum of the region's top/left and the top/left parameters. */ +CG_EXTERN CGError CGSNewWindowWithOpaqueShape(CGSConnectionID cid, CGSBackingType backingType, float left, float top, CGSRegionObj region, CGSRegionObj opaqueShape, int unknown, const int *tags, int tagSize, CGSWindowID *outWID); + +/*! Releases a CGSWindow. */ +CG_EXTERN CGError CGSReleaseWindow(CGSConnectionID cid, CGSWindowID wid); + + +#pragma mark animations +/*! Creates a Dock-style genie animation that goes from `wid` to `destinationWID`. */ +CG_EXTERN CGError CGSCreateGenieWindowAnimation(CGSConnectionID cid, CGSWindowID wid, CGSWindowID destinationWID, CGSAnimationObj *outAnimation); + +/*! 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. */ +CG_EXTERN CGError CGSCreateMetalSheetWindowAnimationWithParent(CGSConnectionID cid, CGSWindowID wid, CGSWindowID parentWID, CGSAnimationObj *outAnimation); + +/*! Sets the progress of an animation. */ +CG_EXTERN CGError CGSSetWindowAnimationProgress(CGSAnimationObj animation, float progress); + +/*! DOCUMENTATION PENDING */ +CG_EXTERN CGError CGSWindowAnimationChangeLevel(CGSAnimationObj animation, CGWindowLevel level); + +/*! DOCUMENTATION PENDING */ +CG_EXTERN CGError CGSWindowAnimationSetParent(CGSAnimationObj animation, CGSWindowID parent) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; + +/*! Releases a window animation. */ +CG_EXTERN CGError CGSReleaseWindowAnimation(CGSAnimationObj animation); + + +#pragma mark window accelleration +/*! Gets the state of accelleration for the window. */ +CG_EXTERN CGError CGSWindowIsAccelerated(CGSConnectionID cid, CGSWindowID wid, bool *outIsAccelerated); + +/*! Gets and sets if this window can be accellerated. I don't know if playing with this is safe. */ +CG_EXTERN CGError CGSWindowCanAccelerate(CGSConnectionID cid, CGSWindowID wid, bool *outCanAccelerate); +CG_EXTERN CGError CGSWindowSetCanAccelerate(CGSConnectionID cid, CGSWindowID wid, bool canAccelerate); + + +#pragma mark system status items +/*! Registers or unregisters a window as a global status item (see `NSStatusItem`, `NSMenuExtra`). Once a window is registered, the window server takes care of placing it in the apropriate location. */ +CG_EXTERN CGError CGSRegisterWindowWithSystemStatusBar(CGSConnectionID cid, CGSWindowID wid, int priority); +CG_EXTERN CGError CGSUnregisterWindowWithSystemStatusBar(CGSConnectionID cid, CGSWindowID wid); + +/*! Rearranges items in the system status bar. You should call this after registering or unregistering a status item or changing the window's width. */ +CG_EXTERN CGError CGSAdjustSystemStatusBarWindows(CGSConnectionID cid); + +CG_EXTERN_C_END diff --git a/CGSInternal/CGSWorkspace.h b/CGSInternal/CGSWorkspace.h new file mode 100644 index 0000000..5872cb4 --- /dev/null +++ b/CGSInternal/CGSWorkspace.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSConnection.h" +#include "CGSWindow.h" +#include "CGSTransitions.h" + +typedef unsigned int CGSWorkspaceID; + +/*! The space id given when we're switching spaces. */ +static const CGSWorkspaceID kCGSTransitioningWorkspaceID = 65538; + + + +CG_EXTERN_C_BEGIN + +/*! Gets and sets the current workspace. */ +CG_EXTERN CGError CGSGetWorkspace(CGSConnectionID cid, CGSWorkspaceID *outWorkspace); +CG_EXTERN CGError CGSSetWorkspace(CGSConnectionID cid, CGSWorkspaceID workspace); + +/*! Transitions to a workspace asynchronously. Note that `duration` is in seconds. */ +CG_EXTERN CGError CGSSetWorkspaceWithTransition(CGSConnectionID cid, CGSWorkspaceID workspace, CGSTransitionType transition, CGSTransitionFlags options, float duration); + +/*! Gets and sets the workspace for a window. */ +CG_EXTERN CGError CGSGetWindowWorkspace(CGSConnectionID cid, CGSWindowID wid, CGSWorkspaceID *outWorkspace); +CG_EXTERN CGError CGSSetWindowWorkspace(CGSConnectionID cid, CGSWindowID wid, CGSWorkspaceID workspace); + +/*! Gets the number of windows in the workspace. */ +CG_EXTERN CGError CGSGetWorkspaceWindowCount(CGSConnectionID cid, int workspaceNumber, int *outCount); +CG_EXTERN CGError CGSGetWorkspaceWindowList(CGSConnectionID cid, int workspaceNumber, int count, CGSWindowID *list, int *outCount); + + +CG_EXTERN_C_END diff --git a/CGSInternal/CarbonHelpers.h b/CGSInternal/CarbonHelpers.h new file mode 100644 index 0000000..a7c796d --- /dev/null +++ b/CGSInternal/CarbonHelpers.h @@ -0,0 +1,40 @@ +/* + * Contains utilities for using Carbon with CGS routines. + * + * Copyright (C) 2007-2008 Alacatia Labs + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Joe Ranieri joe@alacatia.com + * + */ + +#pragma once +#include "CGSWindow.h" + + +CG_EXTERN_C_BEGIN + +/* Gets a CGSWindowID for a WindowRef. Implemented in Carbon.framework. + This call is deprecated in 10.5. Please use the public alternative, `HIWindowGetCGWindowID`. */ +CG_EXTERN CGSWindowID GetNativeWindowFromWindowRef(WindowRef ref) DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER; + +/* Gets a WindowRef (in the current process) from a CGSWindowID. Implemented in Carbon.framework. + This call is deprecated in 10.5. Please use the public alternative, `HIWindowFromCGWindowID`. */ +CG_EXTERN WindowRef GetWindowRefFromNativeWindow(CGSWindowID wid) DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER; + +CG_EXTERN_C_END diff --git a/English.lproj/InfoPlist.strings b/English.lproj/InfoPlist.strings new file mode 100644 index 0000000..5e45963 Binary files /dev/null and b/English.lproj/InfoPlist.strings differ diff --git a/Info.plist b/Info.plist new file mode 100644 index 0000000..b153b46 --- /dev/null +++ b/Info.plist @@ -0,0 +1,37 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleName + ${PRODUCT_NAME} + CFBundleIconFile + + CFBundleIdentifier + com.yourcompany.${PRODUCT_NAME:identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSPrincipalClass + WindowBlurSIMBL + SIMBLTargetApplications + + + BundleIdentifier + com.apple.Terminal + MaxBundleVersion + 240 + MinBundleVersion + 240 + + + + diff --git a/WindowBlur.xcodeproj/TemplateIcon.icns b/WindowBlur.xcodeproj/TemplateIcon.icns new file mode 100644 index 0000000..62cb701 Binary files /dev/null and b/WindowBlur.xcodeproj/TemplateIcon.icns differ diff --git a/WindowBlur.xcodeproj/project.pbxproj b/WindowBlur.xcodeproj/project.pbxproj new file mode 100644 index 0000000..31930cc --- /dev/null +++ b/WindowBlur.xcodeproj/project.pbxproj @@ -0,0 +1,314 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; + 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; + FA22EE5F0FBA6A6D003C3105 /* WindowBlurSIMBL.m in Sources */ = {isa = PBXBuildFile; fileRef = FA22EE5E0FBA6A6D003C3105 /* WindowBlurSIMBL.m */; }; + FA22EE640FBA6C19003C3105 /* WindowBlurWindowHack.m in Sources */ = {isa = PBXBuildFile; fileRef = FA22EE630FBA6C19003C3105 /* WindowBlurWindowHack.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; + 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; + 32DBCF630370AF2F00C91783 /* WindowBlur_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowBlur_Prefix.pch; sourceTree = ""; }; + 8D5B49B6048680CD000E48DA /* WindowBlur.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WindowBlur.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; + 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; + FA22EE5D0FBA6A6D003C3105 /* WindowBlurSIMBL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowBlurSIMBL.h; sourceTree = ""; }; + FA22EE5E0FBA6A6D003C3105 /* WindowBlurSIMBL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WindowBlurSIMBL.m; sourceTree = ""; }; + FA22EE620FBA6C19003C3105 /* WindowBlurWindowHack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowBlurWindowHack.h; sourceTree = ""; }; + FA22EE630FBA6C19003C3105 /* WindowBlurWindowHack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WindowBlurWindowHack.m; sourceTree = ""; }; + FA22EE820FBA737C003C3105 /* CarbonHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CarbonHelpers.h; sourceTree = ""; }; + FA22EE830FBA737C003C3105 /* CGSAccessibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSAccessibility.h; sourceTree = ""; }; + FA22EE840FBA737C003C3105 /* CGSCIFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSCIFilter.h; sourceTree = ""; }; + FA22EE850FBA737C003C3105 /* CGSConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSConnection.h; sourceTree = ""; }; + FA22EE860FBA737C003C3105 /* CGSCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSCursor.h; sourceTree = ""; }; + FA22EE870FBA737C003C3105 /* CGSDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSDebug.h; sourceTree = ""; }; + FA22EE880FBA737C003C3105 /* CGSDisplays.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSDisplays.h; sourceTree = ""; }; + FA22EE890FBA737C003C3105 /* CGSHotKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSHotKeys.h; sourceTree = ""; }; + FA22EE8A0FBA737C003C3105 /* CGSInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSInternal.h; sourceTree = ""; }; + FA22EE8B0FBA737C003C3105 /* CGSMisc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSMisc.h; sourceTree = ""; }; + FA22EE8C0FBA737C003C3105 /* CGSNotifications.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSNotifications.h; sourceTree = ""; }; + FA22EE8D0FBA737C003C3105 /* CGSRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSRegion.h; sourceTree = ""; }; + FA22EE8E0FBA737C003C3105 /* CGSSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSSession.h; sourceTree = ""; }; + FA22EE8F0FBA737C003C3105 /* CGSTransitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSTransitions.h; sourceTree = ""; }; + FA22EE900FBA737C003C3105 /* CGSWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSWindow.h; sourceTree = ""; }; + FA22EE910FBA737C003C3105 /* CGSWorkspace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSWorkspace.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D5B49B3048680CD000E48DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 089C166AFE841209C02AAC07 /* WindowBlur */ = { + isa = PBXGroup; + children = ( + 08FB77AFFE84173DC02AAC07 /* Classes */, + 32C88E010371C26100C91783 /* Other Sources */, + 089C167CFE841241C02AAC07 /* Resources */, + 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, + 19C28FB8FE9D52D311CA2CBB /* Products */, + ); + name = WindowBlur; + sourceTree = ""; + }; + 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, + 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, + ); + name = "Frameworks and Libraries"; + sourceTree = ""; + }; + 089C167CFE841241C02AAC07 /* Resources */ = { + isa = PBXGroup; + children = ( + 8D5B49B7048680CD000E48DA /* Info.plist */, + 089C167DFE841241C02AAC07 /* InfoPlist.strings */, + ); + name = Resources; + sourceTree = ""; + }; + 08FB77AFFE84173DC02AAC07 /* Classes */ = { + isa = PBXGroup; + children = ( + FA22EE5D0FBA6A6D003C3105 /* WindowBlurSIMBL.h */, + FA22EE5E0FBA6A6D003C3105 /* WindowBlurSIMBL.m */, + FA22EE620FBA6C19003C3105 /* WindowBlurWindowHack.h */, + FA22EE630FBA6C19003C3105 /* WindowBlurWindowHack.m */, + ); + name = Classes; + sourceTree = ""; + }; + 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, + ); + name = "Linked Frameworks"; + sourceTree = ""; + }; + 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 089C167FFE841241C02AAC07 /* AppKit.framework */, + D2F7E65807B2D6F200F64583 /* CoreData.framework */, + 089C1672FE841209C02AAC07 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 19C28FB8FE9D52D311CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D5B49B6048680CD000E48DA /* WindowBlur.bundle */, + ); + name = Products; + sourceTree = ""; + }; + 32C88E010371C26100C91783 /* Other Sources */ = { + isa = PBXGroup; + children = ( + FA22EE810FBA737C003C3105 /* CGSInternal */, + 32DBCF630370AF2F00C91783 /* WindowBlur_Prefix.pch */, + ); + name = "Other Sources"; + sourceTree = ""; + }; + FA22EE810FBA737C003C3105 /* CGSInternal */ = { + isa = PBXGroup; + children = ( + FA22EE820FBA737C003C3105 /* CarbonHelpers.h */, + FA22EE830FBA737C003C3105 /* CGSAccessibility.h */, + FA22EE840FBA737C003C3105 /* CGSCIFilter.h */, + FA22EE850FBA737C003C3105 /* CGSConnection.h */, + FA22EE860FBA737C003C3105 /* CGSCursor.h */, + FA22EE870FBA737C003C3105 /* CGSDebug.h */, + FA22EE880FBA737C003C3105 /* CGSDisplays.h */, + FA22EE890FBA737C003C3105 /* CGSHotKeys.h */, + FA22EE8A0FBA737C003C3105 /* CGSInternal.h */, + FA22EE8B0FBA737C003C3105 /* CGSMisc.h */, + FA22EE8C0FBA737C003C3105 /* CGSNotifications.h */, + FA22EE8D0FBA737C003C3105 /* CGSRegion.h */, + FA22EE8E0FBA737C003C3105 /* CGSSession.h */, + FA22EE8F0FBA737C003C3105 /* CGSTransitions.h */, + FA22EE900FBA737C003C3105 /* CGSWindow.h */, + FA22EE910FBA737C003C3105 /* CGSWorkspace.h */, + ); + path = CGSInternal; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8D5B49AC048680CD000E48DA /* WindowBlur */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "WindowBlur" */; + buildPhases = ( + 8D5B49AF048680CD000E48DA /* Resources */, + 8D5B49B1048680CD000E48DA /* Sources */, + 8D5B49B3048680CD000E48DA /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = WindowBlur; + productInstallPath = "$(HOME)/Library/Bundles"; + productName = WindowBlur; + productReference = 8D5B49B6048680CD000E48DA /* WindowBlur.bundle */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 089C1669FE841209C02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "WindowBlur" */; + compatibilityVersion = "Xcode 3.1"; + hasScannedForEncodings = 1; + mainGroup = 089C166AFE841209C02AAC07 /* WindowBlur */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8D5B49AC048680CD000E48DA /* WindowBlur */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D5B49AF048680CD000E48DA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D5B49B1048680CD000E48DA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + FA22EE5F0FBA6A6D003C3105 /* WindowBlurSIMBL.m in Sources */, + FA22EE640FBA6C19003C3105 /* WindowBlurWindowHack.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C167EFE841241C02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 1DEB913B08733D840010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = WindowBlur_Prefix.pch; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Library/Bundles"; + PRODUCT_NAME = WindowBlur; + WRAPPER_EXTENSION = bundle; + }; + name = Debug; + }; + 1DEB913C08733D840010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = WindowBlur_Prefix.pch; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Library/Bundles"; + PRODUCT_NAME = WindowBlur; + WRAPPER_EXTENSION = bundle; + }; + name = Release; + }; + 1DEB913F08733D840010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + SDKROOT = macosx10.5; + }; + name = Debug; + }; + 1DEB914008733D840010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = macosx10.5; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "WindowBlur" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB913B08733D840010E9CD /* Debug */, + 1DEB913C08733D840010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "WindowBlur" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB913F08733D840010E9CD /* Debug */, + 1DEB914008733D840010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 089C1669FE841209C02AAC07 /* Project object */; +} diff --git a/WindowBlurSIMBL.h b/WindowBlurSIMBL.h new file mode 100644 index 0000000..984b057 --- /dev/null +++ b/WindowBlurSIMBL.h @@ -0,0 +1,17 @@ +// +// WindowBlurSIMBL.h +// WindowBlur +// +// Created by Joseph Spiros on 5/12/09. +// Copyright 2009 __MyCompanyName__. All rights reserved. +// + +#import + +void MethodSwizzle(Class aClass, SEL orig_sel, SEL alt_sel); + +@interface WindowBlurSIMBL : NSObject { + +} + +@end \ No newline at end of file diff --git a/WindowBlurSIMBL.m b/WindowBlurSIMBL.m new file mode 100644 index 0000000..49b8bdc --- /dev/null +++ b/WindowBlurSIMBL.m @@ -0,0 +1,43 @@ +// +// WindowBlurSIMBL.m +// WindowBlur +// +// Created by Joseph Spiros on 5/12/09. +// Copyright 2009 __MyCompanyName__. All rights reserved. +// + +#import "WindowBlurSIMBL.h" +#import "WindowBlurWindowHack.h" +#import + +void MethodSwizzle(Class aClass, SEL orig_sel, SEL alt_sel) +{ + Method orig_method = nil, alt_method = nil; + + // First, look for the methods + orig_method = class_getInstanceMethod(aClass, orig_sel); + alt_method = class_getInstanceMethod(aClass, alt_sel); + + // If both are found, swizzle them + if ((orig_method != nil) && (alt_method != nil)) + { + char *temp1; + IMP temp2; + + temp1 = orig_method->method_types; + orig_method->method_types = alt_method->method_types; + alt_method->method_types = temp1; + + temp2 = orig_method->method_imp; + orig_method->method_imp = alt_method->method_imp; + alt_method->method_imp = temp2; + } +} + +@implementation WindowBlurSIMBL + ++ (void)load { + [WindowBlurWindowHack poseAsClass:[NSWindow class]]; +} + +@end diff --git a/WindowBlurWindowHack.h b/WindowBlurWindowHack.h new file mode 100644 index 0000000..a811b44 --- /dev/null +++ b/WindowBlurWindowHack.h @@ -0,0 +1,14 @@ +// +// WindowBlurWindowHack.h +// WindowBlur +// +// Created by Joseph Spiros on 5/12/09. +// Copyright 2009 __MyCompanyName__. All rights reserved. +// + +#import + +@interface WindowBlurWindowHack : NSWindow + + +@end diff --git a/WindowBlurWindowHack.m b/WindowBlurWindowHack.m new file mode 100644 index 0000000..16696a1 --- /dev/null +++ b/WindowBlurWindowHack.m @@ -0,0 +1,84 @@ +// +// WindowBlurWindowHack.m +// WindowBlur +// +// Created by Joseph Spiros on 5/12/09. +// Copyright 2009 __MyCompanyName__. All rights reserved. +// + +#import "WindowBlurSIMBL.h" +#import "WindowBlurWindowHack.h" +#import "CGSInternal.h" + +static NSMutableDictionary *instanceIDToIvars = nil; +static BOOL needToSwizzleDealloc = YES; + +@implementation WindowBlurWindowHack + +- (id)PRE__instanceID +{ + return [NSValue valueWithPointer:self]; +} + +- (NSMutableDictionary *)PRE__ivars +{ + NSMutableDictionary *ivars; + + if (needToSwizzleDealloc) + { + MethodSwizzle([NSWindow class], + @selector(dealloc), + @selector(PRE__deallocSwizzler)); + needToSwizzleDealloc = NO; + } + + if (instanceIDToIvars == nil) + { + instanceIDToIvars = [[NSMutableDictionary alloc] init]; + } + + ivars = [instanceIDToIvars objectForKey:[self PRE__instanceID]]; + if (ivars == nil) + { + ivars = [NSMutableDictionary dictionary]; + [instanceIDToIvars setObject:ivars forKey:[self PRE__instanceID]]; + } + + return ivars; +} + +- (void)PRE__deallocSwizzler +{ + [instanceIDToIvars removeObjectForKey:[self PRE__instanceID]]; + if ([instanceIDToIvars count] == 0) + { + [instanceIDToIvars release]; + instanceIDToIvars = nil; + } + + [self PRE__deallocSwizzler]; +} + +- (void)update { + if ([[[self PRE__ivars] objectForKey:@"blurred"] boolValue] != YES) { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + if (floor(NSAppKitVersionNumber) > 824) { + NSLog(@"AppKit Check Confirmed"); + CGSConnectionID con = CGSMainConnectionID(); + if (con) { + NSLog(@"CGSConnection Confirmed"); + int blurFilter; + if (noErr == CGSNewCIFilterByName(con, (CFStringRef)@"CIGaussianBlur", &blurFilter)) { + NSLog(@"Should work!"); + NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:2.0] forKey:@"inputRadius"]; + CGSSetCIFilterValuesFromDictionary(con, blurFilter, (CFDictionaryRef)optionsDict); + CGSAddWindowFilter(con, [self windowNumber], blurFilter, kCGWindowFilterUnderlay); + [[self PRE__ivars] setObject:[NSNumber numberWithBool:YES] forKey:@"blurred"]; + } + } + } +#endif + } +} + +@end diff --git a/WindowBlur_Prefix.pch b/WindowBlur_Prefix.pch new file mode 100644 index 0000000..c4bc93d --- /dev/null +++ b/WindowBlur_Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'WindowBlur' target in the 'WindowBlur' project. +// + +#ifdef __OBJC__ + #import +#endif