From dba4fd728a38aafc21eeff7579e74370d700d37f Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Sun, 12 Jul 2026 18:26:18 +0200 Subject: [PATCH] [Cocoa] Replace deprecated NSProgressIndicatorPreferredThickness NSProgressIndicatorPreferredThickness is deprecated since macOS 10.14 in favor of using controlSize and sizeToFit. Add a binding for NSProgressIndicator#sizeToFit and use it in ProgressBar#computeSize to determine the default thickness for the progress indicator's control size, restoring the original frame afterwards. Contributes to https://github.com/eclipse-platform/eclipse.platform.swt/issues/3214 Co-Authored-By: Claude Sonnet 5 # Conflicts: # bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras # bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java --- .../swt/internal/cocoa/AppKitFull.bridgesupport.extras | 4 +++- .../eclipse/swt/internal/cocoa/NSProgressIndicator.java | 9 +++++---- .../cocoa/org/eclipse/swt/internal/cocoa/OS.java | 1 - .../cocoa/org/eclipse/swt/widgets/ProgressBar.java | 6 +++++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras index 8778c0d26a2..136adf9f5d1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras @@ -2376,6 +2376,9 @@ + + + @@ -4507,7 +4510,6 @@ - diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSProgressIndicator.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSProgressIndicator.java index 3397ada72d7..d430ad015e9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSProgressIndicator.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSProgressIndicator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2019 IBM Corporation and others. + * Copyright (c) 2000, 2026 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -7,9 +7,6 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.internal.cocoa; @@ -63,6 +60,10 @@ public void setUsesThreadedAnimation(boolean usesThreadedAnimation) { OS.objc_msgSend(this.id, OS.sel_setUsesThreadedAnimation_, usesThreadedAnimation); } +public void sizeToFit() { + OS.objc_msgSend(this.id, OS.sel_sizeToFit); +} + public void startAnimation(id sender) { OS.objc_msgSend(this.id, OS.sel_startAnimation_, sender != null ? sender.id : 0); } 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 bfe161cc67b..23bec8f1326 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 @@ -2281,7 +2281,6 @@ public static Selector getSelector (long value) { public static final int NSPortraitOrientation = 0; public static final int NSPrintPanelShowsPageSetupAccessory = 256; public static final int NSPrintPanelShowsPrintSelection = 32; -public static final int NSProgressIndicatorPreferredThickness = 14; public static final int NSRegularSquareBezelStyle = 2; public static final int NSResizableWindowMask = 8; public static final int NSRightMouseDown = 3; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ProgressBar.java index eac59b1a91f..a01615d5b55 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ProgressBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ProgressBar.java @@ -87,7 +87,11 @@ static int checkStyle (int style) { @Override public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget(); - int size = OS.NSProgressIndicatorPreferredThickness; + NSProgressIndicator widget = (NSProgressIndicator)view; + NSRect oldFrame = widget.frame(); + widget.sizeToFit(); + int size = (int)widget.frame().height; + widget.setFrame(oldFrame); int width = 0, height = 0; if ((style & SWT.HORIZONTAL) != 0) { height = size;