< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

@@ -33,10 +33,11 @@
   */
  #define DEFAULT_DEVICE_WIDTH 1024
  #define DEFAULT_DEVICE_HEIGHT 768
  #define DEFAULT_DEVICE_DPI 72
  
+ static NSInteger architecture = -1;
  /*
   * Convert the mode string to the more convenient bits per pixel value
   */
  static int getBPPFromModeString(CFStringRef mode)
  {

@@ -56,11 +57,21 @@
      }
  
      return 0;
  }
  
- static BOOL isValidDisplayMode(CGDisplayModeRef mode){
+ static BOOL isValidDisplayMode(CGDisplayModeRef mode) {
+     // Workaround for apple bug FB13261205, since it only affects arm based macs
+     // and arm support started with macOS 11 ignore the workaround for previous versions
+     if (@available(macOS 11, *)) {
+         if (architecture == -1) {
+             architecture = [[NSRunningApplication currentApplication] executableArchitecture];
+         }
+         if (architecture == NSBundleExecutableArchitectureARM64) {
+             return (CGDisplayModeGetPixelWidth(mode) >= 800);
+         }
+     }
      return (1 < CGDisplayModeGetWidth(mode) && 1 < CGDisplayModeGetHeight(mode));
  }
  
  static CFMutableArrayRef getAllValidDisplayModes(jint displayID){
      // CGDisplayCopyAllDisplayModes can return NULL if displayID is invalid
< prev index next >