Repository navigation
Fix for [macOS] some UI elements (e.g. list, tree views) seem to have more space between lines now #1674 - #1117
Conversation
|
@kohlschuetter It's not easy to work with this PR as it is.
|
0f1d659 to
71854d4
Compare
|
@Phillipus OK, I've stashed the reverting changes into one commit, which still applies cleanly to master. |
| */ | ||
| public abstract class Device implements Drawable { | ||
|
|
||
| public static final boolean SMALL_FONTS = System.getProperty("org.eclipse.swt.internal.carbon.smallFonts") != null; |
There was a problem hiding this comment.
This isn't needed. You can reference display.smallFonts directly.
| public Table (Composite parent, int style) { | ||
| super (parent, checkStyle (style)); | ||
|
|
||
| this.nativeItemHeight = (int)((NSTableView)view).rowHeight(); |
There was a problem hiding this comment.
This returns 24 whereas the calculated height with font metrics as returned by getItemHeight is 25. I'm not sure whether that matters?
There was a problem hiding this comment.
It may return an arbitrary value different from 24 (especially if smallFonts is set or when you're on an older macOS). We only use that value as a minimum. In the end, it seems to work out.
| } | ||
| return enforce; | ||
| } | ||
|
|
There was a problem hiding this comment.
Users might want small fonts and native item height. See eclipse-platform/eclipse.platform.ui#1674 (comment)
There was a problem hiding this comment.
the native height is smaller since we use NSFont.smallSystemFontSize(), which is taken into account.
|
@kohlschuetter Based on this PR I created a hybrid version at #1057 which uses your idea of having the opt-in option, calculation of max height, and also initializes the height in each control's constructor in case users don't use the |
|
The native height with smallFonts enabled is smaller than without (14 instead of 24), which is taken into consideration by my patch. I think your original assumption that a padding of "+8" is always true just doesn't hold for the "smallFonts" case. The question about how something would look better than the current default is yet another problem (I initially conflate that as well). For that you want the ability to specify a separate padding, probably as leading factor based upon the font size. I can remove the Regarding #1057, I'm not sure what the difference is to my PR here? Why do we need to call |
71854d4 to
5db6015
Compare
OK, so
I agree that this padding of 8 has to be removed. |
(To be clear it's
Edit: see next comment |
|
There's a problem when Run the test Snippet #677 (comment) and you can see the original problem. The item heights are initially big and then shrink when |
5db6015 to
5d26108
Compare
|
@Phillipus Right, I forgot to remove the corresponding code from my version of TableFont. I've now changed the assignment in the constructor to |
|
That seems to have fixed it, thanks. Why does Could it be simplified to: private boolean initDefaultEnforceNativeItemHeightMinimum() {
return !smallFonts && System.getProperty("org.eclipse.swt.internal.cocoa.enforceNativeItemHeightMinimum") != null;
}Or simply: enforceNativeItemHeightMinimum = !smallFonts && System.getProperty("org.eclipse.swt.internal.cocoa.enforceNativeItemHeightMinimum") != null; |
It is important to check the value so we can set the state regardless of what we determined from Generally, I think you could always come up with some clever logic (whether you write an Moreover, this simplifies scripting when you have something like
No because then you couldn't enforce the minimum with |
If you mean setting |
|
I edited my last comment which was wrong. What I observe is that if |
|
@Phillipus that‘s because the native height happens to be small enough, as discussed before |
Yes, I understand that. But effectively it means that the |
|
No, because the native row height for small fonts could still be a number that is higher than ascent+descent+1. Just because we haven’t seen these yet doesn’t mean they don’t or won’t exist. I wouldn’t be surprised, for example, if turning one of the many Accessibility options results in a few more pixels. The whole misery with the initial bug came from wrong assumptions around pixel math (the fixed 1 or 8 pixels). Lastly, what are we trying to optimize here? This check is called just once … |
|
Fair enough. As this PR seems to fulfil all requirements, it should be reviewed by others who are code owners and committers. It took me a few times to test all the permutations, but I now understand what you've done here, and accounted for all cases. Good job! These are the permutations of the two system properties ("Native" is large on later macOS, "Medium" is how it was before, "Small" is small fonts with no padding):
|
|
I don't think you can have the following public platform-dependent API: public boolean isEnforceNativeItemHeightMinimum() {
}
public void setEnforceNativeItemHeightMinimum(boolean enforce) {
}The classes are Mac-only, so public API can't be used. These methods will have to be private or package private. |
5d26108 to
a5b3aa9
Compare
|
@kohlschuetter Thanks for those changes. The PR commit seems no longer to be based on the most recent |
a5b3aa9 to
b42dccf
Compare
@merks Is it worth me creating a draft copy of this PR rebased onto latest master branch to trigger another build? |
|
I sort of doubt it. But I did have a case where a new pr with the same commit worked so it doesn’t hurt to try. |
|
Now that @kohlschuetter is no longer engaged in his PR and the tests are failing I can't see how this PR can progress. For my own part, I have tried to advise and help with this issue but I'm afraid I can no longer usefully participate in this as I have spent weeks of my time on this and have to move on. I'll leave a summary of the situation and a suggestion:
I suggest one of the two following options:
or
|
|
Are you sure test failures related to this PR? Tests on jenkins are running on Linux, this PR touches Mac code. |
|
Github runner shows two test fails onac, so one should analyse and fix that before merge. |
9ba9ad4 to
289a5b6
Compare
|
@iloveeclipse @lshanmug I've managed to unbreak the tests. The test The solution is to further increase the font size in the test (see my second commit) |
Thanks, but one is still failing: https://github.com/eclipse-platform/eclipse.platform.swt/runs/22917018117 |
289a5b6 to
d93e98c
Compare
|
@iloveeclipse Right, I missed that one. It should be fixed now. Please note that some Jenkins build still fails with SIGKILL ("script returned exit code 137"). I think that's a problem in your build system, unrelated to this change. |
May I ask you to create a trivial dummy change in Mac related SWT code and push a draft PR based on latest master commit to see if that would also fail Linux build? If so, please create new ticket to investigate. |
|
Note that yesterday, this "test" PR was created and it didn't fail the build... So I will push these changes to a new PR and see if that PR works... |
|
By some magic I don't understand, pushing this makes the builds here start again but they actually link to the build from this PR: |
My point was that if a dummy change on Mac SWT code fails Linux build, we should investigate & fix that issue. |
|
This will need to be squashed into a single commit. (It's typically better to amend a commit and force push it to avoid multiple commits in a PR). But please hold off until the builds are completed so we can verify that all builds are successful before change something again... |
|
|
This build fails only for Windows now, but that looks unrelated. (What a nightmare.) Please squash to create a single commit with a single description. (Thanks for your help in the face of what are an awful lot of frustrations!) |
This one is green. |
Newer versions of macOS introduced a new style of table rows with a padding that is larger than previously seen. This broke item height computations (eclipse-platform#677). An attempt to fix this had the unexpected side effect that now some UI elements in Eclipse IDE (and other apps with "-Dorg.eclipse.swt.internal.carbon.smallFonts" enabled), eclise.platform.ui eclipse-platform#1674, and it also broke compatibility with older versions of macOS that did not have the additional padding. This change reverts the previous fix, and adds logic to enforce the native item height by default, without making assumption about the exact height (which varies with "smallFonts", for example). The setting can be controlled by a new System property, org.eclipse.swt.internal.cocoa.useNativeItemHeight, that, if set to false, overrules the default. This allows apps to bring brack the old macOS behavior. Lastly, update two tests in Test_org_eclipse_swt_widgets_List that made assumptions about the item height being different for two small font sizes -- this is no longer true when the native item height is enforced. We now increase the font size of the second font such that this corner case no longer matters. Fixes eclipse-platform/eclipse.platform.ui#1674 Fixes eclipse-platform#677
d93e98c to
1656982
Compare
|
@merks Done (squashed). Let's see what this run brings. Thanks for your help! |
|
Yeah, everything was green! Thanks everyone involved!! 🏆 💟 |
|
Thanks everyone for your efforts in resolving the issue! |
This still needs to be done before 4.32 (I am not volunteering). |
|
Hi, i have tried all of these (in eclipse.ini) without any effect: i would be happy if one could clarify what the right approach should be. thanks in advance |
|
@arauchberger Search eclipse-platform/eclipse.platform.ui#1674 for "hotfix.zip". Alternatively, try updating to 2024-06 M1, however that seems to have other problems. |
cocoa: Enforce native item height for Table, Tree, List if necessary
Newer versions of macOS introduced a new style of table rows with a
padding that is larger than previously seen. This broke item height
computations (#677). An attempt to fix this had the unexpected side
effect that now some UI elements in Eclipse IDE (and other apps with
"-Dorg.eclipse.swt.internal.carbon.smallFonts" enabled),
eclise.platform.ui #1674, and it also broke compatibility with older
versions of macOS that did not have the additional padding.
This change, reverts the previous fix and adds logic to enforce
the native item height by default, but only when smallFonts is not
enabled.
The setting can also be controlled by a new System property,
org.eclipse.swt.internal.cocoa.enforceNativeItemHeightMinimum, that, if
set, overrules any default (smallFonts or not). This allows apps to
bring brack the old macOS behavior even when the smallFonts setting is
undesired.
Lastly, we add support to selectively enable/disable the native item
height minimum for Table, Tree and List on a per-instance basis, so
applications can selectively control the behavior for specific use
cases.
Fixes eclipse-platform/eclipse.platform.ui#1674
Fixes #677