Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Priya Shanmugam2019-01-28 05:42:58 -0500
committerLakshmi Shanmugam2019-01-29 04:56:45 -0500
commitf9a780b8e305bbc053e090be94b9ff2610ffb5e1 (patch)
tree94e94c628d4ad7641e9c624b7837620fc2c090ee /bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse
parent732aeea54dc70567c84da4e52e0a7686af3bcae0 (diff)
downloadeclipse.platform.swt-f9a780b8e305bbc053e090be94b9ff2610ffb5e1.tar.gz
eclipse.platform.swt-f9a780b8e305bbc053e090be94b9ff2610ffb5e1.tar.xz
eclipse.platform.swt-f9a780b8e305bbc053e090be94b9ff2610ffb5e1.zip
Bug 459789 - [Mac] Window title bar should be dark when Eclipse is in
dark theme Use NSWindow.appearance to set the the title bar to dark or light. Added a new setTheme method that will send the appAppearanceChanged custom message and set the appearance of the window to either Dark or Light. It'll be called from Platform UI code whenever there is a theme change.
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAppearance.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java2
4 files changed, 69 insertions, 0 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 abe13bd574..26a9992f71 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
@@ -53,6 +53,15 @@
<retval swt_gen="true" swt_java_type="NSPanel"></retval>
</method>
</class>
+ <class name="NSAppearance" swt_gen="mixed">
+ <method class_method="true" selector="appearanceNamed:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
+ <method selector="name" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
+ </class>
<class name="NSApplication" swt_gen="mixed" swt_superclass="NSResponder">
<method selector="activateIgnoringOtherApps:" swt_gen="true">
<arg swt_gen="true"></arg>
@@ -5151,6 +5160,12 @@
<retval></retval>
</method>
</informal_protocol>
+ <informal_protocol name="NSAppearanceCustomization" swt_gen="mixed">
+ <method selector="setAppearance:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
+ </informal_protocol>
<informal_protocol name="NSApplicationDelegate" swt_gen="mixed">
<method selector="application:openFile:" swt_gen="true">
<arg swt_gen="true"></arg>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAppearance.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAppearance.java
new file mode 100644
index 0000000000..172c1a9563
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAppearance.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * 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;
+
+public class NSAppearance extends NSObject {
+
+public NSAppearance() {
+ super();
+}
+
+public NSAppearance(long /*int*/ id) {
+ super(id);
+}
+
+public NSAppearance(id id) {
+ super(id);
+}
+
+public static NSAppearance appearanceNamed(NSString name) {
+ long /*int*/ result = OS.objc_msgSend(OS.class_NSAppearance, OS.sel_appearanceNamed_, name != null ? name.id : 0);
+ return result != 0 ? new NSAppearance(result) : null;
+}
+
+public NSString name() {
+ long /*int*/ result = OS.objc_msgSend(this.id, OS.sel_name);
+ 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 f85f0d80c4..0d8a7bd603 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
@@ -213,6 +213,14 @@ public class OS extends C {
OS.beginSheetModalForWindow(id.id, OS.sel_beginSheetModalForWindow_completionHandler_, window != null ? window.id : 0, handler);
}
+ /*
+ * Custom message that will be sent when setTheme is called for example from Platform UI code.
+ */
+ public static final long /*int*/ sel_appAppearanceChanged = OS.sel_registerName("appAppearanceChanged");
+ public static void setTheme(boolean isDarkTheme) {
+ OS.objc_msgSend(NSApplication.sharedApplication().id, sel_appAppearanceChanged, isDarkTheme ? 1 : 0);
+ }
+
/** JNI natives */
/** @method flags=jni */
@@ -776,6 +784,7 @@ public static final long /*int*/ class_DOMWheelEvent = objc_getClass("DOMWheelEv
public static final long /*int*/ class_NSActionCell = objc_getClass("NSActionCell");
public static final long /*int*/ class_NSAffineTransform = objc_getClass("NSAffineTransform");
public static final long /*int*/ class_NSAlert = objc_getClass("NSAlert");
+public static final long /*int*/ class_NSAppearance = objc_getClass("NSAppearance");
public static final long /*int*/ class_NSAppleEventDescriptor = objc_getClass("NSAppleEventDescriptor");
public static final long /*int*/ class_NSApplication = objc_getClass("NSApplication");
public static final long /*int*/ class_NSArray = objc_getClass("NSArray");
@@ -922,6 +931,7 @@ public static final long /*int*/ class_WebView = objc_getClass("WebView");
/** Protocols */
public static final long /*int*/ protocol_NSAccessibility = objc_getProtocol("NSAccessibility");
public static final long /*int*/ protocol_NSAccessibilityAdditions = objc_getProtocol("NSAccessibilityAdditions");
+public static final long /*int*/ protocol_NSAppearanceCustomization = objc_getProtocol("NSAppearanceCustomization");
public static final long /*int*/ protocol_NSApplicationDelegate = objc_getProtocol("NSApplicationDelegate");
public static final long /*int*/ protocol_NSApplicationNotifications = objc_getProtocol("NSApplicationNotifications");
public static final long /*int*/ protocol_NSColorPanelResponderMethod = objc_getProtocol("NSColorPanelResponderMethod");
@@ -1037,6 +1047,7 @@ public static final long /*int*/ sel_altKey = Selector.sel_altKey.value;
public static final long /*int*/ sel_alternateSelectedControlColor = Selector.sel_alternateSelectedControlColor.value;
public static final long /*int*/ sel_alternateSelectedControlTextColor = Selector.sel_alternateSelectedControlTextColor.value;
public static final long /*int*/ sel_alwaysShowsDecimalSeparator = Selector.sel_alwaysShowsDecimalSeparator.value;
+public static final long /*int*/ sel_appearanceNamed_ = Selector.sel_appearanceNamed_.value;
public static final long /*int*/ sel_appendAttributedString_ = Selector.sel_appendAttributedString_.value;
public static final long /*int*/ sel_appendBezierPath_ = Selector.sel_appendBezierPath_.value;
public static final long /*int*/ sel_appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_ = Selector.sel_appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_.value;
@@ -1889,6 +1900,7 @@ public static final long /*int*/ sel_setAllowsUserCustomization_ = Selector.sel_
public static final long /*int*/ sel_setAlpha_ = Selector.sel_setAlpha_.value;
public static final long /*int*/ sel_setAlphaValue_ = Selector.sel_setAlphaValue_.value;
public static final long /*int*/ sel_setAlternateButtonTitle_ = Selector.sel_setAlternateButtonTitle_.value;
+public static final long /*int*/ sel_setAppearance_ = Selector.sel_setAppearance_.value;
public static final long /*int*/ sel_setApplicationIconImage_ = Selector.sel_setApplicationIconImage_.value;
public static final long /*int*/ sel_setApplicationNameForUserAgent_ = Selector.sel_setApplicationNameForUserAgent_.value;
public static final long /*int*/ sel_setAttachmentCell_ = Selector.sel_setAttachmentCell_.value;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
index 8baedd10c5..619d19f2b4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
@@ -158,6 +158,7 @@ public enum Selector {
, sel_alternateSelectedControlColor("alternateSelectedControlColor")
, sel_alternateSelectedControlTextColor("alternateSelectedControlTextColor")
, sel_alwaysShowsDecimalSeparator("alwaysShowsDecimalSeparator")
+ , sel_appearanceNamed_("appearanceNamed:")
, sel_appendAttributedString_("appendAttributedString:")
, sel_appendBezierPath_("appendBezierPath:")
, sel_appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_("appendBezierPathWithArcWithCenter:radius:startAngle:endAngle:")
@@ -1010,6 +1011,7 @@ public enum Selector {
, sel_setAlpha_("setAlpha:")
, sel_setAlphaValue_("setAlphaValue:")
, sel_setAlternateButtonTitle_("setAlternateButtonTitle:")
+ , sel_setAppearance_("setAppearance:")
, sel_setApplicationIconImage_("setApplicationIconImage:")
, sel_setApplicationNameForUserAgent_("setApplicationNameForUserAgent:")
, sel_setAttachmentCell_("setAttachmentCell:")

Back to the top