Skip to content

Commit 77fa4e3

Browse files
committed
Adapt StyledText DPI_CHANGE handling
This commit adapts how StyledText handles the scaling of Caret with better platform independent APIs instead of utilizing win32 specific static methods. contributes to #62 and #128
1 parent 3f54b85 commit 77fa4e3

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10912,6 +10912,8 @@ void updateSelection(int startOffset, int replacedLength, int newLength) {
1091210912
* @noreference This method is not intended to be referenced by clients.
1091310913
*/
1091410914
public static void updateAndRefreshCarets(StyledText styledText, Consumer<Caret> caretUpdater) {
10915+
styledText.updateCaretVisibility();
10916+
styledText.setCaretLocations();
1091510917
Set<Caret> caretSet = new HashSet<>();
1091610918
caretSet.add(styledText.getCaret());
1091710919
caretSet.add(styledText.defaultCaret);
@@ -10922,9 +10924,6 @@ public static void updateAndRefreshCarets(StyledText styledText, Consumer<Caret>
1092210924
}
1092310925
caretSet.stream().filter(Objects::nonNull).forEach(caretUpdater);
1092410926

10925-
styledText.updateCaretVisibility();
10926-
styledText.setCaretLocations();
10927-
1092810927
}
1092910928

1093010929
}

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/CommonWidgetsDPIChangeHandlers.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,8 @@ private static void handleStyledTextDPIChange(Widget widget, int newZoom, float
5151
if (!(widget instanceof StyledText styledText)) {
5252
return;
5353
}
54-
55-
5654
StyledText.updateAndRefreshCarets(styledText, caretToRefresh -> {
5755
DPIZoomChangeRegistry.applyChange(caretToRefresh, newZoom, scalingFactor);
58-
Caret.win32_setHeight(caretToRefresh, styledText.getLineHeight());
5956
});
6057
}
6158
private static void handleCComboDPIChange(Widget widget, int newZoom, float scalingFactor) {

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ private static void handleDPIChange(Widget widget, int newZoom, float scalingFac
688688
if (caret.font != null) {
689689
caret.setFont(caret.font);
690690
}
691+
caret.resize();
691692
}
692693
}
693694

0 commit comments

Comments
 (0)