Skip to content

Commit 6993ddd

Browse files
committed
Drop visual effect view, use image view.
1 parent 04db659 commit 6993ddd

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drag/AppDelegate.m

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#import "AppDelegate.h"
1212
#import "DragView.h"
1313

14-
static NSImage *MaskImage(NSScreen *screen, CGSize size, CGFloat cornerRadius)
14+
static NSImage *MaskImage(NSScreen *screen, CGSize size, CGFloat cornerRadius, CGFloat white)
1515
{
1616
CGFloat scale = screen.backingScaleFactor;
1717

@@ -32,7 +32,7 @@
3232
NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithBitmapImageRep:rep];
3333
[NSGraphicsContext setCurrentContext:context];
3434

35-
[[NSColor blackColor] set];
35+
[[NSColor colorWithWhite:white alpha:1.0] set];
3636
[[NSBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size.width * scale, size.height * scale)
3737
xRadius:cornerRadius
3838
yRadius:cornerRadius] fill];
@@ -97,23 +97,24 @@ -(void)applicationDidFinishLaunching:(NSNotification *)notification
9797
CGRect viewFrame = { .origin = CGPointZero, .size = windowSize };
9898

9999
// create visual effect view as the root container
100-
NSVisualEffectView *effectView = [[NSVisualEffectView alloc] initWithFrame:viewFrame];
101-
effectView.blendingMode = NSVisualEffectBlendingModeBehindWindow;
102-
effectView.material = NSVisualEffectMaterialDark;
103-
effectView.maskImage = MaskImage(ScreenForPoint(mouseLocation), windowSize, 10);
104-
_window.contentView = effectView;
100+
NSImageView *view = [[NSImageView alloc] initWithFrame:viewFrame];
101+
NSScreen *screen = ScreenForPoint(mouseLocation);
102+
view.image = MaskImage(screen, windowSize, 10, 0.2);
103+
_window.contentView = view;
105104

106105
// add drag view
107106
_dragView = [[DragView alloc] initWithFrame:viewFrame];
108107
_dragView.fileURLs = _fileURLs;
109-
[effectView addSubview:_dragView];
108+
[view addSubview:_dragView];
110109

111110
[_window makeKeyAndOrderFront:nil];
112111

113112
// drag view behavior
114113
__weak typeof(self) weakSelf = self;
115114

116115
_dragView.startDrag = ^(NSEvent *event) {
116+
view.image = MaskImage(screen, windowSize, 10, 0.05);
117+
117118
NSMutableArray *items = [NSMutableArray arrayWithCapacity:weakSelf.fileURLs.count];
118119

119120
for (NSURL *URL in weakSelf.fileURLs)

0 commit comments

Comments
 (0)