Skip to content

Commit 9e2a543

Browse files
committed
Add optional blur to transparent windows
The actual blur code is taken from the iTerm2 project.
1 parent 51e413b commit 9e2a543

23 files changed

Lines changed: 551 additions & 2 deletions

runtime/doc/gui_mac.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ to your .gvimrc file to revert back to the default Vim tab label.
110110

111111
*macvim-options*
112112
These are the non-standard options that MacVim supports:
113-
'antialias' 'fullscreen' 'fuoptions'
114-
'macmeta' 'toolbariconsize' 'transparency'
113+
'antialias' 'blurradius' 'fullscreen'
114+
'fuoptions' 'macmeta' 'toolbariconsize'
115+
'transparency'
115116

116117
*macvim-commands*
117118
These are the non-standard commands that MacVim supports:

runtime/doc/options.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,14 @@ A jump table for the options with a short description can be found at |Q_op|.
11691169
terminal over a serial port reset this option.
11701170
Also see |'conskey'|.
11711171

1172+
*'blurradius'* *'blur'*
1173+
'blurradius' 'blur' number (default 0)
1174+
global
1175+
{not in Vi}
1176+
{only in MacVim GUI}
1177+
When 'transparency' is in effect, a positive value adds a blur effect
1178+
to the window background.
1179+
11721180
*'bomb'* *'nobomb'*
11731181
'bomb' boolean (default off)
11741182
local to buffer

runtime/doc/quickref.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ Short explanation of each option: *option-list*
622622
'balloonexpr' 'bexpr' expression to show in balloon
623623
'binary' 'bin' read/write/edit file in binary mode
624624
'bioskey' 'biosk' MS-DOS: use bios calls for input characters
625+
'blurradius' 'blur' transparency blur of the GUI window (MacVim only)
625626
'bomb' prepend a Byte Order Mark to the file
626627
'breakat' 'brk' characters that may cause a line break
627628
'breakindent' 'bri' wrapped line repeats indent

runtime/doc/tags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ $VIMRUNTIME starting.txt /*$VIMRUNTIME*
8989
'bk' options.txt /*'bk'*
9090
'bkc' options.txt /*'bkc'*
9191
'bl' options.txt /*'bl'*
92+
'blur' options.txt /*'blur'*
93+
'blurradius' options.txt /*'blurradius'*
9294
'bomb' options.txt /*'bomb'*
9395
'breakat' options.txt /*'breakat'*
9496
'breakindent' options.txt /*'breakindent'*

runtime/optwin.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,8 @@ if has("gui")
645645
if has("gui_macvim")
646646
call append("$", "transparency\ttransparency of the text background as a percent")
647647
call append("$", " \tset transparency=" . &transp)
648+
call append("$", "blurradius\tblur effect of the transparent background")
649+
call append("$", " \tset blurradius=" . &blur)
648650
call append("$", "fullscreen\tdisplay vim in fullscreen mode")
649651
call <SID>BinOptionG("fullscreen", &fullscreen)
650652
call append("$", "fuoptions\tcontrol how fullscreen mode should behave")
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright (C) 2007-2008 Alacatia Labs
3+
*
4+
* This software is provided 'as-is', without any express or implied
5+
* warranty. In no event will the authors be held liable for any damages
6+
* arising from the use of this software.
7+
*
8+
* Permission is granted to anyone to use this software for any purpose,
9+
* including commercial applications, and to alter it and redistribute it
10+
* freely, subject to the following restrictions:
11+
*
12+
* 1. The origin of this software must not be misrepresented; you must not
13+
* claim that you wrote the original software. If you use this software
14+
* in a product, an acknowledgment in the product documentation would be
15+
* appreciated but is not required.
16+
* 2. Altered source versions must be plainly marked as such, and must not be
17+
* misrepresented as being the original software.
18+
* 3. This notice may not be removed or altered from any source distribution.
19+
*
20+
* Joe Ranieri [email protected]
21+
*
22+
*/
23+
24+
#pragma once
25+
26+
#include "Compatability.h"
27+
28+
typedef int CGSConnectionID;
29+
static const CGSConnectionID kCGSNullConnectionID = 0;
30+
31+
32+
CG_EXTERN_C_BEGIN
33+
34+
/*! DOCUMENTATION PENDING - verify this is Leopard only! */
35+
CG_EXTERN CGError CGSSetLoginwindowConnection(CGSConnectionID cid) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
36+
CG_EXTERN CGError CGSSetLoginwindowConnectionWithOptions(CGSConnectionID cid, CFDictionaryRef options) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
37+
38+
/*! Enables or disables updates on a connection. The WindowServer will forcibly reenable updates after 1 second. */
39+
CG_EXTERN CGError CGSDisableUpdate(CGSConnectionID cid);
40+
CG_EXTERN CGError CGSReenableUpdate(CGSConnectionID cid);
41+
42+
/*! Is there a menubar associated with this connection? */
43+
CG_EXTERN bool CGSMenuBarExists(CGSConnectionID cid);
44+
45+
46+
47+
#pragma mark notifications
48+
/*! Registers or removes a function to get notified when a connection is created. Only gets notified for connections created in the current application. */
49+
typedef void (*CGSNewConnectionNotificationProc)(CGSConnectionID cid);
50+
CG_EXTERN CGError CGSRegisterForNewConnectionNotification(CGSNewConnectionNotificationProc proc);
51+
CG_EXTERN CGError CGSRemoveNewConnectionNotification(CGSNewConnectionNotificationProc proc);
52+
53+
/*! Registers or removes a function to get notified when a connection is released. Only gets notified for connections created in the current application. */
54+
typedef void (*CGSConnectionDeathNotificationProc)(CGSConnectionID cid);
55+
CG_EXTERN CGError CGSRegisterForConnectionDeathNotification(CGSConnectionDeathNotificationProc proc);
56+
CG_EXTERN CGError CGSRemoveConnectionDeathNotification(CGSConnectionDeathNotificationProc proc);
57+
58+
/*! Creates a new connection to the window server. */
59+
CG_EXTERN CGError CGSNewConnection(int unused, CGSConnectionID *outConnection);
60+
61+
/*! Releases a CGSConnection and all CGSWindows owned by it. */
62+
CG_EXTERN CGError CGSReleaseConnection(CGSConnectionID cid);
63+
64+
/*! Gets the default connection for this process. `CGSMainConnectionID` is just a more modern name. */
65+
CG_EXTERN CGSConnectionID _CGSDefaultConnection(void);
66+
CG_EXTERN CGSConnectionID CGSMainConnectionID(void);
67+
68+
/*! Gets the default connection for the current thread. */
69+
CG_EXTERN CGSConnectionID CGSDefaultConnectionForThread(void);
70+
71+
/* Gets the `pid` that owns this CGSConnection. */
72+
CG_EXTERN CGError CGSConnectionGetPID(CGSConnectionID cid, pid_t *outPID);
73+
74+
/*! Gets the CGSConnection for the PSN. */
75+
CG_EXTERN CGError CGSGetConnectionIDForPSN(CGSConnectionID cid, const ProcessSerialNumber *psn, CGSConnectionID *outOwnerCID);
76+
77+
/*! Gets and sets a connection's property. */
78+
CG_EXTERN CGError CGSGetConnectionProperty(CGSConnectionID cid, CGSConnectionID targetCID, CFStringRef key, CFTypeRef *outValue);
79+
CG_EXTERN CGError CGSSetConnectionProperty(CGSConnectionID cid, CGSConnectionID targetCID, CFStringRef key, CFTypeRef value);
80+
81+
/*! Closes ALL connections used by the current application. Essentially, it turns it into a console application. */
82+
CG_EXTERN CGError CGSShutdownServerConnections(void);
83+
84+
/*! 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). */
85+
CG_EXTERN CGError CGSSetUniversalOwner(CGSConnectionID cid);
86+
87+
/*! Sets a connection to be a universal owner. This call requires `cid` be a universal connection. */
88+
CG_EXTERN CGError CGSSetOtherUniversalConnection(CGSConnectionID cid, CGSConnectionID otherConnection);
89+
90+
CG_EXTERN_C_END

src/MacVim/CGSInternal/CGSRegion.h

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* Copyright (C) 2007-2008 Alacatia Labs
3+
*
4+
* This software is provided 'as-is', without any express or implied
5+
* warranty. In no event will the authors be held liable for any damages
6+
* arising from the use of this software.
7+
*
8+
* Permission is granted to anyone to use this software for any purpose,
9+
* including commercial applications, and to alter it and redistribute it
10+
* freely, subject to the following restrictions:
11+
*
12+
* 1. The origin of this software must not be misrepresented; you must not
13+
* claim that you wrote the original software. If you use this software
14+
* in a product, an acknowledgment in the product documentation would be
15+
* appreciated but is not required.
16+
* 2. Altered source versions must be plainly marked as such, and must not be
17+
* misrepresented as being the original software.
18+
* 3. This notice may not be removed or altered from any source distribution.
19+
*
20+
* Joe Ranieri [email protected]
21+
*
22+
*/
23+
24+
#pragma once
25+
26+
#pragma mark types
27+
#if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED
28+
// on Leopard and up these are CFTypes
29+
typedef CFTypeRef CGSRegionObj;
30+
typedef CFTypeRef CGSRegionEnumeratorObj;
31+
#else
32+
// but opaque types under 10.4
33+
typedef int CGSRegionObj;
34+
typedef int CGSRegionEnumeratorObj;
35+
#endif
36+
37+
CG_EXTERN_C_BEGIN
38+
39+
/*! Creates a region from a `CGRect`. */
40+
CG_EXTERN CGError CGSNewRegionWithRect(const CGRect *rect, CGSRegionObj *outRegion);
41+
42+
/*! Creates a region from a list of `CGRect`s. */
43+
CG_EXTERN CGError CGSNewRegionWithRectList(const CGRect *rects, int rectCount, CGSRegionObj *outRegion);
44+
45+
/*! Creates a new region from a QuickDraw region. */
46+
CG_EXTERN CGError CGSNewRegionWithQDRgn(RgnHandle region, CGSRegionObj *outRegion);
47+
48+
/*! Creates an empty region. */
49+
CG_EXTERN CGError CGSNewEmptyRegion(CGSRegionObj *outRegion);
50+
51+
/*! Releases a region. */
52+
CG_EXTERN CGError CGSReleaseRegion(CGSRegionObj region);
53+
54+
/*! Creates a `CGRect` from a region. */
55+
CG_EXTERN CGError CGSGetRegionBounds(CGSRegionObj region, CGRect *outRect);
56+
57+
/*! Determines if two regions are equal. */
58+
CG_EXTERN bool CGSRegionsEqual(CGSRegionObj region1, CGSRegionObj region2);
59+
60+
/* Created a new region by changing the origin an existing one. */
61+
CG_EXTERN CGError CGSOffsetRegion(CGSRegionObj region, float offsetLeft, float offsetTop, CGSRegionObj *outRegion);
62+
63+
/*! Creates a new region by copying an existing one. */
64+
CG_EXTERN CGError CGSCopyRegion(CGSRegionObj region, CGSRegionObj *outRegion);
65+
66+
/*! Creates a new region by combining two regions together. */
67+
CG_EXTERN CGError CGSUnionRegion(CGSRegionObj region1, CGSRegionObj region2, CGSRegionObj *outRegion);
68+
69+
/*! Creates a new region by combining a region and a rect. */
70+
CG_EXTERN CGError CGSUnionRegionWithRect(CGSRegionObj region, CGRect *rect, CGSRegionObj *outRegion);
71+
72+
/*! Creates a region by XORing two regions together. */
73+
CG_EXTERN CGError CGSXorRegion(CGSRegionObj region1, CGSRegionObj region2, CGSRegionObj *outRegion);
74+
75+
/*! Determines if the region is empty. */
76+
CG_EXTERN bool CGSRegionIsEmpty(CGSRegionObj region);
77+
78+
/*! Determines if the region is rectangular. */
79+
CG_EXTERN bool CGSRegionIsRectangular(CGSRegionObj region);
80+
81+
/*! Determines if a point in a region. */
82+
CG_EXTERN bool CGSPointInRegion(CGSRegionObj region, const CGPoint *point);
83+
84+
/*! Determines if a rect is in a region. */
85+
CG_EXTERN bool CGSRectInRegion(CGSRegionObj region, const CGRect *rect);
86+
87+
/*! Determines if a region is inside of a region. */
88+
CG_EXTERN bool CGSRegionInRegion(CGSRegionObj region1, CGSRegionObj region2);
89+
90+
/*! Determines if a rect intersects a region. */
91+
CG_EXTERN bool CGSRegionIntersectsRect(CGSRegionObj obj, const CGRect *rect);
92+
93+
/*! Determines if a region intersects a region. */
94+
CG_EXTERN bool CGSRegionIntersectsRegion(CGSRegionObj region1, CGSRegionObj region2);
95+
96+
/*! Creates a rect from the difference of two regions. */
97+
CG_EXTERN CGError CGSDiffRegion(CGSRegionObj region1, CGSRegionObj region2, CGSRegionObj *outRegion);
98+
99+
100+
#pragma mark region enumerators
101+
/*! Gets the enumerator for a region. */
102+
CG_EXTERN CGSRegionEnumeratorObj CGSRegionEnumerator(CGSRegionObj region);
103+
104+
/*! Releases a region enumerator. */
105+
CG_EXTERN void CGSReleaseRegionEnumerator(CGSRegionEnumeratorObj enumerator);
106+
107+
/*! Gets the next rect of a region. */
108+
CG_EXTERN CGRect* CGSNextRect(CGSRegionEnumeratorObj enumerator);
109+
110+
CG_EXTERN_C_END

0 commit comments

Comments
 (0)