Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] macOS 10.14 (mojave)

No no, you can definitely support both macOS 10.14 and older versions in the same application. It’s possible to specify the minimum deployment target when building an application. If you need to use features of a newer version of macOS than the minimum deployment target you need to guard those usages with an if statement. Swift and Objective-C has language support for this, but how it’s actually working is that most symbols in the SDK have weak linkage, that means that the symbols don’t need to be present at runtime. Then you need to check if the symbols are available at runtime before using a feature requiring the new symbol.

In Swift it would look something like:

@available(macOS 10.14, *)
func fooBar()

And the usage:

if #available(macOS 10.14, *) {
  fooBar()
  // 10.14 specific code
} else {
  // fallback for older versions
}

Doing that manually in C would be something like:

void fooBar() __attribute__ ((weak_import));

if (fooBar) {
  fooBar(); // foo is available
} else {
  // fallback for older versions
}

With Java I’m guessing the native dynamic libraries are loaded with the a method similar to “dlopen” and symbols loaded using “dlsym”. In that case the same approach as described above should be possible to use.

I’ve attached a screen shot of the Scala IDE (based on Eclipse which uses SWT, using the NSRequiresAquaSystemAppearance method) when dark mode is enabled. This shows that some parts are correctly using the dark mode colors (like the background color in the side bar and the two bottom views). At the same time it’s possible to see that the text color looks hard coded in the side bar (it would otherwise be white). Also, since Eclipse uses quite a few of the custom controls (like the tab bar and tool bar) that SWT provides, very few parts of the application has the correct colors. SWT needs to use the dynamic colors, that will change depending on if dark mode or light mode is enabled, and not hard coded RGB values. This will also give the correct values for the high contrast versions (an accessibility feature) that are available as well.

In the 10.14 SDK there are quite a few new semantic colors (as they are called) which instead of specifying a color like white or blue specifies what it should be used for, i.e. label color, tab background color and so on. These colors are dynamic and change according to the selected mode. Also standard colors like red, blue, green and so on are available as dynamic colors that change slightly between dark and light mode.

macOS 10.14 also added a new feature making it possible for the users to select the accent color (i.e. usually the color of the “Ok” button in a dialog). This needs to be handled as well.



-- 
/Jacob Carlborg

On 10 Sep 2018, at 18:37, Thomas Singer <ts-swt@xxxxxxxxxxx> wrote:

Hi Jacob,

Thank you very much for the answer. So I understand that SWT (or any other hard-linked application) can't support macOS 10.14 and macOS <10.14 at the same time?

--
Best regards,
Thomas Singer


On 10/09/2018 17:48, Jacob wrote:
For native Cocoa applications they need to be linked against the 10.14 SDK to enable dark mode. How that would work with Java and SWT I don’t know, perhaps link the native dynamic libraries with the new SDK. It is possible to manually handle this if relinking with 10.14 SDK is not enough.
The reason for this is not default is to avoid breaking existing applications. There are applications with hard coded colors which need to be updated to look good with the dark mode. The SDK provides dynamic colors which will change depending on the mode that is used. SWT might need to be updated as well.
There are several good videos from this year’s WWDC which covers dark mode and how to enable that for applications.
https://developer.apple.com/videos/play/wwdc2018/210/
https://developer.apple.com/videos/play/wwdc2018/218/

/Jacob Carlborg
On 10 Sep 2018, at 11:29, Thomas Singer <ts-swt@xxxxxxxxxxx> wrote:

Hi all,

Does anybody already had a chance to try an SWT application on the macOS Mojave preview, especially the dark mode? I've received screenshots from a user of SmartGit and it shows light controls and even a light (system) toolbar. Could it be that there are some changes required on the SWT/native part to make use of the dark mode?

--
Best regards,
Thomas Singer
=============
syntevo GmbH
https://www.syntevo.com
https://www.syntevo.com/blog
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top