|
| 1 | +/* |
| 2 | + * Copyright (C) 2022 DiffPlug |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.diffplug.common.swt; |
| 17 | + |
| 18 | + |
| 19 | +import com.diffplug.common.swt.os.Arch; |
| 20 | +import com.diffplug.common.swt.os.OS; |
| 21 | +import org.eclipse.swt.widgets.List; |
| 22 | +import org.eclipse.swt.widgets.Table; |
| 23 | +import org.eclipse.swt.widgets.Tree; |
| 24 | + |
| 25 | +/** |
| 26 | + * Call these methods whenever a `Table`, `Tree`, or `List` is instantiated and it will do nothing, |
| 27 | + * excpet on Mac Apple Silicon where it will call `setFont(null)` as a workaround for |
| 28 | + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=575696 |
| 29 | + */ |
| 30 | +public class SiliconFix { |
| 31 | + private static final boolean APPLY_FIX = OS.getRunning().isMac() && Arch.getRunning() == Arch.arm64; |
| 32 | + |
| 33 | + public static void fix(Table table) { |
| 34 | + if (APPLY_FIX) { |
| 35 | + table.setFont(null); |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + public static void fix(Tree tree) { |
| 40 | + if (APPLY_FIX) { |
| 41 | + tree.setFont(null); |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + public static void fix(List list) { |
| 46 | + if (APPLY_FIX) { |
| 47 | + list.setFont(null); |
| 48 | + } |
| 49 | + } |
| 50 | +} |
0 commit comments