diff --git a/runtime/doc/gui_mac.txt b/runtime/doc/gui_mac.txt index 769fca9766..a3d3ea729c 100644 --- a/runtime/doc/gui_mac.txt +++ b/runtime/doc/gui_mac.txt @@ -110,8 +110,9 @@ to your .gvimrc file to revert back to the default Vim tab label. *macvim-options* These are the non-standard options that MacVim supports: - 'antialias' 'fullscreen' 'fuoptions' - 'macmeta' 'toolbariconsize' 'transparency' + 'antialias' 'blurradius' 'fullscreen' + 'fuoptions' 'macmeta' 'toolbariconsize' + 'transparency' *macvim-commands* These are the non-standard commands that MacVim supports: diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 239319e424..0bb4ae61f5 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1169,6 +1169,14 @@ A jump table for the options with a short description can be found at |Q_op|. terminal over a serial port reset this option. Also see |'conskey'|. + *'blurradius'* *'blur'* +'blurradius' 'blur' number (default 0) + global + {not in Vi} + {only in MacVim GUI} + When 'transparency' is in effect, a positive value adds a blur effect + to the window background. + *'bomb'* *'nobomb'* 'bomb' boolean (default off) local to buffer diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index 1482591dd8..74350d051b 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -622,6 +622,7 @@ Short explanation of each option: *option-list* 'balloonexpr' 'bexpr' expression to show in balloon 'binary' 'bin' read/write/edit file in binary mode 'bioskey' 'biosk' MS-DOS: use bios calls for input characters +'blurradius' 'blur' transparency blur of the GUI window (MacVim only) 'bomb' prepend a Byte Order Mark to the file 'breakat' 'brk' characters that may cause a line break 'breakindent' 'bri' wrapped line repeats indent diff --git a/runtime/doc/tags b/runtime/doc/tags index d1f42a7961..91ccf21031 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -89,6 +89,8 @@ $VIMRUNTIME starting.txt /*$VIMRUNTIME* 'bk' options.txt /*'bk'* 'bkc' options.txt /*'bkc'* 'bl' options.txt /*'bl'* +'blur' options.txt /*'blur'* +'blurradius' options.txt /*'blurradius'* 'bomb' options.txt /*'bomb'* 'breakat' options.txt /*'breakat'* 'breakindent' options.txt /*'breakindent'* diff --git a/runtime/optwin.vim b/runtime/optwin.vim index cda6bb3a54..d9f174189c 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -645,6 +645,8 @@ if has("gui") if has("gui_macvim") call append("$", "transparency\ttransparency of the text background as a percent") call append("$", " \tset transparency=" . &transp) + call append("$", "blurradius\tblur effect of the transparent background") + call append("$", " \tset blurradius=" . &blur) call append("$", "fullscreen\tdisplay vim in fullscreen mode") call BinOptionG("fullscreen", &fullscreen) call append("$", "fuoptions\tcontrol how fullscreen mode should behave") diff --git a/src/MacVim/CGSInternal/CGSConnection.h b/src/MacVim/CGSInternal/CGSConnection.h new file mode 100644 index 0000000000..8e30d78c21 --- /dev/null +++ b/src/MacVim/CGSInternal/CGSConnection.h @@ -0,0 +1,90 @@ +/* + * 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 "Compatability.h" + +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/src/MacVim/CGSInternal/CGSRegion.h b/src/MacVim/CGSInternal/CGSRegion.h new file mode 100644 index 0000000000..b275c4da0b --- /dev/null +++ b/src/MacVim/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/src/MacVim/CGSInternal/CGSWindow.h b/src/MacVim/CGSInternal/CGSWindow.h new file mode 100644 index 0000000000..cc72e0b0ff --- /dev/null +++ b/src/MacVim/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/src/MacVim/CGSInternal/Compatability.h b/src/MacVim/CGSInternal/Compatability.h new file mode 100644 index 0000000000..4912d5297a --- /dev/null +++ b/src/MacVim/CGSInternal/Compatability.h @@ -0,0 +1,21 @@ +/* + * Compatability.h + * iTerm + * + * Created by Marc on 10.08.10. + * Copyright 2010 Marc Haisenko. All rights reserved. + * + */ + +#pragma once + +#include + +#ifndef CG_EXTERN_C_BEGIN +#define CG_EXTERN_C_BEGIN +#define CG_EXTERN_C_END +#endif + +#ifndef CG_EXTERN +#define CG_EXTERN +#endif diff --git a/src/MacVim/CGSInternal/README.txt b/src/MacVim/CGSInternal/README.txt new file mode 100644 index 0000000000..34be3e1bab --- /dev/null +++ b/src/MacVim/CGSInternal/README.txt @@ -0,0 +1,4 @@ +These header files were originally taken from the iTerm2 project at +https://github.com/gnachman/iTerm2/tree/dff7c9faec90daa7f1974a57bb43d1c2d383892e/ThirdParty/CGSInternal + +iTerm2 is licensed under the GPL version 2. diff --git a/src/MacVim/MMBackend.h b/src/MacVim/MMBackend.h index ee631237d7..d1de31b424 100644 --- a/src/MacVim/MMBackend.h +++ b/src/MacVim/MMBackend.h @@ -137,6 +137,10 @@ extern NSTimeInterval MMBalloonEvalInternalDelay; - (void)setAntialias:(BOOL)antialias; +#ifdef FEAT_TRANSPARENCY +- (void)setBlurRadius:(int)radius; +#endif + - (void)updateModifiedFlag; - (void)registerServerWithName:(NSString *)name; diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 7a4cded10f..81f0fedf8d 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -1180,6 +1180,18 @@ extern GuiFont gui_mch_retain_font(GuiFont font); [self queueMessage:msgid data:nil]; } +#ifdef FEAT_TRANSPARENCY + +- (void)setBlurRadius:(int)radius +{ + NSMutableData *data = [NSMutableData data]; + [data appendBytes:&radius length:sizeof(int)]; + + [self queueMessage:SetBlurRadiusMsgID data:data]; +} + +#endif + - (void)updateModifiedFlag { int state = [self checkForModifiedBuffers]; diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index 3094e4bccb..324bab7c85 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -876,6 +876,10 @@ static BOOL isUnsafeMessage(int msgid); if (filenames) [[NSDocumentController sharedDocumentController] noteNewRecentFilePaths:filenames]; + } else if (SetBlurRadiusMsgID == msgid) { + const void *bytes = [data bytes]; + int radius = *((int*)bytes); + [windowController setBlurRadius:radius]; // IMPORTANT: When adding a new message, make sure to update // isUnsafeMessage() if necessary! diff --git a/src/MacVim/MMWindow.h b/src/MacVim/MMWindow.h index 385a40ea33..9eb7be1cba 100644 --- a/src/MacVim/MMWindow.h +++ b/src/MacVim/MMWindow.h @@ -28,6 +28,7 @@ - (void)setContentMinSize:(NSSize)size; - (void)setContentMaxSize:(NSSize)size; - (void)setContentSize:(NSSize)size; +- (void)setBlurRadius:(int)radius; - (IBAction)toggleFullScreen:(id)sender; - (IBAction)realToggleFullScreen:(id)sender; diff --git a/src/MacVim/MMWindow.m b/src/MacVim/MMWindow.m index 1440f0a8fd..7dc42cf3b5 100644 --- a/src/MacVim/MMWindow.m +++ b/src/MacVim/MMWindow.m @@ -28,9 +28,39 @@ #import "MMWindow.h" #import "Miscellaneous.h" +#import "CGSInternal/CGSWindow.h" +typedef CGError CGSSetWindowBackgroundBlurRadiusFunction(CGSConnectionID cid, CGSWindowID wid, NSUInteger blur); + +static void *GetFunctionByName(NSString *library, char *func) { + CFBundleRef bundle; + CFURLRef bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef) library, kCFURLPOSIXPathStyle, true); + CFStringRef functionName = CFStringCreateWithCString(kCFAllocatorDefault, func, kCFStringEncodingASCII); + bundle = CFBundleCreate(kCFAllocatorDefault, bundleURL); + void *f = NULL; + if (bundle) { + f = CFBundleGetFunctionPointerForName(bundle, functionName); + CFRelease(bundle); + } + CFRelease(functionName); + CFRelease(bundleURL); + return f; +} + +static CGSSetWindowBackgroundBlurRadiusFunction* GetCGSSetWindowBackgroundBlurRadiusFunction(void) { + static BOOL tried = NO; + static CGSSetWindowBackgroundBlurRadiusFunction *function = NULL; + if (!tried) { + function = GetFunctionByName(@"/System/Library/Frameworks/ApplicationServices.framework", + "CGSSetWindowBackgroundBlurRadius"); + tried = YES; + } + return function; +} + + @implementation MMWindow @@ -125,6 +155,20 @@ [super setContentSize:size]; } +- (void)setBlurRadius:(int)radius +{ + if (radius >= 0) { + CGSConnectionID con = CGSMainConnectionID(); + if (!con) { + return; + } + CGSSetWindowBackgroundBlurRadiusFunction* function = GetCGSSetWindowBackgroundBlurRadiusFunction(); + if (function) { + function(con, [self windowNumber], radius); + } + } +} + - (void)performClose:(id)sender { id wc = [self windowController]; diff --git a/src/MacVim/MMWindowController.h b/src/MacVim/MMWindowController.h index a200c16cdc..8874bb03e5 100644 --- a/src/MacVim/MMWindowController.h +++ b/src/MacVim/MMWindowController.h @@ -46,6 +46,7 @@ NSPoint defaultTopLeft; NSToolbar *toolbar; BOOL resizingDueToMove; + int blurRadius; } - (id)initWithVimController:(MMVimController *)controller; @@ -81,6 +82,7 @@ - (void)adjustLinespace:(int)linespace; - (void)liveResizeWillStart; - (void)liveResizeDidEnd; +- (void)setBlurRadius:(int)radius; - (void)enterFullScreen:(int)fuoptions backgroundColor:(NSColor *)back; - (void)leaveFullScreen; diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index ecb9008e73..2d04397474 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -330,6 +330,8 @@ if (fullScreenEnabled && !fullScreenWindow) [decoratedWindow setAlphaValue:0]; + [decoratedWindow setBlurRadius:blurRadius]; + // Flag that the window is now placed on screen. From now on it is OK for // code to depend on the screen state. (Such as constraining views etc.) windowPresented = YES; @@ -719,6 +721,14 @@ } } +- (void)setBlurRadius:(int)radius +{ + blurRadius = radius; + if (windowPresented) { + [decoratedWindow setBlurRadius:radius]; + } +} + - (void)enterFullScreen:(int)fuoptions backgroundColor:(NSColor *)back { if (fullScreenEnabled) return; diff --git a/src/MacVim/MacVim.h b/src/MacVim/MacVim.h index 6531534e0c..6d1135081b 100644 --- a/src/MacVim/MacVim.h +++ b/src/MacVim/MacVim.h @@ -208,6 +208,7 @@ enum { GestureMsgID, AddToMRUMsgID, BackingPropertiesChangedMsgID, + SetBlurRadiusMsgID, LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM! }; diff --git a/src/MacVim/MacVim.m b/src/MacVim/MacVim.m index f1311f4262..3b6b4e0428 100644 --- a/src/MacVim/MacVim.m +++ b/src/MacVim/MacVim.m @@ -100,6 +100,7 @@ char *MessageStrings[] = "GestureMsgID", "AddToMRUMsgID", "BackingPropertiesChangedMsgID", + "SetBlurRadiusMsgID", "END OF MESSAGE IDs" // NOTE: Must be last! }; diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index dc62e2eecf..0ad8492d2f 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -2359,3 +2359,13 @@ gui_mch_post_balloon(beval, mesg) } #endif // FEAT_BEVAL + +#ifdef FEAT_TRANSPARENCY + + void +gui_macvim_set_blur(int radius) +{ + [[MMBackend sharedInstance] setBlurRadius:radius]; +} + +#endif // FEAT_TRANSPARENCY diff --git a/src/option.c b/src/option.c index c69daf65ea..cc19e67519 100644 --- a/src/option.c +++ b/src/option.c @@ -646,6 +646,13 @@ static struct vimoption (char_u *)NULL, PV_NONE, #endif {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, + {"blurradius", "blur", P_NUM|P_VIM, +#ifdef FEAT_TRANSPARENCY + (char_u *)&p_blur, PV_NONE, +#else + (char_u *)NULL, PV_NONE, +#endif + {(char_u *)0L, (char_u *)0L} }, {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, #ifdef FEAT_MBYTE (char_u *)&p_bomb, PV_BOMB, @@ -8706,6 +8713,19 @@ set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags) else if (gui.in_use) gui_mch_new_colors(); } + + else if (pp == &p_blur) + { + if (p_blur < 0) + { + errmsg = e_invarg; + p_blur = old_value; + } + else + { + gui_macvim_set_blur(p_blur); + } + } #endif else if (pp == &curbuf->b_p_tw) diff --git a/src/option.h b/src/option.h index 85e8dc38b6..838cdce016 100644 --- a/src/option.h +++ b/src/option.h @@ -811,6 +811,7 @@ EXTERN char_u *p_tsr; /* 'thesaurus' */ #endif #ifdef FEAT_TRANSPARENCY EXTERN long p_transp; /* 'transparency' */ +EXTERN long p_blur; /* 'blurradius' */ #endif EXTERN int p_ttimeout; /* 'ttimeout' */ EXTERN long p_ttm; /* 'ttimeoutlen' */ diff --git a/src/proto/gui_macvim.pro b/src/proto/gui_macvim.pro index 427205d76f..6443a62f35 100644 --- a/src/proto/gui_macvim.pro +++ b/src/proto/gui_macvim.pro @@ -208,6 +208,10 @@ void gui_macvim_update_modified_flag(); void gui_macvim_add_to_find_pboard(char_u *pat); void gui_macvim_set_antialias(int antialias); +#ifdef FEAT_TRANSPARENCY +void gui_macvim_set_blur(int blur); +#endif + int16_t odb_buffer_close(buf_T *buf); int16_t odb_post_buffer_write(buf_T *buf); void odb_end(void);