File tree 2 files changed +8
-3
lines changed
2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,10 @@ fn main() {
16
16
} ) . collect :: < Vec < _ > > ( ) ;
17
17
18
18
let event_loop = EventLoop :: new ( ) ;
19
- let window = WindowBuilder :: new ( ) . build ( & event_loop) . unwrap ( ) ;
19
+ let window = WindowBuilder :: new ( )
20
+ . with_inner_size ( winit:: dpi:: PhysicalSize :: new ( fruit. width ( ) , fruit. height ( ) ) )
21
+ . build ( & event_loop)
22
+ . unwrap ( ) ;
20
23
21
24
#[ cfg( target_arch = "wasm32" ) ]
22
25
{
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use core_graphics::data_provider::CGDataProvider;
6
6
use core_graphics:: image:: CGImage ;
7
7
8
8
use cocoa:: base:: { id, nil} ;
9
- use cocoa:: appkit:: { NSView , NSViewWidthSizable , NSViewHeightSizable } ;
9
+ use cocoa:: appkit:: { NSView , NSViewWidthSizable , NSViewHeightSizable , NSWindow } ;
10
10
use cocoa:: quartzcore:: { CALayer , ContentsGravity } ;
11
11
use foreign_types:: ForeignType ;
12
12
@@ -18,11 +18,13 @@ pub struct CGImpl {
18
18
19
19
impl CGImpl {
20
20
pub unsafe fn new ( handle : AppKitWindowHandle ) -> Result < Self , SwBufError > {
21
+ let window = handle. ns_window as id ;
21
22
let view = handle. ns_view as id ;
22
23
let layer = CALayer :: new ( ) ;
23
- let subview: id = NSView :: alloc ( nil) . initWithFrame_ ( view . frame ( ) ) ;
24
+ let subview: id = NSView :: alloc ( nil) . initWithFrame_ ( NSView :: frame ( view ) ) ;
24
25
layer. set_contents_gravity ( ContentsGravity :: TopLeft ) ;
25
26
layer. set_needs_display_on_bounds_change ( false ) ;
27
+ layer. set_contents_scale ( window. backingScaleFactor ( ) ) ;
26
28
subview. setLayer ( layer. id ( ) ) ;
27
29
subview. setAutoresizingMask_ ( NSViewWidthSizable | NSViewHeightSizable ) ;
28
30
You can’t perform that action at this time.
0 commit comments