Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8223304

Creating an FXCanvas resets HiDPI scaling of an SWT application on GTK3

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux_redhat_7.3

      Description

      ADDITIONAL SYSTEM INFORMATION :
      RHEL 7.3
      OpenJDK11 + OpenJFX11

      A DESCRIPTION OF THE PROBLEM :
      SWT applications support HiDPI scaling on GTK3, so if I run an SWT app with GDK_SCALE=2, it starts properly scaled. However instantiating an FXCanvas resets the scaling, the UI is repainted with 1:1 scaling.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Set GDK_SCALE=2,
      Run the below snippet (with JFX 11 and SWT 4.10 on the classpath) and click the button "Init FX"



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      SWT app starts scaled x2 and does not change after clicking the button.
      ACTUAL -
      SWT app starts scaled x2, but shrinks to the original scale after clicking the button.

      ---------- BEGIN SOURCE ----------
      public class Main {
       
          public static void main(String[] args) {
              final Display display = new Display();
              final Shell shell = new Shell(display, SWT.BORDER);
              final RowLayout layout = new RowLayout();
              shell.setLayout(layout);
       
              final org.eclipse.swt.widgets.Button swtButton = new org.eclipse.swt.widgets.Button(shell, SWT.PUSH);
              swtButton.setText("Init FX");
              swtButton.addListener(SWT.Selection, event -> {
               new FXCanvas(new Shell(), SWT.NONE);
              });
       
              shell.open();
              shell.pack();
              while (!shell.isDisposed()) {
                  if (!display.readAndDispatch()) {
                      display.sleep();
                  }
              }
              display.dispose();
          }

      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              tschindl Tom Schindl
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: