Skip to content

Commit 8677dea

Browse files
shahzaibShahzaibIbrahim
authored andcommitted
GTK Fixes
1 parent 92569b0 commit 8677dea

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ public boolean getWarnings () {
652652
* @see #create
653653
*/
654654
protected void init () {
655+
final int DOTS_PER_INCH = 96;
655656
if (debug) {
656657
if (xDisplay != 0) {
657658
/* Create the warning and error callbacks */
@@ -734,10 +735,9 @@ protected void init () {
734735
}
735736
}
736737
defaultFont = OS.pango_font_description_copy (defaultFont);
737-
Point dpi = getDPI(), screenDPI = getScreenDPI();
738-
if (dpi.y != screenDPI.y) {
738+
if (this.dpi.y != DOTS_PER_INCH) {
739739
int size = OS.pango_font_description_get_size(defaultFont);
740-
OS.pango_font_description_set_size(defaultFont, size * dpi.y / screenDPI.y);
740+
OS.pango_font_description_set_size(defaultFont, size * this.dpi.y / DOTS_PER_INCH);
741741
}
742742
systemFont = Font.gtk_new (this, defaultFont);
743743

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Font.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,15 @@ public boolean equals(Object object) {
184184
*/
185185
public FontData[] getFontData() {
186186
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
187-
187+
final int DOTS_PER_INCH = 96;
188188
long family = OS.pango_font_description_get_family(handle);
189189
int length = C.strlen(family);
190190
byte[] buffer = new byte[length];
191191
C.memmove(buffer, family, length);
192192
String name = new String(Converter.mbcsToWcs(buffer));
193193
float height = (float)OS.pango_font_description_get_size(handle) / OS.PANGO_SCALE;
194-
Point dpi = device.dpi, screenDPI = device.getScreenDPI();
195-
float size = height * screenDPI.y / dpi.y;
194+
Point dpi = device.dpi;
195+
float size = height * DOTS_PER_INCH / dpi.y;
196196
int pangoStyle = OS.pango_font_description_get_style(handle);
197197
int pangoWeight = OS.pango_font_description_get_weight(handle);
198198
int style = SWT.NORMAL;
@@ -254,8 +254,9 @@ public int hashCode() {
254254
void init(String name, float height, int style, byte[] fontString) {
255255
if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
256256
if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
257-
Point dpi = device.dpi, screenDPI = device.getScreenDPI();
258-
float size = height * dpi.y / screenDPI.y;
257+
final int DOTS_PER_INCH = 96;
258+
Point dpi = device.dpi;
259+
float size = height * dpi.y / DOTS_PER_INCH;
259260
if (fontString != null) {
260261
handle = OS.pango_font_description_from_string (fontString);
261262
if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5043,7 +5043,8 @@ String debugInfoForIndex(long index) {
50435043
}
50445044

50455045
void dpiChanged(int newScaleFactor) {
5046-
DPIUtil.setDeviceZoom (DPIUtil.mapDPIToZoom(getDPI().x * newScaleFactor));
5046+
final int DOTS_PER_INCH = 96;
5047+
DPIUtil.setDeviceZoom (DPIUtil.mapDPIToZoom(DOTS_PER_INCH * newScaleFactor));
50475048
Shell[] shells = getShells();
50485049
for (int i = 0; i < shells.length; i++) {
50495050
shells[i].layout(true, true);

tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug507020_WaylandIconsDoubleScaled.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static void main (String [] args) {
4242
gridData.horizontalSpan = 2;
4343
canvas.setLayoutData (gridData);
4444

45-
new Label (shell, SWT.NONE).setText ("5. 50x50 box\n(Display#getDPI(): " + display.getDPI().x + ")");
45+
new Label(shell, SWT.NONE).setText("5. 50x50 box");
4646
Label box= new Label (shell, SWT.NONE);
4747
box.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
4848
box.setLayoutData (new GridData (50, 50));

0 commit comments

Comments
 (0)