Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2015-08-20 16:48:19 +0000
committerLakshmi Shanmugam2015-09-21 07:06:41 +0000
commit2582197191fb20feaee2c873f27f037e4402a98c (patch)
treeb4b38299ba5ce0516d706140c9fdd2416fa435a6 /bundles/org.eclipse.swt
parent8b753b0ebc77f81709855554fdc470c17af87b20 (diff)
downloadeclipse.platform.swt-2582197191fb20feaee2c873f27f037e4402a98c.tar.gz
eclipse.platform.swt-2582197191fb20feaee2c873f27f037e4402a98c.tar.xz
eclipse.platform.swt-2582197191fb20feaee2c873f27f037e4402a98c.zip
Bug 459402 - [Cocoa] (Mac dual monitor on OS X 10.10) Widgets in
preference dialog become dark and unreadable if a TrayItem instance is created Prevent text foreground and background colors from changing when in dark mode, trayItem is present and System settings for color or display changes.
Diffstat (limited to 'bundles/org.eclipse.swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSUserDefaults.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java37
4 files changed, 47 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
index 7693e5ae17..bb2a47bf9a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
@@ -1143,6 +1143,10 @@
<method class_method="true" selector="standardUserDefaults" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
+ <method selector="stringForKey:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
</class>
<class name="NSValue" swt_gen="mixed">
<method selector="objCType" swt_gen="true">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSUserDefaults.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSUserDefaults.java
index e518eb6508..86ece7badd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSUserDefaults.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSUserDefaults.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -38,4 +38,9 @@ public static NSUserDefaults standardUserDefaults() {
return result != 0 ? new NSUserDefaults(result) : null;
}
+public NSString stringForKey(NSString defaultName) {
+ long /*int*/ result = OS.objc_msgSend(this.id, OS.sel_stringForKey_, defaultName != null ? defaultName.id : 0);
+ return result != 0 ? new NSString(result) : null;
+}
+
}
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 b0e3772d2a..7f0a660ae6 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
@@ -2136,6 +2136,7 @@ public static final long /*int*/ sel_stringByDeletingLastPathComponent = sel_reg
public static final long /*int*/ sel_stringByDeletingPathExtension = sel_registerName("stringByDeletingPathExtension");
public static final long /*int*/ sel_stringByReplacingOccurrencesOfString_withString_ = sel_registerName("stringByReplacingOccurrencesOfString:withString:");
public static final long /*int*/ sel_stringByReplacingPercentEscapesUsingEncoding_ = sel_registerName("stringByReplacingPercentEscapesUsingEncoding:");
+public static final long /*int*/ sel_stringForKey_ = sel_registerName("stringForKey:");
public static final long /*int*/ sel_stringForObjectValue_ = sel_registerName("stringForObjectValue:");
public static final long /*int*/ sel_stringForType_ = sel_registerName("stringForType:");
public static final long /*int*/ sel_stringValue = sel_registerName("stringValue");
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 f82d5f10dd..90f7adbdb4 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
@@ -2984,6 +2984,23 @@ NSFont getFont (long /*int*/ cls, long /*int*/ sel) {
return result;
}
+void initColors (boolean ignoreColorChange) {
+ if (ignoreColorChange && colors != null) {
+ /*
+ * Code to ignore changes to System textColor, textBackgroundColor and controlTextColor
+ */
+ double /*float*/ [] color_list_foreground = colors[SWT.COLOR_LIST_FOREGROUND];
+ double /*float*/ [] color_list_background = colors[SWT.COLOR_LIST_BACKGROUND];
+ double /*float*/ [] color_widget_foreground = colors[SWT.COLOR_WIDGET_FOREGROUND];
+ initColors ();
+ colors[SWT.COLOR_LIST_FOREGROUND] = color_list_foreground;
+ colors[SWT.COLOR_LIST_BACKGROUND] = color_list_background;
+ colors[SWT.COLOR_WIDGET_FOREGROUND] = color_widget_foreground;
+ } else {
+ initColors ();
+ }
+}
+
void initColors () {
colors = new double /*float*/ [SWT.COLOR_LINK_FOREGROUND + 1][];
colors[SWT.COLOR_INFO_FOREGROUND] = getWidgetColorRGB(SWT.COLOR_INFO_FOREGROUND);
@@ -4136,7 +4153,25 @@ boolean runPopups () {
boolean runSettings () {
if (!runSettings) return false;
runSettings = false;
- initColors ();
+
+ 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) {
+ /*
+ * osxMode will be "Dark" when in OSX dark mode. Otherwise, it'll be null.
+ */
+ NSString osxMode = NSUserDefaults.standardUserDefaults ().stringForKey (NSString.stringWith ("AppleInterfaceStyle"));
+ if (osxMode != null && "Dark".equals (osxMode.getString ())) {
+ ignoreColorChange = true;
+ }
+ }
+ initColors (ignoreColorChange);
+
sendEvent (SWT.Settings, null);
Shell [] shells = getShells ();
for (int i=0; i<shells.length; i++) {

Back to the top