mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-26 03:36:32 +11:00
Implement window transparency on macOS.
Fixes https://github.com/tomaka/winit/issues/57.
This commit is contained in:
parent
13620118f6
commit
cb0811faf3
2 changed files with 4 additions and 3 deletions
|
@ -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"
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue