|
18 | 18 |
|
19 | 19 | #include "window-osx.h"
|
20 | 20 |
|
| 21 | +NSOperatingSystemVersion OSversion = [NSProcessInfo processInfo].operatingSystemVersion; |
| 22 | + |
21 | 23 | void renderFrames(WindowInfo* wi)
|
22 | 24 | {
|
23 | 25 | while (!wi->view.glData->stop) {
|
@@ -385,18 +387,24 @@ @implementation WindowImplObj
|
385 | 387 | NSView *viewParent = *reinterpret_cast<NSView**>(handle);
|
386 | 388 | NSWindow *winParent = [viewParent window];
|
387 | 389 |
|
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; |
398 | 390 | wi->view = [[OpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)];
|
399 |
| - [wi->window.contentView addSubview:wi->view]; |
| 391 | + |
| 392 | + if (OSversion.majorVersion == 10 && OSversion.minorVersion < 14) { |
| 393 | + // Less performant but solves flickering issue on macOS High Sierra and lower |
| 394 | + NSRect content_rect = NSMakeRect(0, 0, 0, 0); |
| 395 | + wi->window = [ |
| 396 | + [NSWindow alloc] |
| 397 | + initWithContentRect:content_rect |
| 398 | + styleMask:NSBorderlessWindowMask |
| 399 | + backing:NSBackingStoreBuffered |
| 400 | + defer:NO |
| 401 | + ]; |
| 402 | + [winParent addChildWindow:wi->window ordered:NSWindowAbove]; |
| 403 | + wi->window.ignoresMouseEvents = true; |
| 404 | + [wi->window.contentView addSubview:wi->view]; |
| 405 | + } else { |
| 406 | + [winParent.contentView addSubview:wi->view]; |
| 407 | + } |
400 | 408 | windows.emplace(name, wi);
|
401 | 409 | }
|
402 | 410 |
|
@@ -425,7 +433,8 @@ @implementation WindowImplObj
|
425 | 433 | [wi->view removeFromSuperview];
|
426 | 434 | CFRelease(wi->view);
|
427 | 435 |
|
428 |
| - [wi->window close]; |
| 436 | + if (wi->window) |
| 437 | + [wi->window close]; |
429 | 438 |
|
430 | 439 | windows.erase(name);
|
431 | 440 | }
|
@@ -467,23 +476,28 @@ @implementation WindowImplObj
|
467 | 476 |
|
468 | 477 | WindowInfo* wi = reinterpret_cast<WindowInfo*>(it->second);
|
469 | 478 |
|
470 |
| - NSWindow* parent = (NSWindow*)[wi->window parentWindow]; |
471 |
| - NSRect parentFrame = [parent frame]; |
| 479 | + if (OSversion.majorVersion == 10 && OSversion.minorVersion < 14) { |
| 480 | + NSWindow* parent = (NSWindow*)[wi->window parentWindow]; |
| 481 | + NSRect parentFrame = [parent frame]; |
472 | 482 |
|
473 |
| - NSRect frame = [wi->window frame]; |
474 |
| - frame.size = NSMakeSize( |
475 |
| - IOSurfaceGetWidth(wi->view.glData->surface), |
476 |
| - IOSurfaceGetHeight(wi->view.glData->surface) |
477 |
| - ); |
478 |
| - |
479 |
| - frame.origin.x = parentFrame.origin.x + cx; |
480 |
| - frame.origin.y = parentFrame.origin.y + cy; |
| 483 | + NSRect frame = [wi->window frame]; |
| 484 | + frame.size = NSMakeSize( |
| 485 | + IOSurfaceGetWidth(wi->view.glData->surface), |
| 486 | + IOSurfaceGetHeight(wi->view.glData->surface) |
| 487 | + ); |
481 | 488 |
|
482 |
| - [wi->view setFrameSize:NSMakeSize(IOSurfaceGetWidth(wi->view.glData->surface), |
483 |
| - IOSurfaceGetHeight(wi->view.glData->surface))]; |
| 489 | + frame.origin.x = parentFrame.origin.x + cx; |
| 490 | + frame.origin.y = parentFrame.origin.y + cy; |
484 | 491 |
|
485 |
| - [wi->window setFrame:frame display: YES animate: NO]; |
| 492 | + [wi->view setFrameSize:NSMakeSize(IOSurfaceGetWidth(wi->view.glData->surface), |
| 493 | + IOSurfaceGetHeight(wi->view.glData->surface))]; |
486 | 494 |
|
| 495 | + [wi->window setFrame:frame display: YES animate: NO]; |
| 496 | + } else { |
| 497 | + [wi->view setFrameSize:NSMakeSize(IOSurfaceGetWidth(wi->view.glData->surface), |
| 498 | + IOSurfaceGetHeight(wi->view.glData->surface))]; |
| 499 | + [wi->view setFrameOrigin:NSMakePoint(cx, cy)]; |
| 500 | + } |
487 | 501 | }
|
488 | 502 |
|
489 | 503 | @end
|
0 commit comments