@@ -385,9 +385,18 @@ @implementation WindowImplObj
385385 NSView *viewParent = *reinterpret_cast <NSView **>(handle);
386386 NSWindow *winParent = [viewParent window ];
387387
388+ NSRect content_rect = NSMakeRect (0 , 0 , 0 , 0 );
389+ wi->window = [
390+ [NSWindow alloc ]
391+ initWithContentRect: content_rect
392+ styleMask: NSBorderlessWindowMask
393+ backing: NSBackingStoreBuffered
394+ defer: NO
395+ ];
396+ [winParent addChildWindow: wi->window ordered: NSWindowAbove];
397+ wi->window .ignoresMouseEvents = true ;
388398 wi->view = [[OpenGLView alloc ] initWithFrame: NSMakeRect (0 , 0 , 0 , 0 )];
389- [winParent.contentView addSubview: wi->view];
390-
399+ [wi->window.contentView addSubview: wi->view];
391400 windows.emplace (name, wi);
392401}
393402
@@ -416,6 +425,8 @@ @implementation WindowImplObj
416425 [wi->view removeFromSuperview ];
417426 CFRelease (wi->view );
418427
428+ [wi->window close ];
429+
419430 windows.erase (name);
420431}
421432
@@ -434,6 +445,11 @@ @implementation WindowImplObj
434445 wi->view .glData ->stop = false ;
435446 wi->view .glData ->thread = new std::thread (renderFrames, wi);
436447
448+ NSRect frame = [wi->window frame ];
449+ frame.size = NSMakeSize (IOSurfaceGetWidth (wi->view .glData ->surface ),
450+ IOSurfaceGetHeight (wi->view .glData ->surface ));
451+ [wi->window setFrame: frame display: YES animate: NO ];
452+
437453 [wi->view setFrameSize: NSMakeSize (IOSurfaceGetWidth (wi->view.glData->surface),
438454 IOSurfaceGetHeight (wi->view.glData->surface))];
439455}
@@ -458,7 +474,10 @@ @implementation WindowImplObj
458474 return ;
459475
460476 WindowInfo* wi = reinterpret_cast <WindowInfo*>(it->second );
461- [wi->view setFrameOrigin: NSMakePoint (cx, cy)];
477+
478+ NSWindow * parent = (NSWindow *)[wi->window parentWindow ];
479+ NSRect frame = [parent frame ];
480+ [wi->window setFrameOrigin: NSMakePoint (frame.origin.x + cx, frame.origin.y + cy)];
462481}
463482
464483@end
0 commit comments