Merge pull request #95 from frewsxcv/transparent

Implement window transparency on macOS.
This commit is contained in:
tomaka 2016-12-04 07:59:51 +01:00 committed by GitHub
commit 3b93c7c664
2 changed files with 4 additions and 3 deletions

View file

@ -26,7 +26,7 @@ objc = "0.2"
[target.'cfg(target_os = "macos")'.dependencies] [target.'cfg(target_os = "macos")'.dependencies]
objc = "0.2" objc = "0.2"
cgl = "0.1" cgl = "0.1"
cocoa = "0.5.0" cocoa = "0.5.2"
core-foundation = "0" core-foundation = "0"
core-graphics = "0.4" core-graphics = "0.4"

View file

@ -14,7 +14,7 @@ use objc::declare::ClassDecl;
use cocoa::base::{id, nil}; use cocoa::base::{id, nil};
use cocoa::foundation::{NSAutoreleasePool, NSDate, NSDefaultRunLoopMode, NSPoint, NSRect, NSSize, use cocoa::foundation::{NSAutoreleasePool, NSDate, NSDefaultRunLoopMode, NSPoint, NSRect, NSSize,
NSString, NSUInteger}; NSString, NSUInteger};
use cocoa::appkit::{self, NSApplication, NSEvent, NSView, NSWindow}; use cocoa::appkit::{self, NSApplication, NSColor, NSEvent, NSView, NSWindow};
use core_graphics::display::{CGAssociateMouseAndMouseCursorPosition, CGMainDisplayID, CGDisplayPixelsHigh, CGWarpMouseCursorPosition}; use core_graphics::display::{CGAssociateMouseAndMouseCursorPosition, CGMainDisplayID, CGDisplayPixelsHigh, CGWarpMouseCursorPosition};
@ -287,7 +287,8 @@ impl Window {
unsafe { unsafe {
if win_attribs.transparent { if win_attribs.transparent {
unimplemented!(); (*window as id).setOpaque_(NO);
(*window as id).setBackgroundColor_(NSColor::clearColor(nil));
} }
app.activateIgnoringOtherApps_(YES); app.activateIgnoringOtherApps_(YES);