diff options
19 files changed, 97 insertions, 201 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa/org/eclipse/swt/accessibility/Accessible.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa/org/eclipse/swt/accessibility/Accessible.java index 7197c0aecf..9be3649131 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa/org/eclipse/swt/accessibility/Accessible.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa/org/eclipse/swt/accessibility/Accessible.java @@ -1268,8 +1268,8 @@ public class Accessible { if (attribute.isEqualToString(OS.NSAccessibilityHeaderAttribute)) return getHeaderAttribute(childID); if (attribute.isEqualToString(OS.NSAccessibilityIndexAttribute)) return getIndexAttribute(childID); if (attribute.isEqualToString(OS.NSAccessibilitySelectedAttribute)) return getSelectedAttribute(childID); - if (OS.VERSION >= 0x1060 && attribute.isEqualToString(OS.NSAccessibilityRowIndexRangeAttribute)) return getRowIndexRangeAttribute(childID); - if (OS.VERSION >= 0x1060 && attribute.isEqualToString(OS.NSAccessibilityColumnIndexRangeAttribute)) return getColumnIndexRangeAttribute(childID); + if (attribute.isEqualToString(OS.NSAccessibilityRowIndexRangeAttribute)) return getRowIndexRangeAttribute(childID); + if (attribute.isEqualToString(OS.NSAccessibilityColumnIndexRangeAttribute)) return getColumnIndexRangeAttribute(childID); // If this object don't know how to get the value it's up to the control itself to return an attribute value. return null; @@ -1296,7 +1296,7 @@ public class Accessible { if (attribute.isEqualToString(OS.NSAccessibilityRangeForPositionParameterizedAttribute)) return getRangeForPositionParameterizedAttribute(parameter, childID); if (attribute.isEqualToString(OS.NSAccessibilityAttributedStringForRangeParameterizedAttribute)) return getAttributedStringForRangeParameterizedAttribute(parameter, childID); if (attribute.isEqualToString(OS.NSAccessibilityStyleRangeForIndexParameterizedAttribute)) return getStyleRangeForIndexAttribute(parameter, childID); - if (OS.VERSION >= 0x1060 && attribute.isEqualToString(OS.NSAccessibilityCellForColumnAndRowParameterizedAttribute)) return getCellForColumnAndRowParameter(parameter, childID); + if (attribute.isEqualToString(OS.NSAccessibilityCellForColumnAndRowParameterizedAttribute)) return getCellForColumnAndRowParameter(parameter, childID); return null; } @@ -1460,7 +1460,7 @@ public class Accessible { returnValue.addObject(OS.NSAccessibilityStyleRangeForIndexParameterizedAttribute); break; case ACC.ROLE_TABLE: - if (OS.VERSION >= 0x1060) returnValue.addObject(OS.NSAccessibilityCellForColumnAndRowParameterizedAttribute); + returnValue.addObject(OS.NSAccessibilityCellForColumnAndRowParameterizedAttribute); break; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/FileTransfer.java index 4cc0095835..bdf0b8e1fa 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/FileTransfer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/FileTransfer.java @@ -109,20 +109,12 @@ public Object nativeToJava(TransferData transferData) { @Override protected int[] getTypeIds(){ - if (OS.VERSION >= 0x1060) { - return new int[] {ID, ID1}; - } else { - return new int[] {ID}; - } + return new int[] {ID, ID1}; } @Override protected String[] getTypeNames(){ - if (OS.VERSION >= 0x1060) { - return new String[] {ID_NAME, ID1_NAME}; - } else { - return new String[] {ID_NAME}; - } + return new String[] {ID_NAME, ID1_NAME}; } boolean checkFile(Object object) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/URLTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/URLTransfer.java index 97bade5cb1..abaf2bf2e8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/URLTransfer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/URLTransfer.java @@ -91,20 +91,12 @@ public Object nativeToJava(TransferData transferData){ @Override protected int[] getTypeIds(){ - if (OS.VERSION >= 0x1060) { - return new int[] {URL_ID, URL_ID1}; - } else { - return new int[] {URL_ID}; - } + return new int[] {URL_ID, URL_ID1}; } @Override protected String[] getTypeNames(){ - if (OS.VERSION >= 0x1060) { - return new String[] {URL, URL1}; - } else { - return new String[] {URL}; - } + return new String[] {URL, URL1}; } boolean checkURL(Object object) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java index 3a4f2eec4a..cd774929e0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java @@ -21,26 +21,17 @@ public class OS extends C { Library.loadLibrary("swt-pi"); //$NON-NLS-1$ } - /** - * NOTE: For new code, use {@link #VERSION_MMB} and {@link #VERSION_MMB(int, int, int)} - */ public static final int VERSION; - public static final int VERSION_MMB; static { - int [] response = new int [1]; - OS.Gestalt (OS.gestaltSystemVersion, response); - VERSION = response [0] & 0xffff; - OS.Gestalt (OS.gestaltSystemVersionMajor, response); - int major = response [0]; - OS.Gestalt (OS.gestaltSystemVersionMinor, response); - int minor = response [0]; - OS.Gestalt (OS.gestaltSystemVersionBugFix, response); - int bugFix = response [0]; - VERSION_MMB = VERSION_MMB (major, minor, bugFix); + int [] major = new int [1], minor = new int [1], bugfix = new int [1]; + OS.Gestalt (OS.gestaltSystemVersionMajor, major); + OS.Gestalt (OS.gestaltSystemVersionMinor, minor); + OS.Gestalt (OS.gestaltSystemVersionBugFix, bugfix); + VERSION = VERSION (major [0], minor [0], bugfix [0]); } - public static int VERSION_MMB (int major, int minor, int bugFix) { - return (major << 16) + (minor << 8) + bugFix; + public static int VERSION (int major, int minor, int bugfix) { + return (major << 16) + (minor << 8) + bugfix; } /* @@ -221,7 +212,7 @@ public class OS extends C { OS.objc_msgSend(NSApplication.sharedApplication().id, sel_appAppearanceChanged, isDarkTheme ? 1 : 0); } public static boolean isAppDarkAppearance() { - if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 14, 0)) { + if (OS.VERSION >= OS.VERSION(10, 14, 0)) { NSAppearance currentAppearance = NSAppearance.currentAppearance(); if (currentAppearance != null) { return "NSAppearanceNameDarkAqua".equals(currentAppearance.name().getString()); @@ -230,7 +221,7 @@ public class OS extends C { return false; } public static boolean isSystemDarkAppearance() { - if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 14, 0)) { + if (OS.VERSION >= OS.VERSION(10, 14, 0)) { NSString osxMode = NSUserDefaults.standardUserDefaults ().stringForKey (NSString.stringWith ("AppleInterfaceStyle")); return osxMode != null && "Dark".equals (osxMode.getString ()); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/PrintDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/PrintDialog.java index 769fbd433d..ad2d5b424d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/PrintDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa/org/eclipse/swt/printing/PrintDialog.java @@ -186,11 +186,7 @@ public PrinterData open() { dict.setValue(NSNumber.numberWithInt(printerData.startPage), OS.NSPrintFirstPage); dict.setValue(NSNumber.numberWithInt(printerData.endPage), OS.NSPrintLastPage); } - // NSPrintSelectionOnly is not available in version 10.5 - // dict.setValue(NSNumber.numberWithBool(printerData.scope == PrinterData.SELECTION), OS.NSPrintSelectionOnly); - if (OS.VERSION >= 0x1060) { - printInfo.setSelectionOnly (printerData.scope == PrinterData.SELECTION); - } + printInfo.setSelectionOnly (printerData.scope == PrinterData.SELECTION); panel.setOptions(OS.NSPrintPanelShowsPageSetupAccessory | OS.NSPrintPanelShowsPrintSelection | panel.options()); Shell parent = getParent(); @@ -224,7 +220,7 @@ public PrinterData open() { NSString filename = new NSString(dict.objectForKey(OS.NSPrintSavePath)); data.fileName = filename.getString(); } - if (OS.VERSION >= 0x1060 && printInfo.isSelectionOnly ()) { + if (printInfo.isSelectionOnly ()) { data.scope = PrinterData.SELECTION; } else { data.scope = new NSNumber(dict.objectForKey(OS.NSPrintAllPages)).intValue() != 0 ? PrinterData.ALL_PAGES : PrinterData.PAGE_RANGE; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java index 583aa79a96..e634fe2366 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java @@ -428,10 +428,7 @@ Point getScreenDPI () { NSDictionary dictionary = screen.deviceDescription(); NSValue value = new NSValue(dictionary.objectForKey(new id(OS.NSDeviceResolution())).id); NSSize size = value.sizeValue(); - double scaling = 1; - if (OS.VERSION >= 0x1070) { - scaling = screen.backingScaleFactor(); - } + double scaling = screen.backingScaleFactor(); return new Point((int)(size.width / scaling), (int)(size.height / scaling)); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java index 0d5190b29c..63ca42bfda 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java @@ -1620,7 +1620,7 @@ void initClasses () { OS.class_addProtocol(cls, OS.protocol_NSTextAttachmentCell); OS.class_addMethod(cls, OS.sel_cellSize, cellSizeProc, "@:"); OS.class_addMethod(cls, OS.sel_cellBaselineOffset, cellBaselineOffsetProc, "@:"); - if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 11, 0)) { + if (OS.VERSION >= OS.VERSION(10, 11, 0)) { long attachmentProc = OS.CALLBACK_NSTextAttachmentCell_attachment(proc2); OS.class_addMethod(cls, OS.sel_attachment, attachmentProc, "@:"); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java index 7d6267708c..92217d86ef 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java @@ -315,27 +315,6 @@ boolean dragDetect(int x, int y, boolean filter, boolean[] consume) { return dragging; } -@Override -void drawImageWithFrameInView (long id, long sel, long image, NSRect rect, long view) { - /* - * Feature in Cocoa. Images touch the edge of rounded buttons - * when set to small size. The fix to subclass the button cell - * and offset the image drawing. - * This workaround is not required for OSX 10.9 and later as - * the problem doesn't happen there. - */ - if (OS.VERSION_MMB < OS.VERSION_MMB(10, 9, 0)) { - NSCell cell = ((NSControl)this.view).cell(); - if (cell != null && cell.controlSize() == OS.NSRegularControlSize) { - if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0 && (style & (SWT.FLAT | SWT.WRAP)) == 0) { - rect.y += EXTRA_HEIGHT / 2; - rect.height += EXTRA_HEIGHT; - } - } - } - super.drawImageWithFrameInView(id, sel, image, rect, view); -} - private static NSRect smallerRect (NSRect cellFrame, double dx, double dy1, double dy2, float lineWidth) { if (lineWidth == 2) { dx -= 0.5; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java index f86c9244f7..c04bb46b4c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java @@ -520,7 +520,7 @@ void createHandle () { widget.init(); widget.setDelegate(widget); NSCell cell = widget.cell(); - if (OS.VERSION >= 0x1060 && cell != null){ + if (cell != null) { cell.setUsesSingleLineMode(true); } view = widget; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java index 5d3bc1ce5b..537ba226e2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java @@ -841,9 +841,8 @@ protected void create (DeviceData data) { } void createDisplay (DeviceData data) { - if (OS.VERSION < 0x1050) { - System.out.println ("***WARNING: SWT requires MacOS X version " + 10 + "." + 5 + " or greater"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - System.out.println ("***WARNING: Detected: " + Integer.toHexString((OS.VERSION & 0xFF00) >> 8) + "." + Integer.toHexString((OS.VERSION & 0xF0) >> 4) + "." + Integer.toHexString(OS.VERSION & 0xF)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + if (OS.VERSION < OS.VERSION (10, 10, 0)) { + System.out.println ("***WARNING: SWT requires MacOS X version 10.10 or greater"); //$NON-NLS-1$ error(SWT.ERROR_NOT_IMPLEMENTED); } @@ -881,10 +880,8 @@ void createDisplay (DeviceData data) { long ptr = getApplicationName().UTF8String(); if (ptr != 0) OS.CPSSetProcessName (psn, ptr); if (!isBundled ()) { - if (OS.VERSION_MMB >= OS.VERSION_MMB (10, 9, 0)) { - application.setActivationPolicy (OS.NSApplicationActivationPolicyRegular); - NSRunningApplication.currentApplication().activateWithOptions (OS.NSApplicationActivateIgnoringOtherApps); - } + application.setActivationPolicy (OS.NSApplicationActivationPolicyRegular); + NSRunningApplication.currentApplication().activateWithOptions (OS.NSApplicationActivateIgnoringOtherApps); } ptr = C.getenv (ascii ("APP_ICON_" + pid)); if (ptr != 0) { @@ -1874,10 +1871,7 @@ double [] getWidgetColorRGB (int id) { NSColor color = null; switch (id) { case SWT.COLOR_INFO_FOREGROUND: color = NSColor.blackColor (); break; - case SWT.COLOR_INFO_BACKGROUND: return - OS.VERSION_MMB >= OS.VERSION_MMB (10, 10, 0) - ? new double [] {236/255f, 235/255f, 236/255f, 1} - : new double [] {.984f, .988f, 0.773f, 1}; + case SWT.COLOR_INFO_BACKGROUND: return new double [] {236/255f, 235/255f, 236/255f, 1}; case SWT.COLOR_TITLE_FOREGROUND: color = NSColor.windowFrameTextColor(); break; case SWT.COLOR_TITLE_BACKGROUND: color = NSColor.alternateSelectedControlColor(); break; case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = NSColor.selectedControlColor(); break; @@ -1886,20 +1880,20 @@ double [] getWidgetColorRGB (int id) { case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: color = NSColor.secondarySelectedControlColor(); break; case SWT.COLOR_WIDGET_DARK_SHADOW: color = NSColor.controlDarkShadowColor(); break; case SWT.COLOR_WIDGET_NORMAL_SHADOW: - if (OS.VERSION_MMB >= OS.VERSION_MMB (10, 14, 0)) { + if (OS.VERSION >= OS.VERSION (10, 14, 0)) { return new double [] {159/255f, 159/255f, 159/255f, 1}; } color = NSColor.controlShadowColor(); break; case SWT.COLOR_WIDGET_LIGHT_SHADOW: - if (OS.VERSION_MMB >= OS.VERSION_MMB (10, 14, 0)) { + if (OS.VERSION >= OS.VERSION (10, 14, 0)) { return new double [] {232/255f, 232/255f, 232/255f, 1}; } color = NSColor.controlHighlightColor(); break; case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: color = NSColor.controlLightHighlightColor(); break; case SWT.COLOR_WIDGET_BACKGROUND: - color = OS.VERSION_MMB >= OS.VERSION_MMB (10, 14, 0) ? NSColor.windowBackgroundColor() + color = OS.VERSION >= OS.VERSION (10, 14, 0) ? NSColor.windowBackgroundColor() : NSColor.controlHighlightColor(); break; case SWT.COLOR_WIDGET_FOREGROUND: color = NSColor.controlTextColor(); break; @@ -2167,8 +2161,7 @@ public Thread getThread () { */ public boolean getTouchEnabled() { checkDevice(); - // Gestures are available on OS X 10.5.3 and later. Touch events are only available on 10.6 and later. - return (OS.VERSION > 0x1053); + return true; } int getToolTipTime () { @@ -2328,7 +2321,7 @@ protected void init () { textView.release (); NSUserDefaults defaults = NSUserDefaults.standardUserDefaults(); - defaults.setInteger(0, NSString.stringWith(OS.VERSION >= 0x1080 ? "NSScrollAnimationEnabled" : "AppleScrollAnimationEnabled")); + defaults.setInteger(0, NSString.stringWith("NSScrollAnimationEnabled")); id blink = defaults.objectForKey(NSString.stringWith("NSTextInsertionPointBlinkPeriod")); if (blink != null) blinkTime = (int)new NSNumber(blink).integerValue(); if (blinkTime == 0) blinkTime = 560; @@ -2578,9 +2571,7 @@ void initClasses () { OS.class_addMethod(cls, OS.sel_drawBezelWithFrame_inView_, drawBezelWithFrameInViewProc, "@:{NSRect}@"); OS.class_addMethod(cls, OS.sel_titleRectForBounds_, titleRectForBoundsProc, "@:{NSRect}"); OS.class_addMethod(cls, OS.sel_cellSizeForBounds_, cellSizeForBoundsProc, "@:{NSRect}"); - if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 10, 0)) { - OS.class_addMethod(cls, OS.sel_focusRingMaskBoundsForFrame_inView_, focusRingMaskBoundsForFrameProc, "@:{NSRect}@"); - } + OS.class_addMethod(cls, OS.sel_focusRingMaskBoundsForFrame_inView_, focusRingMaskBoundsForFrameProc, "@:{NSRect}@"); OS.objc_registerClassPair (cls); className = "SWTCanvasView"; @@ -2754,9 +2745,7 @@ void initClasses () { // NSPopUpButtonCell cls = registerCellSubclass(NSPopUpButton.cellClass(), size, align, types); addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); - if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 10, 0)) { - OS.class_addMethod(cls, OS.sel_focusRingMaskBoundsForFrame_inView_, focusRingMaskBoundsForFrameProc, "@:{NSRect}@"); - } + OS.class_addMethod(cls, OS.sel_focusRingMaskBoundsForFrame_inView_, focusRingMaskBoundsForFrameProc, "@:{NSRect}@"); className = "SWTProgressIndicator"; cls = OS.objc_allocateClassPair(OS.class_NSProgressIndicator, className, 0); @@ -2776,11 +2765,9 @@ void initClasses () { addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc); addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc); OS.objc_registerClassPair(cls); - if (OS.VERSION >= 0x1070) { - /* Note that isFlippedProc is used for performance and convenience */ - long metaClass = OS.objc_getMetaClass(className); - OS.class_addMethod(metaClass, OS.sel_isCompatibleWithOverlayScrollers, isFlippedProc, "@:"); - } + /* Note that isFlippedProc is used for performance and convenience */ + long metaClass = OS.objc_getMetaClass(className); + OS.class_addMethod(metaClass, OS.sel_isCompatibleWithOverlayScrollers, isFlippedProc, "@:"); className = "SWTScrollView"; cls = OS.objc_allocateClassPair(OS.class_NSScrollView, className, 0); @@ -3339,11 +3326,7 @@ public boolean post(Event event) { } if (vKey != -1) { - if (OS.VERSION < 0x1060) { - returnValue = OS.CGPostKeyboardEvent((short)0, vKey, type == SWT.KeyDown) == OS.noErr; - } else { - eventRef = OS.CGEventCreateKeyboardEvent(eventSource, vKey, type == SWT.KeyDown); - } + eventRef = OS.CGEventCreateKeyboardEvent(eventSource, vKey, type == SWT.KeyDown); } break; } @@ -3396,17 +3379,14 @@ public boolean post(Event event) { } } - // returnValue is true if we called CGPostKeyboardEvent (10.5 only). - if (returnValue == false) { - if (eventRef != 0) { - OS.CGEventPost(OS.kCGHIDEventTap, eventRef); - OS.CFRelease(eventRef); - try { - Thread.sleep(1); - } catch (Exception e) { - } - returnValue = true; + if (eventRef != 0) { + OS.CGEventPost(OS.kCGHIDEventTap, eventRef); + OS.CFRelease(eventRef); + try { + Thread.sleep(1); + } catch (Exception e) { } + returnValue = true; } if (eventSource != 0) OS.CFRelease(eventSource); @@ -4245,13 +4225,13 @@ boolean runSettings () { runSettings = false; boolean ignoreColorChange = false; - /** + /* * Feature in Cocoa: When dark mode is enabled on OSX version >= 10.10 and a SWT TrayItem (NSStatusItem) is present in the menubar, * changing the OSX appearance or changing the configuration of attached displays causes the textColor and textBackground color to change. * This sets the text foreground of several widgets as white and hence text is invisible. The workaround is to detect this case and prevent * the update of LIST_FOREGROUND, LIST_BACKGROUND and COLOR_WIDGET_FOREGROUND colors. */ - if (OS.VERSION_MMB >= OS.VERSION_MMB (10, 10, 0) && tray != null && tray.itemCount > 0) { + if (tray != null && tray.itemCount > 0) { /* * osxMode will be "Dark" when in OSX dark mode. Otherwise, it'll be null. */ @@ -4280,7 +4260,7 @@ NSAppearance getAppearance (APPEARANCE newMode) { } void setAppAppearance (APPEARANCE newMode) { - if (OS.VERSION_MMB < OS.VERSION_MMB (10, 14, 0)) return; + if (OS.VERSION < OS.VERSION (10, 14, 0)) return; NSAppearance appearance = getAppearance(newMode); if (appearance != null && application != null) { @@ -4296,7 +4276,7 @@ void setWindowAppearance (NSWindow window, NSAppearance appearance) { } void setWindowsAppearance (APPEARANCE newMode) { - if (OS.VERSION_MMB < OS.VERSION_MMB (10, 14, 0)) return; + if (OS.VERSION < OS.VERSION (10, 14, 0)) return; NSAppearance appearance = getAppearance(newMode); if (appearance != null) { @@ -4755,11 +4735,9 @@ void setMenuBar (Menu menu) { * menu for languages other than english. The fix is to detect * it ourselves. */ - if (OS.VERSION >= 0x1060) { - NSMenu submenu = nsItem.submenu(); - if (submenu != null && submenu.title().getString().equals(SWT.getMessage("SWT_Help"))) { - application.setHelpMenu(submenu); - } + NSMenu submenu = nsItem.submenu(); + if (submenu != null && submenu.title().getString().equals(SWT.getMessage("SWT_Help"))) { + application.setHelpMenu(submenu); } nsItem.setMenu(null); @@ -5181,18 +5159,7 @@ Control findControl (boolean checkTrim) { Control findControl (boolean checkTrim, NSView[] hitView) { NSView view = null; NSPoint screenLocation = NSEvent.mouseLocation(); - long hitWindowNumber = 0; - if (OS.VERSION >= 0x1060) { - hitWindowNumber = NSWindow.windowNumberAtPoint(screenLocation, 0); - } else { - long outWindow[] = new long [1]; - OS.FindWindow ((long)screenLocation.x, (long)(getPrimaryFrame().height - screenLocation.y), outWindow); - - if (outWindow[0] != 0) { - hitWindowNumber = OS.HIWindowGetCGWindowID(outWindow[0]); - } - } - + long hitWindowNumber = NSWindow.windowNumberAtPoint(screenLocation, 0); NSWindow window = application.windowWithWindowNumber(hitWindowNumber); if (window != null) { NSView contentView = window.contentView(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java index 62827a3815..c38faea3f5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java @@ -173,7 +173,7 @@ void createHandle () { scrollWidget.setDrawsBackground(false); scrollWidget.setAutoresizesSubviews (true); scrollWidget.setBorderType(hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder); - if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 7, 0)) scrollWidget.setVerticalScrollElasticity(OS.NSScrollElasticityNone); + scrollWidget.setVerticalScrollElasticity(OS.NSScrollElasticityNone); NSTextView widget = (NSTextView)new SWTTextView().alloc(); widget.init(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ScrollBar.java index 29e72b1b87..05ad18ed1c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ScrollBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ScrollBar.java @@ -747,7 +747,7 @@ void updateBar (int selection, int minimum, int maximum, int thumb) { widget.setDoubleValue(fraction); widget.setKnobProportion(knob); widget.setEnabled (range > 0); - if (OS.VERSION >= 0x1070 && target == null && (knob != oldKnob || fraction != oldFraction)) { + if (target == null && (knob != oldKnob || fraction != oldFraction)) { OS.objc_msgSend(parent.scrollView.id, OS.sel_flashScrollers); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scrollable.java index 80224d21e0..e220de04fc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scrollable.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scrollable.java @@ -110,17 +110,13 @@ public Rectangle computeTrim (int x, int y, int width, int height) { size.width = width; size.height = height; int border = hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder; - if (OS.VERSION >= 0x1070) { - // Always include the scroll bar in the trim even when the scroll style is overlay - OS.objc_msgSend_stret(size, OS.class_NSScrollView, - OS.sel_frameSizeForContentSize_horizontalScrollerClass_verticalScrollerClass_borderType_controlSize_scrollerStyle_, - size, - (style & SWT.H_SCROLL) != 0 ? OS.class_NSScroller : 0, - (style & SWT.V_SCROLL) != 0 ? OS.class_NSScroller : 0, - border, OS.NSRegularControlSize, OS.NSScrollerStyleLegacy); - } else { - size = NSScrollView.frameSizeForContentSize(size, (style & SWT.H_SCROLL) != 0, (style & SWT.V_SCROLL) != 0, border); - } + // Always include the scroll bar in the trim even when the scroll style is overlay + OS.objc_msgSend_stret(size, OS.class_NSScrollView, + OS.sel_frameSizeForContentSize_horizontalScrollerClass_verticalScrollerClass_borderType_controlSize_scrollerStyle_, + size, + (style & SWT.H_SCROLL) != 0 ? OS.class_NSScroller : 0, + (style & SWT.V_SCROLL) != 0 ? OS.class_NSScroller : 0, + border, OS.NSRegularControlSize, OS.NSScrollerStyleLegacy); width = (int)size.width; height = (int)size.height; NSRect frame = scrollView.contentView().frame(); @@ -250,7 +246,7 @@ public ScrollBar getHorizontalBar () { public int getScrollbarsMode () { checkWidget(); int style = SWT.NONE; - if (scrollView != null && OS.VERSION >= 0x1070) { + if (scrollView != null) { if (OS.objc_msgSend (scrollView.id, OS.sel_scrollerStyle) == OS.NSScrollerStyleOverlay) { style = SWT.SCROLLBAR_OVERLAY; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java index 9ef1cabb70..1b0caf89bf 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java @@ -686,7 +686,7 @@ void createHandle () { if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0 || (style & (SWT.TOOL | SWT.SHEET)) != 0) { window.setHasShadow (true); } - if ((style & SWT.NO_MOVE) != 0 && (OS.VERSION_MMB >= OS.VERSION_MMB(10, 6, 0))) { + if ((style & SWT.NO_MOVE) != 0) { window.setMovable(false); } if ((style & SWT.TOOL) != 0) { @@ -710,7 +710,7 @@ void createHandle () { OS.objc_msgSend(window.id, OS.sel_setMovable_, 0); } } - if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 12, 0)) { + if (OS.VERSION >= OS.VERSION(10, 12, 0)) { /* * In macOS 10.12, a new system preference "prefer tabs when opening documents" * has been added which causes automatic tabbing of windows in Eclipse. @@ -766,28 +766,19 @@ void createHandle () { NSWindow hostWindow = view.window(); attachObserversToWindow(hostWindow); } else { - int behavior = 0; - if (parent != null) behavior |= OS.NSWindowCollectionBehaviorMoveToActiveSpace; - if (OS.VERSION >= 0x1070) { - if (parent == null) { - if ((style & SWT.TOOL) != 0) { - behavior = OS.NSWindowCollectionBehaviorFullScreenAuxiliary; - } else { - behavior = OS.NSWindowCollectionBehaviorFullScreenPrimary; - } - } + int behavior; + if (parent != null) { + behavior = OS.NSWindowCollectionBehaviorMoveToActiveSpace; + } else if ((style & SWT.TOOL) != 0) { + behavior = OS.NSWindowCollectionBehaviorFullScreenAuxiliary; + } else { + behavior = OS.NSWindowCollectionBehaviorFullScreenPrimary; } - if (behavior != 0) window.setCollectionBehavior(behavior); + window.setCollectionBehavior(behavior); window.setAcceptsMouseMovedEvents(true); window.setDelegate(windowDelegate); } - if (OS.VERSION < 0x1060) { - // Force a WindowRef to be created for this window so we can use - // FindWindow() (see Display.findControl()) - if (window != null) window.windowRef(); - } - NSWindow fieldEditorWindow = window; if (fieldEditorWindow == null) fieldEditorWindow = view.window(); id id = fieldEditorWindow.fieldEditor (true, null); @@ -2018,9 +2009,6 @@ void setWindowVisible (boolean visible, boolean key) { if ((style & (SWT.SHEET)) != 0) { NSApplication application = NSApplication.sharedApplication(); application.beginSheet(window, parentWindow (), null, 0, 0); - if (OS.VERSION <= 0x1060 && window.respondsToSelector(OS.sel__setNeedsToUseHeartBeatWindow_)) { - OS.objc_msgSend(window.id, OS.sel__setNeedsToUseHeartBeatWindow_, 0); - } } else { // If the parent window is miniaturized, the window will be shown // when its parent is shown. @@ -2151,7 +2139,7 @@ void updateParent (boolean visible) { */ if ((style & SWT.ON_TOP) != 0) { window.setLevel(OS.NSStatusWindowLevel); - } else if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 11, 0)) { + } else if (OS.VERSION >= OS.VERSION(10, 11, 0)) { /* * Feature in Cocoa on 10.11: Second-level child windows of * a full-screen window are sometimes shown behind their diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java index 469188bb84..c80631d01e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java @@ -664,7 +664,7 @@ void tabView_willSelectTabViewItem(long id, long sel, long tabView, long tabView if (currentIndex != -1) { TabItem selected = items [currentIndex]; if (selected != null) { - if (OS.VERSION >= 0x1070) selected.updateText(false); + selected.updateText(false); Control control = selected.control; if (control != null && !control.isDisposed ()) { control.setVisible (false); @@ -675,7 +675,7 @@ void tabView_willSelectTabViewItem(long id, long sel, long tabView, long tabView if (control != null && !control.isDisposed ()) { control.setVisible (true); } - if (OS.VERSION >= 0x1070) item.updateText(true); + item.updateText(true); break; } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabItem.java index 9e6672339e..cc7de410df 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabItem.java @@ -465,7 +465,7 @@ void updateText (boolean selected) { } double [] foreground = parent.foreground; if (foreground == null) { - if (selected && OS.VERSION >= 0x1070) { + if (selected) { foreground = display.getNSColorRGB(NSColor.alternateSelectedControlTextColor()); } else { foreground = parent.defaultForeground().handle; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java index c4fea6f523..161429c0a5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java @@ -1303,7 +1303,7 @@ public Rectangle getClientArea () { * OSX 10.11 - The origin of the table is the header and the header's * height is already included in the rect. Hence, we return the rect as is. */ - if (OS.VERSION_MMB < OS.VERSION_MMB (10, 11, 0)) { + if (OS.VERSION < OS.VERSION (10, 11, 0)) { NSTableHeaderView headerView = ((NSTableView) view).headerView (); if (headerView != null) { int height = (int) headerView.bounds ().height; @@ -1854,7 +1854,7 @@ public int getTopIndex () { * In OSX 10.11, the origin of the table is the header, not the top-left of the rows. * Offset the point's y coordinate accordingly. */ - if (OS.VERSION_MMB >= OS.VERSION_MMB (10, 11, 0)) { + if (OS.VERSION >= OS.VERSION (10, 11, 0)) { NSTableHeaderView headerView = ((NSTableView) view).headerView (); if (headerView != null) { int height = (int) headerView.bounds ().height; @@ -3131,7 +3131,7 @@ public void setTopIndex (int index) { * In OSX 10.11, the origin of the table is the header, not the top-left of the rows. * Offset the point's y coordinate accordingly. */ - if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 11, 0)) { + if (OS.VERSION >= OS.VERSION(10, 11, 0)) { if (widget.headerView() != null) { NSRect headerRect = headerView.frame(); pt.y -= headerRect.y + headerRect.height; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolItem.java index 5547ece2b9..ab80291ad7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolItem.java @@ -638,23 +638,21 @@ public Image getHotImage () { } NSString getItemID() { - NSString itemID = id; - - // For separators, return a Cocoa constant for the tool item ID. - if ((style & SWT.SEPARATOR) != 0) { - // If we are using a non-default width or control use that instead. - if (control == null) { - if (width == DEFAULT_SEPARATOR_WIDTH || width == 0) { - if (OS.VERSION < 0x1070) itemID = OS.NSToolbarSeparatorItemIdentifier; - } else if (width == SWT.DEFAULT) { - itemID = OS.NSToolbarSpaceItemIdentifier; - } else if (width == SWT.SEPARATOR_FILL) { - itemID = OS.NSToolbarFlexibleSpaceItemIdentifier; - } - } - } + NSString itemID = id; + + // For separators, return a Cocoa constant for the tool item ID. + if ((style & SWT.SEPARATOR) != 0) { + // If we are using a non-default width or control use that instead. + if (control == null) { + if (width == SWT.DEFAULT) { + itemID = OS.NSToolbarSpaceItemIdentifier; + } else if (width == SWT.SEPARATOR_FILL) { + itemID = OS.NSToolbarFlexibleSpaceItemIdentifier; + } + } + } - return itemID; + return itemID; } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java index 81a60d6717..fcbf5c28ae 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java @@ -1377,7 +1377,7 @@ public Rectangle getClientArea () { * OSX 10.11 & above - The origin of the tree is the header and the header's * height is already included in the rect. Hence, we return the rect as is. */ - if (OS.VERSION_MMB < OS.VERSION_MMB (10, 11, 0)) { + if (OS.VERSION < OS.VERSION (10, 11, 0)) { NSTableHeaderView headerView = ((NSTableView) view).headerView (); if (headerView != null) { int height = (int) headerView.bounds ().height; @@ -1921,7 +1921,7 @@ public TreeItem getTopItem () { * In OSX 10.11, the origin of the tree is the header, not the top-left of the rows. * Offset the point's y coordinate accordingly. */ - if (OS.VERSION_MMB >= OS.VERSION_MMB (10, 11, 0)) { + if (OS.VERSION >= OS.VERSION (10, 11, 0)) { NSTableHeaderView headerView = ((NSTableView) view).headerView (); if (headerView != null) { int height = (int) headerView.bounds ().height; @@ -3361,7 +3361,7 @@ public void setTopItem (TreeItem item) { * In OSX 10.11, the origin of the tree is the header, not the top-left of the rows. * Offset the point's y coordinate accordingly. */ - if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 11, 0)) { + if (OS.VERSION >= OS.VERSION(10, 11, 0)) { if (widget.headerView() != null) { NSRect headerRect = headerView.frame(); pt.y -= headerRect.y + headerRect.height; |